dune-localfunctions
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
localfunctions
raviartthomas
raviartthomas12d
raviartthomas12dlocalinterpolation.hh
Go to the documentation of this file.
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_RAVIARTTHOMAS12DLOCALINTERPOLATION_HH
6
#define DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS12DLOCALINTERPOLATION_HH
7
8
#include <vector>
9
10
#include <dune/geometry/quadraturerules.hh>
11
12
namespace
Dune
13
{
14
23
template
<
class
LB>
24
class
RT12DLocalInterpolation
25
{
26
27
public
:
28
34
RT12DLocalInterpolation
(std::bitset<3> s = 0)
35
{
36
using
std::sqrt;
37
for
(
size_t
i=0; i<3; i++)
38
sign_[i] = (s[i]) ? -1.0 : 1.0;
39
40
n_[0] = { 0.0, -1.0};
41
n_[1] = {-1.0, 0.0};
42
n_[2] = { 1.0/sqrt(2.0), 1.0/sqrt(2.0)};
43
44
c_ = { 0.5*n_[0][0] - 1.0*n_[0][1],
45
-1.0*n_[1][0] + 0.5*n_[1][1],
46
0.5*n_[2][0] + 0.5*n_[2][1]};
47
}
48
57
template
<
typename
F,
typename
C>
58
void
interpolate
(
const
F& f, std::vector<C>& out)
const
59
{
60
// f gives v*outer normal at a point on the edge!
61
typedef
typename
LB::Traits::RangeFieldType Scalar;
62
typedef
typename
LB::Traits::DomainFieldType Vector;
63
64
out.resize(8);
65
std::fill(out.begin(), out.end(), 0.0);
66
67
const
int
qOrder1 = 4;
68
const
auto
& rule1 = Dune::QuadratureRules<Scalar,1>::rule(Dune::GeometryTypes::simplex(1), qOrder1);
69
70
for
(
auto
&& qp : rule1)
71
{
72
Scalar qPos = qp.position();
73
typename
LB::Traits::DomainType localPos;
74
75
localPos = {qPos, 0.0};
76
auto
y = f(localPos);
77
out[0] += (y[0]*n_[0][0] + y[1]*n_[0][1])*qp.weight()*sign_[0]/c_[0];
78
out[3] += (y[0]*n_[0][0] + y[1]*n_[0][1])*(2.0*qPos - 1.0)*qp.weight()/c_[0];
79
80
localPos = {0.0, qPos};
81
y = f(localPos);
82
out[1] += (y[0]*n_[1][0] + y[1]*n_[1][1])*qp.weight()*sign_[1]/c_[1];
83
out[4] += (y[0]*n_[1][0] + y[1]*n_[1][1])*(1.0 - 2.0*qPos)*qp.weight()/c_[1];
84
85
localPos = {1.0 - qPos, qPos};
86
y = f(localPos);
87
out[2] += (y[0]*n_[2][0] + y[1]*n_[2][1])*qp.weight()*sign_[2]/c_[2];
88
out[5] += (y[0]*n_[2][0] + y[1]*n_[2][1])*(2.0*qPos - 1.0)*qp.weight()/c_[2];
89
}
90
91
const
int
qOrder2 = 8;
92
const
auto
& rule2 = Dune::QuadratureRules<Vector,2>::rule(Dune::GeometryTypes::simplex(2), qOrder2);
93
94
for
(
auto
&& qp : rule2)
95
{
96
auto
qPos = qp.position();
97
98
auto
y = f(qPos);
99
out[6] += y[0]*qp.weight();
100
out[7] += y[1]*qp.weight();
101
}
102
}
103
104
private
:
105
// Edge orientations
106
std::array<typename LB::Traits::RangeFieldType, 3> sign_;
107
108
// Edge normals
109
std::array<typename LB::Traits::DomainType, 3> n_;
110
111
std::array<typename LB::Traits::RangeFieldType, 3> c_;
112
};
113
}
114
#endif
// DUNE_LOCALFUNCTIONS_RAVIARTTHOMAS12DLOCALINTERPOLATION_HH
Dune
Definition
bdfmcube.hh:18
Dune::RT12DLocalInterpolation::interpolate
void interpolate(const F &f, std::vector< C > &out) const
Interpolate a given function with shape functions.
Definition
raviartthomas12dlocalinterpolation.hh:58
Dune::RT12DLocalInterpolation::RT12DLocalInterpolation
RT12DLocalInterpolation(std::bitset< 3 > s=0)
Make set number s, where 0 <= s < 8.
Definition
raviartthomas12dlocalinterpolation.hh:34
Generated by
1.17.0