Dune Core Modules (2.6.0)

raviartthomas02dlocalinterpolation.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_RT02DLOCALINTERPOLATION_HH
4#define DUNE_RT02DLOCALINTERPOLATION_HH
5
6#include <cmath>
7#include <array>
8#include <bitset>
9#include <vector>
10
11namespace Dune
12{
13 template<class LB>
14 class RT02DLocalInterpolation
15 {
16 public:
17
19 RT02DLocalInterpolation (std::bitset<3> s = 0)
20 {
21 for (std::size_t i=0; i<sign_.size(); i++)
22 sign_[i] = (s[i]) ? -1.0 : 1.0;
23
24 m_[0] = {0.5, 0.0};
25 m_[1] = {0.0, 0.5};
26 m_[2] = {0.5, 0.5};
27 n_[0] = {0.0, -1.0};
28 n_[1] = {-1.0, 0.0};
29 n_[2] = {1.0/sqrt(2.0), 1.0/sqrt(2.0)};
30 c_[0] = ( 0.5*n_[0][0] - 1.0*n_[0][1]);
31 c_[1] = (-1.0*n_[1][0] + 0.5*n_[1][1]);
32 c_[2] = ( 0.5*n_[2][0] + 0.5*n_[2][1]);
33 }
34
35 template<typename F, typename C>
36 void interpolate (const F& f, std::vector<C>& out) const
37 {
38 // f gives v*outer normal at a point on the edge!
39 typename F::Traits::RangeType y;
40
41 out.resize(3);
42
43 for (int i=0; i<3; i++)
44 {
45 f.evaluate(m_[i],y);
46 out[i] = (y[0]*n_[i][0]+y[1]*n_[i][1])*sign_[i]/c_[i];
47 }
48 }
49
50 private:
51 // Edge orientations
52 std::array<typename LB::Traits::RangeFieldType,3> sign_;
53 // Edge midpoints of the reference triangle
54 std::array<typename LB::Traits::DomainType,3> m_;
55 // Unit outer normals of the reference triangle
56 std::array<typename LB::Traits::DomainType,3> n_;
57 // Inverse triangle edge length
58 std::array<typename LB::Traits::RangeFieldType,3> c_;
59 };
60}
61
62#endif
Dune namespace.
Definition: alignedallocator.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)