Class documentation of Concepts

Loading...
Searching...
No Matches
basis.hh
Go to the documentation of this file.
1
6#ifndef graphicsbasis_hh
7#define graphicsbasis_hh
8
9#include <fstream>
10#include "basics/debug.hh"
11#include "basics/exceptions.hh"
13#include "basics/typedefs.hh"
14#include "toolbox/array.hh"
16#include "toolbox/sequence.hh"
17#include "geometry/cell2D.hh"
18#include "space/function.hh"
19#include "space/postProcess.hh"
20#include "space/space.hh"
21
22namespace concepts {
23 template<class F>
24 class Vector;
25
26 template<class F, class G>
27 class ElementFormula;
28
29 template<class F>
30 class PiecewiseFormulaBase;
31}
32
33namespace graphics {
34
35 using concepts::Real;
36
37 // ****************************************************************** Size **
38
43 template<class F>
44 struct Size {
45 const uint n() = 0;
46 };
47
48 template<>
49 struct Size<Real> {
50 static const uint n() { return 1; }
51 };
52
53 template<>
54 struct Size<concepts::Cmplx> {
55 static const uint n() { return 1; }
56 };
57
58 template<class F, uint dim>
59 struct Size<concepts::Point<F, dim> > {
60 static const uint n() { return Size<F>::n() * dim; }
61 };
62
63 template<class F, uint dim>
64 struct Size<concepts::Mapping<F, dim> > {
65 static const uint n() { return Size<F>::n() * dim * dim; }
66 };
67
68 // ************************************************************ OutputBase **
69
75 public:
78 OutputBase(const std::string filename, const bool append = false);
79 virtual ~OutputBase() { ofs_.reset(0); }
80 protected:
81 virtual std::ostream& info(std::ostream& os) const;
83 std::unique_ptr<std::ofstream> ofs_;
84 };
85
86 // ******************************************************** BaseOutputCell **
87
94 template<class F = Real>
96 public:
97 BaseOutputCell(std::map<std::string, std::ostream*>& os, const uint dim,
98 const concepts::ElementGraphicsBase::graphicsType type)
99 : type_(type), dim_(dim), os_(os) {}
100 virtual void operator()(const concepts::Element<F>& elm) = 0;
101 virtual void operator()(const concepts::Cell& cell) = 0;
103 std::map<std::string, std::ostream*>& write() { return os_; }
105 uint streams() const { return os_.size(); }
107// uint& count() { return cnt_; }
108 std::vector<uint>& count() { return cnt_; }
110// uint& elm() { return elm_; }
112 uint dim() const { return dim_; }
114 virtual uint n() const = 0;
115 protected:
116 virtual std::ostream& info(std::ostream& os) const;
118 const enum concepts::ElementGraphicsBase::graphicsType type_;
122// uint elm_;
124 const uint dim_;
126 std::map<std::string, std::ostream*>& os_;
127 };
128
129 // ********************************************************** BaseDataCell **
130
139 template<class F, class G = typename concepts::Realtype<F>::type>
140 class BaseDataCell : public BaseOutputCell<G> {
141 public:
148 BaseDataCell(std::map<std::string, std::ostream*>& os,
149 const uint dim,
150 const concepts::ElementGraphicsBase::graphicsType type,
151 const concepts::Vector<F>& sol,
152 const concepts::ElementFunction<F,G>* fun = 0);
155 virtual void operator()(const concepts::Element<G>& elm);
157 virtual void operator()(const concepts::Cell& cell);
159 const concepts::Array<F>& coeff() const { return coeff_; }
162 { return fun_; }
163 const concepts::Vector<F>& sol() const { return sol_; }
164 virtual uint n() const;
165 protected:
166 virtual std::ostream& info(std::ostream& os) const;
167 private:
169 concepts::Array<F> coeff_;
171 const concepts::Vector<F>& sol_;
174 };
175
176 // ************************************************ BaseElementFormulaCell **
177
184 template<class F, class G = typename concepts::Realtype<F>::type>
186 public:
194 (std::map<std::string, std::ostream*>& os, const uint dim,
195 const concepts::ElementGraphicsBase::graphicsType type,
199 virtual void operator()(const concepts::Element<G>& elm);
201 virtual void operator()(const concepts::Cell& cell);
205 virtual uint n() const { return Size<F>::n(); }
206 protected:
207 virtual std::ostream& info(std::ostream& os) const;
210 };
211
212 // ******************************************************* BaseFormulaCell **
213
220 template<class F, class G = typename concepts::Realtype<F>::type>
221 class BaseFormulaCell : public BaseOutputCell<G> {
222 public:
230 BaseFormulaCell(std::map<std::string, std::ostream*>& os,
231 const uint dim,
232 const concepts::ElementGraphicsBase::graphicsType type,
234 const uint points = 5);
237 virtual void operator()(const concepts::Element<G>& elm);
239 virtual void operator()(const concepts::Cell& cell);
241 const concepts::PiecewiseFormulaBase<F>* formula() const { return &frm_; }
242 virtual uint n() const { return Size<F>::n(); }
243 protected:
244 virtual std::ostream& info(std::ostream& os) const;
245 private:
249 const concepts::Array<uint> Points_;
250 };
251
252 // ********************************************************** BaseMeshCell **
253
260 class BaseMeshCell : public BaseOutputCell<Real> {
261 public:
268 BaseMeshCell(std::map<std::string, std::ostream*>& os, const uint dim,
269 const concepts::ElementGraphicsBase::graphicsType type,
270 const uint points = 5);
273 virtual void operator()(const concepts::Element<Real>& elm);
276 virtual void operator()(const concepts::Cell& cell);
278 virtual uint n() const { return 0; }
279 protected:
280 virtual std::ostream& info(std::ostream& os) const;
281 private:
283 const concepts::Array<uint> Points_;
284 };
285
286} // namespace concepts
287
288#endif // graphicsbasis_hh
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual uint n() const
Number of components.
const concepts::ElementFunction< F, G > *& elementFunction()
Returns the function of the solution.
Definition basis.hh:161
const concepts::Array< F > & coeff() const
Returns the coefficients of the elements shape functions.
Definition basis.hh:159
virtual void operator()(const concepts::Element< G > &elm)
virtual void operator()(const concepts::Cell &cell)
Not operational.
BaseDataCell(std::map< std::string, std::ostream * > &os, const uint dim, const concepts::ElementGraphicsBase::graphicsType type, const concepts::Vector< F > &sol, const concepts::ElementFunction< F, G > *fun=0)
const concepts::ElementFormula< F, G > & fun_
Element Formula.
Definition basis.hh:209
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const concepts::ElementFormula< F, G > & elementFormula()
Returns the coefficients of the elements shape functions.
Definition basis.hh:203
BaseElementFormulaCell(std::map< std::string, std::ostream * > &os, const uint dim, const concepts::ElementGraphicsBase::graphicsType type, const concepts::ElementFormula< F, G > &fun)
virtual uint n() const
Number of components.
Definition basis.hh:205
virtual void operator()(const concepts::Element< G > &elm)
virtual void operator()(const concepts::Cell &cell)
Not operational.
const concepts::PiecewiseFormulaBase< F > * formula() const
Returns the formula.
Definition basis.hh:241
BaseFormulaCell(std::map< std::string, std::ostream * > &os, const uint dim, const concepts::ElementGraphicsBase::graphicsType type, const concepts::PiecewiseFormulaBase< F > &frm, const uint points=5)
virtual uint n() const
Number of components.
Definition basis.hh:242
virtual void operator()(const concepts::Cell &cell)
Not operational.
virtual void operator()(const concepts::Element< G > &elm)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
BaseMeshCell(std::map< std::string, std::ostream * > &os, const uint dim, const concepts::ElementGraphicsBase::graphicsType type, const uint points=5)
virtual uint n() const
Number of components.
Definition basis.hh:278
virtual void operator()(const concepts::Element< Real > &elm)
virtual void operator()(const concepts::Cell &cell)
virtual void operator()(const concepts::Element< F > &elm)=0
std::map< std::string, std::ostream * > & os_
Streams to write the data to.
Definition basis.hh:126
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
enum concepts::ElementGraphicsBase::graphicsType type_
Type of Output, like Matlab, Gnuplot.
Definition basis.hh:118
std::vector< uint > & count()
Number of points written to the files, used for mesh representation.
Definition basis.hh:108
uint dim() const
Number of the elements, used for drawing mesh representation.
Definition basis.hh:112
uint streams() const
Number of streams.
Definition basis.hh:105
std::map< std::string, std::ostream * > & write()
Returns the streams to write the data to.
Definition basis.hh:103
virtual void operator()(const concepts::Cell &cell)=0
virtual uint n() const =0
Number of components.
concepts::Sequence< uint > cnt_
Some counters.
Definition basis.hh:120
const uint dim_
Number of drawn elements.
Definition basis.hh:124
std::unique_ptr< std::ofstream > ofs_
Stream for output file.
Definition basis.hh:83
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
OutputBase(const std::string filename, const bool append=false)
double Real
Definition typedefs.hh:39