Debian Codegraph @

dune/localfunctions/raviartthomas/raviartthomas0prism/raviartthomas0prismlocalinterpolation.hh

raw symbols SCIP
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_RAVIARTTHOMAS0_PRISM_LOCALINTERPOLATION_HH
6 #define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALINTERPOLATION_HH
7
8 #include <vector>
9
10 namespace Dune
11 {
12 /**
13 * \brief First order Raviart-Thomas shape functions on the reference prism.
14 *
15 * \tparam LB corresponding LocalBasis giving traits
16 *
17 * \ingroup RaviartThomasImpl
18 * \nosubgrouping
19 */
20 template<class LB>
21 class RT0PrismLocalInterpolation
22 {
23
24 public:
25
26 /**
27 * \brief Make set number s, where 0 <= s < 32
28 *
29 * \param s Face orientation indicator
30 */
31 RT0PrismLocalInterpolation (std::bitset<5> s = 0)
32 {
33 typedef typename LB::Traits::RangeFieldType Scalar;
34
35 for (size_t i=0; i<5; i++)
36 sign[i] = (s[i]) ? -1.0 : 1.0;
37
38 Scalar r = 1/std::sqrt(2);
39
40 n[0] = { 0.0, -1.0, 0.0};
41 n[1] = {-1.0, 0.0, 0.0};
42 n[2] = { r, r, 0.0};
43 n[3] = { 0.0, 0.0, -1.0};
44 n[4] = { 0.0, 0.0, 1.0};
45
46 c[0] = 1.0;
47 c[1] = 1.0;
48 c[2] = std::sqrt(2);
49 c[3] = 1/2.0;
50 c[4] = 1/2.0;
51
52 m[0] = { 0.5, 0.0, 0.5};
53 m[1] = { 0.0, 0.5, 0.5};
54 m[2] = { 0.5, 0.5, 0.5};
55 m[3] = { 1/3.0, 1/3.0, 0.0};
56 m[4] = { 1/3.0, 1/3.0, 1.0};
57 }
58
59 /**
60 * \brief Interpolate a given function with shape functions
61 *
62 * \tparam F Function type for function which should be interpolated
63 * \tparam C Coefficient type
64 * \param f function which should be interpolated
65 * \param out return value, vector of coefficients
66 */
67 template<class F, class C>
68 void interpolate (const F& f, std::vector<C>& out) const
69 {
70 out.resize(5);
71 for(int i=0; i<5; i++)
72 out[i] = f(m[i]).dot(n[i]) * c[i] * sign[i];
73 }
74
75 private:
76 // Facet orientations
77 std::array<typename LB::Traits::RangeFieldType, 5> sign;
78 // Facet area
79 std::array<typename LB::Traits::RangeFieldType, 5> c;
80
81 // Facet normals
82 std::array<typename LB::Traits::DomainType, 5> n;
83 // Facet midpoints
84 std::array<typename LB::Traits::DomainType, 5> m;
85 };
86 }
87 #endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PRISM_LOCALINTERPOLATION_HH