Dune Core Modules (2.9.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// SPDX-FileCopyrightInfo: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5
6#ifndef DUNE_LOCALFUNCTIONS_COMMON_LOCALTOGLOBALADAPTORS_HH
7#define DUNE_LOCALFUNCTIONS_COMMON_LOCALTOGLOBALADAPTORS_HH
8
9#include <cstddef>
10#include <vector>
11
15
16#include <dune/geometry/type.hh>
17
18namespace Dune {
19
21
29 template<class LocalBasisTraits, std::size_t dimDomainGlobal_>
31 typedef typename LocalBasisTraits::DomainFieldType DomainField;
32 static const std::size_t dimDomainLocal = LocalBasisTraits::dimDomain;
33 static const std::size_t dimDomainGlobal = dimDomainGlobal_;
34 typedef typename LocalBasisTraits::DomainType DomainLocal;
36
37 typedef typename LocalBasisTraits::RangeFieldType RangeField;
38 static const std::size_t dimRange = LocalBasisTraits::dimRange;
39 typedef typename LocalBasisTraits::RangeType Range;
40
42 };
43
45
64 template<class LocalBasis, class Geometry>
66 static_assert(LocalBasis::Traits::dimRange == 1,
67 "ScalarLocalToGlobalBasisAdaptor can only wrap a "
68 "scalar local basis.");
69 static_assert((std::is_same<typename LocalBasis::Traits::DomainFieldType,
70 typename Geometry::ctype>::value),
71 "ScalarLocalToGlobalBasisAdaptor: LocalBasis must use "
72 "the same ctype as Geometry");
73 static_assert
74 ( static_cast<std::size_t>(LocalBasis::Traits::dimDomain) ==
75 static_cast<std::size_t>(Geometry::mydimension),
76 "ScalarLocalToGlobalBasisAdaptor: LocalBasis domain dimension must "
77 "match local dimension of Geometry");
78
79 const LocalBasis& localBasis;
80 Geometry geometry;
81
82 public:
83 typedef LocalToGlobalBasisAdaptorTraits<typename LocalBasis::Traits,
85
87
96 ScalarLocalToGlobalBasisAdaptor(const LocalBasis& localBasis_,
97 const Geometry& geometry_) :
98 localBasis(localBasis_), geometry(geometry_)
99 { }
100
101 std::size_t size() const { return localBasis.size(); }
103
110 std::size_t order() const {
111 if(geometry.affine())
112 // affine linear
113 return localBasis.order();
114 else
115 // assume at most order dim
116 return localBasis.order() + Traits::dimDomainGlobal - 1;
117 }
118
119 void evaluateFunction(const typename Traits::DomainLocal& in,
120 std::vector<typename Traits::Range>& out) const
121 {
122 localBasis.evaluateFunction(in, out);
123 }
124
125 void evaluateJacobian(const typename Traits::DomainLocal& in,
126 std::vector<typename Traits::Jacobian>& out) const
127 {
128 std::vector<typename LocalBasis::Traits::JacobianType>
129 localJacobian(size());
130 localBasis.evaluateJacobian(in, localJacobian);
131
132 const typename Geometry::JacobianInverseTransposed &geoJacobian =
133 geometry.jacobianInverseTransposed(in);
134
135 out.resize(size());
136 for(std::size_t i = 0; i < size(); ++i)
137 geoJacobian.mv(localJacobian[i][0], out[i][0]);
138 }
139 };
140
142
148 template<class LocalInterpolation, class Traits_>
150 const LocalInterpolation& localInterpolation;
151
152 public:
153 typedef Traits_ Traits;
154
156
165 ( const LocalInterpolation& localInterpolation_) :
166 localInterpolation(localInterpolation_)
167 { }
168
169 template<class Function, class Coeff>
170 void interpolate(const Function& function, std::vector<Coeff>& out) const
171 { localInterpolation.interpolate(function, out); }
172 };
173
176
186 template<class LocalFiniteElement, class Geometry>
191 struct Traits {
192 typedef ScalarLocalToGlobalBasisAdaptor<typename LocalFiniteElement::
193 Traits::LocalBasisType, Geometry> Basis;
194 typedef LocalToGlobalInterpolationAdaptor<typename LocalFiniteElement::
195 Traits::LocalInterpolationType, typename Basis::Traits>
196 Interpolation;
197 typedef typename LocalFiniteElement::Traits::LocalCoefficientsType
198 Coefficients;
199 };
200
201 private:
202 const LocalFiniteElement &localFE;
203 typename Traits::Basis basis_;
204 typename Traits::Interpolation interpolation_;
205
206 public:
208
218 ( const LocalFiniteElement& localFE_, const Geometry &geometry) :
219 localFE(localFE_),
220 basis_(localFE.localBasis(), geometry),
221 interpolation_(localFE.localInterpolation())
222 { }
223
224 const typename Traits::Basis& basis() const { return basis_; }
225 const typename Traits::Interpolation& interpolation() const
226 { return interpolation_; }
227 const typename Traits::Coefficients& coefficients() const
228 { return localFE.localCoefficients(); }
229 GeometryType type() const { return localFE.type(); }
230 };
231
233
243 template<class LocalFiniteElement, class Geometry>
245 const LocalFiniteElement& localFE;
246
247 public:
248 typedef ScalarLocalToGlobalFiniteElementAdaptor<LocalFiniteElement,
250
252
261 (const LocalFiniteElement &localFE_) : localFE(localFE_) {}
262
264
274 const FiniteElement make(const Geometry& geometry) {
275 return FiniteElement(localFE, geometry);
276 }
277 };
278
279} // namespace Dune
280
281#endif // DUNE_LOCALFUNCTIONS_COMMON_LOCALTOGLOBALADAPTORS_HH
A dense n x m matrix.
Definition: fmatrix.hh:117
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Base class template for function classes.
Definition: function.hh:41
Wrapper class for geometries.
Definition: geometry.hh:71
Implementation::JacobianInverseTransposed JacobianInverseTransposed
type of jacobian inverse transposed
Definition: geometry.hh:120
static constexpr int coorddimension
dimension of embedding coordinate system
Definition: geometry.hh:97
GridImp::ctype ctype
define type used for coordinates in grid module
Definition: geometry.hh:100
bool affine() const
Return true if the geometry mapping is affine and false otherwise.
Definition: geometry.hh:197
static constexpr int mydimension
geometry dimension
Definition: geometry.hh:94
JacobianInverseTransposed jacobianInverseTransposed(const LocalCoordinate &local) const
Return inverse of transposed of Jacobian.
Definition: geometry.hh:328
Convert a local interpolation into a global interpolation.
Definition: localtoglobaladaptors.hh:149
LocalToGlobalInterpolationAdaptor(const LocalInterpolation &localInterpolation_)
construct a LocalToGlobalInterpolationAdaptor
Definition: localtoglobaladaptors.hh:165
Convert a simple scalar local basis into a global basis.
Definition: localtoglobaladaptors.hh:65
std::size_t order() const
return maximum polynomial order of the base function
Definition: localtoglobaladaptors.hh:110
ScalarLocalToGlobalBasisAdaptor(const LocalBasis &localBasis_, const Geometry &geometry_)
construct a ScalarLocalToGlobalBasisAdaptor
Definition: localtoglobaladaptors.hh:96
Factory for ScalarLocalToGlobalFiniteElementAdaptor objects.
Definition: localtoglobaladaptors.hh:244
const FiniteElement make(const Geometry &geometry)
construct ScalarLocalToGlobalFiniteElementAdaptor
Definition: localtoglobaladaptors.hh:274
ScalarLocalToGlobalFiniteElementAdaptorFactory(const LocalFiniteElement &localFE_)
construct a ScalarLocalToGlobalFiniteElementAdaptorFactory
Definition: localtoglobaladaptors.hh:261
Traits for type conversions and type information.
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
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:13
types of domain and range
Definition: interface.hh:188
Dummy struct used for documentation purposes.
Definition: documentation.hh:42
D DomainType
domain type
Definition: localbasis.hh:42
RF RangeFieldType
Export type for range field.
Definition: localbasis.hh:45
static constexpr int dimRange
dimension of the range
Definition: localbasis.hh:48
DF DomainFieldType
Export type for domain field.
Definition: localbasis.hh:36
static constexpr int dimDomain
dimension of the domain
Definition: localbasis.hh:39
R RangeType
range type
Definition: localbasis.hh:51
Traits class for local-to-global basis adaptors.
Definition: localtoglobaladaptors.hh:30
Convert a simple scalar local finite element into a global finite element.
Definition: localtoglobaladaptors.hh:187
ScalarLocalToGlobalFiniteElementAdaptor(const LocalFiniteElement &localFE_, const Geometry &geometry)
construct a ScalarLocalToGlobalFiniteElementAdaptor
Definition: localtoglobaladaptors.hh:218
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)