5#ifndef DUNE_DUAL_Q1_LOCALINTERPOLATION_HH
6#define DUNE_DUAL_Q1_LOCALINTERPOLATION_HH
11#include <dune/common/fvector.hh>
12#include <dune/common/fmatrix.hh>
19 template<
int dim,
class LB>
24 void setCoefficients(
const std::array<Dune::FieldVector<
typename LB::Traits::RangeFieldType, (1<<dim)> ,(1<<dim)>& coefficients)
26 coefficients_ = coefficients;
31 template<
typename F,
typename C>
34 typename LB::Traits::DomainType x;
36 auto&& f = Impl::makeFunctionWithCallOperator<decltype(x)>(ff);
38 const int size = 1<<dim;
41 Dune::FieldVector<C,size> q1Coefficients;
43 for (
int i=0; i< (1<<dim); i++) {
48 for (
int j=0; j<dim; j++)
49 x[j] = (i & (1<<j)) ? 1.0 : 0.0;
51 q1Coefficients[i] = f(x);
58 Dune::FieldMatrix<C,size,size> mat;
60 for (
int i=0; i<size; i++)
61 for (
int j=0; j<size; j++)
62 mat[i][j] = coefficients_[j][i];
65 Dune::FieldVector<C,size> sol(0);
67 mat.solve(sol,q1Coefficients);
70 for (
int i=0; i<size; i++)
75 std::array<Dune::FieldVector<
typename LB::Traits::RangeFieldType, (1<<dim)> ,(1<<dim)> coefficients_;
Definition: bdfmcube.hh:18
Definition: dualq1localinterpolation.hh:21
void setCoefficients(const std::array< Dune::FieldVector< typename LB::Traits::RangeFieldType,(1<< dim)>,(1<< dim)> &coefficients)
Definition: dualq1localinterpolation.hh:24
void interpolate(const F &ff, std::vector< C > &out) const
Local interpolation of a function.
Definition: dualq1localinterpolation.hh:32