dune-localfunctions
2.11
Toggle main menu visibility
Loading...
Searching...
No Matches
dune
localfunctions
monomial
monomiallocalinterpolation.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_MONOMIAL_MONOMIALLOCALINTERPOLATION_HH
6
#define DUNE_LOCALFUNCTIONS_MONOMIAL_MONOMIALLOCALINTERPOLATION_HH
7
8
#include <vector>
9
10
#include <dune/common/fvector.hh>
11
#include <dune/common/fmatrix.hh>
12
13
#include <dune/geometry/type.hh>
14
#include <dune/geometry/quadraturerules.hh>
15
16
namespace
Dune
17
{
18
22
template
<
class
LB,
unsigned
int
size>
23
class
MonomialLocalInterpolation
24
{
25
typedef
typename
LB::Traits::DomainType D;
26
typedef
typename
LB::Traits::DomainFieldType DF;
27
static
const
int
dimD=LB::Traits::dimDomain;
28
typedef
typename
LB::Traits::RangeType R;
29
typedef
typename
LB::Traits::RangeFieldType RF;
30
31
typedef
QuadratureRule<DF,dimD> QR;
32
typedef
typename
QR::iterator QRiterator;
33
34
public
:
35
MonomialLocalInterpolation
(
const
GeometryType >_,
36
const
LB &lb_)
37
: gt(gt_), lb(lb_), Minv(0)
38
, qr(QuadratureRules<DF,dimD>::rule(gt, 2*lb.order()))
39
{
40
// Compute inverse of the mass matrix of the local basis, and store it in Minv
41
if
(size != lb.size())
42
DUNE_THROW(Exception,
"size template parameter does not match size of "
43
"local basis"
);
44
45
const
QRiterator qrend = qr.end();
46
for
(QRiterator qrit = qr.begin(); qrit != qrend; ++qrit) {
47
std::vector<R> base;
48
lb.evaluateFunction(qrit->position(),base);
49
50
for(unsigned int i = 0; i < size; ++i)
51
for(unsigned int j = 0; j < size; ++j)
52
Minv[i][j] += qrit->weight() * base[i] * base[j];
53
}
54
Minv.invert();
55
}
56
64
template
<
typename
F,
typename
C>
65
void
interpolate
(
const
F& f, std::vector<C>& out)
const
66
{
67
out.clear();
68
out.resize(size, 0);
69
70
const
QRiterator qrend = qr.end();
71
for
(QRiterator qrit = qr.begin(); qrit != qrend; ++qrit) {
72
//TODO: mass matrix
73
R y = f(qrit->position());
74
75
std::vector<R> base;
76
lb.evaluateFunction(qrit->position(),base);
77
78
for
(
unsigned
int
i = 0; i < size; ++i)
79
for
(
unsigned
int
j = 0; j < size; ++j)
80
out[i] += Minv[i][j] * qrit->weight() * y * base[j];
81
}
82
}
83
84
private
:
85
GeometryType gt;
86
const
LB &lb;
87
FieldMatrix<RF, size, size> Minv;
88
const
QR &qr;
89
};
90
91
}
92
93
#endif
//DUNE_LOCALFUNCTIONS_MONOMIAL_MONOMIALLOCALINTERPOLATION_HH
Dune
Definition
bdfmcube.hh:18
Dune::MonomialLocalInterpolation::interpolate
void interpolate(const F &f, std::vector< C > &out) const
Determine coefficients interpolating a given function.
Definition
monomiallocalinterpolation.hh:65
Dune::MonomialLocalInterpolation::MonomialLocalInterpolation
MonomialLocalInterpolation(const GeometryType >_, const LB &lb_)
Definition
monomiallocalinterpolation.hh:35
Generated by
1.17.0