spacePreBuilder.hh

Go to the documentation of this file.
1 /* space pre builder classes for 2D spaces
2 */
3 
4 #ifndef hpSpacePreBuilder2D_hh
5 #define hpSpacePreBuilder2D_hh
6 
7 #include <set>
8 #include <queue>
10 #include "geometry/cell2D.hh"
11 #include "space/spacePreBuilder.hh"
12 #include "space/space.hh"
13 #include "space/hpMethod.hh" // for AdaptiveControlP
14 #include "toolbox/stiffArray.hh"
15 #include "toolbox/multiArray.hh"
16 #include "toolbox/hashMap.hh"
17 #include "toolbox/sequence.hh"
18 #include "toolbox/set.hh"
19 #include "hp2D/edgeMinMax.hh"
20 
21 // If flag is set to 1, edgelist_ and vertexlist_ collect keys, not
22 // local indices. That is easier to debug, but lightly slower.
23 #define KeyLists 1
24 
25 namespace hp2D {
26 
27  // *********************************************************** NotValidDof **
28 
33  // class NotValidDof : public concepts::ExceptionBase {};
34 
35  // ******************************************************* SpacePreBuilder **
36 
38  public:
42  virtual ~SpacePreBuilder() {}
43 
45  virtual concepts::Mesh2& mesh() const { return msh_; }
48  virtual bool vtxDof(const concepts::Connector2& cntr, uint i) const = 0;
53  virtual ushort edgeDof(const concepts::Connector2& cntr, uint i) const = 0;
58  virtual const ushort* innerDof(const concepts::Connector2& cntr) const = 0;
66  virtual const ushort* pMax(const concepts::Connector2& cntr,
67  ushort* p = 0) const = 0;
72  virtual ushort edgeP(const concepts::Connector2& cntr, uint i) const = 0;
73 
74  //not necessary declaration, but usefull for pyplusplus
75  virtual concepts::IndexRange&
76  setIndex(uint& firstIdx, uint noIdx, uint dim,
77  const concepts::Connector& cntr, uint i = 0,
78  uint spcNo = 0) throw(concepts::NotValidDof) = 0;
79 
80  //not necessary declaration, but usefull for pyplusplus
81  virtual concepts::Set<concepts::IndexRange> indices
82  (uint dim, const concepts::Connector& cntr, uint spcNo = 0) const
83  throw(concepts::MissingFeature) = 0;
84 
85  protected:
87  concepts::Mesh2& msh_;
88  };
89 
90  typedef concepts::Adaptivity<concepts::Connector,
91  concepts::AdaptiveAdjustP<2> > Adaptivity;
92 
93  // *********************************************************** DegreeDim **
94 
103  template<typename F>
104  struct DegreeDim {};
105 
106  template<>
107  struct DegreeDim<concepts::Quad> { static const ushort dim = 2; };
108 
109  template<>
110  struct DegreeDim<concepts::InfiniteQuad> { static const ushort dim = 2; };
111 
112  template<>
113  struct DegreeDim<concepts::Triangle> { static const ushort dim = 1; };
114 
115 
116  // **************************************************************** hpFull **
117 
168  class hpFull : public SpacePreBuilder, public Adaptivity {
169  public:
171  hpFull(concepts::Mesh2& msh, uint l = 0, uint p = 1, bool build = false);
176  hpFull(const hpFull& preBuild);
178  virtual ~hpFull() {}
179 
180  void setPolyEdgeRule(const PolyEdgeRule& rule);
181 
185  virtual void adjust(const concepts::Connector& cell,
191  void adjust(const uint nrCell, const concepts::AdaptiveAdjustP<2>& a);
197 
204  uint available() const { return rebuild_ ? 0 : build_; }
208  virtual void rebuildMesh();
212  virtual void rebuildDof();
215  virtual bool vtxDof(const concepts::Connector2& cntr, uint i) const;
220  virtual ushort edgeDof(const concepts::Connector2& cntr, uint i) const;
226  virtual const ushort* innerDof(const concepts::Connector2& cntr) const;
236  virtual const ushort* pMax(const concepts::Connector2& cntr,
237  ushort* p = 0) const;
242  virtual ushort edgeP(const concepts::Connector2& cntr, uint i) const;
251  const concepts::IndexRange& index(uint dim,
252  const concepts::Connector2& cntr,
253  uint i = 0, uint spcNo = 0) const;
266  virtual concepts::IndexRange&
267  setIndex(uint& firstIdx, uint noIdx, uint dim,
268  const concepts::Connector& cntr, uint i = 0,
269  uint spcNo = 0) throw(concepts::NotValidDof);
270 
277  virtual concepts::Set<concepts::IndexRange> indices
278  (uint dim, const concepts::Connector& cntr, uint spcNo = 0) const
279  throw(concepts::MissingFeature);
280 
295  virtual void setP(uint p, const concepts::Set<uint>& donts);
296 
300  void clearAllIndices(uint spcNo = 0);
301 
303  uint ncells() { return cells_.size(); }
304 
306  bool isHangEdge(const concepts::Connector1& cntr) const;
310  void storeMatlab(const std::string name);
311 
313  concepts::Set<concepts::Cell2*> cells() const { return cells_; }
315  std::set<concepts::Cell2*> allCells() const { return allCells_; }
316  protected:
317  virtual std::ostream& info(std::ostream& os) const;
318  private:
322  bool rebuild_;
324  uint build_;
326  std::unique_ptr<const PolyEdgeRule> polyEdgeRule_;
327 
330 
331  // mapping from space number to an index range
332  typedef std::map<uint, concepts::IndexRange> IndexType;
333  // index range per space number for all 'member of space' vertices dof
335  // index range per space number for all 'member of space' edge dof
337  // index range per space number for all inner dof
339 
346 
360 
364  std::set<concepts::Cell2*> allCells_;
375 
377  bool isMember_(const concepts::Connector2& cntr) const;
379  bool isMember_(const concepts::Connector1& cntr) const;
380 
384  const ushort* pMinInner_(const concepts::Quad& quad);
385 
389  void refine_(concepts::Quad2d& cell, concepts::Level<2> L, short* P,
398 
404  std::set<const concepts::Connector1*>& edges);
405 
411  (const concepts::Connector1& edge, const concepts::Connector1& cntr1,
412  std::set<const concepts::Connector1*>& edges,
413  std::set<const concepts::Connector0*>& vertices);
414 
416  template<class F>
417  bool getEdgeSupport_(F cntr);
418 
419  class Cause : public std::pair<const concepts::Connector2*,
420  const concepts::Connector1*>,
422  {
423  public:
425  const concepts::Connector1* edge) :
426  std::pair<const concepts::Connector2*,
427  const concepts::Connector1*>(cell, edge) {}
428  protected:
429  virtual std::ostream& info(std::ostream& os) const {
430  return os << concepts::typeOf(*this)<<"(causing cell = " << *this->first
431  << ", appropiate edge = " << *this->second << ")";
432  }
433  };
434 
438  template<class F>
440  (F cntr,
441  concepts::HashMap<std::queue<Cause> >& nonLocal);
442 
445  (const concepts::Connector2& cntr, const std::set<uint>& vertices,
446  std::map<uint, concepts::Sequence<const concepts::Connector2*> >& rootCells);
447 
453  (concepts::HashMap<std::queue<Cause> >& nonLocal,
455  rootCells);
456 
471  (uint key, uint cKey,
474  std::map<uint,
476  std::map<uint, const concepts::Connector1*>& fatherEdges,
477  std::map<uint, uint>& mosEdges) const;
478 
485  bool eliminateNonCauses_(std::queue<Cause>& causes);
486 
487  void dependentEdges_(const concepts::Quad& quad);
489  const concepts::Edge& edge,
490  const concepts::Edge& oppEdge, const uint p);
491 
492  ushort* pMax_(const concepts::Quad& cntr) const;
493  ushort* pMax_(const concepts::InfiniteQuad& cntr) const;
494 
495  void setPmax_(const concepts::Connector2& cntr, ushort* Pmax);
496 
500  void polyHangingEdges_(const concepts::Connector1& edge, const uint& p);
501 
507  template<class F>
508  void findControl_(F*& ctrl, const concepts::Connector2& cntr, uint i);
509 
517  IndexType& findIndex_(uint dim, const concepts::Connector2& cntr,
518  uint i);
519  const IndexType& findIndex_(uint dim, const concepts::Connector2& cntr,
520  uint i) const;
521  };
522 
523 } // namespace hp2D
524 
525 #endif // hpSpacePreBuilder2D_hh
concepts::HashMap< concepts::StiffArray< 2, ushort > > pmax_
Hash table for polynomial degree in cells to represent all those basis functions whose support contai...
virtual ~hpFull()
Destructor.
virtual concepts::Set< concepts::IndexRange > indices(uint dim, const concepts::Connector &cntr, uint spcNo=0) const =0
Returns all indices of entities of a cell of a particular dimension.
ushort * pMax_(const concepts::InfiniteQuad &cntr) const
const concepts::IndexRange & index(uint dim, const concepts::Connector2 &cntr, uint i=0, uint spcNo=0) const
Returns the index range of the dof inside cell cntr.
bool isMember_(const concepts::Connector1 &cntr) const
Returns true, if edge is 'member of space'.
void findControl_(F *&ctrl, const concepts::Connector2 &cntr, uint i)
Returns pointer to control information ctrl of vertex, edge or inner dof i in cell cntr.
uint available() const
Returns 0 if the potential degrees of freedom has to be rebuilt with rebuildDof(),...
virtual const ushort * pMax(const concepts::Connector2 &cntr, ushort *p=0) const
Returns a pointer to the maximal polynomial degrees in the cell quad to represent all those basis fun...
concepts::HashMap< CtrlType_2 > ctrl2_
Hash table of the control information for the 2D cells.
A 2D cell: quadrilateral.
Definition: cell2D.hh:378
std::set< concepts::Cell2 * > allCells() const
Returns set of all cells.
void refine_(concepts::InfiniteQuad2d &cell, concepts::Level< 2 > L, short *P, concepts::HashMap< CtrlType_2 >::iterator &i2)
virtual ushort edgeDof(const concepts::Connector2 &cntr, uint i) const =0
Returns the maximal polynomial degree of the degrees of freedom on edge i in the cell cntr.
std::set< concepts::Cell2 * > allCells_
Set of all cells.
const ushort * pMinInner_(const concepts::Quad &quad)
Returns a pointer to the minimal polynomial degrees of the inner degrees in the cell quad and their c...
virtual void adjust(const concepts::Connector &cell, const concepts::AdaptiveAdjustP< 2 > &a)
Adjusts the mesh and polynomial degrees in the next rebuild step for this cell.
void memberEdges_(const concepts::Connector2 &cntr, std::set< const concepts::Connector1 * > &edges)
Collect all edges of cells without children in the set edges and assign the polynomial degree of each...
bool eliminateNonCauses_(std::queue< Cause > &causes)
Eliminate two causes of non-local decidability if the two edges are the same or one cause of non-loca...
A 2D FEM element: an infinite quad.
Definition: quad.hh:317
SpacePreBuilder(concepts::Mesh2 &msh)
Constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
concepts::HashMap< concepts::AdaptiveAdjustP< 2 > > adj_
Hash table of the adjustment information of the elements.
concepts::AdaptiveControl< IndexType > CtrlType_0
A infinite quadrilateral in the topology, which possess one Edge and two InfiniteEdges since one edge...
Definition: topology.hh:423
A quadrilateral in the topology.
Definition: topology.hh:272
virtual const ushort * innerDof(const concepts::Connector2 &cntr) const
Returns a pointer to the maximal polynomial degrees of the inner degree of freedom in the cell quad.
hpFull(const hpFull &preBuild)
Copy constructor, the copy contains the same mesh, all information about adjustments and degrees of f...
concepts::Set< concepts::Cell2 * > cells_
Set of cells of finest mesh (without children)
Class for a range of global indices.
Definition: space.hh:226
Helper class for building 2D hp-FEM spaces (space pre builder).
void polyDependentEdges_(const concepts::Quad &quad, const concepts::Edge &edge, const concepts::Edge &oppEdge, const uint p)
virtual ushort edgeP(const concepts::Connector2 &cntr, uint i) const =0
Returns the maximal polynomial degree of an edge i in cell cntr, if edge has degrees of freedom or is...
void adjust(const concepts::AdaptiveAdjustP< 2 > &a)
Adjusts the mesh and polynomial degrees in the next rebuild step for all 'member of space' cell.
virtual concepts::Mesh2 & mesh() const
Returns mesh.
concepts::Set< uint > hangEdges_
Keys of hanging edges (with and without children)
2D hp-FEM for H1-conforming elements.
void setPolyEdgeRule(const PolyEdgeRule &rule)
ushort * pMax_(const concepts::Quad &cntr) const
virtual const ushort * pMax(const concepts::Connector2 &cntr, ushort *p=0) const =0
Returns a pointer to the maximal polynomial degrees in the cell quad to represent all those basis fun...
Class to describe control structures of an adaptive space.
Definition: space.hh:271
Describe control structures of a high order adaptive space.
Definition: hpMethod.hh:28
uint build_
Number of the build.
concepts::AdaptiveControlP< 2, IndexType > CtrlType_2
void setPmax_(const concepts::Connector2 &cntr, ushort *Pmax)
concepts::HashMap< std::set< uint > > edgeList_
Hash table which maps from key of cell to the key of those edges, whose support cell is the cell.
void storeMatlab(const std::string name)
Stores the mesh and degrees of freedoms in a matlab file, ".m" ending is needed.
virtual concepts::IndexRange & setIndex(uint &firstIdx, uint noIdx, uint dim, const concepts::Connector &cntr, uint i=0, uint spcNo=0)=0
Sets the index range of the dof inside cell cntr and returns it.
bool isMember_(const concepts::Connector2 &cntr) const
Returns true, if cell is 'member of space'.
concepts::HashMap< CtrlType_0 > ctrl0_
Hash table of the control information for the vertices.
Container typename for multidimensional Array which is based on std::map.
Definition: multiArray.hh:33
void getRootCells_(const concepts::Connector2 &cntr, const std::set< uint > &vertices, std::map< uint, concepts::Sequence< const concepts::Connector2 * > > &rootCells)
Returns the roots of the cell families for the nonlocal vertices.
A 2D element of the topology.
Definition: connector.hh:226
virtual void rebuildMesh()
Rebuilds the mesh due to adjustments, set polynomial degrees in inner degrees of freedom.
void polyHangingEdges_(const concepts::Connector1 &edge, const uint &p)
Give recursivly edge and its hanging children edges the polynomial degree p in polyHang_.
concepts::HashMap< CtrlType_1 > ctrl1_
Hash table of the control information for the edges.
void getEdgeMappings_(uint key, uint cKey, const concepts::Sequence< const concepts::Connector2 * > &root, concepts::MultiArray< 2, const concepts::Connector2 * > &edgesToCell, std::map< uint, concepts::Sequence< const concepts::Connector2 * > > &edgeToCell, std::map< uint, const concepts::Connector1 * > &fatherEdges, std::map< uint, uint > &mosEdges) const
Returns.
virtual bool vtxDof(const concepts::Connector2 &cntr, uint i) const
Returns, if the i th vertex of cell cntr has a degree of freedom.
virtual concepts::IndexRange & setIndex(uint &firstIdx, uint noIdx, uint dim, const concepts::Connector &cntr, uint i=0, uint spcNo=0)
Sets the index range of the dof inside cell cntr and returns it.
An abstract class for 2D meshes.
Definition: mesh.hh:103
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
Two dimensional cell.
Definition: cell.hh:89
virtual ~SpacePreBuilder()
Destructor.
void refine_(concepts::Cell2 &cell, ushort *P, concepts::HashMap< CtrlType_2 >::iterator &i2)
Method for given the polynomial degrees to children, if the mesh was refined outside of this class.
bool getPretendedVertexSupport_(F cntr, concepts::HashMap< std::queue< Cause > > &nonLocal)
Collect for each cell that nodes, which pretend to belong to its support.
bool getEdgeSupport_(F cntr)
Collect for each cell those edges, which belong to its support.
const IndexType & findIndex_(uint dim, const concepts::Connector2 &cntr, uint i) const
A 2D cell: infinite quadrilateral.
Definition: cell2D.hh:610
ushort takeOutchildrenEdges_(const concepts::Connector1 &edge, const concepts::Connector1 &cntr1, std::set< const concepts::Connector1 * > &edges, std::set< const concepts::Connector0 * > &vertices)
Erase all hanging edges and hanging nodes from the sets edges and vertices and from the control objec...
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
concepts::HashMap< std::set< uint > > vertexList_
Hash table which maps from key of cell to the key of those vertices, whose support cell is the cell.
void getNonLocalVertexSupport_(concepts::HashMap< std::queue< Cause > > &nonLocal, const std::map< uint, concepts::Sequence< const concepts::Connector2 * > > &rootCells)
Enlarges the supports of non local vertex dof, that means to demark some cells from vertexList_ and t...
virtual const ushort * innerDof(const concepts::Connector2 &cntr) const =0
Returns a pointer to the maximal polynomial degrees of the inner degree of freedom in the cell quad.
Dimension of the degrees of freedom in a cell.
IndexType & findIndex_(uint dim, const concepts::Connector2 &cntr, uint i)
Returns pointer to index range and control tag of vertex, edge or inner dof i in cell cntr.
A 1D element of the topology.
Definition: connector.hh:182
unsigned short ushort
Abbreviation for unsigned short.
Definition: typedefs.hh:48
std::unique_ptr< const PolyEdgeRule > polyEdgeRule_
Rule for defining polynomial degrees on edges.
concepts::Set< concepts::Cell2 * > cells() const
Returns set of 'member of space' cells.
A 2D FEM element: a quad.
Definition: bf_advection.hh:44
virtual bool vtxDof(const concepts::Connector2 &cntr, uint i) const =0
Returns, if the i th vertex of cell cntr has a degree of freedom.
Base class for rules for polynomial degrees of edges.
Definition: edgeMinMax.hh:23
bool isHangEdge(const concepts::Connector1 &cntr) const
Returns true, if edge is hanging.
concepts::HashMap< concepts::StiffArray< 2, ushort > > pminInner_
Hash table for the polynomial degrees in non 'member of space' cells, which is the minimum of the pol...
std::map< uint, concepts::IndexRange > IndexType
void dependentEdges_(const concepts::Quad &quad)
Cause(const concepts::Connector2 *cell, const concepts::Connector1 *edge)
virtual ushort edgeP(const concepts::Connector2 &cntr, uint i) const
Returns the maximal polynomial degree of an edge i in cell cntr, if edge has degrees of freedom or is...
virtual void rebuildDof()
Rebuilds the potential degrees of freedom.
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
concepts::HashMap< ushort > polyDep_
Hash table for polynomial degree of dependent edges.
An edge in the topology.
Definition: topology.hh:73
hpFull(concepts::Mesh2 &msh, uint l=0, uint p=1, bool build=false)
Constructor.
Exception class to express that an inquired dof is not valid.
Class providing an output operator.
concepts::HashMap< ushort > polyHang_
Hash table for polynomial degree of hanging edges.
concepts::Mesh2 & msh_
Mesh.
virtual ushort edgeDof(const concepts::Connector2 &cntr, uint i) const
Returns the maximal polynomial degree of the degrees of freedom on edge i in the cell cntr.
void adjust(const uint nrCell, const concepts::AdaptiveAdjustP< 2 > &a)
Adjusts the mesh and polynomial degrees in the next rebuild step for the nrCell th 'member of space' ...
An abstract class for elements of the topology.
Definition: connector.hh:85
concepts::AdaptiveControlP< 1, IndexType > CtrlType_1
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
void refine_(concepts::Quad2d &cell, concepts::Level< 2 > L, short *P, concepts::HashMap< CtrlType_2 >::iterator &i2)
Method for refinement of mesh and enlargment of polynomial degrees of inner degrees of freedom.
bool rebuild_
If true: the potential degrees of freedom have to be rebuilt.
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich