DUNE PDELab (git)

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// SPDX-FileCopyrightInfo: Copyright © 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_INTERFACESWITCH_HH
7#define DUNE_LOCALFUNCTIONS_COMMON_INTERFACESWITCH_HH
8
9#include <cstddef>
10#include <memory>
11#include <vector>
12
16
17namespace Dune {
18
21
29 template<class FiniteElement, class Dummy = void>
32 typedef typename FiniteElement::Traits::Basis Basis;
34 typedef typename FiniteElement::Traits::Interpolation Interpolation;
36 typedef typename FiniteElement::Traits::Coefficients Coefficients;
37
39 static const Basis &basis(const FiniteElement& fe)
40 { return fe.basis(); }
42 static const Interpolation &interpolation(const FiniteElement& fe)
43 { return fe.interpolation(); }
45 static const Coefficients &coefficients(const FiniteElement& fe)
46 { return fe.coefficients(); }
47
49
78 typedef std::shared_ptr<const FiniteElement> Store;
80
85 static void setStore(Store& store, const FiniteElement& fe)
86 { store = std::make_shared<const FiniteElement>(fe); }
88 static void setStore(Store& store, FiniteElement&& fe)
89 { store = std::make_shared<const FiniteElement>(std::move(fe)); }
91 static void setStore(Store& store, const Store& fe)
92 { store = fe; }
93 };
94
95#ifndef DOXYGEN
98 template<class FiniteElement>
99 struct FiniteElementInterfaceSwitch<
100 FiniteElement,
101 typename std::enable_if<AlwaysTrue<typename FiniteElement::Traits::
102 LocalBasisType>::value>::type
103 >
104 {
106 typedef typename FiniteElement::Traits::LocalBasisType Basis;
108 typedef typename FiniteElement::Traits::LocalInterpolationType
111 typedef typename FiniteElement::Traits::LocalCoefficientsType Coefficients;
112
114 static const Basis &basis(const FiniteElement& fe)
115 { return fe.localBasis(); }
117 static const Interpolation &interpolation(const FiniteElement& fe)
118 { return fe.localInterpolation(); }
120 static const Coefficients &coefficients(const FiniteElement& fe)
121 { return fe.localCoefficients(); }
122
124 typedef std::shared_ptr<const FiniteElement> Store;
126 static void setStore(Store& store, const FiniteElement& fe)
127 { store = stackobject_to_shared_ptr<const FiniteElement>(fe); }
129 static void setStore(Store& store, FiniteElement&& fe)
130 { store = std::make_shared<const FiniteElement>(std::move(fe)); }
132 static void setStore(Store& store, const Store& fe)
133 { store = fe; }
134 };
135#endif // !DOXYGEN
136
138
153 template<class Basis, class Dummy = void>
156 typedef typename Basis::Traits::DomainField DomainField;
158 static const std::size_t dimDomainLocal = Basis::Traits::dimDomainLocal;
160 typedef typename Basis::Traits::DomainLocal DomainLocal;
161
163 typedef typename Basis::Traits::RangeField RangeField;
165 static const std::size_t dimRange = Basis::Traits::dimRange;
167 typedef typename Basis::Traits::Range Range;
168
170
180 template<typename Geometry>
181 static void gradient(const Basis& basis, const Geometry& geometry,
182 const DomainLocal& xl,
183 std::vector<FieldMatrix<RangeField, 1,
185 {
186 grad.resize(basis.size());
187 basis.evaluateJacobian(xl, grad);
188 }
189 };
190
191#ifndef DOXYGEN
193 template<class Basis>
194 struct BasisInterfaceSwitch<Basis,
195 typename std::enable_if<
196 AlwaysTrue<
197 std::integral_constant<
198 std::size_t,
199 Basis::Traits::dimDomain
200 >
201 >::value
202 >::type
203 >
204 {
206 typedef typename Basis::Traits::DomainFieldType DomainField;
208 static const std::size_t dimDomainLocal = Basis::Traits::dimDomain;
210 typedef typename Basis::Traits::DomainType DomainLocal;
211
213 typedef typename Basis::Traits::RangeFieldType RangeField;
215 static const std::size_t dimRange = Basis::Traits::dimRange;
217 typedef typename Basis::Traits::RangeType Range;
218
220 template<typename Geometry>
221 static void gradient(const Basis& basis, const Geometry& geometry,
222 const DomainLocal& xl,
223 std::vector<FieldMatrix<RangeField, 1,
225 {
226 std::vector<typename Basis::Traits::JacobianType> lgrad(basis.size());
227 basis.evaluateJacobian(xl, lgrad);
228
229 const typename Geometry::JacobianInverseTransposed& jac =
230 geometry.jacobianInverseTransposed(xl);
231
232 grad.resize(basis.size());
233 for(std::size_t i = 0; i < basis.size(); ++i)
234 jac.mv(lgrad[i][0], grad[i][0]);
235 }
236 };
237#endif // !DOXYGEN
238
239} // namespace Dune
240
241#endif // DUNE_LOCALFUNCTIONS_COMMON_INTERFACESWITCH_HH
A dense n x m matrix.
Definition: fmatrix.hh:117
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
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:13
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:154
static const std::size_t dimRange
export dimension of the values
Definition: interfaceswitch.hh:165
static const std::size_t dimDomainLocal
export dimension of local coordinates
Definition: interfaceswitch.hh:158
Basis::Traits::RangeField RangeField
export field type of the values
Definition: interfaceswitch.hh:163
Basis::Traits::Range Range
export vector type of the values
Definition: interfaceswitch.hh:167
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:181
Basis::Traits::DomainLocal DomainLocal
export vector type of the local coordinates
Definition: interfaceswitch.hh:160
Basis::Traits::DomainField DomainField
export field types of the coordinates
Definition: interfaceswitch.hh:156
Switch for uniform treatment of finite element with either the local or the global interface.
Definition: interfaceswitch.hh:30
static const Coefficients & coefficients(const FiniteElement &fe)
access coefficients
Definition: interfaceswitch.hh:45
static void setStore(Store &store, FiniteElement &&fe)
Store a finite element in the store.
Definition: interfaceswitch.hh:88
FiniteElement::Traits::Coefficients Coefficients
export the type of the coefficients
Definition: interfaceswitch.hh:36
static void setStore(Store &store, const Store &fe)
Store a finite element in the store.
Definition: interfaceswitch.hh:91
static void setStore(Store &store, const FiniteElement &fe)
Store a finite element in the store.
Definition: interfaceswitch.hh:85
FiniteElement::Traits::Interpolation Interpolation
export the type of the interpolation
Definition: interfaceswitch.hh:34
std::shared_ptr< const FiniteElement > Store
Type for storing finite elements.
Definition: interfaceswitch.hh:78
static const Basis & basis(const FiniteElement &fe)
access basis
Definition: interfaceswitch.hh:39
FiniteElement::Traits::Basis Basis
export the type of the basis
Definition: interfaceswitch.hh:32
static const Interpolation & interpolation(const FiniteElement &fe)
access interpolation
Definition: interfaceswitch.hh:42
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 12, 23:30, 2024)