DUNE-FEM (2.10)

raviartthomas0pyramidlocalbasis.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#ifndef DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PYRAMID_LOCALBASIS_HH
6#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PYRAMID_LOCALBASIS_HH
7
8#include <numeric>
9#include <vector>
10
12
13#include "../../common/localbasis.hh"
14
15namespace Dune
16{
26 template<class D, class R>
28 {
29
30 public:
33
39 RT0PyramidLocalBasis (std::bitset<5> s = 0)
40 {
41 // For each basis function we store the constant offset vector
42 // and the factor of the linear term for both sub-elements.
43 // In the j-th sub-element the i-th basis function is then
44 // given by y = offset_[i][j] + factor_[i][j]*x.
45 offset_[0][0] = {0.0, 0.0, -1.0};
46 factor_[0][0] = 1.0;
47 offset_[0][1] = {0.0, 0.0, -1.0};
48 factor_[0][1] = 1.0;
49
50 offset_[1][0] = {-2.0, -2.0, 0.0};
51 factor_[1][0] = 2.0;
52 offset_[1][1] = {0.0, 0.0, 0.0};
53 factor_[1][1] = 0.0;
54
55 offset_[2][0] = {0.0, 0.0, 0.0};
56 factor_[2][0] = 0.0;
57 offset_[2][1] = {0.0, 0.0, 0.0};
58 factor_[2][1] = 2.0;
59
60 offset_[3][0] = {0.0, 0.0, 0.0};
61 factor_[3][0] = 0.0;
62 offset_[3][1] = {-2.0, -2.0, 0.0};
63 factor_[3][1] = 2.0;
64
65 offset_[4][0] = {0.0, 0.0, 0.0};
66 factor_[4][0] = 2.0;
67 offset_[4][1] = {0.0, 0.0, 0.0};
68 factor_[4][1] = 0.0;
69
70 // Adjust the scaling for the triangular faces functions.
71 // The tetrahedral RT-basis is scaled rather strange:
72 // The dual basis does not evaluate the face integral
73 // of the normal component, but sqrt(2) times this integral.
74 // In order to match the basis functions, we need to rescale
75 // the triangular face functions here, too.
76 for(std::size_t i=1; i<5; ++i)
77 for(std::size_t j=0; j<2; ++j)
78 {
79 offset_[i][j] /= std::sqrt(2.0);
80 factor_[i][j] /= std::sqrt(2.0);
81 }
82
83 // Interior basis function associated to the interior
84 // face given by the intersection of the sub-elements
85 // in the plane where x[0]==x[1].
86 offset_[5][0] = {0.0, -2.0, 0.0};
87 factor_[5][0] = 2.0;
88 offset_[5][1] = {2.0, 0.0, 0.0};
89 factor_[5][1] = -2.0;
90
91 for (size_t i=0; i<5; i++)
92 sign_[i] = s[i] ? -1.0 : 1.0;
93
94 // No need to flip the sign_ for the interior basis function
95 sign_[5] = 1.0;
96 }
97
99 unsigned int size () const
100 {
101 return 6;
102 }
103
110 inline void evaluateFunction (const typename Traits::DomainType& x,
111 std::vector<typename Traits::RangeType>& out) const
112 {
113 out.resize(size());
114 bool compositeElement = x[0] > x[1];
115 for (std::size_t i=0; i<size(); i++)
116 {
117 out[i] = x;
118 out[i] *= factor_[i][compositeElement];
119 out[i] += offset_[i][compositeElement];
120 out[i] *= sign_[i];
121 }
122 }
123
130 inline void evaluateJacobian (const typename Traits::DomainType& x,
131 std::vector<typename Traits::JacobianType>& out) const
132 {
133 out.resize(size());
134 bool compositeElement = x[0] > x[1];
135 for (std::size_t i=0; i<size(); i++)
136 for(std::size_t j=0; j<3; j++)
137 for(std::size_t k=0; k<3; k++)
138 out[i][j][k] = (j==k) * factor_[i][compositeElement] * sign_[i];
139 }
140
142 void partial (const std::array<unsigned int, 3>& order,
143 const typename Traits::DomainType& in, // position
144 std::vector<typename Traits::RangeType>& out) const // return value
145 {
146 auto totalOrder = std::accumulate(order.begin(), order.end(), 0);
147 if (totalOrder == 0) {
148 evaluateFunction(in, out);
149 } else {
150 DUNE_THROW(NotImplemented, "Desired derivative order is not implemented");
151 }
152 }
153
155 unsigned int order () const
156 {
157 return 1;
158 }
159
160 private:
161 std::array<R,6> sign_;
162 std::array<std::array<typename Traits::RangeType, 2>, 6> offset_;
163 std::array<std::array<R, 2>, 6> factor_;
164 };
165}
166#endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PYRAMID_LOCALBASIS_HH
A dense n x m matrix.
Definition: fmatrix.hh:117
vector space out of a tensor product of fields.
Definition: fvector.hh:91
Default exception for dummy implementations.
Definition: exceptions.hh:263
First order Raviart-Thomas shape functions on the reference pyramid.
Definition: raviartthomas0pyramidlocalbasis.hh:28
RT0PyramidLocalBasis(std::bitset< 5 > s=0)
Make set number s, where 0 <= s < 32.
Definition: raviartthomas0pyramidlocalbasis.hh:39
void evaluateFunction(const typename Traits::DomainType &x, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: raviartthomas0pyramidlocalbasis.hh:110
unsigned int order() const
Polynomial order of the shape functions.
Definition: raviartthomas0pyramidlocalbasis.hh:155
unsigned int size() const
number of shape functions
Definition: raviartthomas0pyramidlocalbasis.hh:99
void evaluateJacobian(const typename Traits::DomainType &x, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: raviartthomas0pyramidlocalbasis.hh:130
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: raviartthomas0pyramidlocalbasis.hh:142
Implements a matrix constructed from a given type representing a field and compile-time given number ...
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
constexpr T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:279
Dune namespace.
Definition: alignedallocator.hh:13
Type traits for LocalBasisVirtualInterface.
Definition: localbasis.hh:35
D DomainType
domain type
Definition: localbasis.hh:43
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Sep 3, 22:42, 2025)