/usr/include/dune/localfunctions/monomial/monomiallocalinterpolation.hh is in libdune-localfunctions-dev 2.5.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_LOCALFUNCTIONS_MONOMIAL_MONOMIALLOCALINTERPOLATION_HH
#define DUNE_LOCALFUNCTIONS_MONOMIAL_MONOMIALLOCALINTERPOLATION_HH
#include <vector>
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <dune/geometry/type.hh>
#include <dune/geometry/quadraturerules.hh>
namespace Dune
{
template<class LB, unsigned int size>
class MonomialLocalInterpolation
{
typedef typename LB::Traits::DomainType D;
typedef typename LB::Traits::DomainFieldType DF;
static const int dimD=LB::Traits::dimDomain;
typedef typename LB::Traits::RangeType R;
typedef typename LB::Traits::RangeFieldType RF;
typedef QuadratureRule<DF,dimD> QR;
typedef typename QR::iterator QRiterator;
public:
MonomialLocalInterpolation (const GeometryType >_,
const LB &lb_)
: gt(gt_), lb(lb_), Minv(0)
, qr(QuadratureRules<DF,dimD>::rule(gt, 2*lb.order()))
{
// Compute inverse of the mass matrix of the local basis, and store it in Minv
if(size != lb.size())
DUNE_THROW(Exception, "size template parameter does not match size of "
"local basis");
const QRiterator qrend = qr.end();
for(QRiterator qrit = qr.begin(); qrit != qrend; ++qrit) {
std::vector<R> base;
lb.evaluateFunction(qrit->position(),base);
for(unsigned int i = 0; i < size; ++i)
for(unsigned int j = 0; j < size; ++j)
Minv[i][j] += qrit->weight() * base[i] * base[j];
}
Minv.invert();
}
/** \brief Determine coefficients interpolating a given function
*
* The method computes the coefficients
* for the L^2 projection with respect to the given
* GeometryType. Be careful: the implementation is
* unstable for higher polynomial degrees.
*/
template<typename F, typename C>
void interpolate (const F& f, std::vector<C>& out) const
{
out.clear();
out.resize(size, 0);
const QRiterator qrend = qr.end();
for(QRiterator qrit = qr.begin(); qrit != qrend; ++qrit) {
//TODO: mass matrix
R y;
f.evaluate(qrit->position(),y);
std::vector<R> base;
lb.evaluateFunction(qrit->position(),base);
for(unsigned int i = 0; i < size; ++i)
for(unsigned int j = 0; j < size; ++j)
out[i] += Minv[i][j] * qrit->weight() * y * base[j];
}
}
private:
GeometryType gt;
const LB &lb;
FieldMatrix<RF, size, size> Minv;
const QR &qr;
};
}
#endif //DUNE_LOCALFUNCTIONS_MONOMIAL_MONOMIALLOCALINTERPOLATION_HH
|