Dune Core Modules (unstable)

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