Dune Core Modules (2.6.0)

localtoglobaladaptors.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_LOCALTOGLOBALADAPTORS_HH
5#define DUNE_LOCALFUNCTIONS_COMMON_LOCALTOGLOBALADAPTORS_HH
6
7#include <cstddef>
8#include <vector>
9
13
14#include <dune/geometry/type.hh>
15
16namespace Dune {
17
19
27 template<class LocalBasisTraits, std::size_t dimDomainGlobal_>
30 static const std::size_t dimDomainLocal = LocalBasisTraits::dimDomain;
31 static const std::size_t dimDomainGlobal = dimDomainGlobal_;
34
36 static const std::size_t dimRange = LocalBasisTraits::dimRange;
37 typedef typename LocalBasisTraits::RangeType Range;
38
40 };
41
43
62 template<class LocalBasis, class Geometry>
64 static_assert(LocalBasis::Traits::dimRange == 1,
65 "ScalarLocalToGlobalBasisAdaptor can only wrap a "
66 "scalar local basis.");
67 static_assert((std::is_same<typename LocalBasis::Traits::DomainFieldType,
68 typename Geometry::ctype>::value),
69 "ScalarLocalToGlobalBasisAdaptor: LocalBasis must use "
70 "the same ctype as Geometry");
71 static_assert
72 ( static_cast<std::size_t>(LocalBasis::Traits::dimDomain) ==
73 static_cast<std::size_t>(Geometry::mydimension),
74 "ScalarLocalToGlobalBasisAdaptor: LocalBasis domain dimension must "
75 "match local dimension of Geometry");
76
77 const LocalBasis& localBasis;
78 Geometry geometry;
79
80 public:
81 typedef LocalToGlobalBasisAdaptorTraits<typename LocalBasis::Traits,
83
85
94 ScalarLocalToGlobalBasisAdaptor(const LocalBasis& localBasis_,
95 const Geometry& geometry_) :
96 localBasis(localBasis_), geometry(geometry_)
97 { }
98
99 std::size_t size() const { return localBasis.size(); }
101
108 std::size_t order() const {
109 if(geometry.affine())
110 // affine linear
111 return localBasis.order();
112 else
113 // assume at most order dim
114 return localBasis.order() + Traits::dimDomainGlobal - 1;
115 }
116
117 void evaluateFunction(const typename Traits::DomainLocal& in,
118 std::vector<typename Traits::Range>& out) const
119 {
120 localBasis.evaluateFunction(in, out);
121 }
122
123 void evaluateJacobian(const typename Traits::DomainLocal& in,
124 std::vector<typename Traits::Jacobian>& out) const
125 {
126 std::vector<typename LocalBasis::Traits::JacobianType>
127 localJacobian(size());
128 localBasis.evaluateJacobian(in, localJacobian);
129
130 const typename Geometry::JacobianInverseTransposed &geoJacobian =
131 geometry.jacobianInverseTransposed(in);
132
133 out.resize(size());
134 for(std::size_t i = 0; i < size(); ++i)
135 geoJacobian.mv(localJacobian[i][0], out[i][0]);
136 }
137 };
138
140
146 template<class LocalInterpolation, class Traits_>
148 const LocalInterpolation& localInterpolation;
149
150 public:
151 typedef Traits_ Traits;
152
154
163 ( const LocalInterpolation& localInterpolation_) :
164 localInterpolation(localInterpolation_)
165 { }
166
167 template<class Function, class Coeff>
168 void interpolate(const Function& function, std::vector<Coeff>& out) const
169 { localInterpolation.interpolate(function, out); }
170 };
171
174
184 template<class LocalFiniteElement, class Geometry>
189 struct Traits {
190 typedef ScalarLocalToGlobalBasisAdaptor<typename LocalFiniteElement::
191 Traits::LocalBasisType, Geometry> Basis;
192 typedef LocalToGlobalInterpolationAdaptor<typename LocalFiniteElement::
193 Traits::LocalInterpolationType, typename Basis::Traits>
194 Interpolation;
195 typedef typename LocalFiniteElement::Traits::LocalCoefficientsType
196 Coefficients;
197 };
198
199 private:
200 const LocalFiniteElement &localFE;
201 typename Traits::Basis basis_;
202 typename Traits::Interpolation interpolation_;
203
204 public:
206
216 ( const LocalFiniteElement& localFE_, const Geometry &geometry) :
217 localFE(localFE_),
218 basis_(localFE.localBasis(), geometry),
219 interpolation_(localFE.localInterpolation())
220 { }
221
222 const typename Traits::Basis& basis() const { return basis_; }
223 const typename Traits::Interpolation& interpolation() const
224 { return interpolation_; }
225 const typename Traits::Coefficients& coefficients() const
226 { return localFE.localCoefficients(); }
227 GeometryType type() const { return localFE.type(); }
228 };
229
231
241 template<class LocalFiniteElement, class Geometry>
243 const LocalFiniteElement& localFE;
244
245 public:
246 typedef ScalarLocalToGlobalFiniteElementAdaptor<LocalFiniteElement,
248
250
259 (const LocalFiniteElement &localFE_) : localFE(localFE_) {}
260
262
272 const FiniteElement make(const Geometry& geometry) {
273 return FiniteElement(localFE, geometry);
274 }
275 };
276
277} // namespace Dune
278
279#endif // DUNE_LOCALFUNCTIONS_COMMON_LOCALTOGLOBALADAPTORS_HH
A dense n x m matrix.
Definition: fmatrix.hh:68
vector space out of a tensor product of fields.
Definition: fvector.hh:93
Base class template for function classes.
Definition: function.hh:29
Wrapper class for geometries.
Definition: geometry.hh:67
@ mydimension
Definition: geometry.hh:90
Implementation::JacobianInverseTransposed JacobianInverseTransposed
type of jacobian inverse transposed
Definition: geometry.hh:112
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: geometry.hh:95
bool affine() const
Return true if the geometry mapping is affine and false otherwise.
Definition: geometry.hh:131
@ coorddimension
Definition: geometry.hh:92
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Return inverse of transposed of Jacobian.
Definition: geometry.hh:262
Convert a local interpolation into a global interpolation.
Definition: localtoglobaladaptors.hh:147
LocalToGlobalInterpolationAdaptor(const LocalInterpolation &localInterpolation_)
construct a LocalToGlobalInterpolationAdaptor
Definition: localtoglobaladaptors.hh:163
Convert a simple scalar local basis into a global basis.
Definition: localtoglobaladaptors.hh:63
std::size_t order() const
return maximum polynomial order of the base function
Definition: localtoglobaladaptors.hh:108
ScalarLocalToGlobalBasisAdaptor(const LocalBasis &localBasis_, const Geometry &geometry_)
construct a ScalarLocalToGlobalBasisAdaptor
Definition: localtoglobaladaptors.hh:94
Factory for ScalarLocalToGlobalFiniteElementAdaptor objects.
Definition: localtoglobaladaptors.hh:242
const FiniteElement make(const Geometry &geometry)
construct ScalarLocalToGlobalFiniteElementAdaptor
Definition: localtoglobaladaptors.hh:272
ScalarLocalToGlobalFiniteElementAdaptorFactory(const LocalFiniteElement &localFE_)
construct a ScalarLocalToGlobalFiniteElementAdaptorFactory
Definition: localtoglobaladaptors.hh:259
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:10
types of domain and range
Definition: interface.hh:186
Dummy struct used for documentation purposes.
Definition: documentation.hh:40
D DomainType
domain type
Definition: localbasis.hh:43
@ dimRange
dimension of the range
Definition: localbasis.hh:51
RF RangeFieldType
Export type for range field.
Definition: localbasis.hh:46
@ dimDomain
dimension of the domain
Definition: localbasis.hh:39
DF DomainFieldType
Export type for domain field.
Definition: localbasis.hh:34
R RangeType
range type
Definition: localbasis.hh:55
Traits class for local-to-global basis adaptors.
Definition: localtoglobaladaptors.hh:28
Convert a simple scalar local finite element into a global finite element.
Definition: localtoglobaladaptors.hh:185
ScalarLocalToGlobalFiniteElementAdaptor(const LocalFiniteElement &localFE_, const Geometry &geometry)
construct a ScalarLocalToGlobalFiniteElementAdaptor
Definition: localtoglobaladaptors.hh:216
A unique label for each type of element that can occur in a grid.
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)