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