Dune Core Modules (unstable)

raviartthomas12dlocalinterpolation.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_RAVIARTTHOMAS12DLOCALINTERPOLATION_HH
6 #define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS12DLOCALINTERPOLATION_HH
7 
8 #include <vector>
9 
11 
12 namespace Dune
13 {
14 
23  template<class LB>
25  {
26 
27  public:
28 
34  RT12DLocalInterpolation (std::bitset<3> s = 0)
35  {
36  using std::sqrt;
37  for (size_t i=0; i<3; i++)
38  sign_[i] = (s[i]) ? -1.0 : 1.0;
39 
40  n_[0] = { 0.0, -1.0};
41  n_[1] = {-1.0, 0.0};
42  n_[2] = { 1.0/sqrt(2.0), 1.0/sqrt(2.0)};
43 
44  c_ = { 0.5*n_[0][0] - 1.0*n_[0][1],
45  -1.0*n_[1][0] + 0.5*n_[1][1],
46  0.5*n_[2][0] + 0.5*n_[2][1]};
47  }
48 
57  template<typename F, typename C>
58  void interpolate (const F& f, std::vector<C>& out) const
59  {
60  // f gives v*outer normal at a point on the edge!
61  typedef typename LB::Traits::RangeFieldType Scalar;
62  typedef typename LB::Traits::DomainFieldType Vector;
63 
64  out.resize(8);
65  fill(out.begin(), out.end(), 0.0);
66 
67  const int qOrder1 = 4;
69 
70  for (auto&& qp : rule1)
71  {
72  Scalar qPos = qp.position();
73  typename LB::Traits::DomainType localPos;
74 
75  localPos = {qPos, 0.0};
76  auto y = f(localPos);
77  out[0] += (y[0]*n_[0][0] + y[1]*n_[0][1])*qp.weight()*sign_[0]/c_[0];
78  out[3] += (y[0]*n_[0][0] + y[1]*n_[0][1])*(2.0*qPos - 1.0)*qp.weight()/c_[0];
79 
80  localPos = {0.0, qPos};
81  y = f(localPos);
82  out[1] += (y[0]*n_[1][0] + y[1]*n_[1][1])*qp.weight()*sign_[1]/c_[1];
83  out[4] += (y[0]*n_[1][0] + y[1]*n_[1][1])*(1.0 - 2.0*qPos)*qp.weight()/c_[1];
84 
85  localPos = {1.0 - qPos, qPos};
86  y = f(localPos);
87  out[2] += (y[0]*n_[2][0] + y[1]*n_[2][1])*qp.weight()*sign_[2]/c_[2];
88  out[5] += (y[0]*n_[2][0] + y[1]*n_[2][1])*(2.0*qPos - 1.0)*qp.weight()/c_[2];
89  }
90 
91  const int qOrder2 = 8;
93 
94  for (auto&& qp : rule2)
95  {
96  auto qPos = qp.position();
97 
98  auto y = f(qPos);
99  out[6] += y[0]*qp.weight();
100  out[7] += y[1]*qp.weight();
101  }
102  }
103 
104  private:
105  // Edge orientations
106  std::array<typename LB::Traits::RangeFieldType, 3> sign_;
107 
108  // Edge normals
109  std::array<typename LB::Traits::DomainType, 3> n_;
110 
111  std::array<typename LB::Traits::RangeFieldType, 3> c_;
112  };
113 }
114 #endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS12DLOCALINTERPOLATION_HH
static const QuadratureRule & rule(const GeometryType &t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
select the appropriate QuadratureRule for GeometryType t and order p
Definition: quadraturerules.hh:324
First order Raviart-Thomas shape functions on the reference quadrilateral.
Definition: raviartthomas12dlocalinterpolation.hh:25
void interpolate(const F &f, std::vector< C > &out) const
Interpolate a given function with shape functions.
Definition: raviartthomas12dlocalinterpolation.hh:58
RT12DLocalInterpolation(std::bitset< 3 > s=0)
Make set number s, where 0 <= s < 8.
Definition: raviartthomas12dlocalinterpolation.hh:34
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition: type.hh:453
typename Overloads::ScalarType< std::decay_t< V > >::type Scalar
Element type of some SIMD type.
Definition: interface.hh:235
Dune namespace.
Definition: alignedallocator.hh:13
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.80.0 (May 4, 22:30, 2024)