Dune Core Modules (2.6.0)

virtualinterface.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_LOCALFUNCTIONS_COMMON_VIRTUALINTERFACE_HH
4#define DUNE_LOCALFUNCTIONS_COMMON_VIRTUALINTERFACE_HH
5
6#include <array>
7#include <vector>
8
10
11#include <dune/geometry/type.hh>
12
13#include <dune/localfunctions/common/localbasis.hh>
14#include <dune/localfunctions/common/localkey.hh>
15#include <dune/localfunctions/common/localfiniteelementtraits.hh>
16
17namespace Dune
18{
19
20 // forward declaration needed by the helper traits
21 template<class DomainType, class RangeType>
22 class LocalInterpolationVirtualInterface;
23
24 // -----------------------------------------------------------------
25 // Helper traits classes
26 // -----------------------------------------------------------------
27
33 template<class FE>
35 {
36 typedef typename FE::Traits::LocalBasisType::Traits::DomainType DomainType;
37 typedef typename FE::Traits::LocalBasisType::Traits::RangeType RangeType;
38
40 typedef typename FE::Traits::LocalInterpolationType Implementation;
41
42 public:
43
46
52 typedef typename std::conditional<std::is_base_of<Interface, Implementation>::value, VirtualFunctionBase, FunctionBase>::type type;
53 };
54
55
56
57 // -----------------------------------------------------------------
58 // Basis
59 // -----------------------------------------------------------------
60
67 template<class T>
69 {
70 public:
71 using Traits = T;
72
73
75
77 virtual unsigned int size () const = 0;
78
80 virtual unsigned int order () const = 0;
81
87 virtual void evaluateFunction (const typename Traits::DomainType& in,
88 std::vector<typename Traits::RangeType>& out) const = 0;
89
98 virtual void evaluateJacobian(const typename Traits::DomainType& in, // position
99 std::vector<typename Traits::JacobianType>& out) const = 0;
100
106 virtual void partial(const std::array<unsigned int,Traits::dimDomain>& order,
107 const typename Traits::DomainType& in,
108 std::vector<typename Traits::RangeType>& out) const = 0;
109 };
110
111
112
113 // -----------------------------------------------------------------
114 // Interpolation
115 // -----------------------------------------------------------------
116
129 template<class DomainType, class RangeType>
131 {
132 public:
133
136
138 typedef typename RangeType::field_type CoefficientType;
139
141
149 virtual void interpolate (const FunctionType& f, std::vector<CoefficientType>& out) const = 0;
150 };
151
159 template<class DomainType, class RangeType>
161 : public LocalInterpolationVirtualInterfaceBase<DomainType, RangeType>
162 {
163 public:
164
167
169 typedef typename RangeType::field_type CoefficientType;
170
171
173
174 // This method is only noted again for to make the documentation complete.
175
183 virtual void interpolate (const FunctionType& f, std::vector<CoefficientType>& out) const = 0;
184
187 template<class F>
188 void interpolate (const F& f, std::vector<CoefficientType>& out) const
189 {
191 asBase.interpolate(VirtualFunctionWrapper<F>(f),out);
192 }
193
194 template<class F, class C>
195 void interpolate (const F& f, std::vector<C>& out) const
196 {
197 std::vector<CoefficientType> outDummy;
199 asBase.interpolate(VirtualFunctionWrapper<F>(f),outDummy);
200 out.resize(outDummy.size());
201 for(typename std::vector<CoefficientType>::size_type i=0; i<outDummy.size(); ++i)
202 out[i] = outDummy[i];
203 }
204
205 private:
206
207 template <typename F>
208 struct VirtualFunctionWrapper
209 : public FunctionType
210 {
211 public:
212 VirtualFunctionWrapper(const F &f)
213 : f_(f)
214 {}
215
216 virtual ~VirtualFunctionWrapper() {}
217
218 virtual void evaluate(const DomainType& x, RangeType& y) const
219 {
220 f_.evaluate(x,y);
221 }
222
223 const F &f_;
224 };
225 };
226
227
228
229 // -----------------------------------------------------------------
230 // Coefficients
231 // -----------------------------------------------------------------
232
239 {
240 public:
241
243
245 virtual std::size_t size () const = 0;
246
248 const virtual LocalKey& localKey (std::size_t i) const = 0;
249
250 };
251
252
253
254 // -----------------------------------------------------------------
255 // Finite Element
256 // -----------------------------------------------------------------
257
258
264 template<class T>
266 {
267 using LocalBasisTraits = T;
268 public:
275
277
279 virtual const typename Traits::LocalBasisType& localBasis () const = 0;
280
282 virtual const typename Traits::LocalCoefficientsType& localCoefficients () const = 0;
283
285 virtual const typename Traits::LocalInterpolationType& localInterpolation () const = 0;
286
288 virtual unsigned int size () const = 0;
289
291 virtual const GeometryType type () const = 0;
292
293 virtual LocalFiniteElementVirtualInterface<T>* clone() const = 0;
294 };
295}
296#endif
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:277
virtual base class for a local basis
Definition: virtualinterface.hh:69
virtual unsigned int order() const =0
Polynomial order of the shape functions.
virtual void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const =0
Evaluate jacobian of all shape functions at given position.
virtual unsigned int size() const =0
Number of shape functions.
virtual void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const =0
Evaluate all basis function at given position.
virtual void partial(const std::array< unsigned int, Traits::dimDomain > &order, const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const =0
Evaluate partial derivatives of any order of all shape functions.
virtual base class for local coefficients
Definition: virtualinterface.hh:239
virtual std::size_t size() const =0
number of coefficients
virtual const LocalKey & localKey(std::size_t i) const =0
get i'th index
Return a proper base class for functions to use with LocalInterpolation.
Definition: virtualinterface.hh:35
std::conditional< std::is_base_of< Interface, Implementation >::value, VirtualFunctionBase, FunctionBase >::type type
Base class type for functions to use with LocalInterpolation.
Definition: virtualinterface.hh:52
virtual base class for local finite elements with functions
Definition: virtualinterface.hh:266
virtual const Traits::LocalInterpolationType & localInterpolation() const =0
virtual unsigned int size() const =0
virtual const Traits::LocalBasisType & localBasis() const =0
virtual const GeometryType type() const =0
virtual const Traits::LocalCoefficientsType & localCoefficients() const =0
virtual base class for a local interpolation
Definition: virtualinterface.hh:131
Dune::VirtualFunction< DomainType, RangeType > FunctionType
type of virtual function to interpolate
Definition: virtualinterface.hh:135
RangeType::field_type CoefficientType
type of the coefficient vector in the interpolate method
Definition: virtualinterface.hh:138
virtual void interpolate(const FunctionType &f, std::vector< CoefficientType > &out) const =0
determine coefficients interpolating a given function
virtual base class for a local interpolation
Definition: virtualinterface.hh:162
RangeType::field_type CoefficientType
type of the coefficient vector in the interpolate method
Definition: virtualinterface.hh:169
Dune::VirtualFunction< DomainType, RangeType > FunctionType
type of virtual function to interpolate
Definition: virtualinterface.hh:166
virtual void interpolate(const FunctionType &f, std::vector< CoefficientType > &out) const =0
determine coefficients interpolating a given function
void interpolate(const F &f, std::vector< CoefficientType > &out) const
determine coefficients interpolating a given function
Definition: virtualinterface.hh:188
Describe position of one degree of freedom.
Definition: localkey.hh:21
Virtual base class template for function classes.
Definition: function.hh:72
virtual void evaluate(const typename Traits::DomainType &x, typename Traits::RangeType &y) const =0
Function evaluation.
Simple base class templates for functions.
Dune namespace.
Definition: alignedallocator.hh:10
D DomainType
domain type
Definition: localbasis.hh:43
R RangeType
range type
Definition: localbasis.hh:55
traits helper struct
Definition: localfiniteelementtraits.hh:11
LB LocalBasisType
Definition: localfiniteelementtraits.hh:14
LC LocalCoefficientsType
Definition: localfiniteelementtraits.hh:18
LI LocalInterpolationType
Definition: localfiniteelementtraits.hh:22
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 (Nov 24, 23:30, 2024)