Dune Core Modules (2.8.0)

raviartthomas0cube3dall.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_RAVIARTTHOMAS0_CUBE3D_ALL_HH
4#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_CUBE3D_ALL_HH
5
6#include <cstddef>
7#include <numeric>
8#include <vector>
9
11
12#include <dune/localfunctions/common/localbasis.hh>
13#include <dune/localfunctions/common/localkey.hh>
14#include <dune/localfunctions/common/localinterpolation.hh>
15
16namespace Dune
17{
26 template<class D, class R>
28 {
29 public:
32
34 RT0Cube3DLocalBasis (unsigned int s = 0)
35 {
36 sign0 = sign1 = sign2 = sign3 = sign4 = sign5 = 1.0;
37 if (s&1) sign0 = -1.0;
38 if (s&2) sign1 = -1.0;
39 if (s&4) sign2 = -1.0;
40 if (s&8) sign3 = -1.0;
41 if (s&16) sign4 = -1.0;
42 if (s&32) sign5 = -1.0;
43 }
44
46 unsigned int size () const
47 {
48 return 6;
49 }
50
52 inline void evaluateFunction (const typename Traits::DomainType& in,
53 std::vector<typename Traits::RangeType>& out) const
54 {
55 out.resize(6);
56 out[0][0] = sign0*(in[0]-1.0); out[0][1]=0.0; out[0][2]=0.0;
57 out[1][0] = sign1*(in[0]); out[1][1]=0.0; out[1][2]=0.0;
58 out[2][0] = 0.0; out[2][1]=sign2*(in[1]-1.0); out[2][2]=0.0;
59 out[3][0] = 0.0; out[3][1]=sign3*(in[1]); out[3][2]=0.0;
60 out[4][0] = 0.0; out[4][1]=0.0; out[4][2]=sign4*(in[2]-1.0);
61 out[5][0] = 0.0; out[5][1]=0.0; out[5][2]=sign5*(in[2]);
62 }
63
65 inline void
66 evaluateJacobian (const typename Traits::DomainType& in, // position
67 std::vector<typename Traits::JacobianType>& out) const // return value
68 {
69 out.resize(6);
70 out[0][0][0] = sign0; out[0][0][1] = 0; out[0][0][2] = 0;
71 out[0][1][0] = 0; out[0][1][1] = 0; out[0][1][2] = 0;
72 out[0][2][0] = 0; out[0][2][1] = 0; out[0][2][2] = 0;
73
74 out[1][0][0] = sign1; out[1][0][1] = 0; out[1][0][2] = 0;
75 out[1][1][0] = 0; out[1][1][1] = 0; out[1][1][2] = 0;
76 out[1][2][0] = 0; out[1][2][1] = 0; out[1][2][2] = 0;
77
78 out[2][0][0] = 0; out[2][0][1] = 0; out[2][0][2] = 0;
79 out[2][1][0] = 0; out[2][1][1] = sign2; out[2][1][2] = 0;
80 out[2][2][0] = 0; out[2][2][1] = 0; out[2][2][2] = 0;
81
82 out[3][0][0] = 0; out[3][0][1] = 0; out[3][0][2] = 0;
83 out[3][1][0] = 0; out[3][1][1] = sign3; out[3][1][2] = 0;
84 out[3][2][0] = 0; out[3][2][1] = 0; out[3][2][2] = 0;
85
86 out[4][0][0] = 0; out[4][0][1] = 0; out[4][0][2] = 0;
87 out[4][1][0] = 0; out[4][1][1] = 0; out[4][1][2] = 0;
88 out[4][2][0] = 0; out[4][2][1] = 0; out[4][2][2] = sign4;
89
90 out[5][0][0] = 0; out[5][0][1] = 0; out[5][0][2] = 0;
91 out[5][1][0] = 0; out[5][1][1] = 0; out[5][1][2] = 0;
92 out[5][2][0] = 0; out[5][2][1] = 0; out[5][2][2] = sign5;
93 }
94
96 void partial (const std::array<unsigned int, 3>& order,
97 const typename Traits::DomainType& in, // position
98 std::vector<typename Traits::RangeType>& out) const // return value
99 {
100 auto totalOrder = std::accumulate(order.begin(), order.end(), 0);
101 if (totalOrder == 0) {
102 evaluateFunction(in, out);
103 } else if (totalOrder == 1) {
104 auto const direction = std::distance(order.begin(), std::find(order.begin(), order.end(), 1));
105 out.resize(size());
106
107 for (std::size_t i = 0; i < size(); ++i)
108 out[i][0] = out[i][1] = out[i][2] = 0;
109
110 switch (direction) {
111 case 0:
112 out[0][0] = sign0;
113 out[1][0] = sign1;
114 break;
115 case 1:
116 out[2][1] = sign2;
117 out[3][1] = sign3;
118 break;
119 case 2:
120 out[4][2] = sign4;
121 out[5][2] = sign5;
122 break;
123 default:
124 DUNE_THROW(RangeError, "Component out of range.");
125 }
126 } else {
127 out.resize(size());
128 for (std::size_t i = 0; i < size(); ++i)
129 for (std::size_t j = 0; j < 2; ++j)
130 out[i][j] = 0;
131 }
132
133 }
134
136 unsigned int order () const
137 {
138 return 1;
139 }
140
141 private:
142 R sign0, sign1, sign2, sign3, sign4, sign5;
143 };
144
145
153 template<class LB>
155 {
156 public:
157
159 RT0Cube3DLocalInterpolation (unsigned int s = 0)
160 {
161 sign0 = sign1 = sign2 = sign3 = sign4 = sign5 = 1.0;
162 if (s&1) sign0 *= -1.0;
163 if (s&2) sign1 *= -1.0;
164 if (s&4) sign2 *= -1.0;
165 if (s&8) sign3 *= -1.0;
166 if (s&16) sign4 *= -1.0;
167 if (s&32) sign5 *= -1.0;
168
169 m0[0] = 0.0; m0[1] = 0.5; m0[2] = 0.5;
170 m1[0] = 1.0; m1[1] = 0.5; m1[2] = 0.5;
171 m2[0] = 0.5; m2[1] = 0.0; m2[2] = 0.5;
172 m3[0] = 0.5; m3[1] = 1.0; m3[2] = 0.5;
173 m4[0] = 0.5; m4[1] = 0.5; m4[2] = 0.0;
174 m5[0] = 0.5; m5[1] = 0.5; m5[2] = 1.0;
175
176 n0[0] = -1.0; n0[1] = 0.0; n0[2] = 0.0;
177 n1[0] = 1.0; n1[1] = 0.0; n1[2] = 0.0;
178 n2[0] = 0.0; n2[1] = -1.0; n2[2] = 0.0;
179 n3[0] = 0.0; n3[1] = 1.0; n3[2] = 0.0;
180 n4[0] = 0.0; n4[1] = 0.0; n4[2] =-1.0;
181 n5[0] = 0.0; n5[1] = 0.0; n5[2] = 1.0;
182 }
183
184 template<typename F, typename C>
185 void interpolate (const F& ff, std::vector<C>& out) const
186 {
187 // f gives v*outer normal at a point on the edge!
188 auto&& f = Impl::makeFunctionWithCallOperator<typename LB::Traits::DomainType>(ff);
189
190 out.resize(6);
191
192 auto y = f(m0); out[0] = (y[0]*n0[0]+y[1]*n0[1]+y[2]*n0[2])*sign0;
193 y = f(m1); out[1] = (y[0]*n1[0]+y[1]*n1[1]+y[2]*n1[2])*sign1;
194 y = f(m2); out[2] = (y[0]*n2[0]+y[1]*n2[1]+y[2]*n2[2])*sign2;
195 y = f(m3); out[3] = (y[0]*n3[0]+y[1]*n3[1]+y[2]*n3[2])*sign3;
196 y = f(m4); out[4] = (y[0]*n4[0]+y[1]*n4[1]+y[2]*n4[2])*sign4;
197 y = f(m5); out[5] = (y[0]*n5[0]+y[1]*n5[1]+y[2]*n5[2])*sign5;
198 }
199
200 private:
201 typename LB::Traits::RangeFieldType sign0,sign1,sign2,sign3,sign4,sign5;
202 typename LB::Traits::DomainType m0,m1,m2,m3,m4,m5;
203 typename LB::Traits::DomainType n0,n1,n2,n3,n4,n5;
204 };
205
213 {
214 public:
217 {
218 for (std::size_t i=0; i<6; i++)
219 li[i] = LocalKey(i,1,0);
220 }
221
223 std::size_t size () const
224 {
225 return 6;
226 }
227
229 const LocalKey& localKey (std::size_t i) const
230 {
231 return li[i];
232 }
233
234 private:
235 std::vector<LocalKey> li;
236 };
237
238}
239#endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_CUBE3D_ALL_HH
A dense n x m matrix.
Definition: fmatrix.hh:69
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Describe position of one degree of freedom.
Definition: localkey.hh:21
Lowest order Raviart-Thomas shape functions on the reference hexahedron.
Definition: raviartthomas0cube3dall.hh:28
unsigned int size() const
number of shape functions
Definition: raviartthomas0cube3dall.hh:46
void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: raviartthomas0cube3dall.hh:66
unsigned int order() const
Polynomial order of the shape functions.
Definition: raviartthomas0cube3dall.hh:136
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: raviartthomas0cube3dall.hh:96
RT0Cube3DLocalBasis(unsigned int s=0)
Make set number s, where 0 <= s < 64.
Definition: raviartthomas0cube3dall.hh:34
void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: raviartthomas0cube3dall.hh:52
Layout map for RT0 elements on quadrilaterals.
Definition: raviartthomas0cube3dall.hh:213
RT0Cube3DLocalCoefficients()
Standard constructor.
Definition: raviartthomas0cube3dall.hh:216
std::size_t size() const
number of coefficients
Definition: raviartthomas0cube3dall.hh:223
const LocalKey & localKey(std::size_t i) const
get i'th index
Definition: raviartthomas0cube3dall.hh:229
Lowest order Raviart-Thomas shape functions on the reference hexahedron.
Definition: raviartthomas0cube3dall.hh:155
RT0Cube3DLocalInterpolation(unsigned int s=0)
Make set number s, where 0 <= s < 64.
Definition: raviartthomas0cube3dall.hh:159
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 ...
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
constexpr T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:289
Dune namespace.
Definition: alignedallocator.hh:11
Type traits for LocalBasisVirtualInterface.
Definition: localbasis.hh:32
D DomainType
domain type
Definition: localbasis.hh:43
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)