dune-localfunctions  2.11
raviartthomas03dlocalinterpolation.hh
Go to the documentation of this file.
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_RAVIARTTHOMAS03DLOCALINTERPOLATION_HH
6 #define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS_RAVIARTTHOMAS03D_RAVIARTTHOMAS03DLOCALINTERPOLATION_HH
7 
8 #include <cmath>
9 #include <array>
10 #include <bitset>
11 #include <vector>
12 
13 namespace Dune
14 {
15  template<class LB>
17  {
18  public:
19 
25  RT03DLocalInterpolation (std::bitset<4> s = 0)
26  {
27  using std::sqrt;
28  for (std::size_t i=0; i<sign_.size(); i++)
29  sign_[i] = (s[i]) ? -1.0 : 1.0;
30 
31  m_[0] = {1/3.0, 1/3.0, 0.0};
32  m_[1] = {1/3.0, 0.0, 1/3.0};
33  m_[2] = { 0.0, 1/3.0, 1/3.0};
34  m_[3] = {1/3.0, 1/3.0, 1/3.0};
35  n_[0] = { 0.0, 0.0, -1.0};
36  n_[1] = { 0.0, -1.0, 0.0};
37  n_[2] = { -1.0, 0.0, 0.0};
38  n_[3] = {1.0/sqrt(3.0), 1.0/sqrt(3.0), 1.0/sqrt(3.0)};
39  c_[0] = 1.0/2.0;
40  c_[1] = 1.0/2.0;
41  c_[2] = 1.0/2.0;
42  c_[3] = sqrt(3.0)/2.0;
43  }
44 
45  template<typename F, typename C>
46  void interpolate (const F& f, std::vector<C>& out) const
47  {
48  // f gives v*outer normal at a point on the face!
49 
50  out.resize(4);
51 
52  for (int i=0; i<4; i++)
53  {
54  auto y = f(m_[i]);
55  out[i] = (y[0]*n_[i][0]+y[1]*n_[i][1]+y[2]*n_[i][2])*sign_[i]*c_[i];
56  }
57  }
58 
59  private:
60  // Face orientations
61  std::array<typename LB::Traits::RangeFieldType,4> sign_;
62  // Face midpoints of the reference tetrahedron
63  std::array<typename LB::Traits::DomainType,4> m_;
64  // Unit outer normals of the reference tetrahedron
65  std::array<typename LB::Traits::DomainType,4> n_;
66  // Triangle face area
67  std::array<typename LB::Traits::RangeFieldType,4> c_;
68  };
69 }
70 
71 #endif
Definition: raviartthomas03dlocalinterpolation.hh:16
RT03DLocalInterpolation(std::bitset< 4 > s=0)
Constructor with given set of face orientations.
Definition: raviartthomas03dlocalinterpolation.hh:25
void interpolate(const F &f, std::vector< C > &out) const
Definition: raviartthomas03dlocalinterpolation.hh:46
Definition: bdfmcube.hh:17