3#ifndef DUNE_HIERARCHICAL_SIMPLEX_P2_WITH_ELEMENT_BUBBLE_LOCALBASIS_HH
4#define DUNE_HIERARCHICAL_SIMPLEX_P2_WITH_ELEMENT_BUBBLE_LOCALBASIS_HH
16#include <dune/localfunctions/common/localbasis.hh>
17#include <dune/localfunctions/common/localkey.hh>
21 template<
class D,
class R,
int dim>
22 class HierarchicalSimplexP2WithElementBubbleLocalBasis
25 HierarchicalSimplexP2WithElementBubbleLocalBasis()
45 template<
class D,
class R>
46 class HierarchicalSimplexP2WithElementBubbleLocalBasis<D,R,1>
61 std::vector<typename Traits::RangeType>& out)
const
67 out[2] = 1-4*(in[0]-0.5)*(in[0]-0.5);
73 std::vector<typename Traits::JacobianType>& out)
const
79 out[2][0][0] = 4-8*in[0];
83 void partial (
const std::array<unsigned int, 1>& order,
85 std::vector<typename Traits::RangeType>& out)
const
87 auto totalOrder = order[0];
88 if (totalOrder == 0) {
89 evaluateFunction(in, out);
90 }
else if (totalOrder == 1) {
95 }
else if (totalOrder == 2) {
102 out[0] = out[1] = out[2] = 0;
135 template<
class D,
class R>
136 class HierarchicalSimplexP2WithElementBubbleLocalBasis<D,R,2>
151 std::vector<typename Traits::RangeType>& out)
const
155 out[0] = 1 - in[0] - in[1];
156 out[1] = 4*in[0]*(1-in[0]-in[1]);
158 out[3] = 4*in[1]*(1-in[0]-in[1]);
159 out[4] = 4*in[0]*in[1];
161 out[6] = 27*in[0]*in[1]*(1-in[0]-in[1]);
168 std::vector<typename Traits::JacobianType>& out)
const
172 out[0][0][0] = -1; out[0][0][1] = -1;
173 out[1][0][0] = 4-8*in[0]-4*in[1]; out[1][0][1] = -4*in[0];
174 out[2][0][0] = 1; out[2][0][1] = 0;
175 out[3][0][0] = -4*in[1]; out[3][0][1] = 4-4*in[0]-8*in[1];
176 out[4][0][0] = 4*in[1]; out[4][0][1] = 4*in[0];
177 out[5][0][0] = 0; out[5][0][1] = 1;
180 out[6][0][0] = 27 * in[1] * (1 - 2*in[0] - in[1]);
181 out[6][0][1] = 27 * in[0] * (1 - 2*in[1] - in[0]);
186 void partial (
const std::array<unsigned int, 2>& order,
188 std::vector<typename Traits::RangeType>& out)
const
191 if (totalOrder == 0) {
192 evaluateFunction(in, out);
193 }
else if (totalOrder == 1) {
195 auto const direction = std::distance(order.begin(), std::find(order.begin(), order.end(), 1));
200 out[1] = 4-8*in[0]-4*in[1];
205 out[6] = 27 * in[1] * (1 - 2*in[0] - in[1]);
211 out[3] = 4-4*in[0]-8*in[1];
214 out[6] = 27 * in[0] * (1 - 2*in[1] - in[0]);
257 template<
class D,
class R>
258 class HierarchicalSimplexP2WithElementBubbleLocalBasis<D,R,3>
273 std::vector<typename Traits::RangeType>& out)
const
277 out[0] = 1 - in[0] - in[1] - in[2];
278 out[1] = 4 * in[0] * (1 - in[0] - in[1] - in[2]);
280 out[3] = 4 * in[1] * (1 - in[0] - in[1] - in[2]);
281 out[4] = 4 * in[0] * in[1];
283 out[6] = 4 * in[2] * (1 - in[0] - in[1] - in[2]);
284 out[7] = 4 * in[0] * in[2];
285 out[8] = 4 * in[1] * in[2];
289 out[10] = 81*in[0]*in[1]*in[2]*(1-in[0]-in[1]-in[2]);
294 std::vector<typename Traits::JacobianType>& out)
const
298 out[0][0][0] = -1; out[0][0][1] = -1; out[0][0][2] = -1;
299 out[1][0][0] = 4-8*in[0]-4*in[1]-4*in[2]; out[1][0][1] = -4*in[0]; out[1][0][2] = -4*in[0];
300 out[2][0][0] = 1; out[2][0][1] = 0; out[2][0][2] = 0;
301 out[3][0][0] = -4*in[1]; out[3][0][1] = 4-4*in[0]-8*in[1]-4*in[2]; out[3][0][2] = -4*in[1];
302 out[4][0][0] = 4*in[1]; out[4][0][1] = 4*in[0]; out[4][0][2] = 0;
303 out[5][0][0] = 0; out[5][0][1] = 1; out[5][0][2] = 0;
304 out[6][0][0] = -4*in[2]; out[6][0][1] = -4*in[2]; out[6][0][2] = 4-4*in[0]-4*in[1]-8*in[2];
305 out[7][0][0] = 4*in[2]; out[7][0][1] = 0; out[7][0][2] = 4*in[0];
306 out[8][0][0] = 0; out[8][0][1] = 4*in[2]; out[8][0][2] = 4*in[1];
307 out[9][0][0] = 0; out[9][0][1] = 0; out[9][0][2] = 1;
309 out[10][0][0] = 81 * in[1] * in[2] * (1 - 2*in[0] - in[1] - in[2]);
310 out[10][0][1] = 81 * in[0] * in[2] * (1 - in[0] - 2*in[1] - in[2]);
311 out[10][0][2] = 81 * in[0] * in[1] * (1 - in[0] - in[1] - 2*in[2]);
315 void partial (
const std::array<unsigned int, 3>& order,
317 std::vector<typename Traits::RangeType>& out)
const
320 if (totalOrder == 0) {
321 evaluateFunction(in, out);
322 }
else if (totalOrder == 1) {
324 auto const direction = std::distance(order.begin(), std::find(order.begin(), order.end(), 1));
329 out[1] = 4-8*in[0]-4*in[1]-4*in[2];
338 out[10] = 81 * in[1] * in[2] * (1 - 2*in[0] - in[1] - in[2]);
344 out[3] = 4-4*in[0]-8*in[1]-4*in[2];
351 out[10] = 81 * in[0] * in[2] * (1 - in[0] - 2*in[1] - in[2]);
360 out[6] = 4-4*in[0]-4*in[1]-8*in[2];
364 out[10] = 81 * in[0] * in[1] * (1 - in[0] - in[1] - 2*in[2]);
413 static const int numVertices = dim+1;
416 static const int numEdges = (dim+1)*dim / 2;
421 : li(numVertices+numEdges + 1)
438 return numVertices+numEdges + 1;
448 std::vector<Dune::LocalKey> li;
452 class HierarchicalSimplexP2WithElementBubbleLocalInterpolation
457 template<
typename F,
typename C>
458 void interpolate (
const F& f, std::vector<C>& out)
const
460 typename LB::Traits::DomainType x;
461 typename LB::Traits::RangeType y;
466 x[0] = 0.0; x[1] = 0.0; f.evaluate(x,y); out[0] = y;
467 x[0] = 1.0; x[1] = 0.0; f.evaluate(x,y); out[2] = y;
468 x[0] = 0.0; x[1] = 1.0; f.evaluate(x,y); out[5] = y;
471 x[0] = 0.5; x[1] = 0.0; f.evaluate(x,y);
472 out[1] = y - out[0]*(1-x[0]) - out[2]*x[0];
474 x[0] = 0.0; x[1] = 0.5; f.evaluate(x,y);
475 out[3] = y - out[0]*(1-x[1]) - out[5]*x[1];
477 x[0] = 0.5; x[1] = 0.5; f.evaluate(x,y);
478 out[4] = y - out[2]*x[0] - out[5]*x[1];
481 x[0] = 1.0/3; x[1] = 1.0/3; f.evaluate(x,y);
484 HierarchicalSimplexP2WithElementBubbleLocalBasis<double,double,2> shapeFunctions;
485 std::vector<typename LB::Traits::RangeType> sfValues;
486 shapeFunctions.evaluateFunction(x, sfValues);
489 for (
int i=0; i<6; i++)
490 out[6] -= out[i]*sfValues[i];
A dense n x m matrix.
Definition: fmatrix.hh:68
vector space out of a tensor product of fields.
Definition: fvector.hh:93
void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: hierarchicalsimplexp2withelementbubble.hh:72
LocalBasisTraits< D, 1, Dune::FieldVector< D, 1 >, R, 1, Dune::FieldVector< R, 1 >, Dune::FieldMatrix< R, 1, 1 > > Traits
export type traits for function signature
Definition: hierarchicalsimplexp2withelementbubble.hh:51
void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: hierarchicalsimplexp2withelementbubble.hh:60
unsigned int order() const
Polynomial order of the shape functions (2, in this case)
Definition: hierarchicalsimplexp2withelementbubble.hh:108
unsigned int size() const
number of shape functions
Definition: hierarchicalsimplexp2withelementbubble.hh:54
void partial(const std::array< unsigned int, 1 > &order, const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate partial derivatives of all shape functions.
Definition: hierarchicalsimplexp2withelementbubble.hh:83
unsigned int size() const
number of shape functions
Definition: hierarchicalsimplexp2withelementbubble.hh:144
unsigned int order() const
Polynomial order of the shape functions (3 in this case)
Definition: hierarchicalsimplexp2withelementbubble.hh:226
void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: hierarchicalsimplexp2withelementbubble.hh:150
void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: hierarchicalsimplexp2withelementbubble.hh:167
void partial(const std::array< unsigned int, 2 > &order, const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate partial derivatives of all shape functions.
Definition: hierarchicalsimplexp2withelementbubble.hh:186
LocalBasisTraits< D, 2, Dune::FieldVector< D, 2 >, R, 1, Dune::FieldVector< R, 1 >, Dune::FieldMatrix< R, 1, 2 > > Traits
export type traits for function signature
Definition: hierarchicalsimplexp2withelementbubble.hh:141
unsigned int size() const
number of shape functions
Definition: hierarchicalsimplexp2withelementbubble.hh:266
void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: hierarchicalsimplexp2withelementbubble.hh:272
unsigned int order() const
Polynomial order of the shape functions (4 in this case)
Definition: hierarchicalsimplexp2withelementbubble.hh:376
void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: hierarchicalsimplexp2withelementbubble.hh:293
void partial(const std::array< unsigned int, 3 > &order, const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate partial derivatives of all shape functions.
Definition: hierarchicalsimplexp2withelementbubble.hh:315
LocalBasisTraits< D, 3, Dune::FieldVector< D, 3 >, R, 1, Dune::FieldVector< R, 1 >, Dune::FieldMatrix< R, 1, 3 > > Traits
export type traits for function signature
Definition: hierarchicalsimplexp2withelementbubble.hh:263
The local finite element needed for the Zou-Kornhuber estimator for Signorini problems.
Definition: hierarchicalsimplexp2withelementbubble.hh:411
size_t size() const
number of coefficients
Definition: hierarchicalsimplexp2withelementbubble.hh:436
const Dune::LocalKey & localKey(size_t i) const
get i'th index
Definition: hierarchicalsimplexp2withelementbubble.hh:442
HierarchicalSimplexP2WithElementBubbleLocalCoefficients()
Standard constructor.
Definition: hierarchicalsimplexp2withelementbubble.hh:420
Describe position of one degree of freedom.
Definition: localkey.hh:21
Default exception for dummy implementations.
Definition: exceptions.hh:261
Default exception class for range errors.
Definition: exceptions.hh:252
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.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:331
Dune namespace.
Definition: alignedallocator.hh:10
Type traits for LocalBasisVirtualInterface.
Definition: localbasis.hh:32
D DomainType
domain type
Definition: localbasis.hh:43