3#ifndef GENERIC_INTERPOLATIONHELPER_HH
4#define GENERIC_INTERPOLATIONHELPER_HH
10#include <dune/localfunctions/utility/field.hh>
11#include <dune/localfunctions/common/localinterpolation.hh>
18 template<
class F,
unsigned int dimension >
19 struct InterpolationHelper
21 template <
class Func,
class Container,
bool type>
24 template <
class F,
unsigned int d>
25 template <
class Func,
class Vector>
26 struct InterpolationHelper<F,d>::Helper<Func,Vector,true>
29 typedef std::vector< Dune::FieldVector<F,d> > Result;
30 Helper(
const Func & func, Vector &vec)
35 const typename Vector::value_type &operator()(
unsigned int row,
unsigned int col)
40 void set(
unsigned int row,
unsigned int col,
44 assert(row<vec_.size());
48 void add(
unsigned int row,
unsigned int col,
52 assert(row<vec_.size());
53 vec_[row] += field_cast<typename Vector::value_type>(val);
55 template <
class DomainVector,
56 std::enable_if_t<models<Impl::FunctionWithCallOperator<DomainVector>, Func>(),
int> = 0>
57 const Result &evaluate(
const DomainVector &x)
const
62 template <
class DomainVector,
63 std::enable_if_t<not models<Impl::FunctionWithCallOperator<DomainVector>, Func>(),
int> = 0>
64 const Result &evaluate(
const DomainVector &x)
const
66 typename Func::DomainType xx ;
67 typename Func::RangeType ff ;
69 func_.evaluate(xx,ff);
73 unsigned int size()
const
81 template <
class F,
unsigned int d>
82 template <
class Basis,
class Matrix>
83 struct InterpolationHelper<F,d>::Helper<Basis,Matrix,false>
86 typedef std::vector< Dune::FieldVector<F,d> > Result;
87 Helper(
const Basis & basis, Matrix &matrix)
91 const F &operator()(
unsigned int row,
unsigned int col)
const
93 return matrix_(row,col);
95 F &operator()(
unsigned int row,
unsigned int col)
97 return matrix_(row,col);
100 void set(
unsigned int row,
unsigned int col,
103 assert(col<matrix_.cols());
104 assert(row<matrix_.rows());
108 void add(
unsigned int row,
unsigned int col,
111 assert(col<matrix_.cols());
112 assert(row<matrix_.rows());
113 matrix_(row,col) += val;
115 template <
class DomainVector>
116 const Result &evaluate(
const DomainVector &x)
const
118 basis_.template evaluate<0>(x,tmp_);
121 unsigned int size()
const
123 return basis_.size();
Infrastructure for concepts.
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:11
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:157