Class documentation of Concepts

Loading...
Searching...
No Matches
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"
15#include "geometry/cellConditions.hh"
16#include "space/space.hh"
17#include "hp1D/element.hh"
18#include "hp2D/element.hh"
19#include "hp2D/edge.hh"
20
21namespace concepts {
22
23 // forward declaration
24 class EdgeNormalVectorRule;
25}
26
27namespace hp2D {
28
29 using concepts::Real;
30
31 // forward declaration
32 template<typename F>
33 class Quad;
34
35
36 // ************************************************************ TraceSpace **
37
51 class TraceSpace : public concepts::SpaceOnCells<Real> {
52 public:
55
56 enum traceTypes { FIRST, MEAN, JUMP };
57
64 const concepts::Set<uint> edgeAttr,
65 enum traceTypes type = FIRST,
67 normalVectorRule = concepts::EdgeNormalVectorRule());
68
78 const concepts::CellConditions* cc = 0,
79 enum traceTypes type = FIRST,
81 normalVectorRule = concepts::EdgeNormalVectorRule());
83 const concepts::CellConditions* cc = 0,
84 enum traceTypes type = FIRST,
86 normalVectorRule = concepts::EdgeNormalVectorRule());
87
88 virtual ~TraceSpace();
89
90 virtual uint dim() const { return dim_; }
91
93 virtual uint nelm() const { return nelm_; }
94
96 virtual Scan* scan() const
97 {
99 }
100
103 uelm(const concepts::Edge edge) const
104 {
106 const_iterator i = uelm_.find(edge.key());
107 if (i == uelm_.end())
109 return i->second;
110 }
111
116 uelm() const
117 {
118 return uelm_;
119 }
120
125 protected:
126 virtual std::ostream& info(std::ostream& os) const;
127 private:
129 const uint dim_;
130
132 uint nelm_;
133
136
139
142
143 std::unique_ptr<QuadEdgeBase> quadEdge_;
144
145 bool warn_edgeBuildMissElem_;
146
147 void constructType_(enum traceTypes type,
148 const concepts::EdgeNormalVectorRule& normalVectorRule);
149
153 template<class F>
154 bool build_(const Quad<Real>* elm, F condition);
155
159 template<class F>
160 void test_(const concepts::ElementWithCell<Real>& elm, F condition);
161 };
162
163} // namespace hp2D
164
165namespace concepts {
166
167 // *********************************************** DirichletElementFormula **
168
178 public:
179 DirichletElementFormula(const BoundaryConditions bc) : bc_(bc) {}
180
181 virtual F operator() (const ElementWithCell<G>& elm, const Real p,
182 const Real t = 0.0) const;
183 virtual F operator() (const ElementWithCell<G>& elm, const Real2d& p,
184 const Real t = 0.0) const;
185 virtual F operator() (const ElementWithCell<G>& elm, const Real3d& p,
186 const Real t = 0.0) const;
189 return new DirichletElementFormula<F,G>(bc_);
190 }
191 protected:
192 virtual std::ostream& info(std::ostream& os) const;
193 private:
194 const BoundaryConditions bc_;
195
196 template<typename P>
197 F compute_(const Element<G>& elm, const P& p, const Real t) const {
198 const ElementWithCell<G>* e =
199 dynamic_cast<const ElementWithCell<G>*>(&elm);
201 const Cell& cell = e->cell();
202 const Boundary b(bc_(cell.connector().attrib()));
203 if (b.type() != Boundary::DIRICHLET)
204 throw(ElementNotInDomainOfFormula(elm, *this));
205
206 F val = 0.0;
207 if (!compute_(dynamic_cast<const Edge2d*>(&cell), b, p, t, val))
209 ("element not supported"));
210
211 return val;
212 }
213
214 bool compute_(const Edge2d* cell, const Boundary b,
215 const Real p, const Real t, F& val) const {
216 if (cell) {
217 val = b(cell->chi(p), t);
218 return true;
219 }
220 return false;
221 }
222
223 template<typename P>
224 bool compute_(const Edge2d* cell, const Boundary b,
225 const P& p, const Real t, F& val) const {
226 throw conceptsException(concepts::MissingFeature("p should be a real"));
227 return false;
228 }
229 };
230
231} // namespace concepts
232
233
234namespace hp2D {
235
236 namespace l2 {
237
238 using concepts::Real;
239
240 // forward declaration
241 template<typename F>
242 class Quad;
243
244 // ************************************************************ TraceSpace **
245
259 class TraceSpace : public concepts::SpaceOnCells<Real> {
260 public:
262 typedef concepts::ElementAndFacette<hp2D::Element<Real> > UnderlyingElement;
263
264 enum traceTypes { FIRST, MEAN, JUMP };
265
271 TraceSpace(const concepts::SpaceOnCells<Real>& spc,
272 const concepts::Set<uint> edgeAttr,
273 enum traceTypes type = FIRST,
275 normalVectorRule = concepts::EdgeNormalVectorRule());
276
285 TraceSpace(concepts::SpaceOnCells<Real>& spc,
286 const concepts::CellConditions* cc = 0,
287 enum traceTypes type = FIRST,
289 normalVectorRule = concepts::EdgeNormalVectorRule());
290 TraceSpace(const concepts::SpaceOnCells<Real>& spc,
291 const concepts::CellConditions* cc = 0,
292 enum traceTypes type = FIRST,
294 normalVectorRule = concepts::EdgeNormalVectorRule());
295
296 virtual ~TraceSpace();
297
298 virtual uint dim() const { return dim_; }
299
301 virtual uint nelm() const { return nelm_; }
302
304 virtual Scan* scan() const
305 {
307 }
308
311 uelm(const concepts::Edge edge) const
312 {
314 const_iterator i = uelm_.find(edge.key());
315 if (i == uelm_.end())
317 return i->second;
318 }
319
324 uelm() const
325 {
326 return uelm_;
327 }
328
332 virtual void recomputeShapefunctions();
333 protected:
334 virtual std::ostream& info(std::ostream& os) const;
335 private:
337 const uint dim_;
338
340 uint nelm_;
341
344
347
350
351 std::unique_ptr<QuadEdgeBase> quadEdge_;
352
353 bool warn_edgeBuildMissElem_;
354
355 void constructType_(enum traceTypes type,
356 const concepts::EdgeNormalVectorRule& normalVectorRule);
357
361 template<class F>
362 bool build_(const Quad<Real>* elm, F condition);
363
367 template<class F>
368 void test_(const concepts::ElementWithCell<Real>& elm, F condition);
369 };
370
371 } // namespace l2
372
373
374} // namespace hp2D
375
376#endif // hp2dtraces_hh
#define conceptsException(exc)
virtual Connector & connector() const =0
Returns the connector.
const Key & key() const
Returns the key of the connector.
Definition connector.hh:105
const Attribute & attrib() const
Returns the attribute of the connector.
Definition connector.hh:108
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual F operator()(const ElementWithCell< G > &elm, const Real p, const Real t=0.0) const
virtual DirichletElementFormula< F, G > * clone() const
Virtual copy constructor.
Definition traces.hh:188
Real2d chi(Real xi) const
virtual const Cell & cell() const =0
Returns the cell on which the element is built.
const concepts::Sequence< UnderlyingElement > uelm(const concepts::Edge edge) const
Returns the underlying 2D elements.
Definition traces.hh:103
virtual Scan * scan() const
Returns a scanner to iterate over the elements of the space.
Definition traces.hh:96
TraceSpace(concepts::SpaceOnCells< Real > &spc, const concepts::CellConditions *cc=0, enum traceTypes type=FIRST, const concepts::EdgeNormalVectorRule normalVectorRule=concepts::EdgeNormalVectorRule())
const concepts::HashMap< concepts::Sequence< UnderlyingElement > > uelm() const
Definition traces.hh:116
virtual uint dim() const
Returns the dimension of the space.
Definition traces.hh:90
virtual uint nelm() const
Returns the number of elements in the space.
Definition traces.hh:93
TraceSpace(const concepts::SpaceOnCells< Real > &spc, const concepts::Set< uint > edgeAttr, enum traceTypes type=FIRST, const concepts::EdgeNormalVectorRule &normalVectorRule=concepts::EdgeNormalVectorRule())
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void recomputeShapefunctions()
#define conceptsAssert(cond, exc)
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320