space.hh

Go to the documentation of this file.
1 
6 #ifndef bemSpace_hh
7 #define bemSpace_hh
8 
9 #include <stack>
10 
11 #include "basics/output.hh"
12 #include "toolbox/dynArray.hh"
14 #include "geometry/mesh.hh"
15 #include "space/space.hh"
16 #include "bem/element.hh"
17 
18 namespace bem {
19 
20  // *************************************************************** Dirac3d **
21 
32  template <class F = concepts::Real>
33  class Dirac3d : public concepts::Space<F> {
35  uint dim_;
37  uint nelm_;
40 
46  void constructor_(concepts::Triangle3d* cell, uint lvl,
48 
49  protected:
50  std::ostream& info(std::ostream& os) const;
51 
52  public:
58  Dirac3d(concepts::Mesh2& msh, uint lvl);
59  virtual ~Dirac3d();
60 
62  inline uint dim() const {return dim_;}
64  inline uint nelm() const {return nelm_;}
66  inline concepts::Scan<concepts::Element<F> >* scan() const;
67  };
68 
69  template <class F>
70  inline std::ostream& Dirac3d<F>::info(std::ostream& os) const {
71  os << typeOf(*this) << "(dim = " << dim_ << ", nelm = " << nelm_ << ')';
72  return os;
73  }
74 
75  template <class F>
77  return new concepts::PListScan<concepts::Element<F> >(*elm_);
78  }
79 
80  // ************************************************************** Linear3d **
81 
92  template <class F = concepts::Real>
93  class Linear3d : public concepts::Space<F> {
95  uint dim_;
97  uint nelm_;
100 
106  void constructor_(concepts::Triangle3d* cell, uint lvl,
108 
109  protected:
110  std::ostream& info(std::ostream& os) const {return info(os, 0);}
111 
112  public:
118  Linear3d(concepts::Mesh2& msh, uint lvl);
119  virtual ~Linear3d();
120 
122  inline uint dim() const {return dim_;}
124  inline uint nelm() const {return nelm_;}
126  inline concepts::Scan<concepts::Element<F> >* scan() const;
135  std::ostream& info(std::ostream& os, uint mode = 0) const;
136  };
137 
138  template <class F>
140  return new concepts::PListScan<concepts::Element<F> >(*elm_);
141  }
142 
143  // ************************************************************ Constant3d **
144 
155  template <class F = concepts::Real>
156  class Constant3d : public concepts::Space<F> {
158  uint dim_;
160  uint nelm_;
162  uint elmType_;
165 
170  void constructor_(concepts::Triangle3d* cell, uint lvl);
171 
172  protected:
173  std::ostream& info(std::ostream& os) const;
174 
175  public:
184  Constant3d(concepts::Mesh2& msh, uint lvl, uint elmType = 0);
185  virtual ~Constant3d();
186 
188  uint dim() const {return dim_;}
190  uint nelm() const {return nelm_;}
192  inline concepts::Scan<concepts::Element<F> >* scan() const;
193  };
194 
195  template <class F>
197  return new concepts::PListScan<concepts::Element<F> >(*elm_);
198  }
199 
200  template <class F>
201  inline std::ostream& Constant3d<F>::info(std::ostream& os) const {
202  os << "Constant3d(dim = " << dim_ << ", nelm = " << nelm_ << ')';
203  return os;
204  }
205 
206  // ******************************************************** AdaptiveAdjust **
207 
213  struct AdaptiveAdjust {
215  short l_;
216 
218  AdaptiveAdjust() : l_(0) {}
222  AdaptiveAdjust(short l) : l_(l) {}
223 
226  if (this != &adj) l_ = adj.l_;
227  return *this;
228  }
229  };
230 
231  std::ostream& operator<<(std::ostream& os, const AdaptiveAdjust& adj);
232 
233  // ********************************************************* AdaptiveSpace **
234 
235  template<class F = concepts::Real>
236  class AdaptiveSpace :
237  public concepts::SpaceOnCells<F>,
238  public concepts::AdaptiveSpace<F, AdaptiveAdjust> {
239  protected:
240  std::ostream& info(std::ostream& os) const {
241  return os << "bem::" << typeOf(*this) ;
242  }
243  };
244 
245  // ******************************************************* AdaptConst3d000 **
246 
252  template<class F = concepts::Real>
253  class AdaptConst3d000 : public AdaptiveSpace<F> {
255  uint dim_;
257  uint nelm_;
260 
264  uint maxlvl_;
266  uint minlvl_;
272  bool rebuild_;
273 
283  void rebuild0_(concepts::Connector2& cntr, int l, int& L);
284  void rebuild1_(concepts::Triangle3d& cell, uint l);
285 
286  protected:
287  std::ostream& info(std::ostream& os) const {return info(os, 0);}
288 
289  public:
299 
303  uint dim() const;
304  uint dim();
308  uint nelm() const;
309  uint nelm();
311  uint maxlevel();
313  uint minlevel();
320  short l(Constant3d001<F>& elm) {
321  AdaptiveAdjust& adj(adj_[elm.support().key()]);
322  return adj.l_;
323  }
330  void adjust(const concepts::Element<F>& elm,const AdaptiveAdjust& a);
331  void adjust(const Constant3d001<F>& elm, const AdaptiveAdjust& a);
341  void rebuild();
349  std::ostream& info(std::ostream& os, uint mode = 0) const;
350  };
351 
352  template<class F>
353  inline uint AdaptConst3d000<F>::dim() const {
355  return dim_;
356  }
357 
358  template<class F>
359  inline uint AdaptConst3d000<F>::dim() {
360  if (rebuild_) rebuild();
361  return dim_;
362  }
363 
364  template<class F>
365  inline uint AdaptConst3d000<F>::nelm() const {
367  return nelm_;
368  }
369 
370  template<class F>
371  inline uint AdaptConst3d000<F>::nelm() {
372  if (rebuild_) rebuild();
373  return nelm_;
374  }
375 
376  template<class F>
378  if (rebuild_) rebuild();
379  return maxlvl_;
380  }
381 
382  template<class F>
384  if (rebuild_) rebuild();
385  return minlvl_;
386  }
387 
388  template<class F>
393  }
394 
395  template<class F>
398  if (rebuild_) rebuild();
400  }
401 
402  // *************************************************************** EdgeMap **
403 
406  class EdgeMap {
407  friend std::ostream& operator<<(std::ostream& os, const EdgeMap& emp);
408  public:
409  inline EdgeMap() : pnl1(0), pnl2(0), lvl(0), prnt(0), tag(0) {};
410  std::ostream& info(std::ostream& os) const;
411 
427  };
428 
429  // ******************************************************* AdaptConst3d001 **
430 
437  template<class F = concepts::Real>
438  class AdaptConst3d001 : public AdaptiveSpace<F> {
440  uint dim_;
442  uint nelm_;
445 
449  uint maxlvl_;
451  uint minlvl_;
457  bool rebuild_;
467  std::stack<EdgeMap*> stk_;
468 
480  void rebuild0_(concepts::Connector2& cntr, int l, int& L);
482  void rebuild2_();
483  void rebuild3_(concepts::Triangle3d& cell, uint l);
484 
485  protected:
486  std::ostream& info(std::ostream& os) const {return info(os, 0);}
487 
488  public:
497  AdaptConst3d001(concepts::Mesh2& msh, uint lvl, ushort deltal);
499 
503  uint dim() const;
504  uint dim();
508  uint nelm() const;
509  uint nelm();
511  uint maxlevel();
513  uint minlevel();
520  short l(Constant3d001<F>& elm) {
521  AdaptiveAdjust& adj(adj_[elm.support().key()]);
522  return adj.l_;
523  }
530  void adjust(const concepts::Element<F>& elm, const AdaptiveAdjust& a);
531  void adjust(const Constant3d001<F>& elm, const AdaptiveAdjust& a);
541  void rebuild();
549  std::ostream& info(std::ostream& os, uint mode = 0) const;
550  };
551 
552  template<class F>
553  inline uint AdaptConst3d001<F>::dim() const {
555  return dim_;
556  }
557 
558  template<class F>
559  inline uint AdaptConst3d001<F>::dim() {
560  if (rebuild_) rebuild();
561  return dim_;
562  }
563 
564  template<class F>
565  inline uint AdaptConst3d001<F>::nelm() const {
567  return nelm_;
568  }
569 
570  template<class F>
571  inline uint AdaptConst3d001<F>::nelm() {
572  if (rebuild_) rebuild();
573  return nelm_;
574  }
575 
576  template<class F>
578  if (rebuild_) rebuild();
579  return maxlvl_;
580  }
581 
582  template<class F>
584  if (rebuild_) rebuild();
585  return minlvl_;
586  }
587 
588  template<class F>
593  }
594 
595  template<class F>
598  if (rebuild_) rebuild();
600  }
601 
602  // ******************************************************* AdaptConst3d002 **
603 
612  template<class F = concepts::Real>
613  class AdaptConst3d002 : public AdaptiveSpace<F> {
615  uint dim_;
617  uint nelm_;
620 
624  uint maxlvl_;
626  uint minlvl_;
632  bool rebuild_;
644  std::stack<EdgeMap*> stk_;
645 
657  void rebuild0_(concepts::Connector2& cntr, int l, int& L);
658  void rebuild1_(concepts::Connector2& cntr, uint l);
659  void rebuild2_();
660  void rebuild3_(concepts::Triangle3d& cell, uint l, ushort tag);
661 
662  protected:
663  std::ostream& info(std::ostream& os) const {return info(os, 0);}
664 
665  public:
675  AdaptConst3d002(concepts::Mesh2& msh, uint lvl, ushort deltal,
676  ushort deltaL);
678 
682  uint dim() const;
683  uint dim();
687  uint nelm() const;
688  uint nelm();
690  uint maxlevel();
692  uint minlevel();
699  short l(Constant3d001<F>& elm) {
700  AdaptiveAdjust& adj(adj_[elm.support().key()]);
701  return adj.l_;
702  }
709  void adjust(const concepts::Element<F>& elm, const AdaptiveAdjust& a);
710  void adjust(const Constant3d001<F>& elm, const AdaptiveAdjust& a);
720  void rebuild();
728  std::ostream& info(std::ostream& os, uint mode = 0) const;
729  };
730 
731  template<class F>
732  inline uint AdaptConst3d002<F>::dim() const {
734  return dim_;
735  }
736 
737  template<class F>
738  inline uint AdaptConst3d002<F>::dim() {
739  if (rebuild_) rebuild();
740  return dim_;
741  }
742 
743  template<class F>
744  inline uint AdaptConst3d002<F>::nelm() const {
746  return nelm_;
747  }
748 
749  template<class F>
750  inline uint AdaptConst3d002<F>::nelm() {
751  if (rebuild_) rebuild();
752  return nelm_;
753  }
754 
755  template<class F>
757  if (rebuild_) rebuild();
758  return maxlvl_;
759  }
760 
761  template<class F>
763  if (rebuild_) rebuild();
764  return minlvl_;
765  }
766 
767  template<class F>
772  }
773 
774  template<class F>
777  if (rebuild_) rebuild();
779  }
780 
781 } // namespace bem
782 
783 #endif // bemSpace_hh
short l(Constant3d001< F > &elm)
Returns the level of a element.
Definition: space.hh:699
AdaptConst3d002(concepts::Mesh2 &msh, uint lvl, ushort deltal, ushort deltaL)
Constructor.
ushort deltaL_
level difference between two elements less or equal to .
Definition: space.hh:638
uint dim_
Number of degrees of freedom in the space.
Definition: space.hh:158
std::ostream & info(std::ostream &os, uint mode=0) const
Gives some information about the space.
An abstract class for an element of a space.
Definition: exceptions.hh:15
virtual ~Dirac3d()
concepts::DynArray< AdaptiveAdjust > adj_
Dynamic array of the adjustment information of the mesh.
Definition: space.hh:455
void adjust(const concepts::Element< F > &elm, const AdaptiveAdjust &a)
Sets the adjustments for an element.
std::ostream & operator<<(std::ostream &os, const AdaptiveAdjust &adj)
concepts::Connector2 * pnl2
neighbouring panel on the lower level
Definition: space.hh:415
AdaptiveAdjust & operator=(const AdaptiveAdjust &adj)
Assignment operator.
Definition: space.hh:225
concepts::Scan< concepts::ElementWithCell< F > > * scan() const
Returns a scanner for the active elements of the space.
Definition: space.hh:590
uint nelm_
Number of elements currently active in the mesh.
Definition: space.hh:442
uint minlevel()
Returns the minimal level of all elements.
Definition: space.hh:762
virtual ~Linear3d()
uint maxlevel()
Returns the maximal level of all elements.
Definition: space.hh:756
concepts::Mesh2 & msh_
The mesh.
Definition: space.hh:262
void adjust(const Constant3d001< F > &elm, const AdaptiveAdjust &a)
uint nelm() const
Returns number of elements in the space.
Definition: space.hh:64
concepts::DynArray< concepts::AdaptiveControl<> > ctrl_
Dynamic array of the control information for the elements.
Definition: space.hh:628
std::stack< EdgeMap * > stk_
stack for the edge panels mappings with a too large level difference
Definition: space.hh:644
void rebuild()
Rebuilds the space.
void rebuild0_(concepts::Connector2 &cntr, int l, int &L)
Marks the cells correctly for the new space.
uint dim() const
Returns the number of degrees of freedom.
Definition: space.hh:553
#define conceptsException(exc)
Prepares an exception for throwing.
Definition: exceptions.hh:344
std::ostream & info(std::ostream &os) const
Definition: space.hh:240
Abstract class for a space.
concepts::Scan< concepts::ElementWithCell< F > > * scan() const
Returns a scanner for the active elements of the space.
Definition: space.hh:769
uint dim() const
Returns the number of degrees of freedom.
Definition: space.hh:732
uint dim() const
Returns dimension of the space.
Definition: space.hh:62
std::ostream & info(std::ostream &os) const
Definition: space.hh:486
void rebuild1_(concepts::Connector2 &cntr, uint l)
std::ostream & info(std::ostream &os, uint mode=0) const
Returns information in an output stream.
uint elmType_
Type of element used.
Definition: space.hh:162
Joiner class with multiple successors, i.e.
Linear3d(concepts::Mesh2 &msh, uint lvl)
Constructor.
uint nelm_
Number of elements currently active in the mesh.
Definition: space.hh:617
void rebuild()
Rebuilds the space.
uint dim_
Number of degrees of freedom in the space.
Definition: space.hh:95
concepts::Joiner< concepts::ElementWithCell< F > *, 1 > * elm_
Linked list of the elements.
Definition: space.hh:619
unsigned char uchar
Abbreviation for unsigned char.
Definition: typedefs.hh:45
uint minlvl_
Minimal level of all elements.
Definition: space.hh:451
uint dim() const
Returns the number of degrees of freedom.
Definition: space.hh:188
std::stack< EdgeMap * > stk_
stack for the edge panels mappings with a too large level difference
Definition: space.hh:467
concepts::Mesh2 & msh_
The mesh.
Definition: space.hh:447
virtual ~Constant3d()
uint dim() const
Returns the number of degrees of freedom.
Definition: space.hh:353
uint maxlvl_
Maximal level of all elements.
Definition: space.hh:624
concepts::Scan< concepts::Element< F > > * scan() const
Returns a scanner of the space.
Definition: space.hh:76
short l(Constant3d001< F > &elm)
Returns the level of a element.
Definition: space.hh:320
concepts::Joiner< concepts::Element< F > *, 1 > * elm_
Linked list of elements.
Definition: space.hh:164
uint nelm_
Number of elements in the space.
Definition: space.hh:37
ushort deltal_
level difference between two neighbouring elements less or equal to .
Definition: space.hh:461
uint maxlvl_
Maximal level of all elements.
Definition: space.hh:449
concepts::DynArray< EdgeMap > edgmap_
Dynamic array of the edge panel mapping.
Definition: space.hh:463
concepts::DynArray< AdaptiveAdjust > adj_
Dynamic array of the adjustment information of the mesh.
Definition: space.hh:270
std::ostream & info(std::ostream &os) const
Definition: space.hh:201
void rebuild1_(concepts::Triangle3d &cell, uint l)
concepts::Scan< concepts::ElementWithCell< F > > * scan() const
Returns a scanner for the active elements of the space.
Definition: space.hh:390
Dirac3d(concepts::Mesh2 &msh, uint lvl)
Constructor.
bool rebuild_
If true: the mesh has to be rebuilt (refined or coarsened)
Definition: space.hh:457
uint minlevel()
Returns the minimal level of all elements.
Definition: space.hh:383
concepts::DynArray< AdaptiveAdjust > adj_
Dynamic array of the adjustment information of the mesh.
Definition: space.hh:630
concepts::Scan< concepts::Element< F > > * scan() const
Returns a scanner of the space.
Definition: space.hh:139
std::ostream & info(std::ostream &os) const
friend std::ostream & operator<<(std::ostream &os, const EdgeMap &emp)
Class to describe adjustments to elements in an adaptive space.
Definition: space.hh:213
AdaptiveAdjust(short l)
Constructor.
Definition: space.hh:222
void rebuild0_(concepts::Connector2 &cntr, int l, int &L)
Marks the cells correctly for the new space.
uint minlvl_
Minimal level of all elements.
Definition: space.hh:266
uint nelm_
Number of elements.
Definition: space.hh:160
ushort lvl
level difference to the highest level on this edge
Definition: space.hh:417
Constant space element with a level dependent key.
Definition: element.hh:335
const Key & key() const
Returns the key of the connector.
Definition: connector.hh:105
concepts::Mesh2 & msh_
The mesh.
Definition: space.hh:622
A 2D element of the topology.
Definition: connector.hh:226
void adjust(const concepts::Element< F > &elm, const AdaptiveAdjust &a)
Sets the adjustments for an element.
A 3D adaptive BEM space with piecewise constant basis functions.
Definition: space.hh:613
concepts::uchar tag
Bitfield bit 0: none of the two panels is in the space (0) one of the two panels is in the space (1) ...
Definition: space.hh:426
void adjust(const concepts::Element< F > &elm, const AdaptiveAdjust &a)
Sets the adjustments for an element.
An abstract class for scanning a mesh (a set of cells) or a space (a set of elements).
A 3D space with continuous, piecewise linear basis functions.
Definition: space.hh:93
std::ostream & info(std::ostream &os, uint mode=0) const
Gives some information about the space.
An abstract class for 2D meshes.
Definition: mesh.hh:103
void rebuild()
Rebuilds the space.
void rebuild3_(concepts::Triangle3d &cell, uint l)
uint nelm_
Number of elements currently active in the mesh.
Definition: space.hh:257
uint nelm_
Number of elements.
Definition: space.hh:97
void rebuild0_(concepts::Connector2 &cntr, int l, int &L)
Marks the cells correctly for the new space.
short l_
Level.
Definition: space.hh:215
short l(Constant3d001< F > &elm)
Returns the level of a element.
Definition: space.hh:520
ushort deltal_
level difference between two neighbouring elements less or equal to .
Definition: space.hh:636
bool rebuild_
If true: the mesh has to be rebuilt (refined or coarsened)
Definition: space.hh:632
uint minlevel()
Returns the minimal level of all elements.
Definition: space.hh:583
std::ostream & info(std::ostream &os) const
Definition: space.hh:663
void constructor_(concepts::Triangle3d *cell, uint lvl)
Private constructor for recursive construction.
void constructor_(concepts::Triangle3d *cell, uint lvl, concepts::DynArray< uint > &map)
Private constructor for recursive construction.
A 3D space with discontinuous, piecewise constant basis functions.
Definition: space.hh:156
concepts::Joiner< concepts::Element< F > *, 1 > * elm_
Linked list of elements.
Definition: space.hh:99
AdaptConst3d001(concepts::Mesh2 &msh, uint lvl, ushort deltal)
Constructor.
Indicates that the space on which a function was called was not yet correctly built.
Definition: space.hh:36
void adjust(const Constant3d001< F > &elm, const AdaptiveAdjust &a)
concepts::DynArray< EdgeMap > edgmap_
Dynamic array of the edge panel mapping.
Definition: space.hh:640
Class to map the edges to the two neighbouring panels.
Definition: space.hh:406
const concepts::Triangle & support() const
Returns the support.
Definition: element.hh:414
void rebuild3_(concepts::Triangle3d &cell, uint l, ushort tag)
uint minlvl_
Minimal level of all elements.
Definition: space.hh:626
Used for the basic classes of the boundary element method.
Definition: bform.hh:13
concepts::DynArray< concepts::AdaptiveControl<> > ctrl_
Dynamic array of the control information for the elements.
Definition: space.hh:453
concepts::Joiner< concepts::ElementWithCell< F > *, 1 > * elm_
Linked list of the elements.
Definition: space.hh:259
uint dim_
Number of degrees of freedom in the space.
Definition: space.hh:255
AdaptConst3d000(concepts::Mesh2 &msh, uint lvl)
Constructor.
Abstract class for a space.
Definition: space.hh:81
uint dim_
Number of degrees of freedom in the space.
Definition: space.hh:615
A 3D adaptive BEM space with piecewise constant basis functions.
Definition: space.hh:438
unsigned short ushort
Abbreviation for unsigned short.
Definition: typedefs.hh:48
std::ostream & info(std::ostream &os) const
Definition: space.hh:70
AdaptiveAdjust()
Default constructor.
Definition: space.hh:218
Constant3d(concepts::Mesh2 &msh, uint lvl, uint elmType=0)
Constructor.
uint nelm() const
Returns the number of elements of the space.
Definition: space.hh:744
concepts::DynArray< concepts::AdaptiveControl<> > ctrl_
Dynamic array of the control information for the elements.
Definition: space.hh:268
uint dim_
Number of degrees of freedom in the space.
Definition: space.hh:440
concepts::Joiner< concepts::Element< F > *, 1 > * elm_
Linked list of the elements in the space.
Definition: space.hh:39
A 3D cell: triangle.
Definition: cell2D.hh:719
std::ostream & info(std::ostream &os, uint mode=0) const
Gives some information about the space.
Abstract base class for an adaptive space.
Definition: space.hh:350
void adjust(const Constant3d001< F > &elm, const AdaptiveAdjust &a)
bool rebuild_
If true: the mesh has to be rebuilt (refined or coarsened)
Definition: space.hh:272
concepts::Scan< concepts::Element< F > > * scan() const
Returns a scanner of the space.
Definition: space.hh:196
uint dim_
Number of degrees of freedom in the space.
Definition: space.hh:35
uint nelm() const
Returns the number of elements of the space.
Definition: space.hh:365
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
void rebuild1_(concepts::Connector2 &cntr)
uint nelm() const
Returns the number of elements of the space.
Definition: space.hh:565
void constructor_(concepts::Triangle3d *cell, uint lvl, concepts::DynArray< uint > &map)
Private constructor for recursive construction.
uint maxlevel()
Returns the maximal level of all elements.
Definition: space.hh:577
uint nelm() const
Returns the number of elements.
Definition: space.hh:124
uint maxlvl_
Maximal level of all elements.
Definition: space.hh:264
concepts::Connector2 * pnl1
neighbouring panel on the higher level
Definition: space.hh:413
EdgeMap * prnt
pointer to the EdgeMap of the parent edge
Definition: space.hh:419
std::ostream & info(std::ostream &os) const
Definition: space.hh:287
uint nelm() const
Returns the number of elements.
Definition: space.hh:190
uint dim() const
Returns the number of degrees of freedom.
Definition: space.hh:122
uint maxlevel()
Returns the maximal level of all elements.
Definition: space.hh:377
A 3D adaptive BEM space with piecewise constant basis functions without any constaints.
Definition: space.hh:253
A 3D space with Dirac basis functions.
Definition: space.hh:33
Scanner for a list of pointers.
concepts::Joiner< concepts::ElementWithCell< F > *, 1 > * elm_
Linked list of the elements.
Definition: space.hh:444
std::ostream & info(std::ostream &os) const
Definition: space.hh:110
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich