Class documentation of Concepts

Loading...
Searching...
No Matches
vectorial.hh
Go to the documentation of this file.
1
6#ifndef vectorialThings_hh
7#define vectorialThings_hh
8
9#include <memory>
10#include "basics/cloneable.hh"
11#include "toolbox/array.hh"
14#include "space/tmatrix.hh"
15#include "space/element.hh"
16#include "space/space.hh"
18#include "vectorial/graphics.hh"
19#include "geometry/integral.hh"
20
21// debugging
22#include "basics/debug.hh"
23
24#define VectorialConstr_D 0
25#define VectorialPut_D 0
26
27#define TMatrixOffsetConstr_D 0
28
29#define TMatrixConstr_D 0
30
31#define ElementConstr_D 0
32
33#define BilinearFormConstr_D 0
34
35#define LinearFormConstr_D 0
36
37#define SpaceConstr_D 0
38
39namespace concepts {
40 // forward declaration
41 template<typename F>
42 class ElementGraphics;
43
44 template<typename F, typename G>
45 class ElementFunction;
46}
47
48namespace vectorial {
49
50 using concepts::Real;
51
52 // ************************************************************* Vectorial **
53
58 template<class F>
59 class Vectorial {
60 public:
65 Vectorial(uint vdim, uint arrayWidth) :
66 vdim_(vdim), idx_(0), vdata_(arrayWidth, 0) {
67 DEBUGL(VectorialConstr_D,
68 "vdim = " << vdim_ << ", arraywidth = " << arrayWidth);
69 }
70 virtual ~Vectorial();
72 virtual void insert(F& vdata, const int a = 0, const int b = 0);
74 virtual const F* get(const int a, const int b = 0) const
75 { return vdata_[a]; }
77 uint vdim() const { return vdim_; }
78 protected:
80 uint vdim_;
82 uint idx_;
85 private:
87 Vectorial(const Vectorial<F>& c);
88 };
89
90 template<class F>
92
93 template<class F>
94 void Vectorial<F>::insert(F& vdata, int, int) {
95 vdata_[idx_++] = &vdata;
96 DEBUGL(VectorialConstr_D, "idx = " << idx_);
97 }
98
99 // ********************************************************* TMatrixOffset **
100
101 template<class F>
102 class TMatrix;
103
107 template<class F>
109 friend class TMatrix<F>;
110 public:
111 TMatrixOffset(const concepts::TMatrixBase<F> &T, int offsetRow,
112 int offsetColumn) :
114 offsetRow_(offsetRow), offsetColumn_(offsetColumn), T_(T) {
115 DEBUGL(TMatrixOffsetConstr_D,
116 "offsetRow = " << offsetRow_ << ", " <<
117 "offsetColumn = " << offsetColumn_ << ", T = " << T_);
118 }
119 virtual ~TMatrixOffset();
122 { return T_(A,B); }
123 virtual void operator ()
126 { return T_(A,B); }
127
129 virtual uint index(unsigned int i) const { return T_.index(i); }
130
131 inline uint m() const { return T_.m(); }
132
133 inline uint n() const { return T_.n(); }
134
135 virtual void usedIdx(concepts::TColumn<bool>& c) const {}
136 virtual void extract(const concepts::Vector<F>& solution,
137 concepts::Array<F>& coeff) const;
138 virtual void extract(const concepts::Vector<std::complex<F> >& solution,
139 concepts::Array<std::complex<F> >& coeff) const;
140 protected:
141 virtual std::ostream& info(std::ostream& os) const;
142 //private:
143 uint offsetRow_, offsetColumn_;
144 const concepts::TMatrixBase<F> &T_;
145 };
146
147 // *************************************************************** TMatrix **
148
152 template<class F>
154 public Vectorial<TMatrixOffset<F> > {
155 public:
156 TMatrix(uint vdim, uint arrayWidth = 0) :
159 offsetRow_(0), offsetColumn_(0) {
160 DEBUGL(TMatrixConstr_D, "done.");
161 }
162 virtual ~TMatrix();
163
166 virtual void operator()
174 void put(const concepts::TMatrixBase<F> &T, const int dim);
175
177 virtual uint index(unsigned int i) const;
178
179 // not needed in Vectorial problems
180 virtual void usedIdx(concepts::TColumn<bool>& c) const {}
188 virtual void extract(const concepts::Vector<F>& solution,
189 concepts::Array<F>& coeff) const;
190 virtual void extract(const concepts::Vector<std::complex<F> >& solution,
191 concepts::Array<std::complex<F> >& coeff) const;
192 protected:
193 virtual std::ostream& info(std::ostream& os) const;
194 private:
195 uint offsetRow_, offsetColumn_;
196 };
197
198
199 // ******************************************************* ElementNotBuilt **
200
210
211
212 // *********************************************************** ElementBase **
213
214 // forward declaration
215 template<class F>
216 class Graphics;
217
223 template<class ElementType>
224 class ElementBase : public Vectorial<ElementType>,
225 public ElementType {
226 public:
227 typedef typename ElementType::type F;
228
229 ElementBase(uint vdim, uint arrayWidth, std::string name = "ElementBase") :
230 Vectorial<ElementType>(vdim, vdim), ElementType(),
231 T_(new TMatrix<F>(vdim)), name_(name) {
232 DEBUGL(ElementConstr_D, "done.");
233 }
234 virtual ~ElementBase();
235
240 virtual void put(ElementType& em, const int dim, const int b = 0);
241
242 virtual vectorial::TMatrix<F>& T() const { return *T_; }
243 virtual const Graphics<F>* graphics() const {
244 if (! graphics_.get())
245 graphics_.reset(new Graphics<F>());
246 return graphics_.get();
247 }
248 static Graphics<F>* vecGraphics() {
249 if (! graphics_.get())
250 graphics_.reset(new Graphics<F>());
251 return graphics_.get();
252 }
253 protected:
254 virtual std::ostream& info(std::ostream& os) const;
256 std::unique_ptr<vectorial::TMatrix<F> > T_;
257 private:
258 static std::unique_ptr<Graphics<F> > graphics_;
260 std::string name_;
261 };
262
263 // *************************************************************** Element **
264
269 template<class F>
270 class Element : public ElementBase<concepts::Element<F> > {
271 public:
272 Element(uint vdim, uint arrayWidth=0) :
274 "vectorial::Element") {}
275 virtual ~Element();
276 };
277
278 // ******************************************************* ElementWithCell **
279
284 template<class F>
285 class ElementWithCell : public ElementBase<concepts::ElementWithCell<F> >,
287 public:
288 ElementWithCell(uint vdim, uint arrayWidth=0) :
290 "vectorial::ElementWithCell"),
291 cell_(0), intCell_(0) {}
292 virtual ~ElementWithCell();
293
299 const int dim, const int b = 0);
300
301 virtual bool quadraturePoint(uint i, intPoint &p, intFormType form,
302 bool localCoord) const;
303
305 virtual const concepts::Cell& cell() const;
306 private:
307 const concepts::Cell* cell_;
308 const concepts::IntegrationCell* intCell_;
309 };
310
311 // ********************************************************** BilinearForm **
312
316 template<class F, class G = typename concepts::Realtype<F>::type>
318 public Vectorial<concepts::BilinearForm<F,G> > {
319 public:
324 BilinearForm(const uint vdim1, const uint vdim2 = 0) :
325 Vectorial<concepts::BilinearForm<F,G> >(vdim1,
326 vdim1*(vdim2 ? vdim2 : vdim1)),
327 vdim2(vdim2 ? vdim2 : vdim1), deepCopies_(0)
328 {
329 DEBUGL(BilinearFormConstr_D, "done.");
330 }
333 virtual ~BilinearForm();
334 virtual BilinearForm* clone() const;
335
342 virtual void put(concepts::BilinearForm<F,G> &bf, const int i, const int j);
347 void putStore(concepts::BilinearForm<F,G>* bf, const int i, const int j);
349 const int i, const int j);
350
354 void putData(concepts::Cloneable* data) { sharedData_.reset(data); }
355
358
359 virtual void operator ()(const concepts::Element<G>& elmX,
360 const concepts::Element<G>& elmY,
362 virtual void operator ()(const concepts::Element<G>& elmV,
363 const concepts::Element<G>& elmU,
365 const concepts::ElementPair<G>& elmp) const;
366
368 uint vdim2;
369 protected:
370 virtual std::ostream& info(std::ostream& os) const;
371 private:
377 std::unique_ptr<concepts::Cloneable> sharedData_;
378 };
379
380} // namespace vectorial
381
382namespace concepts {
383
384 // ****************************************************************** Scan **
385
386 template<class F>
387 class Scan<vectorial::Element<F> > :
388 public concepts::Scan<concepts::Element<F> > {
389 public:
390 virtual vectorial::Element<F>& operator++(int) = 0;
391 };
392
393 template<class F>
394 class Scan<vectorial::ElementWithCell<F> > :
395 public concepts::Scan<concepts::ElementWithCell<F> > {
396 public:
398 };
399
400} // namespace concepts
401
402namespace vectorial {
403
404 template<class F>
406
407 template<class F>
409 public:
410 typedef Element<F> type;
411 };
412
413 template<class F>
415 public:
416 typedef ElementWithCell<F> type;
417 };
418
419 // ***************************************************************** SpaceBase **
420
425 template<class SpaceType>
426 class SpaceBase : public SpaceType,
427 public Vectorial<SpaceType> {
428 public:
429 typedef
431
432 SpaceBase(const uint vdim, const uint arrayWidth = 0,
433 std::string name = "SpaceBase")
434 : SpaceType()
436 , dim_(0), nelm_(0), elm_(0), name_(name)
437 {
438 DEBUGL(SpaceConstr_D, "done.");
439 }
440 SpaceBase(const SpaceBase & spcb)
441 : Vectorial<SpaceType>(spcb.vdim(), spcb.vdim())
442 , dim_(spcb.dim_) , nelm_(spcb.nelm_)
443 , elm_(spcb.elm_) , name_(spcb.name_)
444 {
445 }
446
447 virtual ~SpaceBase();
448
449 virtual uint dim() const { return dim_; }
450 virtual uint nelm() const { return nelm_; }
452 virtual Scanner* scan() const;
453
457 virtual void put(SpaceType &spc, const int i = 0, const int j = 0);
458
460 void rebuild();
461 protected:
462 virtual std::ostream& info(std::ostream& os) const;
463 private:
464 uint dim_, nelm_;
467 std::string name_;
468 void buildElm_(const SpaceType& spc, uint idx);
469 };
470
471 // ***************************************************************** Space **
472
477 template<class F>
478 class Space : public SpaceBase<concepts::Space<F> > {
479 public:
480 Space(const uint vdim, const uint arrayWidth=0)
481 : SpaceBase<concepts::Space<F> >(vdim, arrayWidth, "Space") {}
482 virtual ~Space();
483 };
484
485 // ********************************************************** SpaceOnCells **
486
491 template<class F>
492 class SpaceOnCells : public SpaceBase<concepts::SpaceOnCells<F> > {
493 public:
494 SpaceOnCells(const uint vdim, const uint arrayWidth=0)
495 : SpaceBase<concepts::SpaceOnCells<F> >(vdim, arrayWidth, "SpaceOnCells") {}
496 virtual ~SpaceOnCells();
497 };
498
499 // *********************************************************** ElementPair **
500
504 template<class F>
506 : public concepts::ElementPair<F>,
507 public Vectorial<concepts::ElementPair<F> > {
508 public:
509 ElementPair(const Element<F>& elm1, const Element<F>& elm2)
511 elm1.vdim()*elm2.vdim()),
512 elm1_(elm1), elm2_(elm2) { }
513 virtual ~ElementPair() { }
514 virtual void put(concepts::ElementPair<F>& ep,
515 const int iV, const int iU);
517 virtual const concepts::Element<F>& elm1() const;
519 virtual const concepts::Element<F>& elm2() const;
520 private:
521 const Element<F>& elm1_;
522 const Element<F>& elm2_;
523 };
524
525} // namespace vectorial
526
527#endif // vectorialThings_hh
virtual T & operator++(int)=0
Returns the next element in the scanned set.
uint vdim2
vectorial dimension of second argument of bilinear form
Definition vectorial.hh:368
void putData(concepts::Cloneable *data)
Definition vectorial.hh:354
virtual void operator()(const concepts::Element< G > &elmX, const concepts::Element< G > &elmY, concepts::ElementMatrix< F > &em) const
void putStore(concepts::BilinearForm< F, G > *bf, const int i, const int j)
BilinearForm< F, G > & reset()
Clear the stores bilinear forms and the shared data.
virtual BilinearForm * clone() const
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
BilinearForm(const uint vdim1, const uint vdim2=0)
Definition vectorial.hh:324
virtual void put(concepts::BilinearForm< F, G > &bf, const int i, const int j)
BilinearForm(const BilinearForm &b)
Copy constructor. This copy constructor performs a deep copy of b.
std::unique_ptr< vectorial::TMatrix< F > > T_
T matrix for the vector valued element.
Definition vectorial.hh:256
virtual void put(ElementType &em, const int dim, const int b=0)
virtual const concepts::Element< F > & elm1() const
Returns reference to the first element.
virtual const concepts::Element< F > & elm2() const
Returns reference to the second element.
virtual bool quadraturePoint(uint i, intPoint &p, intFormType form, bool localCoord) const
virtual const concepts::Cell & cell() const
Returns the cell on which the element is built.
virtual void put(concepts::ElementWithCell< F > &em, const int dim, const int b=0)
void rebuild()
Rebuilds the vectorial space from the scalar spaces.
virtual void put(SpaceType &spc, const int i=0, const int j=0)
virtual void operator()(const concepts::ElementMatrix< F > &A, concepts::ElementMatrix< F > &B) const
Definition vectorial.hh:120
virtual void extract(const concepts::Vector< F > &solution, concepts::Array< F > &coeff) const
virtual void usedIdx(concepts::TColumn< bool > &c) const
Definition vectorial.hh:135
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual uint index(unsigned int i) const
Maps the local index i to the global index.
Definition vectorial.hh:129
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void extract(const concepts::Vector< F > &solution, concepts::Array< F > &coeff) const
virtual uint index(unsigned int i) const
Maps the local index i to the global index.
virtual void operator()(const concepts::ElementMatrix< F > &A, concepts::ElementMatrix< F > &B) const
virtual void usedIdx(concepts::TColumn< bool > &c) const
Definition vectorial.hh:180
void put(const concepts::TMatrixBase< F > &T, const int dim)
virtual const F * get(const int a, const int b=0) const
Get a component.
Definition vectorial.hh:74
uint vdim() const
Returns number of components.
Definition vectorial.hh:77
uint vdim_
Number of components.
Definition vectorial.hh:80
virtual void insert(F &vdata, const int a=0, const int b=0)
Add a component.
Definition vectorial.hh:94
uint idx_
Index of the last added component.
Definition vectorial.hh:82
Vectorial(uint vdim, uint arrayWidth)
Definition vectorial.hh:65
concepts::Array< F * > vdata_
Storage.
Definition vectorial.hh:84
#define DEBUGL(doit, msg)
Definition debug.hh:40
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320