DUNE PDELab (2.8)

raviartthomas03dlocalinterpolation.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_RAVIARTTHOMAS03DLOCALINTERPOLATION_HH
4#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS_RAVIARTTHOMAS03D_RAVIARTTHOMAS03DLOCALINTERPOLATION_HH
5
6#include <cmath>
7#include <array>
8#include <bitset>
9#include <vector>
10#include <dune/localfunctions/common/localinterpolation.hh>
11
12namespace Dune
13{
14 template<class LB>
15 class RT03DLocalInterpolation
16 {
17 public:
18
20 RT03DLocalInterpolation (std::bitset<4> s = 0)
21 {
22 using std::sqrt;
23 for (std::size_t i=0; i<sign_.size(); i++)
24 sign_[i] = (s[i]) ? -1.0 : 1.0;
25
26 m_[0] = {1/3.0, 1/3.0, 0.0};
27 m_[1] = {1/3.0, 0.0, 1/3.0};
28 m_[2] = { 0.0, 1/3.0, 1/3.0};
29 m_[3] = {1/3.0, 1/3.0, 1/3.0};
30 n_[0] = { 0.0, 0.0, -1.0};
31 n_[1] = { 0.0, -1.0, 0.0};
32 n_[2] = { -1.0, 0.0, 0.0};
33 n_[3] = {1.0/sqrt(3.0), 1.0/sqrt(3.0), 1.0/sqrt(3.0)};
34 c_[0] = sqrt(2.0);
35 c_[1] = sqrt(2.0);
36 c_[2] = sqrt(2.0);
37 c_[3] = sqrt(2.0)/sqrt(3.0);
38 }
39
40 template<typename F, typename C>
41 void interpolate (const F& ff, std::vector<C>& out) const
42 {
43 // f gives v*outer normal at a point on the face!
44 auto&& f = Impl::makeFunctionWithCallOperator<typename LB::Traits::DomainType>(ff);
45
46 out.resize(4);
47
48 for (int i=0; i<4; i++)
49 {
50 auto y = f(m_[i]);
51 out[i] = (y[0]*n_[i][0]+y[1]*n_[i][1]+y[2]*n_[i][2])*sign_[i]/c_[i];
52 }
53 }
54
55 private:
56 // Face orientations
57 std::array<typename LB::Traits::RangeFieldType,4> sign_;
58 // Face midpoints of the reference tetrahedron
59 std::array<typename LB::Traits::DomainType,4> m_;
60 // Unit outer normals of the reference tetrahedron
61 std::array<typename LB::Traits::DomainType,4> n_;
62 // Inverse triangle face area
63 std::array<typename LB::Traits::RangeFieldType,4> c_;
64 };
65}
66
67#endif
void interpolate(const F &f, const GFS &gfs, XG &xg)
interpolation from a given grid function
Definition: interpolate.hh:177
Dune namespace.
Definition: alignedallocator.hh:11
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)