space.hh

Go to the documentation of this file.
1 
6 #ifndef hpSpace2D_hh
7 #define hpSpace2D_hh
8 
9 #include <memory>
10 #include <cstring>
11 #include <set>
12 #include "basics/exceptions.hh"
13 #include "basics/typedefs.hh"
15 #include "toolbox/hashMap.hh"
17 #include "geometry/cell2D.hh"
18 #include "geometry/mesh.hh"
20 #include "space/space.hh"
21 #include "space/hpMethod.hh"
22 #include "element.hh"
23 
24 namespace concepts {
25 
26  // forward declarations
27  template<class F>
28  class SMatrixBase;
29 
30  class SMatrix1D;
31 
32 // // ****************************************************************** Scan **
33 
34 // template<>
35 // class Scan<hp2D::Element<Real> > :
36 // public concepts::Scan<concepts::Element<Real> >
37 // {
38 // public:
39 // hp2D::Element<Real>& operator++(int) = 0;
40 // };
41 
42 } // namespace concepts
43 
44 namespace hp2D {
45  using concepts::Real;
46 
47  // forward declarations
48  template<class F>
49  class Quad;
50 
51  class BuildDofsBase;
52 
53  // ****************************************************** IndexNotExisting **
54 
60 
61  // ***************************************************************** Space **
62 
85  class Space :
86  public concepts::SpaceOnCells<Real>,
87  public concepts::AdaptiveSpace<Real, concepts::AdaptiveAdjustP<2> >
88  {
89  public:
90  friend class BuildDofsBase;
91 
93 
104  Space(concepts::Mesh2& msh, uint l, uint p,
109  Space(const Space& spc);
110  virtual ~Space();
111 
112  inline virtual uint dim() const;
113  inline virtual uint nelm() const;
114  inline virtual Scan* scan() const;
119  inline Scan* constScan() const;
120 
121  inline uint dim();
122  inline uint nelm();
123  inline Scan* scan();
124 
125  virtual void adjust(const concepts::Element<Real>& elm,
127 
146 
158 
166  void buildEdgeDofs(const BuildDofsBase& b);
167 
177 
179  uint connectedIdx(const concepts::Attribute& a) const;
180 
185  protected:
186  virtual std::ostream& info(std::ostream& os) const;
187  private:
192 
197  bool rebuild_;
198 
200  uint dim_;
201 
203  uint nelm_;
204 
207 
209  std::unordered_map<uint, concepts::AdaptiveControl<> > ctrl0_;
211  std::unique_ptr<std::unordered_map< uint, concepts::AdaptiveControlP<1> > > ctrl1_;
213  std::unordered_map<uint, concepts::AdaptiveControlP<2> > ctrl2_;
214 
216  std::unordered_map<uint, concepts::AdaptiveControl<> > ctrlc0_;
217 
219  std::unordered_map<uint, const concepts::Attribute*> vtxConnect_;
220 
222  std::map<uint, concepts::CellData> cellList_;
224  std::map<uint, concepts::EdgeData> edgeList_;
226  std::map<uint, concepts::VertexData> vertexList_;
227 
228  /* Linked list of ghost cells, created for handling subdivision
229  in 4 quadrilaterials
230  */
231  // concepts::Joiner<concepts::Quad*, 1>* ghostCells_;
232 
234  std::unordered_map<uint, concepts::AdaptiveAdjustP<2> > adj_;
235 
237  std::unique_ptr<concepts::SMatrix1D> S1left_, S1right_;
241  std::unique_ptr<concepts::SMatrixBase<Real> > Smatrices2H_[2];
245  std::unique_ptr<concepts::SMatrixBase<Real> > Smatrices2V_[2];
249  std::unique_ptr<concepts::SMatrixBase<Real> > Smatrices4_[4];
250 
254  std::unique_ptr<BuildDofsBase> buildVertexDofs_;
258  std::unique_ptr<BuildDofsBase> buildEdgeDofs_;
262  std::unique_ptr<BuildDofsBase> buildInnerDofs_;
263 
264  private:
286 
291  void enforceBC_(const concepts::Connector2& cell);
292 
295  const concepts::CellData* father);
298 
313  void enrichElm_(const concepts::Quad2d& cell, int* p);
314 
325  const concepts::Connector1& edge);
326 
341  concepts::TColumn<Real>* T0 = 0);
342 
344 
350  ushort Pmax[2]) const;
351 
358  void recomputeSmatrices_(const Quad<Real>& elm);
359 
360  void deactivate_(const concepts::Edge& edg);
361  void deactivate_(const concepts::Vertex& vtx);
362 
380  void status_();
382 
383 
390  Space(const Space& spc, uint i);
391  };
392 
393  uint Space::dim() const {
395  return dim_;
396  }
397 
398  uint Space::nelm() const {
400  return nelm_;
401  }
402 
405  return new concepts::PListScan<Element<Real> >(*elm_);
406  }
407 
409  return new concepts::PListScan<Element<Real> >(*elm_);
410  }
411 
412  uint Space::dim() {
413  if (rebuild_) rebuild();
414  return dim_;
415  }
416 
417  uint Space::nelm() {
418  if (rebuild_) rebuild();
419  return nelm_;
420  }
421 
423  if (rebuild_) rebuild();
424  return new concepts::PListScan<Element<Real> >(*elm_);
425  }
426 
427 } // namespace hp2D
428 
429 #include "buildDofsBase.hh"
430 
431 #endif // hpSpace2D_h
virtual std::ostream & info(std::ostream &os) const
Mesh.
std::unique_ptr< concepts::SMatrixBase< Real > > Smatrices4_[4]
S matrices for subdivision into 4 quads.
Definition: space.hh:249
A column of a T matrix.
Definition: analytical.hh:18
void createCellList_(const concepts::Connector &cntr, const concepts::CellData *father)
Initially fills cellList_ (recusively)
void enforceBC_(const concepts::Connector2 &cell)
Enforce Dirichlet boundary conditions.
Space(const Space &spc)
Copy constructor.
void matlabstatus_()
Mesh.
std::unordered_map< uint, concepts::AdaptiveAdjustP< 2 > > adj_
Hash table of the adjustment information of the elements.
Definition: space.hh:234
A 2D cell: quadrilateral.
Definition: cell2D.hh:378
void createVtxEdgList_(const concepts::Connector2 &cell)
Initially fills edgeListVtx_ and vertexList_.
uint dim_
Dimension of the FE space.
Definition: space.hh:200
std::unique_ptr< BuildDofsBase > buildEdgeDofs_
Strategy to build the edge degrees of freedom.
Definition: space.hh:258
#define conceptsException(exc)
Prepares an exception for throwing.
Definition: exceptions.hh:344
Base class for exceptions.
Definition: exceptions.hh:86
void deactivate_(const concepts::Vertex &vtx)
Mesh.
Stores additional information on a cell, namely its father.
Joiner class with multiple successors, i.e.
std::unordered_map< uint, concepts::AdaptiveControlP< 2 > > ctrl2_
Hash table of the control information for the 2D elements.
Definition: space.hh:213
A cell in a mesh consist of topological information (neighbours, connectivity, orientation) and geome...
Definition: cell.hh:39
void buildInnerDofs(const BuildDofsBase &b)
Change the strategy how the degrees of freedom for the interior are built.
std::map< uint, concepts::VertexData > vertexList_
List of vertices.
Definition: space.hh:226
bool rebuild_
If true: the elements have to be rebuilt.
Definition: space.hh:197
std::map< uint, concepts::CellData > cellList_
List of cells.
Definition: space.hh:222
void recomputeSmatrices_(const Quad< Real > &elm)
Checks if the S matrices need to be recomputed and does so if necessary.
2D hp-FEM for H1-conforming elements.
std::unique_ptr< concepts::SMatrixBase< Real > > Smatrices2H_[2]
S matrices for horizontal subdivision.
Definition: space.hh:241
void meshAndPoly_(concepts::Quad2d &cell, concepts::Level< 2 > &L, int *P)
Adjusts the mesh and the polynomial degree.
Space(const Space &spc, uint i)
Copy constructor used to return a snapshot of the old space from rebuild()
void buildVertexDofs(const BuildDofsBase &b)
Change the strategy how the degrees of freedom for the vertices are built.
virtual ~Space()
concepts::BoundaryConditions * bc_
Boundary conditions.
Definition: space.hh:191
std::unique_ptr< concepts::SMatrixBase< Real > > Smatrices2V_[2]
S matrices for vertical subdivision.
Definition: space.hh:245
Space rebuild()
Rebuilds the space.
std::unique_ptr< concepts::SMatrix1D > S1right_
Mesh.
Definition: space.hh:237
uint nelm_
Number of elements currently active in the mesh.
Definition: space.hh:203
virtual Scan * scan() const
Definition: space.hh:403
A vertex in the topology.
Definition: topology.hh:40
std::unique_ptr< std::unordered_map< uint, concepts::AdaptiveControlP< 1 > > > ctrl1_
Hash table of the control information for the edges.
Definition: space.hh:211
virtual void adjust(const concepts::Element< Real > &elm, const concepts::AdaptiveAdjustP< 2 > &a)
A 2D element of the topology.
Definition: connector.hh:226
concepts::Joiner< Element< Real > *, 1 > * elm_
Linked list of the elements.
Definition: space.hh:206
std::unordered_map< uint, const concepts::Attribute * > vtxConnect_
Hash table for connected vertex dofs (mapping from cell key)
Definition: space.hh:219
An abstract class for scanning a mesh (a set of cells) or a space (a set of elements).
void status_()
Gives the cells and edges with given polynomial degree (for debugging)
An abstract class for 2D meshes.
Definition: mesh.hh:103
void minimumRule_(const concepts::Connector2 &cntr, const concepts::Connector1 &edge)
Used to enforce the minimum rule.
std::unique_ptr< BuildDofsBase > buildInnerDofs_
Strategy to build the inner degrees of freedom.
Definition: space.hh:262
concepts::Mesh2 & msh_
Mesh.
Definition: space.hh:189
Exception class to express that a connected index wasn't found.
Definition: space.hh:59
Indicates that the space on which a function was called was not yet correctly built.
Definition: space.hh:36
virtual uint dim() const
Definition: space.hh:393
bool activeCell_(concepts::Cell &cell)
Checks if a cell is in active region.
void deactivate_(const concepts::Edge &edg)
Mesh.
std::map< uint, concepts::EdgeData > edgeList_
List of edges.
Definition: space.hh:224
void buildEdgeDofs(const BuildDofsBase &b)
Change the strategy how the degrees of freedom for the edge are built.
virtual uint nelm() const
Definition: space.hh:398
void recomputeShapefunctions()
Recompute shape functions, e.g.
void computePmax_(const concepts::Connector2 &cntr, ushort Pmax[2]) const
Computes the maximal polynomial degree of cell in each direction.
A 2D hp FEM space with continuous, piecewise polynomial basis functions.
Definition: space.hh:88
void buildEmptyElements_(concepts::Quad2d &cell)
Mesh.
Abstract class for a space.
Definition: space.hh:81
A 1D element of the topology.
Definition: connector.hh:182
std::unique_ptr< concepts::SMatrix1D > S1left_
S matrices in 1D.
Definition: space.hh:237
unsigned short ushort
Abbreviation for unsigned short.
Definition: typedefs.hh:48
uint connectedIdx(const concepts::Attribute &a) const
Gives the number of connected dofs for one attribute.
void buildElements_(concepts::Quad2d &cell, ushort *Pmax, concepts::TColumn< Real > *T0=0)
Creates the elements and their T matrices.
void enrichElm_(const concepts::Quad2d &cell, int *p)
Enriches the polynomial degrees.
Abstract base class for an adaptive space.
Definition: space.hh:350
Scan * constScan() const
Returns constant scanner over elements of last build, In contrast to scan(), this method also workes,...
Definition: space.hh:408
Responsible to build the degrees of freedom in a space.
std::unordered_map< uint, concepts::AdaptiveControl<> > ctrl0_
Hash table of the control information for the vertices.
Definition: space.hh:209
An edge in the topology.
Definition: topology.hh:73
concepts::Scan< hp2D::Element< Real > > Scan
Definition: space.hh:92
std::unique_ptr< BuildDofsBase > buildVertexDofs_
Strategy to build the vertex degrees of freedom.
Definition: space.hh:254
Space(concepts::Mesh2 &msh, uint l, uint p, concepts::BoundaryConditions *bc=0)
Constructor.
Attributes for elements of the topology.
Definition: connector.hh:22
An abstract class for elements of the topology.
Definition: connector.hh:85
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Scanner for a list of pointers.
std::unordered_map< uint, concepts::AdaptiveControl<> > ctrlc0_
Hash table for connected vertex dofs (mapping from attribute)
Definition: space.hh:216
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich