Dune Core Modules (2.8.0)

interfaceswitch.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4#ifndef DUNE_LOCALFUNCTIONS_COMMON_INTERFACESWITCH_HH
5#define DUNE_LOCALFUNCTIONS_COMMON_INTERFACESWITCH_HH
6
7#include <cstddef>
8#include <memory>
9#include <vector>
10
14
15namespace Dune {
16
19
27 template<class FiniteElement, class Dummy = void>
30 typedef typename FiniteElement::Traits::Basis Basis;
32 typedef typename FiniteElement::Traits::Interpolation Interpolation;
34 typedef typename FiniteElement::Traits::Coefficients Coefficients;
35
37 static const Basis &basis(const FiniteElement& fe)
38 { return fe.basis(); }
40 static const Interpolation &interpolation(const FiniteElement& fe)
41 { return fe.interpolation(); }
43 static const Coefficients &coefficients(const FiniteElement& fe)
44 { return fe.coefficients(); }
45
47
76 typedef std::shared_ptr<const FiniteElement> Store;
78
83 static void setStore(Store& store, const FiniteElement& fe)
84 { store = std::make_shared<const FiniteElement>(fe); }
86 static void setStore(Store& store, FiniteElement&& fe)
87 { store = std::make_shared<const FiniteElement>(std::move(fe)); }
89 static void setStore(Store& store, const Store& fe)
90 { store = fe; }
91 };
92
93#ifndef DOXYGEN
96 template<class FiniteElement>
97 struct FiniteElementInterfaceSwitch<
98 FiniteElement,
99 typename std::enable_if<AlwaysTrue<typename FiniteElement::Traits::
100 LocalBasisType>::value>::type
101 >
102 {
104 typedef typename FiniteElement::Traits::LocalBasisType Basis;
106 typedef typename FiniteElement::Traits::LocalInterpolationType
109 typedef typename FiniteElement::Traits::LocalCoefficientsType Coefficients;
110
112 static const Basis &basis(const FiniteElement& fe)
113 { return fe.localBasis(); }
115 static const Interpolation &interpolation(const FiniteElement& fe)
116 { return fe.localInterpolation(); }
118 static const Coefficients &coefficients(const FiniteElement& fe)
119 { return fe.localCoefficients(); }
120
122 typedef std::shared_ptr<const FiniteElement> Store;
124 static void setStore(Store& store, const FiniteElement& fe)
125 { store = stackobject_to_shared_ptr<const FiniteElement>(fe); }
127 static void setStore(Store& store, FiniteElement&& fe)
128 { store = std::make_shared<const FiniteElement>(std::move(fe)); }
130 static void setStore(Store& store, const Store& fe)
131 { store = fe; }
132 };
133#endif // !DOXYGEN
134
136
151 template<class Basis, class Dummy = void>
154 typedef typename Basis::Traits::DomainField DomainField;
156 static const std::size_t dimDomainLocal = Basis::Traits::dimDomainLocal;
158 typedef typename Basis::Traits::DomainLocal DomainLocal;
159
161 typedef typename Basis::Traits::RangeField RangeField;
163 static const std::size_t dimRange = Basis::Traits::dimRange;
165 typedef typename Basis::Traits::Range Range;
166
168
178 template<typename Geometry>
179 static void gradient(const Basis& basis, const Geometry& geometry,
180 const DomainLocal& xl,
181 std::vector<FieldMatrix<RangeField, 1,
183 {
184 grad.resize(basis.size());
185 basis.evaluateJacobian(xl, grad);
186 }
187 };
188
189#ifndef DOXYGEN
191 template<class Basis>
192 struct BasisInterfaceSwitch<Basis,
193 typename std::enable_if<
194 AlwaysTrue<
195 std::integral_constant<
196 std::size_t,
197 Basis::Traits::dimDomain
198 >
199 >::value
200 >::type
201 >
202 {
204 typedef typename Basis::Traits::DomainFieldType DomainField;
206 static const std::size_t dimDomainLocal = Basis::Traits::dimDomain;
208 typedef typename Basis::Traits::DomainType DomainLocal;
209
211 typedef typename Basis::Traits::RangeFieldType RangeField;
213 static const std::size_t dimRange = Basis::Traits::dimRange;
215 typedef typename Basis::Traits::RangeType Range;
216
218 template<typename Geometry>
219 static void gradient(const Basis& basis, const Geometry& geometry,
220 const DomainLocal& xl,
221 std::vector<FieldMatrix<RangeField, 1,
223 {
224 std::vector<typename Basis::Traits::JacobianType> lgrad(basis.size());
225 basis.evaluateJacobian(xl, lgrad);
226
227 const typename Geometry::JacobianInverseTransposed& jac =
228 geometry.jacobianInverseTransposed(xl);
229
230 grad.resize(basis.size());
231 for(std::size_t i = 0; i < basis.size(); ++i)
232 jac.mv(lgrad[i][0], grad[i][0]);
233 }
234 };
235#endif // !DOXYGEN
236
237} // namespace Dune
238
239#endif // DUNE_LOCALFUNCTIONS_COMMON_INTERFACESWITCH_HH
A dense n x m matrix.
Definition: fmatrix.hh:69
Wrapper class for geometries.
Definition: geometry.hh:67
@ coorddimension
Definition: geometry.hh:92
Implementation::JacobianInverseTransposed JacobianInverseTransposed
type of jacobian inverse transposed
Definition: geometry.hh:115
Traits for type conversions and type information.
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Dune namespace.
Definition: alignedallocator.hh:11
STL namespace.
This file implements several utilities related to std::shared_ptr.
Switch for uniform treatment of local and global basis classes.
Definition: interfaceswitch.hh:152
static const std::size_t dimRange
export dimension of the values
Definition: interfaceswitch.hh:163
static const std::size_t dimDomainLocal
export dimension of local coordinates
Definition: interfaceswitch.hh:156
Basis::Traits::RangeField RangeField
export field type of the values
Definition: interfaceswitch.hh:161
Basis::Traits::Range Range
export vector type of the values
Definition: interfaceswitch.hh:165
static void gradient(const Basis &basis, const Geometry &geometry, const DomainLocal &xl, std::vector< FieldMatrix< RangeField, 1, Geometry::coorddimension > > &grad)
Compute global gradient for scalar valued bases.
Definition: interfaceswitch.hh:179
Basis::Traits::DomainLocal DomainLocal
export vector type of the local coordinates
Definition: interfaceswitch.hh:158
Basis::Traits::DomainField DomainField
export field types of the coordinates
Definition: interfaceswitch.hh:154
Switch for uniform treatment of finite element with either the local or the global interface.
Definition: interfaceswitch.hh:28
static const Coefficients & coefficients(const FiniteElement &fe)
access coefficients
Definition: interfaceswitch.hh:43
static void setStore(Store &store, FiniteElement &&fe)
Store a finite element in the store.
Definition: interfaceswitch.hh:86
FiniteElement::Traits::Coefficients Coefficients
export the type of the coefficients
Definition: interfaceswitch.hh:34
static void setStore(Store &store, const Store &fe)
Store a finite element in the store.
Definition: interfaceswitch.hh:89
static void setStore(Store &store, const FiniteElement &fe)
Store a finite element in the store.
Definition: interfaceswitch.hh:83
FiniteElement::Traits::Interpolation Interpolation
export the type of the interpolation
Definition: interfaceswitch.hh:32
std::shared_ptr< const FiniteElement > Store
Type for storing finite elements.
Definition: interfaceswitch.hh:76
static const Basis & basis(const FiniteElement &fe)
access basis
Definition: interfaceswitch.hh:37
FiniteElement::Traits::Basis Basis
export the type of the basis
Definition: interfaceswitch.hh:30
static const Interpolation & interpolation(const FiniteElement &fe)
access interpolation
Definition: interfaceswitch.hh:40
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)