Dune Core Modules (2.6.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
15namespace Dune
16{
25 template<class D, class R>
27 {
28 public:
31
34 {
35 sign0 = sign1 = sign2 = sign3 = sign4 = sign5 = 1.0;
36 }
37
39 RT0Cube3DLocalBasis (unsigned int s)
40 {
41 sign0 = sign1 = sign2 = sign3 = sign4 = sign5 = 1.0;
42 if (s&1) sign0 = -1.0;
43 if (s&2) sign1 = -1.0;
44 if (s&4) sign2 = -1.0;
45 if (s&8) sign3 = -1.0;
46 if (s&16) sign4 = -1.0;
47 if (s&32) sign5 = -1.0;
48 }
49
51 unsigned int size () const
52 {
53 return 6;
54 }
55
57 inline void evaluateFunction (const typename Traits::DomainType& in,
58 std::vector<typename Traits::RangeType>& out) const
59 {
60 out.resize(6);
61 out[0][0] = sign0*(in[0]-1.0); out[0][1]=0.0; out[0][2]=0.0;
62 out[1][0] = sign1*(in[0]); out[1][1]=0.0; out[1][2]=0.0;
63 out[2][0] = 0.0; out[2][1]=sign2*(in[1]-1.0); out[2][2]=0.0;
64 out[3][0] = 0.0; out[3][1]=sign3*(in[1]); out[3][2]=0.0;
65 out[4][0] = 0.0; out[4][1]=0.0; out[4][2]=sign4*(in[2]-1.0);
66 out[5][0] = 0.0; out[5][1]=0.0; out[5][2]=sign5*(in[2]);
67 }
68
70 inline void
71 evaluateJacobian (const typename Traits::DomainType& in, // position
72 std::vector<typename Traits::JacobianType>& out) const // return value
73 {
74 out.resize(6);
75 out[0][0][0] = sign0; out[0][0][1] = 0; out[0][0][2] = 0;
76 out[0][1][0] = 0; out[0][1][1] = 0; out[0][1][2] = 0;
77 out[0][2][0] = 0; out[0][2][1] = 0; out[0][2][2] = 0;
78
79 out[1][0][0] = sign1; out[1][0][1] = 0; out[1][0][2] = 0;
80 out[1][1][0] = 0; out[1][1][1] = 0; out[1][1][2] = 0;
81 out[1][2][0] = 0; out[1][2][1] = 0; out[1][2][2] = 0;
82
83 out[2][0][0] = 0; out[2][0][1] = 0; out[2][0][2] = 0;
84 out[2][1][0] = 0; out[2][1][1] = sign2; out[2][1][2] = 0;
85 out[2][2][0] = 0; out[2][2][1] = 0; out[2][2][2] = 0;
86
87 out[3][0][0] = 0; out[3][0][1] = 0; out[3][0][2] = 0;
88 out[3][1][0] = 0; out[3][1][1] = sign3; out[3][1][2] = 0;
89 out[3][2][0] = 0; out[3][2][1] = 0; out[3][2][2] = 0;
90
91 out[4][0][0] = 0; out[4][0][1] = 0; out[4][0][2] = 0;
92 out[4][1][0] = 0; out[4][1][1] = 0; out[4][1][2] = 0;
93 out[4][2][0] = 0; out[4][2][1] = 0; out[4][2][2] = sign4;
94
95 out[5][0][0] = 0; out[5][0][1] = 0; out[5][0][2] = 0;
96 out[5][1][0] = 0; out[5][1][1] = 0; out[5][1][2] = 0;
97 out[5][2][0] = 0; out[5][2][1] = 0; out[5][2][2] = sign5;
98 }
99
101 void partial (const std::array<unsigned int, 3>& order,
102 const typename Traits::DomainType& in, // position
103 std::vector<typename Traits::RangeType>& out) const // return value
104 {
105 auto totalOrder = std::accumulate(order.begin(), order.end(), 0);
106 if (totalOrder == 0) {
107 evaluateFunction(in, out);
108 } else if (totalOrder == 1) {
109 auto const direction = std::distance(order.begin(), std::find(order.begin(), order.end(), 1));
110 out.resize(size());
111
112 for (std::size_t i = 0; i < size(); ++i)
113 out[i][0] = out[i][1] = out[i][2] = 0;
114
115 switch (direction) {
116 case 0:
117 out[0][0] = sign0;
118 out[1][0] = sign1;
119 break;
120 case 1:
121 out[2][1] = sign2;
122 out[3][1] = sign3;
123 break;
124 case 2:
125 out[4][2] = sign4;
126 out[5][2] = sign5;
127 break;
128 default:
129 DUNE_THROW(RangeError, "Component out of range.");
130 }
131 } else {
132 out.resize(size());
133 for (std::size_t i = 0; i < size(); ++i)
134 for (std::size_t j = 0; j < 2; ++j)
135 out[i][j] = 0;
136 }
137
138 }
139
141 unsigned int order () const
142 {
143 return 1;
144 }
145
146 private:
147 R sign0, sign1, sign2, sign3, sign4, sign5;
148 };
149
150
158 template<class LB>
160 {
161 public:
162
165 {
166 sign0 = sign1 = sign2 = sign3 = sign4 = sign5 = 1.0;
167 }
168
171 {
172 sign0 = sign1 = sign2 = sign3 = sign4 = sign5 = 1.0;
173 if (s&1) sign0 *= -1.0;
174 if (s&2) sign1 *= -1.0;
175 if (s&4) sign2 *= -1.0;
176 if (s&8) sign3 *= -1.0;
177 if (s&16) sign4 *= -1.0;
178 if (s&32) sign5 *= -1.0;
179
180 m0[0] = 0.0; m0[1] = 0.5; m0[2] = 0.5;
181 m1[0] = 1.0; m1[1] = 0.5; m1[2] = 0.5;
182 m2[0] = 0.5; m2[1] = 0.0; m2[2] = 0.5;
183 m3[0] = 0.5; m3[1] = 1.0; m3[2] = 0.5;
184 m4[0] = 0.5; m4[1] = 0.5; m4[2] = 0.0;
185 m5[0] = 0.5; m5[1] = 0.5; m5[2] = 1.0;
186
187 n0[0] = -1.0; n0[1] = 0.0; n0[2] = 0.0;
188 n1[0] = 1.0; n1[1] = 0.0; n1[2] = 0.0;
189 n2[0] = 0.0; n2[1] = -1.0; n2[2] = 0.0;
190 n3[0] = 0.0; n3[1] = 1.0; n3[2] = 0.0;
191 n4[0] = 0.0; n4[1] = 0.0; n4[2] =-1.0;
192 n5[0] = 0.0; n5[1] = 0.0; n5[2] = 1.0;
193 }
194
195 template<typename F, typename C>
196 void interpolate (const F& f, std::vector<C>& out) const
197 {
198 // f gives v*outer normal at a point on the edge!
199 typename F::Traits::RangeType y;
200
201 out.resize(6);
202
203 f.evaluate(m0,y); out[0] = (y[0]*n0[0]+y[1]*n0[1]+y[2]*n0[2])*sign0;
204 f.evaluate(m1,y); out[1] = (y[0]*n1[0]+y[1]*n1[1]+y[2]*n1[2])*sign1;
205 f.evaluate(m2,y); out[2] = (y[0]*n2[0]+y[1]*n2[1]+y[2]*n2[2])*sign2;
206 f.evaluate(m3,y); out[3] = (y[0]*n3[0]+y[1]*n3[1]+y[2]*n3[2])*sign3;
207 f.evaluate(m4,y); out[4] = (y[0]*n4[0]+y[1]*n4[1]+y[2]*n4[2])*sign4;
208 f.evaluate(m5,y); out[5] = (y[0]*n5[0]+y[1]*n5[1]+y[2]*n5[2])*sign5;
209 }
210
211 private:
212 typename LB::Traits::RangeFieldType sign0,sign1,sign2,sign3,sign4,sign5;
213 typename LB::Traits::DomainType m0,m1,m2,m3,m4,m5;
214 typename LB::Traits::DomainType n0,n1,n2,n3,n4,n5;
215 };
216
224 {
225 public:
228 {
229 for (std::size_t i=0; i<6; i++)
230 li[i] = LocalKey(i,1,0);
231 }
232
234 std::size_t size () const
235 {
236 return 6;
237 }
238
240 const LocalKey& localKey (std::size_t i) const
241 {
242 return li[i];
243 }
244
245 private:
246 std::vector<LocalKey> li;
247 };
248
249}
250#endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_CUBE3D_ALL_HH
A dense n x m matrix.
Definition: fmatrix.hh:68
vector space out of a tensor product of fields.
Definition: fvector.hh:93
Describe position of one degree of freedom.
Definition: localkey.hh:21
Lowest order Raviart-Thomas shape functions on the reference hexahedron.
Definition: raviartthomas0cube3dall.hh:27
unsigned int size() const
number of shape functions
Definition: raviartthomas0cube3dall.hh:51
void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: raviartthomas0cube3dall.hh:71
unsigned int order() const
Polynomial order of the shape functions.
Definition: raviartthomas0cube3dall.hh:141
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:101
RT0Cube3DLocalBasis(unsigned int s)
Make set numer s, where 0<=s<64.
Definition: raviartthomas0cube3dall.hh:39
void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: raviartthomas0cube3dall.hh:57
RT0Cube3DLocalBasis()
Standard constructor.
Definition: raviartthomas0cube3dall.hh:33
Layout map for RT0 elements on quadrilaterals.
Definition: raviartthomas0cube3dall.hh:224
RT0Cube3DLocalCoefficients()
Standard constructor.
Definition: raviartthomas0cube3dall.hh:227
std::size_t size() const
number of coefficients
Definition: raviartthomas0cube3dall.hh:234
const LocalKey & localKey(std::size_t i) const
get i'th index
Definition: raviartthomas0cube3dall.hh:240
Lowest order Raviart-Thomas shape functions on the reference hexahedron.
Definition: raviartthomas0cube3dall.hh:160
RT0Cube3DLocalInterpolation(unsigned int s)
Make set numer s, where 0<=s<64.
Definition: raviartthomas0cube3dall.hh:170
RT0Cube3DLocalInterpolation()
Standard constructor.
Definition: raviartthomas0cube3dall.hh:164
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
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
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)