Dune Core Modules (unstable)

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 // Interior basis function associated to the interior
71 // face given by the intersection of the sub-elements
72 // in the plane where x[0]==x[1].
73 offset_[5][0] = {0.0, -2.0, 0.0};
74 factor_[5][0] = 2.0;
75 offset_[5][1] = {2.0, 0.0, 0.0};
76 factor_[5][1] = -2.0;
77
78 for (size_t i=0; i<5; i++)
79 sign_[i] = s[i] ? -1.0 : 1.0;
80
81 // No need to flip the sign_ for the interior basis function
82 sign_[5] = 1.0;
83 }
84
86 unsigned int size () const
87 {
88 return 6;
89 }
90
97 inline void evaluateFunction (const typename Traits::DomainType& x,
98 std::vector<typename Traits::RangeType>& out) const
99 {
100 out.resize(size());
101 bool compositeElement = x[0] > x[1];
102 for (std::size_t i=0; i<size(); i++)
103 {
104 out[i] = x;
105 out[i] *= factor_[i][compositeElement];
106 out[i] += offset_[i][compositeElement];
107 out[i] *= sign_[i];
108 }
109 }
110
117 inline void evaluateJacobian (const typename Traits::DomainType& x,
118 std::vector<typename Traits::JacobianType>& out) const
119 {
120 out.resize(size());
121 bool compositeElement = x[0] > x[1];
122 for (std::size_t i=0; i<size(); i++)
123 for(std::size_t j=0; j<3; j++)
124 for(std::size_t k=0; k<3; k++)
125 out[i][j][k] = (j==k) * factor_[i][compositeElement] * sign_[i];
126 }
127
129 void partial (const std::array<unsigned int, 3>& order,
130 const typename Traits::DomainType& in, // position
131 std::vector<typename Traits::RangeType>& out) const // return value
132 {
133 auto totalOrder = std::accumulate(order.begin(), order.end(), 0);
134 if (totalOrder == 0) {
135 evaluateFunction(in, out);
136 } else {
137 DUNE_THROW(NotImplemented, "Desired derivative order is not implemented");
138 }
139 }
140
142 unsigned int order () const
143 {
144 return 1;
145 }
146
147 private:
148 std::array<R,6> sign_;
149 std::array<std::array<typename Traits::RangeType, 2>, 6> offset_;
150 std::array<std::array<R, 2>, 6> factor_;
151 };
152}
153#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:97
Default exception for dummy implementations.
Definition: exceptions.hh:357
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:97
unsigned int order() const
Polynomial order of the shape functions.
Definition: raviartthomas0pyramidlocalbasis.hh:142
unsigned int size() const
number of shape functions
Definition: raviartthomas0pyramidlocalbasis.hh:86
void evaluateJacobian(const typename Traits::DomainType &x, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: raviartthomas0pyramidlocalbasis.hh:117
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:129
Implements a matrix constructed from a given type representing a field and compile-time given number ...
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
constexpr T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:280
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 (Aug 31, 22:39, 2025)