Dune Core Modules (2.8.0)

raviartthomas03dlocalbasis.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_RAVIARTTHOMAS_RAVIARTTHOMAS03D_RAVIARTTHOMAS03DLOCALBASIS_HH
4#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS_RAVIARTTHOMAS03D_RAVIARTTHOMAS03DLOCALBASIS_HH
5
6#include <numeric>
7
9
10#include <dune/localfunctions/common/localbasis.hh>
11
12namespace Dune
13{
22 template<class D, class R>
24 {
25 public:
28
30 RT03DLocalBasis (std::bitset<4> s = 0)
31 {
32 for (int i=0; i<4; i++)
33 sign_[i] = s[i] ? -1.0 : 1.0;
34 }
35
37 unsigned int size () const
38 {
39 return 4;
40 }
41
43 inline void evaluateFunction (const typename Traits::DomainType& in,
44 std::vector<typename Traits::RangeType>& out) const
45 {
46 out.resize(4);
47 auto c = std::sqrt(2.0);
48 out[0] = {sign_[0]*c* in[0], sign_[0]*c* in[1], sign_[0]*c*(in[2]-D(1))};
49 out[1] = {sign_[1]*c* in[0], sign_[1]*c*(in[1]-D(1)), sign_[1]*c* in[2] };
50 out[2] = {sign_[2]*c*(in[0]-D(1)), sign_[2]*c* in[1], sign_[2]*c* in[2] };
51 out[3] = {sign_[3]*c* in[0], sign_[3]*c* in[1], sign_[3]*c* in[2] };
52 }
53
55 inline void
56 evaluateJacobian (const typename Traits::DomainType& in, // position
57 std::vector<typename Traits::JacobianType>& out) const // return value
58 {
59 out.resize(4);
60 for (int i=0; i<4; i++)
61 {
62 auto c = std::sqrt(2.0);
63 out[i][0] = {c*sign_[i], 0, 0};
64 out[i][1] = { 0,c*sign_[i], 0};
65 out[i][2] = { 0, 0,c*sign_[i]};
66 }
67 }
68
70 void partial (const std::array<unsigned int, 3>& order,
71 const typename Traits::DomainType& in, // position
72 std::vector<typename Traits::RangeType>& out) const // return value
73 {
74 auto totalOrder = std::accumulate(order.begin(), order.end(), 0);
75 if (totalOrder == 0) {
76 evaluateFunction(in, out);
77 } else if (totalOrder == 1) {
78 auto const direction = std::distance(order.begin(), std::find(order.begin(), order.end(), 1));
79 out.resize(size());
80
81 for (int i=0; i<size(); i++)
82 {
83 out[i][direction] = sign_[i]* std::sqrt(2.0) ;
84 out[i][(direction+1)%3] = 0;
85 out[i][(direction+2)%3] = 0;
86 }
87 } else {
88 out.resize(size());
89 for (std::size_t i = 0; i < size(); ++i)
90 for (std::size_t j = 0; j < 3; ++j)
91 out[i][j] = 0;
92 }
93
94 }
95
97 unsigned int order () const
98 {
99 return 1;
100 }
101
102 private:
103
104 // Signs of the face normals
105 std::array<R,4> sign_;
106 };
107}
108#endif
A dense n x m matrix.
Definition: fmatrix.hh:69
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Lowest order Raviart-Thomas shape functions on the reference tetrahedron.
Definition: raviartthomas03dlocalbasis.hh:24
RT03DLocalBasis(std::bitset< 4 > s=0)
Make set number s, where 0 <= s < 16.
Definition: raviartthomas03dlocalbasis.hh:30
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: raviartthomas03dlocalbasis.hh:70
unsigned int order() const
Polynomial order of the shape functions.
Definition: raviartthomas03dlocalbasis.hh:97
unsigned int size() const
number of shape functions
Definition: raviartthomas03dlocalbasis.hh:37
void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: raviartthomas03dlocalbasis.hh:56
void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: raviartthomas03dlocalbasis.hh:43
Implements a matrix constructed from a given type representing a field and compile-time given number ...
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 (Nov 13, 23:29, 2024)