Dune Core Modules (2.6.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
12#include <dune/common/std/type_traits.hh>
13
14namespace Dune {
15
18
26 template<class FiniteElement, class Dummy = void>
29 typedef typename FiniteElement::Traits::Basis Basis;
31 typedef typename FiniteElement::Traits::Interpolation Interpolation;
33 typedef typename FiniteElement::Traits::Coefficients Coefficients;
34
36 static const Basis &basis(const FiniteElement& fe)
37 { return fe.basis(); }
39 static const Interpolation &interpolation(const FiniteElement& fe)
40 { return fe.interpolation(); }
42 static const Coefficients &coefficients(const FiniteElement& fe)
43 { return fe.coefficients(); }
44
46
68 typedef std::shared_ptr<const FiniteElement> Store;
70
75 static void setStore(Store& store, const FiniteElement& fe)
76 { store.reset(new FiniteElement(fe)); }
77 };
78
79#ifndef DOXYGEN
82 template<class FiniteElement>
83 struct FiniteElementInterfaceSwitch<
84 FiniteElement,
85 typename std::enable_if<Std::to_true_type<typename FiniteElement::Traits::
86 LocalBasisType>::value>::type
87 >
88 {
90 typedef typename FiniteElement::Traits::LocalBasisType Basis;
92 typedef typename FiniteElement::Traits::LocalInterpolationType
95 typedef typename FiniteElement::Traits::LocalCoefficientsType Coefficients;
96
98 static const Basis &basis(const FiniteElement& fe)
99 { return fe.localBasis(); }
101 static const Interpolation &interpolation(const FiniteElement& fe)
102 { return fe.localInterpolation(); }
104 static const Coefficients &coefficients(const FiniteElement& fe)
105 { return fe.localCoefficients(); }
106
108 typedef const FiniteElement *Store;
110 static void setStore(Store& store, const FiniteElement& fe)
111 { store = &fe; }
112 };
113#endif // !DOXYGEN
114
116
131 template<class Basis, class Dummy = void>
134 typedef typename Basis::Traits::DomainField DomainField;
136 static const std::size_t dimDomainLocal = Basis::Traits::dimDomainLocal;
138 typedef typename Basis::Traits::DomainLocal DomainLocal;
139
141 typedef typename Basis::Traits::RangeField RangeField;
143 static const std::size_t dimRange = Basis::Traits::dimRange;
145 typedef typename Basis::Traits::Range Range;
146
148 static const std::size_t diffOrder = Basis::Traits::diffOrder;
149
151
161 template<typename Geometry>
162 static void gradient(const Basis& basis, const Geometry& geometry,
163 const DomainLocal& xl,
164 std::vector<FieldMatrix<RangeField, 1,
166 {
167 grad.resize(basis.size());
168 basis.evaluateJacobian(xl, grad);
169 }
170 };
171
172#ifndef DOXYGEN
174 template<class Basis>
175 struct BasisInterfaceSwitch<Basis,
176 typename std::enable_if<
177 Std::to_true_type<
178 std::integral_constant<
179 std::size_t,
180 Basis::Traits::dimDomain
181 >
182 >::value
183 >::type
184 >
185 {
187 typedef typename Basis::Traits::DomainFieldType DomainField;
189 static const std::size_t dimDomainLocal = Basis::Traits::dimDomain;
191 typedef typename Basis::Traits::DomainType DomainLocal;
192
194 typedef typename Basis::Traits::RangeFieldType RangeField;
196 static const std::size_t dimRange = Basis::Traits::dimRange;
198 typedef typename Basis::Traits::RangeType Range;
199
201 template<typename Geometry>
202 static void gradient(const Basis& basis, const Geometry& geometry,
203 const DomainLocal& xl,
204 std::vector<FieldMatrix<RangeField, 1,
206 {
207 std::vector<typename Basis::Traits::JacobianType> lgrad(basis.size());
208 basis.evaluateJacobian(xl, lgrad);
209
210 const typename Geometry::JacobianInverseTransposed& jac =
211 geometry.jacobianInverseTransposed(xl);
212
213 grad.resize(basis.size());
214 for(std::size_t i = 0; i < basis.size(); ++i)
215 jac.mv(lgrad[i][0], grad[i][0]);
216 }
217 };
218#endif // !DOXYGEN
219
220} // namespace Dune
221
222#endif // DUNE_LOCALFUNCTIONS_COMMON_INTERFACESWITCH_HH
A dense n x m matrix.
Definition: fmatrix.hh:68
Wrapper class for geometries.
Definition: geometry.hh:67
Implementation::JacobianInverseTransposed JacobianInverseTransposed
type of jacobian inverse transposed
Definition: geometry.hh:112
@ coorddimension
Definition: geometry.hh:92
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Dune namespace.
Definition: alignedallocator.hh:10
STL namespace.
Switch for uniform treatment of local and global basis classes.
Definition: interfaceswitch.hh:132
static const std::size_t dimRange
export dimension of the values
Definition: interfaceswitch.hh:143
static const std::size_t dimDomainLocal
export dimension of local coordinates
Definition: interfaceswitch.hh:136
Basis::Traits::RangeField RangeField
export field type of the values
Definition: interfaceswitch.hh:141
Basis::Traits::Range Range
export vector type of the values
Definition: interfaceswitch.hh:145
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:162
static const std::size_t diffOrder
export number of supported differentiations
Definition: interfaceswitch.hh:148
Basis::Traits::DomainLocal DomainLocal
export vector type of the local coordinates
Definition: interfaceswitch.hh:138
Basis::Traits::DomainField DomainField
export field types of the coordinates
Definition: interfaceswitch.hh:134
Switch for uniform treatment of finite element with either the local or the global interface.
Definition: interfaceswitch.hh:27
static const Coefficients & coefficients(const FiniteElement &fe)
access coefficients
Definition: interfaceswitch.hh:42
FiniteElement::Traits::Coefficients Coefficients
export the type of the coefficients
Definition: interfaceswitch.hh:33
static void setStore(Store &store, const FiniteElement &fe)
Store a finite element in the store.
Definition: interfaceswitch.hh:75
FiniteElement::Traits::Interpolation Interpolation
export the type of the interpolation
Definition: interfaceswitch.hh:31
std::shared_ptr< const FiniteElement > Store
Type for storing finite elements.
Definition: interfaceswitch.hh:68
static const Basis & basis(const FiniteElement &fe)
access basis
Definition: interfaceswitch.hh:36
FiniteElement::Traits::Basis Basis
export the type of the basis
Definition: interfaceswitch.hh:29
static const Interpolation & interpolation(const FiniteElement &fe)
access interpolation
Definition: interfaceswitch.hh:39
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 26, 23:30, 2024)