dune-localfunctions
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
localfunctions
dualmortarbasis
dualq1
dualq1localinterpolation.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_DUAL_Q1_LOCALINTERPOLATION_HH
6
#define DUNE_DUAL_Q1_LOCALINTERPOLATION_HH
7
8
#include <array>
9
#include <vector>
10
11
#include <dune/common/fvector.hh>
12
#include <dune/common/fmatrix.hh>
13
14
namespace
Dune
15
{
16
20
template
<
int
dim,
class
LB>
21
class
DualQ1LocalInterpolation
22
{
23
public
:
24
25
void
setCoefficients
(
const
std::array<Dune::FieldVector<
typename
LB::Traits::RangeFieldType, (1<<dim)> ,(1<<dim)>&
coefficients
)
26
{
27
coefficients_ =
coefficients
;
28
}
29
30
32
template
<
typename
F,
typename
C>
33
void
interpolate
(
const
F& f, std::vector<C>& out)
const
34
{
35
typename
LB::Traits::DomainType x;
36
37
const
int
size = 1<<dim;
38
39
// compute Q1 interpolation coefficients
40
Dune::FieldVector<C,size> q1Coefficients;
41
42
for
(
int
i=0; i< (1<<dim); i++) {
43
44
// Generate coordinate of the i-th corner of the reference cube
45
// We could use the ReferenceElement for this as well, but it is
46
// still not clear how dune-localfunctions should have access to them.
47
for
(
int
j=0; j<dim; j++)
48
x[j] = (i & (1<<j)) ? 1.0 : 0.0;
49
50
q1Coefficients[i] = f(x);
51
52
}
53
54
out.resize(size);
55
56
// solve a linear system to compute the dual coefficients
57
Dune::FieldMatrix<C,size,size> mat;
58
59
for
(
int
i=0; i<size; i++)
60
for
(
int
j=0; j<size; j++)
61
mat[i][j] = coefficients_[j][i];
62
63
// now solve for the weights
64
Dune::FieldVector<C,size> sol(0);
65
66
mat.solve(sol,q1Coefficients);
67
68
// write result in out vector
69
for
(
int
i=0; i<size; i++)
70
out[i] = sol[i];
71
}
72
73
private
:
74
std::array<Dune::FieldVector<
typename
LB::Traits::RangeFieldType, (1<<dim)> ,(1<<dim)>
coefficients_
;
75
};
76
77
}
78
79
#endif
Dune
Definition
bdfmcube.hh:18
Dune::coefficients_
const EdgeS0_5FiniteElement< Geometry, RF >::Traits::Coefficients & EdgeS0_5FiniteElement< Geometry, RF >::coefficients_
Definition
edges0.5.hh:84
Dune::coefficients
const int RannacherTurek3DLocalBasis< D, R >::coefficients[6][6]
Definition
rannacherturek3dlocalbasis.hh:121
Dune::DualQ1LocalInterpolation
Definition
dualq1localinterpolation.hh:22
Dune::DualQ1LocalInterpolation::setCoefficients
void setCoefficients(const std::array< Dune::FieldVector< typename LB::Traits::RangeFieldType,(1<< dim)>,(1<< dim)> &coefficients)
Definition
dualq1localinterpolation.hh:25
Dune::DualQ1LocalInterpolation::interpolate
void interpolate(const F &f, std::vector< C > &out) const
Local interpolation of a function.
Definition
dualq1localinterpolation.hh:33
Generated by
1.17.0