Dune Core Modules (2.6.0)

monomiallocalinterpolation.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_LOCALFUNCTIONS_MONOMIAL_MONOMIALLOCALINTERPOLATION_HH
4#define DUNE_LOCALFUNCTIONS_MONOMIAL_MONOMIALLOCALINTERPOLATION_HH
5
6#include <vector>
7
10
11#include <dune/geometry/type.hh>
13
14namespace Dune
15{
16
17 template<class LB, unsigned int size>
18 class MonomialLocalInterpolation
19 {
20 typedef typename LB::Traits::DomainType D;
21 typedef typename LB::Traits::DomainFieldType DF;
22 static const int dimD=LB::Traits::dimDomain;
23 typedef typename LB::Traits::RangeType R;
24 typedef typename LB::Traits::RangeFieldType RF;
25
26 typedef QuadratureRule<DF,dimD> QR;
27 typedef typename QR::iterator QRiterator;
28
29 public:
30 MonomialLocalInterpolation (const GeometryType &gt_,
31 const LB &lb_)
32 : gt(gt_), lb(lb_), Minv(0)
33 , qr(QuadratureRules<DF,dimD>::rule(gt, 2*lb.order()))
34 {
35 // Compute inverse of the mass matrix of the local basis, and store it in Minv
36 if(size != lb.size())
37 DUNE_THROW(Exception, "size template parameter does not match size of "
38 "local basis");
39
40 const QRiterator qrend = qr.end();
41 for(QRiterator qrit = qr.begin(); qrit != qrend; ++qrit) {
42 std::vector<R> base;
43 lb.evaluateFunction(qrit->position(),base);
44
45 for(unsigned int i = 0; i < size; ++i)
46 for(unsigned int j = 0; j < size; ++j)
47 Minv[i][j] += qrit->weight() * base[i] * base[j];
48 }
49 Minv.invert();
50 }
51
59 template<typename F, typename C>
60 void interpolate (const F& f, std::vector<C>& out) const
61 {
62 out.clear();
63 out.resize(size, 0);
64
65 const QRiterator qrend = qr.end();
66 for(QRiterator qrit = qr.begin(); qrit != qrend; ++qrit) {
67 //TODO: mass matrix
68 R y;
69 f.evaluate(qrit->position(),y);
70
71 std::vector<R> base;
72 lb.evaluateFunction(qrit->position(),base);
73
74 for(unsigned int i = 0; i < size; ++i)
75 for(unsigned int j = 0; j < size; ++j)
76 out[i] += Minv[i][j] * qrit->weight() * y * base[j];
77 }
78 }
79
80 private:
82 const LB &lb;
83 FieldMatrix<RF, size, size> Minv;
84 const QR &qr;
85 };
86
87}
88
89#endif //DUNE_LOCALFUNCTIONS_MONOMIAL_MONOMIALLOCALINTERPOLATION_HH
std::vector< QuadraturePoint< ct, dim > >::const_iterator iterator
Definition: quadraturerules.hh:128
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:147
Dune namespace.
Definition: alignedallocator.hh:10
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 15, 22:36, 2024)