element.hh

Go to the documentation of this file.
1 
6 #ifndef Element1D_h
7 #define Element1D_h
8 
9 #include "basics/debug.hh"
10 #include "basics/output.hh"
11 #include "basics/typedefs.hh"
13 #include "geometry/connector.hh"
14 #include "geometry/cell1D.hh"
15 #include "geometry/integral.hh"
16 #include "space/element.hh"
17 #include "space/tmatrix.hh"
18 #include "integration/quadRule.hh"
20 #include "integration/legendre.hh"
21 #include "lineGraphics.hh"
22 
23 // debugging Element
24 #define ElementConstr_D 0
25 #define ElementDestr_D 0
26 
27 namespace hp1D {
28 using concepts::Real;
29 
30 // ********************************************************* IntegrableElm **
31 
35 public:
37 
40  const concepts::Real3d chi(const Real x) const {
41  return cell_.elemMap(x);
42  }
43 
45  inline Real jacobianDeterminant(const Real x) const {
46  // factor comes due to integration over [-1,1]^2
47  return cell_.jacobianDeterminant(x) * 0.5;
48  }
49 
52  return int_.get();
53  }
54 
63  return rule_;
64  }
65 
66  virtual bool quadraturePoint(uint i, intPoint& p, intFormType form = ZERO,
67  bool localCoord = false) const;
68 protected:
72  std::unique_ptr<concepts::QuadratureRule1d> int_;
73  // Factory for the integration rule
75 };
76 
77 // ********************************************************* BaseElement **
78 
79 template<class F>
81 public:
82  typedef F FieldT;
83 
85  IntegrableElm(cell), p_(p) {
86  }
87  ;
88 
89  virtual ~BaseElement();
90 
91  virtual const concepts::Edge& support() const {
92  return cell_.connector();
93  }
94 
95  virtual concepts::Real3d vertex(uint i) const {
96  return cell_.vertex(i);
97  }
98 
99  virtual const concepts::EdgeNd& cell() const {
100  return cell_;
101  }
102 
103  ushort p() const {
104  return p_;
105  }
106 
109 
113  virtual void recomputeShapefunctions() = 0;
114 
116  virtual const concepts::ShapeFunction1D<Real>* shpfct() const = 0;
117 
118 protected:
119  virtual std::ostream& info(std::ostream& os) const;
120 
122  // concepts::TMatrix<Real> T_;
123 
125 
126  static std::unique_ptr<LineGraphics> graphics_;
127 
128 };
129 
131 
132 // *************************************************************** KarniadakisMixin ***
133 
136 template<class F>
137 class KarniadakisMixin: public BaseElement<F> {
138 public:
140  BaseElement<F>(cell, p), shpfct_(nullptr), shpfctD_(nullptr), shpfctDD_(
141  nullptr), secondDerivativeUsed_(false) {
143  }
144 
148  void recomputeShapefunctions() override;
149 
151  const concepts::Karniadakis<1, 0>* shpfct() const override {
152  return shpfct_.get();
153  }
156  return shpfctD_.get();
157  }
158 
161  if (!secondDerivativeUsed_) {
162  shpfctDD_.reset(
163  new concepts::Karniadakis<1, 2>(this->p_, this->int_->abscissas(),
164  this->int_->n()));
165  secondDerivativeUsed_ = true;
166  }
167  return shpfctDD_.get();
168  }
169 
170 private:
176 
178  std::unique_ptr<concepts::Karniadakis<1, 0> > shpfct_;
180  std::unique_ptr<concepts::Karniadakis<1, 1> > shpfctD_;
181 
183  mutable std::unique_ptr<concepts::Karniadakis<1, 2> > shpfctDD_;
184 
185  mutable bool secondDerivativeUsed_;
186 
187 };
188 
189 
190 
191 // ******************************************************** LegendreMixin ***
192 
195 template<class F>
196 class LegendreMixin: public BaseElement<F> {
197 public:
200  }
201 
205  void recomputeShapefunctions() override;
206 
208  const concepts::Legendre* shpfct() const override {
209  return shpfct_.get();
210  }
211 
212 private:
214  std::unique_ptr<concepts::Legendre> shpfct_;
215 
216 };
217 
218 
219 // ******************************************************* GenericElement **
220 
224 template<class BaseT>
225 class GenericElement: public BaseT {
226 public:
233  GenericElement(const concepts::EdgeNd& cell, uint p,
236  : BaseT(cell,p), T_(T1)
237  {
238  if (T0)
239  T_.append(T0);
240  DEBUGL(ElementConstr_D, cell << ", p = " << p << ", T = " << T_);
241  }
242 
243  ~GenericElement() override
244  {
245  DEBUGL(ElementDestr_D, "done.");
246  }
247 
249  return T_;
250  }
251 
254  T_.append(T);
255  }
256 
257 protected:
258  virtual std::ostream& info(std::ostream& os) const override
259  {
260  return os << typeOf(*this);
261  }
262 
265 
266 };
267 
269 template<class F>
271 
272 
273 template<class F>
275 
276 }// namespace hp1D
277 
278 namespace concepts {
279 
280 // ****************************************************************** Scan **
281 
283 
284 template<class F>
285 class Scan<hp1D::BaseElement<F> > : public Scan<ElementWithCell<F> > {
286 public:
288 };
289 
290 } // namespace concepts
291 
292 #endif // Element1D_h
LegendreMixin(const concepts::EdgeNd &cell, ushort p)
Definition: element.hh:198
A column of a T matrix.
Definition: analytical.hh:18
Class representing Legendre polynomials evaluated on quadrature points.
Definition: legendre.hh:24
Integration point consisting of coordinates and intermediate data.
Definition: integral.hh:34
Edge & connector() const
Returns the connector (topology)
Definition: cell1D.hh:59
#define ElementDestr_D
Definition: element.hh:25
virtual const concepts::EdgeNd & cell() const
Returns the cell on which the element is built.
Definition: element.hh:99
const concepts::Legendre * shpfct() const override
Returns the shape functions.
Definition: element.hh:208
const concepts::TMatrix< typename BaseT::FieldT > & T() const override
Definition: element.hh:248
virtual std::ostream & info(std::ostream &os) const
virtual concepts::Real3d vertex(uint i) const
Definition: element.hh:95
const concepts::Karniadakis< 1, 2 > * shpfctDD() const
Returns the second derivatives of the shape functions.
Definition: element.hh:160
#define ElementConstr_D
Definition: element.hh:24
KarniadakisMixin(const concepts::EdgeNd &cell, ushort p)
Definition: element.hh:139
virtual void recomputeShapefunctions()=0
Recompute shape functions, e.g.
intFormType
Integration form, which determines terms coming from integration over reference element.
Definition: integral.hh:29
Class for creation of a quadrature rule.
Definition: quadRule.hh:224
static concepts::QuadRuleFactory & rule()
Access to the quadrature rule, which is valid for all elements of this type (hp1D::IntegrableElm).
Definition: element.hh:62
ushort p_
T matrix of the element.
Definition: element.hh:124
virtual Real3d vertex(const uint i) const
Returns the coordinates of the ith vertex.
hp1D::BaseElement< F > & operator++(int)=0
Returns the next element in the scanned set.
Element with cell.
IntegrableElm(const concepts::EdgeNd &cell)
#define DEBUGL(doit, msg)
const concepts::QuadratureRule1d * integration() const
Returns the integration rule.
Definition: element.hh:51
~GenericElement() override
Definition: element.hh:243
virtual bool quadraturePoint(uint i, intPoint &p, intFormType form=ZERO, bool localCoord=false) const
Delivers a quadrature point.
Real jacobianDeterminant(const Real x) const
Computes the determinant of the Jacobian.
Definition: element.hh:45
std::unique_ptr< concepts::Karniadakis< 1, 1 > > shpfctD_
The derivatives of the shape functions.
Definition: element.hh:180
std::unique_ptr< concepts::Karniadakis< 1, 0 > > shpfct_
The shape functions.
Definition: element.hh:178
void recomputeShapefunctions() override
Recompute shape functions, e.g.
virtual Real jacobianDeterminant(const Real x) const =0
Returns the determinant of the Jacobian.
const concepts::Karniadakis< 1, 1 > * shpfctD() const
Returns the derivatives of the shape functions.
Definition: element.hh:155
void append(TColumn< F > *T)
Appends the columns to the matrix.
static concepts::QuadRuleFactory rule_
Definition: element.hh:74
virtual const concepts::ElementGraphics< Real > * graphics() const
Returns element graphics class.
1D generic element.
Definition: element.hh:225
An abstract class for scanning a mesh (a set of cells) or a space (a set of elements).
const concepts::EdgeNd & cell_
The cell.
Definition: element.hh:70
virtual const concepts::ShapeFunction1D< Real > * shpfct() const =0
Returns the shape functions.
void recomputeShapefunctions() override
Recompute shape functions, e.g.
void recomputeSecondDerivativeOfShapefunctions_()
Recompute second derivative of the shape functions, e.g.
virtual Real3d elemMap(const Real coord_local) const
Element map from point local coordinates in 1D.
virtual const concepts::Edge & support() const
Definition: element.hh:91
static std::unique_ptr< LineGraphics > graphics_
Definition: element.hh:126
BaseElement(const concepts::EdgeNd &cell, ushort p)
Definition: element.hh:84
Cell over which can be integrated.
Definition: integral.hh:24
std::unique_ptr< concepts::Legendre > shpfct_
The shape functions.
Definition: element.hh:214
A 1D cell in any dimension: edge.
Definition: cell1D.hh:32
The following two types are shape function mixins.
Definition: element.hh:137
std::unique_ptr< concepts::Karniadakis< 1, 2 > > shpfctDD_
The second derivatives of the shape functions.
Definition: element.hh:183
unsigned short ushort
Abbreviation for unsigned short.
Definition: typedefs.hh:48
Class holding the quadrature rule and the cell of a 1D element.
Definition: element.hh:34
GenericElement(const concepts::EdgeNd &cell, uint p, concepts::TColumn< typename BaseT::FieldT > *T0, concepts::TColumn< typename BaseT::FieldT > *T1)
Constructor.
Definition: element.hh:233
Quadrature rule for numerical integration.
Definition: quadRule.hh:30
const concepts::Real3d chi(const Real x) const
Computes the element map.
Definition: element.hh:40
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
virtual std::ostream & info(std::ostream &os) const override
Definition: element.hh:258
An edge in the topology.
Definition: topology.hh:73
const concepts::Karniadakis< 1, 0 > * shpfct() const override
Returns the shape functions.
Definition: element.hh:151
concepts::TMatrix< typename BaseT::FieldT > T_
T matrix of the element.
Definition: element.hh:264
ushort p() const
Definition: element.hh:103
std::unique_ptr< concepts::QuadratureRule1d > int_
The integration rule.
Definition: element.hh:72
Legendre shape functions mixin.
Definition: element.hh:196
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
virtual ~BaseElement()
void appendT(concepts::TColumn< typename BaseT::FieldT > *T)
Appends the T columns to the T matrix.
Definition: element.hh:253
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
1D hp-FEM
Part of the multidimensional expansion bases for the shape functions of Karniadakis and Sherwin.
Definition: karniadakis.hh:163
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich