traces.hh

Go to the documentation of this file.
1 
8 #ifndef hp2dtraces_hh
9 #define hp2dtraces_hh
10 
11 #include "toolbox/sequence.hh"
12 #include "formula/boundary.hh"
13 #include "formula/exceptions.hh"
16 #include "space/space.hh"
17 #include "hp1D/element.hh"
18 #include "hp2D/element.hh"
19 #include "hp2D/edge.hh"
20 
21 
22 namespace concepts {
23 
24  // forward declaration
25  class EdgeNormalVectorRule;
26 }
27 
28 namespace hp2D {
29 
30  using concepts::Real;
31 
32  // forward declaration
33  template<typename F>
34  class Quad;
35 
36 
37  // ************************************************************ TraceSpace **
38 
52  class TraceSpace : public concepts::SpaceOnCells<Real> {
53  public:
56 
57  enum traceTypes { FIRST, MEAN, JUMP };
58 
65  const concepts::Set<uint> edgeAttr,
66  enum traceTypes type = FIRST,
68  normalVectorRule = concepts::EdgeNormalVectorRule());
69 
79  const concepts::CellConditions* cc = 0,
80  enum traceTypes type = FIRST,
82  normalVectorRule = concepts::EdgeNormalVectorRule());
84  const concepts::CellConditions* cc = 0,
85  enum traceTypes type = FIRST,
87  normalVectorRule = concepts::EdgeNormalVectorRule());
88 
89  virtual ~TraceSpace();
90 
91  virtual uint dim() const { return dim_; }
92 
94  virtual uint nelm() const { return nelm_; }
95 
97  virtual Scan* scan() const
98  {
100  }
101 
104  uelm(const concepts::Edge edge) const
105  {
107  const_iterator i = uelm_.find(edge.key());
108  if (i == uelm_.end())
110  return i->second;
111  }
112 
117  uelm() const
118  {
119  return uelm_;
120  }
121 
125  virtual void recomputeShapefunctions();
126  protected:
127  virtual std::ostream& info(std::ostream& os) const;
128  private:
130  const uint dim_;
131 
133  uint nelm_;
134 
137 
140 
143 
144  std::unique_ptr<QuadEdgeBase> quadEdge_;
145 
147 
149  const concepts::EdgeNormalVectorRule& normalVectorRule);
150 
154  template<class F>
155  bool build_(const Quad<Real>* elm, F condition);
156 
157 
161  template<class F>
162  void test_(const concepts::ElementWithCell<Real>& elm, F condition);
163  };
164 
165 } // namespace hp2D
166 
167 namespace concepts {
168 
169  // *********************************************** DirichletElementFormula **
170 
178  template<typename F, typename G = typename Realtype<F>::type>
180  public:
182 
183  virtual F operator() (const ElementWithCell<G>& elm, const Real p,
184  const Real t = 0.0) const;
185  virtual F operator() (const ElementWithCell<G>& elm, const Real2d& p,
186  const Real t = 0.0) const;
187  virtual F operator() (const ElementWithCell<G>& elm, const Real3d& p,
188  const Real t = 0.0) const;
191  return new DirichletElementFormula<F,G>(bc_);
192  }
193  protected:
194  virtual std::ostream& info(std::ostream& os) const;
195  private:
197 
198  template<typename P>
199  F compute_(const Element<G>& elm, const P& p, const Real t) const {
200  const ElementWithCell<G>* e =
201  dynamic_cast<const ElementWithCell<G>*>(&elm);
203  const Cell& cell = e->cell();
204  const Boundary b(bc_(cell.connector().attrib()));
205  if (b.type() != Boundary::DIRICHLET)
206  throw(ElementNotInDomainOfFormula(elm, *this));
207 
208  F val = 0.0;
209  if (!compute_(dynamic_cast<const Edge2d*>(&cell), b, p, t, val))
211  ("element not supported"));
212 
213  return val;
214  }
215 
216  bool compute_(const Edge2d* cell, const Boundary b,
217  const Real p, const Real t, F& val) const {
218  if (cell) {
219  val = b(cell->chi(p), t);
220  return true;
221  }
222  return false;
223  }
224 
225  template<typename P>
226  bool compute_(const Edge2d* cell, const Boundary b,
227  const P& p, const Real t, F& val) const {
228  throw conceptsException(concepts::MissingFeature("p should be a real"));
229  return false;
230  }
231  };
232 
233 } // namespace hp2D
234 
235 #endif // hp2dtraces_hh
Dirichlet Data as element formula.
Definition: traces.hh:179
virtual Connector & connector() const =0
Returns the connector.
Real2d chi(Real xi) const
The element map.
DirichletElementFormula(const BoundaryConditions bc)
Definition: traces.hh:181
bool build_(const Quad< Real > *elm, F condition)
Builds elements for the edges w.r.t.
Builds the trace space of an FE space.
Definition: traces.hh:52
bool warn_edgeBuildMissElem_
Definition: traces.hh:146
virtual uint nelm() const
Returns the number of elements in the space.
Definition: traces.hh:94
const Attribute & attrib() const
Returns the attribute of the connector.
Definition: connector.hh:108
bool compute_(const Edge2d *cell, const Boundary b, const Real p, const Real t, F &val) const
Definition: traces.hh:216
#define conceptsException(exc)
Prepares an exception for throwing.
Definition: exceptions.hh:344
std::unique_ptr< QuadEdgeBase > quadEdge_
Definition: traces.hh:144
TraceSpace(const concepts::SpaceOnCells< Real > &spc, const concepts::CellConditions *cc=0, enum traceTypes type=FIRST, const concepts::EdgeNormalVectorRule normalVectorRule=concepts::EdgeNormalVectorRule())
Joiner class with multiple successors, i.e.
A cell in a mesh consist of topological information (neighbours, connectivity, orientation) and geome...
Definition: cell.hh:39
const BoundaryConditions bc_
Definition: traces.hh:196
concepts::Joiner< hp1D::BaseElement< Real > *, 1 > * elm_
Linked list of the elements.
Definition: traces.hh:136
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
A 1D cell: edge in 2D.
Definition: cell1D.hh:189
2D hp-FEM for H1-conforming elements.
concepts::ElementAndFacette< hp2D::Element< Real > > UnderlyingElement
Definition: traces.hh:55
virtual uint dim() const
Definition: traces.hh:91
void test_(const concepts::ElementWithCell< Real > &elm, F condition)
Test if not implemented elements have edges w.r.t.
bool compute_(const Edge2d *cell, const Boundary b, const P &p, const Real t, F &val) const
Definition: traces.hh:226
F compute_(const Element< G > &elm, const P &p, const Real t) const
Definition: traces.hh:199
Exception class for assertions.
Definition: exceptions.hh:258
concepts::HashMap< concepts::Sequence< UnderlyingElement > > uelm_
Map from key of (topological) edge to the underlying 2D elements.
Definition: traces.hh:139
Class to describe an element of the boundary.
Definition: boundary.hh:35
virtual DirichletElementFormula< F, G > * clone() const
Virtual copy constructor.
Definition: traces.hh:190
const Key & key() const
Returns the key of the connector.
Definition: connector.hh:105
virtual ~TraceSpace()
Interface for a formula defined element by element.
virtual F operator()(const ElementWithCell< G > &elm, const Real p, const Real t=0.0) const
concepts::Scan< hp1D::BaseElement< Real > > Scan
Definition: traces.hh:54
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
An abstract class for scanning a mesh (a set of cells) or a space (a set of elements).
void constructType_(enum traceTypes type, const concepts::EdgeNormalVectorRule &normalVectorRule)
Base class for defining rules in which direction the normal vector should point for created edges fro...
Definition: normalVector.hh:31
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
virtual void recomputeShapefunctions()
Recompute shape functions, e.g.
enum boundaryTypes type() const
Returns the type of the boundary condition.
Definition: boundary.hh:74
const concepts::Sequence< UnderlyingElement > uelm(const concepts::Edge edge) const
Returns the underlying 2D elements.
Definition: traces.hh:104
virtual const Cell & cell() const =0
Returns the cell on which the element is built.
Abstract class for a space.
Definition: space.hh:81
Exception class to express a missing feature.
Definition: exceptions.hh:206
const concepts::HashMap< concepts::Sequence< UnderlyingElement > > uelm() const
Returns the mapping from the key of (topological) edge to the underlying 2D elements.
Definition: traces.hh:117
TraceSpace(concepts::SpaceOnCells< Real > &spc, const concepts::CellConditions *cc=0, enum traceTypes type=FIRST, const concepts::EdgeNormalVectorRule normalVectorRule=concepts::EdgeNormalVectorRule())
Constructor.
virtual Scan * scan() const
Returns a scanner to iterate over the elements of the space.
Definition: traces.hh:97
Exception class to express that an inquired element is not in the domain.
Definition: exceptions.hh:24
TraceSpace(const concepts::SpaceOnCells< Real > &spc, const concepts::Set< uint > edgeAttr, enum traceTypes type=FIRST, const concepts::EdgeNormalVectorRule &normalVectorRule=concepts::EdgeNormalVectorRule())
Constructor.
An edge in the topology.
Definition: topology.hh:73
const uint dim_
Dimension of the FE space.
Definition: traces.hh:130
uint nelm_
Number of elements currently active in the mesh.
Definition: traces.hh:133
Container for an element and one facette (edge or face).
Definition: element.hh:113
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
virtual std::ostream & info(std::ostream &os) const
concepts::HashMap< hp1D::Element< Real > * > edges_
Map from key of (topological) edge to the element.
Definition: traces.hh:142
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Scanner for a list of pointers.
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich