3#ifndef DUNE_LOCALFUNCTIONS_LAGRANGE_LAGRANGEPYRAMID_HH
4#define DUNE_LOCALFUNCTIONS_LAGRANGE_LAGRANGEPYRAMID_HH
13#include <dune/geometry/referenceelements.hh>
15#include <dune/localfunctions/common/localbasis.hh>
16#include <dune/localfunctions/common/localfiniteelementtraits.hh>
17#include <dune/localfunctions/common/localinterpolation.hh>
18#include <dune/localfunctions/common/localkey.hh>
20namespace Dune {
namespace Impl
31 template<
class D,
class R,
unsigned int k>
32 class LagrangePyramidLocalBasis
35 using Traits = LocalBasisTraits<D,3,FieldVector<D,3>,R,1,FieldVector<R,1>,FieldMatrix<R,1,3> >;
39 static constexpr std::size_t size ()
41 std::size_t result = 0;
42 for (
unsigned int i=0; i<=k; i++)
43 result +=
power(i+1,2);
49 std::vector<typename Traits::RangeType>& out)
const
64 out[0] = (1-in[0])*(1-in[1])-in[2]*(1-in[1]);
65 out[1] = in[0]*(1-in[1])-in[2]*in[1];
66 out[2] = (1-in[0])*in[1]-in[2]*in[1];
67 out[3] = in[0]*in[1]+in[2]*in[1];
71 out[0] = (1-in[0])*(1-in[1])-in[2]*(1-in[0]);
72 out[1] = in[0]*(1-in[1])-in[2]*in[0];
73 out[2] = (1-in[0])*in[1]-in[2]*in[0];
74 out[3] = in[0]*in[1]+in[2]*in[0];
85 const R x = 2.0*in[0] + in[2] - 1.0;
86 const R y = 2.0*in[1] + in[2] - 1.0;
92 out[0] = 0.25*(x + z)*(x + z - 1)*(y - z - 1)*(y - z);
93 out[1] = -0.25*(x + z)*(y - z)*((x + z + 1)*(-y + z + 1) - 4*z) - z*(x - y);
94 out[2] = 0.25*(x + z)*(y - z)*(y - z + 1)*(x + z - 1);
95 out[3] = 0.25*(y - z)*(x + z)*(y - z + 1)*(x + z + 1);
99 out[5] = -0.5*(y - z + 1)*(x + z - 1)*(y - 1)*x;
100 out[6] = -0.5*(y - z + 1)*(((x + z + 1)*(y - 1)*x - z) + z*(2*y + 1));
101 out[7] = -0.5*(x + z - 1)*(((y - z - 1)*(x + 1)*y - z) + z*(2*x + 1));
102 out[8] = -0.5*(y - z + 1)*(x + z - 1)*(x + 1)*y;
105 out[9] = z*(x + z - 1)*(y - z - 1);
106 out[10] = -z*((x + z + 1)*(y - z - 1) + 4*z);
107 out[11] = -z*(y - z + 1)*(x + z - 1);
108 out[12] = z*(y - z + 1)*(x + z + 1);
111 out[13] = (y - z + 1)*(x + z - 1)*((y - 1)*(x + 1) + z*(x - y + z + 1));
116 out[0] = 0.25*(y + z)*(y + z - 1)*(x - z - 1)*(x - z);
117 out[1] = -0.25*(x - z)*(y + z)*(x - z + 1)*(-y - z + 1);
118 out[2] = 0.25*(x - z)*(y + z)*((x - z - 1)*(y + z + 1) + 4*z) + z*(x - y);
119 out[3] = 0.25*(y + z)*(x - z)*(x - z + 1)*(y + z + 1);
120 out[4] = z*(2*z - 1);
123 out[5] = -0.5*(y + z - 1)*(((x - z - 1)*(y + 1)*x - z) + z*(2*y + 1));
124 out[6] = -0.5*(x - z + 1)*(y + z - 1)*(y + 1)*x;
125 out[7] = -0.5*(x - z + 1)*(y + z - 1)*(x - 1)*y;
126 out[8] = -0.5*(x - z + 1)*(((y + z + 1)*(x - 1)*y - z) + z*(2*x + 1));
129 out[9] = z*(y + z - 1)*(x - z - 1);
130 out[10] = -z*(x - z + 1)*(y + z - 1);
131 out[11] = -z*((y + z + 1)*(x - z - 1) + 4*z);
132 out[12] = z*(x - z + 1)*(y + z + 1);
135 out[13] = (x - z + 1)*(y + z - 1)*((y + 1)*(x - 1) - z*(x - y - z - 1));
141 DUNE_THROW(NotImplemented,
"LagrangePyramidLocalBasis::evaluateFunction for order " << k);
150 std::vector<typename Traits::JacobianType>& out)
const
157 std::fill(out[0][0].begin(), out[0][0].end(), 0);
165 out[0][0] = {-1 + in[1], -1 + in[0] + in[2], -1 + in[1]};
166 out[1][0] = { 1 - in[1], -in[0] - in[2], -in[1]};
167 out[2][0] = { -in[1], 1 - in[0] - in[2], -in[1]};
168 out[3][0] = { in[1], in[0] + in[2], in[1]};
172 out[0][0] = {-1 + in[1] + in[2], -1 + in[0], -1 + in[0]};
173 out[1][0] = { 1 - in[1] - in[2], -in[0], -in[0]};
174 out[2][0] = { -in[1] - in[2], 1 - in[0], -in[0]};
175 out[3][0] = { in[1] + in[2], in[0], in[0]};
178 out[4][0] = {0, 0, 1};
185 const R x = 2.0*in[0] + in[2] - 1.0;
186 const R y = 2.0*in[1] + in[2] - 1.0;
194 out[0][0][0] = 0.5*(y - z - 1)*(y - z)*(2*x + 2*z - 1);
195 out[0][0][1] = 0.5*(x + z)*(x + z - 1)*(2*y - 2*z - 1);
196 out[0][0][2] = 0.5*(out[0][0][0] + out[0][0][1])
197 + 0.25*((2*x + 2*z - 1)*(y - z - 1)*(y - z)
198 + (x + z)*(x + z - 1)*(-2*y + 2*z + 1));
200 out[1][0][0] = 2*(-0.25*((y - z)*((x + z + 1)*(-y + z + 1) - 4*z)
201 + (x + z)*(y - z)*(-y + z + 1)) - z);
202 out[1][0][1] = 2*(-0.25*((x + z)*((x + z + 1)*(-y + z + 1) - 4*z)
203 + (x + z)*(y - z)*(-(x + z + 1))) + z);
204 out[1][0][2] = 0.5*(out[1][0][0] + out[1][0][1])
205 - 0.25*((y - z)*((x + z + 1)*(-y + z + 1) - 4*z)
206 - (x + z)*((x + z + 1)*(-y + z + 1) - 4*z)
207 + (x + z)*(y - z)*(x - y + 2*z - 2))
210 out[2][0][0] = 0.5*(y - z)*(y - z + 1)*(2*x + 2*z - 1);
211 out[2][0][1] = 0.5*(x + z)*(2*y - 2*z + 1)*(x + z - 1);
212 out[2][0][2] = 0.5*(out[2][0][0] + out[2][0][1])
213 + 0.25*((y - x - 2*z)*(y - z + 1)*(x + z - 1)
214 + (x + z)*(y - z)*(y - x - 2*z + 2));
216 out[3][0][0] = 0.5*(y - z)*(2*x + 2*z + 1)*(y - z + 1);
217 out[3][0][1] = 0.5*(2*y - 2*z + 1)*(x + z)*(x + z + 1);
218 out[3][0][2] = 0.5*(out[3][0][0] + out[3][0][1])
219 + 0.25*((y - x - 2*z)*(y - z + 1)*(x + z + 1)
220 + (y - z)*(x + z)*(y - x - 2*z));
224 out[4][0][2] = 4*z - 1;
227 out[5][0][0] = -(y - z + 1)*(y - 1)*(2*x + z - 1);
228 out[5][0][1] = -(x + z - 1)*(y - 1)*x - (y - z + 1)*(x + z - 1)*x;
229 out[5][0][2] = 0.5*(out[5][0][0] + out[5][0][1])
230 + 0.5*(x + z - 1)*(y - 1)*x - 0.5*(y - z + 1)*(y - 1)*x;
232 out[6][0][0] = -(y - z + 1)*(2*x + z + 1)*(y - 1);
233 out[6][0][1] = -(((x + z + 1)*(y - 1)*x - z) + z*(2*y + 1)
234 + (y - z + 1)*((x + z + 1)*x + 2*z));
235 out[6][0][2] = 0.5*(out[6][0][0] + out[6][0][1])
236 - 0.5*(-(((x + z + 1)*(y - 1)*x - z) + z*(2*y + 1))
237 + (y - z + 1)*(((y - 1)*x - 1) + 2*y + 1));
239 out[7][0][0] = -(((y - z - 1)*(x + 1)*y - z) + z*(2*x + 1)
240 + (x + z - 1)*((y - z - 1)*y + 2*z));
241 out[7][0][1] = -(x + z - 1)*(2*y - z - 1)*(x + 1);
242 out[7][0][2] = 0.5*(out[7][0][0] + out[7][0][1])
243 - 0.5*(((y - z - 1)*(x + 1)*y - z) + z*(2*x + 1)
244 + (x + z - 1)*((-(x + 1)*y - 1) + 2*x + 1));
246 out[8][0][0] = -(y - z + 1)*(2*x + z)*y;
247 out[8][0][1] = -(2*y - z + 1)*(x + z - 1)*(x + 1);
248 out[8][0][2] = 0.5*(out[8][0][0] + out[8][0][1])
249 - 0.5*(-x + y - 2*z + 2)*(x + 1)*y;
252 out[9][0][0] = 2*z*(y - z - 1);
253 out[9][0][1] = 2*z*(x + z - 1);
254 out[9][0][2] = 0.5*(out[9][0][0] + out[9][0][1])
255 + (x + z - 1)*(y - z - 1) + z*(-x + y - 2*z);
257 out[10][0][0] = -2*z*(y - z - 1);
258 out[10][0][1] = -2*z*(x + z + 1);
259 out[10][0][2] = 0.5*(out[10][0][0] + out[10][0][1])
260 - ((x + z + 1)*(y - z - 1) + 4*z)
261 - z*(-x + y - 2*z + 2);
263 out[11][0][0] = -2*z*(y - z + 1);
264 out[11][0][1] = -2*z*(x + z - 1);
265 out[11][0][2] = 0.5*(out[11][0][0] + out[11][0][1])
266 - (y - z + 1)*(x + z - 1) - z*(-x + y - 2*z + 2);
268 out[12][0][0] = 2*z*(y - z + 1);
269 out[12][0][1] = 2*z*(x + z + 1);
270 out[12][0][2] = 0.5*(out[12][0][0] + out[12][0][1])
271 + (y - z + 1)*(x + z + 1) + z*(-x + y - 2*z);
274 out[13][0][0] = 2*((y - z + 1)*((y - 1)*(x + 1) + z*(x - y + z + 1))
275 + (y - z + 1)*(x + z - 1)*(y - 1 + z));
276 out[13][0][1] = 2*((x + z - 1)*((y - 1)*(x + 1) + z*(x - y + z + 1))
277 + (y - z + 1)*(x + z - 1)*(x + 1 - z));
278 out[13][0][2] = 0.5*(out[13][0][0] + out[13][0][1])
279 + ((-x + y - 2*z + 2)*((y - 1)*(x + 1) + z*(x - y + z + 1))
280 + (y - z + 1)*(x + z - 1)*(x - y + 2*z + 1));
285 out[0][0][0] = 0.5*(y + z)*(y + z - 1)*(2*x - 2*z - 1);
286 out[0][0][1] = 0.5*(2*y + 2*z - 1)*(x - z - 1)*(x - z);
287 out[0][0][2] = 0.5*(out[0][0][0] + out[0][0][1])
288 + 0.25*((2*y + 2*z - 1)*(x - z - 1)*(x - z)
289 + (y + z)*(y + z - 1)*(-2*x + 2*z + 1));
291 out[1][0][0] = -0.5*(y + z)*(2*x - 2*z + 1)*(-y - z + 1);
292 out[1][0][1] = -0.5*(x - z)*(x - z + 1)*(-2*y - 2*z + 1);
293 out[1][0][2] = 0.5*(out[1][0][0] + out[1][0][1])
294 - 0.25*((x - y - 2*z)*(x - z + 1)*(-y - z + 1)
295 + (x - z)*(y + z)*(-x + y + 2*z - 2));
297 out[2][0][0] = 0.5*((y + z)*((x - z - 1)*(y + z + 1) + 4*z)
298 + (x - z)*(y + z)*(y + z + 1) + 4*z);
299 out[2][0][1] = 0.5*((x - z)*((x - z - 1)*(y + z + 1) + 4*z)
300 + (x - z)*(y + z)*(x - z - 1) - 4*z);
301 out[2][0][2] = 0.5*(out[2][0][0] + out[2][0][1])
302 + 0.25*((x - y - 2*z)*((x - z - 1)*(y + z + 1) + 4*z)
303 + (x - z)*(y + z)*(x - y - 2*z + 2) + 4*(x - y));
305 out[3][0][0] = 0.5*(y + z)*(2*x - 2*z + 1)*(y + z + 1);
306 out[3][0][1] = 0.5*(x - z)*(x - z + 1)*(2*y + 2*z + 1);
307 out[3][0][2] = 0.5*(out[3][0][0] + out[3][0][1])
308 + 0.25*((x - y - 2*z)*(x - z + 1)*(y + z + 1)
309 + (y + z)*(x - z)*(x - y - 2*z));
313 out[4][0][2] = 4*z - 1;
316 out[5][0][0] = -(y + z - 1)*(2*x - z - 1)*(y + 1);
317 out[5][0][1] = -(((x - z - 1)*(y + 1)*x - z) + z*(2*y + 1)
318 + (y + z - 1)*((x - z - 1)*x + 2*z));
319 out[5][0][2] = 0.5*(out[5][0][0] + out[5][0][1])
320 - 0.5*((((x - z - 1)*(y + 1)*x - z) + z*(2*y + 1))
321 + (y + z - 1)*((-(y + 1)*x - 1) + 2*y + 1));
323 out[6][0][0] = -(2*x - z + 1)*(y + z - 1)*(y + 1);
324 out[6][0][1] = -(x - z + 1)*(2*y + z)*x;
325 out[6][0][2] = 0.5*(out[6][0][0] + out[6][0][1])
326 - 0.5*(x - y - 2*z + 2)*(y + 1)*x;
328 out[7][0][0] = -(2*x - z)*(y + z - 1)*y;
329 out[7][0][1] = -(x - z + 1)*(2*y + z - 1)*(x - 1);
330 out[7][0][2] = 0.5*(out[7][0][0] + out[7][0][1])
331 - 0.5*(x - y - 2*z + 2)*(x - 1)*y;
333 out[8][0][0] = -(((y + z + 1)*(x - 1)*y - z) + z*(2*x + 1)
334 + (x - z + 1)*((y + z + 1)*y + 2*z));
335 out[8][0][1] = -(x - z + 1)*(2*y + z + 1)*(x - 1);
336 out[8][0][2] = 0.5*(out[8][0][0] + out[8][0][1])
337 - 0.5*(-(((y + z + 1)*(x - 1)*y - z) + z*(2*x + 1))
338 + (x - z + 1)*(((x - 1)*y - 1) + 2*x + 1));
341 out[9][0][0] = 2*z*(y + z - 1);
342 out[9][0][1] = 2*z*(x - z - 1);
343 out[9][0][2] = 0.5*(out[9][0][0] + out[9][0][1])
344 + (y + z - 1)*(x - z - 1) + z*(x - y - 2*z);
346 out[10][0][0] = -2*z*(y + z - 1);
347 out[10][0][1] = -2*z*(x - z + 1);
348 out[10][0][2] = 0.5*(out[10][0][0] + out[10][0][1])
349 - (x - z + 1)*(y + z - 1) - z*(x - y - 2*z + 2);
351 out[11][0][0] = -2*z*(y + z + 1);
352 out[11][0][1] = -2*z*(x - z - 1);
353 out[11][0][2] = 0.5*(out[11][0][0] + out[11][0][1])
354 - ((y + z + 1)*(x - z - 1) + 4*z) - z*(x - y - 2*z + 2);
356 out[12][0][0] = 2*z*(y + z + 1);
357 out[12][0][1] = 2*z*(x - z + 1);
358 out[12][0][2] = 0.5*(out[12][0][0] + out[12][0][1])
359 + (x - z + 1)*(y + z + 1) + z*(x - y - 2*z);
362 out[13][0][0] = 2*((y + z - 1)*((y + 1)*(x - 1) - z*(x - y - z - 1))
363 + (x - z + 1)*(y + z - 1)*(y + 1 - z));
364 out[13][0][1] = 2*((x - z + 1)*((y + 1)*(x - 1) - z*(x - y - z - 1))
365 + (x - z + 1)*(y + z - 1)*(x - 1 + z));
366 out[13][0][2] = 0.5*(out[13][0][0] + out[13][0][1])
367 + (x - y - 2*z + 2)*((y + 1)*(x - 1) - z*(x - y - z - 1))
368 + (x - z + 1)*(y + z - 1)*(-(x - y - 2*z - 1));
374 DUNE_THROW(NotImplemented,
"LagrangePyramidLocalBasis::evaluateJacobian for order " << k);
383 void partial(
const std::array<unsigned int,3>& order,
385 std::vector<typename Traits::RangeType>& out)
const
393 evaluateFunction(in, out);
407 auto const direction = std::distance(order.begin(), std::find(order.begin(), order.end(), 1));
420 out[0] = -1 + in[0] + in[2];
421 out[1] = -in[0] - in[2];
422 out[2] = 1 - in[0] - in[2];
423 out[3] = in[0]+in[2];
434 DUNE_THROW(RangeError,
"Component out of range.");
442 out[0] = -1 + in[1] + in[2];
443 out[1] = 1 - in[1] - in[2];
444 out[2] = -in[1] - in[2];
445 out[3] = in[1] + in[2];
463 DUNE_THROW(RangeError,
"Component out of range.");
466 }
else if (totalOrder == 2)
468 if ((order[0] == 1 && order[1] == 1) ||
469 (order[1] == 1 && order[2] == 1 && in[0] > in[1]) ||
470 (order[0] == 1 && order[2] == 1 && in[0] <=in[1]))
472 out = {1, -1, -1, 1, 0};
475 out = {0, 0, 0, 0, 0};
480 out = {0, 0, 0, 0, 0};
491 const R x = 2.0*in[0] + in[2] - 1.0;
492 const R y = 2.0*in[1] + in[2] - 1.0;
495 auto const direction = std::distance(order.begin(), std::find(order.begin(), order.end(), 1));
504 out[0] = 0.5*(y - z - 1)*(y - z)*(2*x + 2*z - 1);
505 out[1] = 2*(-0.25*((y - z)*((x + z + 1)*(-y + z + 1) - 4*z) + (x + z)*(y - z)*(-y + z + 1)) - z);
506 out[2] = 0.5*(y - z)*(y - z + 1)*(2*x + 2*z - 1);
507 out[3] = 0.5*(y - z)*(2*x + 2*z + 1)*(y - z + 1);
509 out[5] = -(y - z + 1)*(2*x + z - 1)*(y - 1);
510 out[6] = -(y - z + 1)*(2*x + z + 1)*(y - 1);
511 out[7] = -(((y - z - 1)*(x + 1)*y - z) + z*(2*x + 1) + (x + z - 1)*((y - z - 1)*y + 2*z));
512 out[8] = -(y - z + 1)*(2*x + z)*y;
513 out[9] = 2*z*(y - z - 1);
514 out[10] = -2*z*(y - z - 1);
515 out[11] = -2*z*(y - z + 1);
516 out[12] = 2*z*(y - z + 1);
517 out[13] = 2*((y - z + 1)*((y - 1)*(x + 1) + z*(x - y + z + 1)) + (y - z + 1)*(x + z - 1)*(y - 1 + z));
520 out[0] = 0.5*(x + z)*(x + z - 1)*(2*y - 2*z - 1);
521 out[1] = 2*(-0.25*((x + z)*((x + z + 1)*(-y + z + 1) - 4*z) + (x + z)*(y - z)*(-(x + z + 1))) + z);
522 out[2] = 0.5*(x + z)*(2*y - 2*z + 1)*(x + z - 1);
523 out[3] = 0.5*(2*y - 2*z + 1)*(x + z)*(x + z + 1);
525 out[5] = -(x + z - 1)*(y - 1)*x - (y - z + 1)*(x + z - 1)*x;
526 out[6] = -(((x + z + 1)*(y - 1)*x - z) + z*(2*y + 1) + (y - z + 1)*((x + z + 1)*x + 2*z));
527 out[7] = -(x + z - 1)*(2*y - z - 1)*(x + 1);
528 out[8] = -(2*y - z + 1)*(x + z - 1)*(x + 1);
529 out[9] = 2*z*(x + z - 1);
530 out[10] = -2*z*(x + z + 1);
531 out[11] = -2*z*(x + z - 1);
532 out[12] = 2*z*(x + z + 1);
533 out[13] = 2*((x + z - 1)*((y - 1)*(x + 1) + z*(x - y + z + 1)) + (y - z + 1)*(x + z - 1)*(x + 1 - z));
536 out[0] = -((y - z)*(2*x + 2*z - 1)*(z - y + 1))/2;
537 out[1] = ((y - z + 1)*(y - 2*x + z + 2*x*y - 2*x*z + 2*y*z - 2*z*z))/2;
538 out[2] = ((y - z)*(2*x + 2*z - 1)*(y - z + 1))/2;
539 out[3] = ((y - z)*(2*x + 2*z + 1)*(y - z + 1))/2;
541 out[5] = (-(y - z + 1)*(2*x + z - 1)*(y - 1) - (x + z - 1)*(y - 1)*x - (y - z + 1)*(x + z - 1)*x + (x + z - 1)*(y - 1)*x - (y - z + 1)*(y - 1)*x)/2;
542 out[6] = -((y - z + 1)*(3*y - 2*x + z + 3*x*y + x*z + y*z + x*x - 1))/2;
543 out[7] = z - z*(2*x + 1) - ((2*z - y*(z - y + 1))*(x + z - 1))/2 - ((2*x - y*(x + 1))*(x + z - 1))/2 + ((x + 1)*(x + z - 1)*(z - 2*y + 1))/2 + y*(x + 1)*(z - y + 1);
544 out[8] = -((y - z + 1)*(y + z + 3*x*y + x*z + y*z + x*x - 1))/2;
545 out[9] = -(x + 3*z - 1)*(z - y + 1);
546 out[10] = (x + z + 1)*(z - y + 1) - 2*y*z - 6*z + 2*z*z;
547 out[11] = -(x + 3*z - 1)*(y - z + 1);
548 out[12] = (x + 3*z + 1)*(y - z + 1);
549 out[13] = (y - z + 1)*(2*y - 3*x + z + 2*x*y + 6*x*z - 2*y*z + 2*x*x + 4*z*z - 3);
552 DUNE_THROW(RangeError,
"Component out of range.");
560 out[0] = -((y + z)*(2*z - 2*x + 1)*(y + z - 1))/2;
561 out[1] = ((y + z)*(2*x - 2*z + 1)*(y + z - 1))/2;
562 out[2] = -((y + z + 1)*(y - 3*z - 2*x*y - 2*x*z + 2*y*z + 2*z*z))/2;
563 out[3] = ((y + z)*(2*x - 2*z + 1)*(y + z + 1))/2;
565 out[5] = (y + 1)*(y + z - 1)*(z - 2*x + 1);
566 out[6] = -(y + 1)*(2*x - z + 1)*(y + z - 1);
567 out[7] = -y*(2*x - z)*(y + z - 1);
568 out[8] = z - z*(2*x + 1) - (2*z + y*(y + z + 1))*(x - z + 1) - y*(x - 1)*(y + z + 1);
569 out[9] = 2*z*(y + z - 1);
570 out[10] = -2*z*(y + z - 1);
571 out[11] = -2*z*(y + z + 1);
572 out[12] = 2*z*(y + z + 1);
573 out[13] = 2*(y + z - 1)*(2*x - z + 2*x*y - 2*x*z + 2*z*z);
576 out[0] = -(x - z)*(y + z - 0.5)*(z - x + 1);
577 out[1] = ((x - z)*(2*y + 2*z - 1)*(x - z + 1))/2;
578 out[2] = -((z - x + 1)*(x + 3*z + 2*x*y + 2*x*z - 2*y*z - 2*z*z))/2;
579 out[3] = ((x - z)*(2*y + 2*z + 1)*(x - z + 1))/2;
581 out[5] = z - z*(2*y + 1) - (2*z - x*(z - x + 1))*(y + z - 1) + x*(y + 1)*(z - x + 1);
582 out[6] = -x*(2*y + z)*(x - z + 1);
583 out[7] = -(x - 1)*(x - z + 1)*(2*y + z - 1);
584 out[8] = -(x - 1)*(x - z + 1)*(2*y + z + 1);
585 out[9] = -2*z*(z - x + 1);
586 out[10] = -2*z*(x - z + 1);
587 out[11] = 2*z*(z - x + 1);
588 out[12] = 2*z*(x - z + 1);
589 out[13] = 2*(x - z + 1)*(2*x*y - z - 2*y + 2*y*z + 2*z*z);
592 out[0] = -((x - z)*(2*y + 2*z - 1)*(z - x + 1))/2;
593 out[1] = ((x - z)*(2*y + 2*z - 1)*(x - z + 1))/2;
594 out[2] = ((x - z + 1)*(x - 2*y + z + 2*x*y + 2*x*z - 2*y*z - 2*z*z))/2;
595 out[3] = ((x - z)*(2*y + 2*z + 1)*(x - z + 1))/2;
597 out[5] = z - z*(2*y + 1) - ((2*z - x*(z - x + 1))*(y + z - 1))/2 - ((2*y - x*(y + 1))*(y + z - 1))/2 + ((y + 1)*(y + z - 1)*(z - 2*x + 1))/2 + x*(y + 1)*(z - x + 1);
598 out[6] = -((x - z + 1)*(x + z + 3*x*y + x*z + y*z + y*y - 1))/2;
599 out[7] = -((x - z + 1)*(3*x*y - 4*y - z - x + x*z + y*z + y*y + 1))/2;
600 out[8] = -((x - z + 1)*(3*x - 2*y + z + 3*x*y + x*z + y*z + y*y - 1))/2;
601 out[9] = -(z - x + 1)*(y + 3*z - 1);
602 out[10] = -(x - z + 1)*(y + 3*z - 1);
603 out[11] = (y + z + 1)*(z - x + 1) - 2*x*z - 6*z + 2*z*z;
604 out[12] = (x - z + 1)*(y + 3*z + 1);
605 out[13] = (x - z + 1)*(2*x - 3*y + z + 2*x*y - 2*x*z + 6*y*z + 2*y*y + 4*z*z - 3);
608 DUNE_THROW(RangeError,
"Component out of range.");
612 DUNE_THROW(NotImplemented,
"Desired derivative order is not implemented");
618 DUNE_THROW(NotImplemented,
"LagrangePyramidLocalBasis::partial for order " << k);
622 static constexpr unsigned int order ()
632 template<
unsigned int k>
633 class LagrangePyramidLocalCoefficients
637 LagrangePyramidLocalCoefficients ()
642 localKeys_[0] = LocalKey(0,0,0);
648 for (std::size_t i=0; i<size(); i++)
649 localKeys_[i] = LocalKey(i,3,0);
656 localKeys_[0] = LocalKey(0,3,0);
657 localKeys_[1] = LocalKey(1,3,0);
658 localKeys_[2] = LocalKey(2,3,0);
659 localKeys_[3] = LocalKey(3,3,0);
660 localKeys_[4] = LocalKey(4,3,0);
663 localKeys_[5] = LocalKey(0,2,0);
664 localKeys_[6] = LocalKey(1,2,0);
665 localKeys_[7] = LocalKey(2,2,0);
666 localKeys_[8] = LocalKey(3,2,0);
667 localKeys_[9] = LocalKey(4,2,0);
668 localKeys_[10] = LocalKey(5,2,0);
669 localKeys_[11] = LocalKey(6,2,0);
670 localKeys_[12] = LocalKey(7,2,0);
673 localKeys_[13] = LocalKey(0,1,0);
679 DUNE_THROW(NotImplemented,
"LagrangePyramidLocalCoefficients for order " << k);
684 static constexpr std::size_t size ()
686 std::size_t result = 0;
687 for (
unsigned int i=0; i<=k; i++)
688 result +=
power(i+1,2);
693 const LocalKey& localKey (std::size_t i)
const
695 return localKeys_[i];
699 std::vector<LocalKey> localKeys_;
706 template<
class LocalBasis>
707 class LagrangePyramidLocalInterpolation
718 template<
typename F,
typename C>
719 void interpolate (
const F& ff, std::vector<C>& out)
const
721 constexpr auto k = LocalBasis::order();
722 using D =
typename LocalBasis::Traits::DomainType;
723 using DF =
typename LocalBasis::Traits::DomainFieldType;
725 auto&& f = Impl::makeFunctionWithCallOperator<D>(ff);
727 out.resize(LocalBasis::size());
740 for (
unsigned int i=0; i<LocalBasis::size(); i++)
751 out[0] = f( D( {0.0, 0.0, 0.0} ) );
752 out[1] = f( D( {1.0, 0.0, 0.0} ) );
753 out[2] = f( D( {0.0, 1.0, 0.0} ) );
754 out[3] = f( D( {1.0, 1.0, 0.0} ) );
755 out[4] = f( D( {0.0, 0.0, 1.0} ) );
756 out[5] = f( D( {0.0, 0.5, 0.0} ) );
757 out[6] = f( D( {1.0, 0.5, 0.0} ) );
758 out[7] = f( D( {0.5, 0.0, 0.0} ) );
759 out[8] = f( D( {0.5, 1.0, 0.0} ) );
760 out[9] = f( D( {0.0, 0.0, 0.5} ) );
761 out[10] = f( D( {0.5, 0.0, 0.5} ) );
762 out[11] = f( D( {0.0, 0.5, 0.5} ) );
763 out[12] = f( D( {0.5, 0.5, 0.5} ) );
764 out[13] = f( D( {0.5, 0.5, 0.0} ) );
769 DUNE_THROW(NotImplemented,
"LagrangePyramidLocalInterpolation not implemented for order " << k);
808 template<
class D,
class R,
int k>
815 Impl::LagrangePyramidLocalCoefficients<k>,
816 Impl::LagrangePyramidLocalInterpolation<Impl::LagrangePyramidLocalBasis<D,R,k> > >;
836 return coefficients_;
843 return interpolation_;
847 static constexpr std::size_t
size ()
849 return Impl::LagrangePyramidLocalBasis<D,R,k>::size();
860 Impl::LagrangePyramidLocalBasis<D,R,k> basis_;
861 Impl::LagrangePyramidLocalCoefficients<k> coefficients_;
862 Impl::LagrangePyramidLocalInterpolation<Impl::LagrangePyramidLocalBasis<D,R,k> > interpolation_;
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:279
Lagrange finite element for 3d pyramids with compile-time polynomial order.
Definition: lagrangepyramid.hh:810
const Traits::LocalCoefficientsType & localCoefficients() const
Returns the assignment of the degrees of freedom to the element subentities.
Definition: lagrangepyramid.hh:834
static constexpr std::size_t size()
The number of shape functions.
Definition: lagrangepyramid.hh:847
LagrangePyramidLocalFiniteElement()
Default constructor.
Definition: lagrangepyramid.hh:823
static constexpr GeometryType type()
The reference element that the local finite element is defined on.
Definition: lagrangepyramid.hh:854
const Traits::LocalBasisType & localBasis() const
Returns the local basis, i.e., the set of shape functions.
Definition: lagrangepyramid.hh:827
const Traits::LocalInterpolationType & localInterpolation() const
Returns object that evaluates degrees of freedom.
Definition: lagrangepyramid.hh:841
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
constexpr GeometryType pyramid
GeometryType representing a 3D pyramid.
Definition: type.hh:827
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:797
T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:290
Some useful basic math stuff.
Dune namespace.
Definition: alignedallocator.hh:14
constexpr Mantissa power(Mantissa m, Exponent p)
Power method for integer exponents.
Definition: math.hh:73
static const ReferenceElement & general(const GeometryType &type)
get general reference elements
Definition: referenceelements.hh:196
D DomainType
domain type
Definition: localbasis.hh:43
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