Dune Core Modules (2.9.0)

raviartthomas1cube2dlocalbasis.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 (C) 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_RAVIARTTHOMAS1_CUBE2D_LOCALBASIS_HH
6#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS1_CUBE2D_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 RT1Cube2DLocalBasis (std::bitset<4> s = 0)
40 {
41 for (size_t i=0; i<4; i++)
42 sign_[i] = (s[i]) ? -1.0 : 1.0;
43 }
44
46 unsigned int size () const
47 {
48 return 12;
49 }
50
57 inline void evaluateFunction (const typename Traits::DomainType& in,
58 std::vector<typename Traits::RangeType>& out) const
59 {
60 out.resize(12);
61
62 out[0][0] = sign_[0]*(-1.0 + 4.0*in[0]-3*in[0]*in[0]);
63 out[0][1] = 0.0;
64 out[1][0] = 3.0 - 12.0*in[0] - 6.0*in[1] + 24.0*in[0]*in[1]+9*in[0]*in[0] - 18.0*in[0]*in[0]*in[1];
65 out[1][1] = 0.0;
66 out[2][0] = sign_[1]*(-2.0*in[0] + 3.0*in[0]*in[0]);
67 out[2][1] = 0.0;
68 out[3][0] = -6.0*in[0] + 12.0*in[0]*in[1] + 9.0*in[0]*in[0] - 18.0*in[0]*in[0]*in[1];
69 out[3][1] = 0.0;
70 out[4][0] = 0.0;
71 out[4][1] = sign_[2]*(-1.0 + 4.0*in[1] - 3.0*in[1]*in[1]);
72 out[5][0] = 0.0;
73 out[5][1] = -3.0 + 6.0*in[0] + 12.0*in[1] - 24.0*in[0]*in[1] - 9.0*in[1]*in[1] + 18.0*in[0]*in[1]*in[1];
74 out[6][0] = 0.0;
75 out[6][1] = sign_[3]*(-2.0*in[1] + 3.0*in[1]*in[1]);
76 out[7][0] = 0.0;
77 out[7][1] = 6.0*in[1] - 12.0*in[0]*in[1] - 9.0*in[1]*in[1] + 18.0*in[0]*in[1]*in[1];
78 out[8][0] = 24.0*in[0] - 36.0*in[0]*in[1] - 24.0*in[0]*in[0] + 36.0*in[0]*in[0]*in[1];
79 out[8][1] = 0.0;
80 out[9][0] = 0.0;
81 out[9][1] = 24.0*in[1] - 36.0*in[0]*in[1] - 24.0*in[1]*in[1] + 36.0*in[0]*in[1]*in[1];
82 out[10][0] = -36.0*in[0] + 72.0*in[0]*in[1] + 36.0*in[0]*in[0] - 72.0*in[0]*in[0]*in[1];
83 out[10][1] = 0.0;
84 out[11][0] = 0.0;
85 out[11][1] = -36.0*in[1] + 72.0*in[0]*in[1] + 36*in[1]*in[1] - 72.0*in[0]*in[1]*in[1];
86 }
87
94 inline void evaluateJacobian (const typename Traits::DomainType& in,
95 std::vector<typename Traits::JacobianType>& out) const
96 {
97 out.resize(12);
98
99 out[0][0][0] = sign_[0]*(4.0 - 6.0*in[0]);
100 out[0][0][1] = 0.0;
101 out[0][1][0] = 0.0;
102 out[0][1][1] = 0.0;
103
104 out[1][0][0] = -12.0 + 24.0*in[1] + 18.0*in[0] - 36.0*in[0]*in[1];
105 out[1][0][1] = -6 + 24.0*in[0] - 18.0*in[0]*in[0];
106 out[1][1][0] = 0.0;
107 out[1][1][1] = 0.0;
108
109 out[2][0][0] = sign_[1]*(-2.0 + 6.0*in[0]);
110 out[2][0][1] = 0.0;
111 out[2][1][0] = 0.0;
112 out[2][1][1] = 0.0;
113
114 out[3][0][0] = -6.0 + 12.0*in[1] + 18.0*in[0] - 36.0*in[0]*in[1];
115 out[3][0][1] = 12.0*in[0] - 18.0*in[0]*in[0];
116 out[3][1][0] = 0.0;
117 out[3][1][1] = 0.0;
118
119 out[4][0][0] = 0.0;
120 out[4][0][1] = 0.0;
121 out[4][1][0] = 0.0;
122 out[4][1][1] = sign_[2]*(4.0 - 6.0*in[1]);
123
124 out[5][0][0] = 0.0;
125 out[5][0][1] = 0.0;
126 out[5][1][0] = 6.0 - 24.0*in[1] + 18.0*in[1]*in[1];
127 out[5][1][1] = 12.0 - 24.0*in[0] - 18.0*in[1] + 36.0*in[0]*in[1];
128
129 out[6][0][0] = 0.0;
130 out[6][0][1] = 0.0;
131 out[6][1][0] = 0.0;
132 out[6][1][1] = sign_[3]*(-2.0 + 6.0*in[1]);
133
134 out[7][0][0] = 0.0;
135 out[7][0][1] = 0.0;
136 out[7][1][0] = -12.0*in[1] + 18.0*in[1]*in[1];
137 out[7][1][1] = 6.0 - 12.0*in[0] - 18.0*in[1] + 36.0*in[1]*in[0];
138
139 out[8][0][0] = 24.0 - 36.0*in[1] - 48.0*in[0] + 72.0*in[0]*in[1];
140 out[8][0][1] = -36.0*in[0] + 36.0*in[0]*in[0];
141 out[8][1][0] = 0.0;
142 out[8][1][1] = 0.0;
143
144 out[9][0][0] = 0.0;
145 out[9][0][1] = 0.0;
146 out[9][1][0] = -36.0*in[1] + 36.0*in[1]*in[1];
147 out[9][1][1] = 24.0 - 36.0*in[0] - 48.0*in[1] + 72.0*in[0]*in[1];
148
149 out[10][0][0] = -36.0 + 72.0*in[1] + 72.0*in[0] - 144.0*in[0]*in[1];
150 out[10][0][1] = 72.0*in[0] - 72.0*in[0]*in[0];
151 out[10][1][0] = 0.0;
152 out[10][1][1] = 0.0;
153
154 out[11][0][0] = 0.0;
155 out[11][0][1] = 0.0;
156 out[11][1][0] = 72.0*in[1] - 72.0*in[1]*in[1];
157 out[11][1][1] = -36.0 + 72.0*in[0] + 72.0*in[1] - 144.0*in[0]*in[1];
158 }
159
161 void partial (const std::array<unsigned int, 2>& order,
162 const typename Traits::DomainType& in, // position
163 std::vector<typename Traits::RangeType>& out) const // return value
164 {
165 auto totalOrder = std::accumulate(order.begin(), order.end(), 0);
166 if (totalOrder == 0) {
167 evaluateFunction(in, out);
168 } else {
169 DUNE_THROW(NotImplemented, "Desired derivative order is not implemented");
170 }
171 }
172
174 unsigned int order () const
175 {
176 return 3;
177 }
178
179 private:
180 std::array<R,4> sign_;
181 };
182}
183#endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS1_CUBE2D_LOCALBASIS_HH
A dense n x m matrix.
Definition: fmatrix.hh:117
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Default exception for dummy implementations.
Definition: exceptions.hh:263
First order Raviart-Thomas shape functions on the reference quadrilateral.
Definition: raviartthomas1cube2dlocalbasis.hh:28
void evaluateJacobian(const typename Traits::DomainType &in, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: raviartthomas1cube2dlocalbasis.hh:94
unsigned int order() const
Polynomial order of the shape functions.
Definition: raviartthomas1cube2dlocalbasis.hh:174
void evaluateFunction(const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: raviartthomas1cube2dlocalbasis.hh:57
unsigned int size() const
number of shape functions
Definition: raviartthomas1cube2dlocalbasis.hh:46
RT1Cube2DLocalBasis(std::bitset< 4 > s=0)
Make set number s, where 0 <= s < 16.
Definition: raviartthomas1cube2dlocalbasis.hh:39
void partial(const std::array< unsigned int, 2 > &order, const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate partial derivatives of all shape functions.
Definition: raviartthomas1cube2dlocalbasis.hh:161
Implements a matrix constructed from a given type representing a field and compile-time given number ...
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
constexpr T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:291
Dune namespace.
Definition: alignedallocator.hh:13
Type traits for LocalBasisVirtualInterface.
Definition: localbasis.hh:34
D DomainType
domain type
Definition: localbasis.hh:42
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)