Debian Codegraph @

dune/localfunctions/raviartthomas/raviartthomas0pyramid/raviartthomas0pyramidlocalinterpolation.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_PYRAMID_LOCALINTERPOLATION_HH
6 #define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PYRAMID_LOCALINTERPOLATION_HH
7
8 #include <vector>
9
10 namespace Dune
11 {
12 /**
13 * \brief First order Raviart-Thomas shape functions on the reference hexahedron.
14 *
15 * \tparam LB corresponding LocalBasis giving traits
16 *
17 * \nosubgrouping
18 * \ingroup RaviartThomasImpl
19 */
20 template<class LB>
21 class RT0PyramidLocalInterpolation
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 RT0PyramidLocalInterpolation (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 // No need to flip the sign for the interior basis function
39 sign_[5] = 1.0;
40
41 Scalar r = 1/std::sqrt(2);
42
43 facetNormal_[0] = { 0.0, 0.0, -1.0};
44 facetNormal_[1] = {-1.0, 0.0, 0.0};
45 facetNormal_[2] = { r, 0.0, r};
46 facetNormal_[3] = { 0.0, -1.0, 0.0};
47 facetNormal_[4] = { 0.0, r, r};
48 facetNormal_[5] = { r, -r, 0.0};
49
50 facetArea_[0] = 1.0;
51 facetArea_[1] = 1/2.0;
52 facetArea_[2] = 1/2.0 * std::sqrt(2);
53 facetArea_[3] = 1/2.0;
54 facetArea_[4] = 1/2.0 * std::sqrt(2);
55 facetArea_[5] = 1/2.0 * std::sqrt(2);
56
57 facetCenter_[0] = { 0.5, 0.5, 0.0};
58 facetCenter_[1] = { 0.0, 1/3.0, 1/3.0};
59 facetCenter_[2] = { 2/3.0, 1/3.0, 1/3.0};
60 facetCenter_[3] = { 1/3.0, 0.0, 1/3.0};
61 facetCenter_[4] = { 1/3.0, 2/3.0, 1/3.0};
62 facetCenter_[5] = { 1/3.0, 1/3.0, 1/3.0};
63 }
64
65 /**
66 * \brief Interpolate a given function with shape functions
67 *
68 * \tparam F Function type for function which should be interpolated
69 * \tparam C Coefficient type
70 * \param f function which should be interpolated
71 * \param out return value, vector of coefficients
72 */
73 template<class F, class C>
74 void interpolate (const F& f, std::vector<C>& out) const
75 {
76 out.resize(6);
77 for(int i=0; i<6; i++)
78 out[i] = f(facetCenter_[i]).dot(facetNormal_[i]) * facetArea_[i] * sign_[i];
79 }
80
81 private:
82 // Facet orientations
83 std::array<typename LB::Traits::RangeFieldType, 6> sign_;
84 // Facet area
85 std::array<typename LB::Traits::RangeFieldType, 6> facetArea_;
86
87 // Facet normals
88 std::array<typename LB::Traits::DomainType, 6> facetNormal_;
89 // Facet midpoints
90 std::array<typename LB::Traits::DomainType, 6> facetCenter_;
91 };
92 }
93 #endif // DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS0_PYRAMID_LOCALINTERPOLATION_HH