5#ifndef GENERIC_INTERPOLATIONHELPER_HH
6#define GENERIC_INTERPOLATIONHELPER_HH
12#include <dune/localfunctions/utility/field.hh>
13#include <dune/localfunctions/common/localinterpolation.hh>
20 template<
class F,
unsigned int dimension >
21 struct InterpolationHelper
23 template <
class Func,
class Container,
bool type>
26 template <
class F,
unsigned int d>
27 template <
class Func,
class Vector>
28 struct InterpolationHelper<F,d>::Helper<Func,Vector,true>
31 typedef std::vector< Dune::FieldVector<F,d> > Result;
32 Helper(
const Func & func, Vector &vec)
37 const typename Vector::value_type &operator()(
unsigned int row,
unsigned int col)
42 void set(
unsigned int row,
unsigned int col,
46 assert(row<vec_.size());
50 void add(
unsigned int row,
unsigned int col,
54 assert(row<vec_.size());
55 vec_[row] += field_cast<typename Vector::value_type>(val);
57 template <
class DomainVector,
58 std::enable_if_t<models<Impl::FunctionWithCallOperator<DomainVector>, Func>(),
int> = 0>
59 const Result &evaluate(
const DomainVector &x)
const
64 template <
class DomainVector,
65 std::enable_if_t<not models<Impl::FunctionWithCallOperator<DomainVector>, Func>(),
int> = 0>
66 const Result &evaluate(
const DomainVector &x)
const
68 typename Func::DomainType xx ;
69 typename Func::RangeType ff ;
71 func_.evaluate(xx,ff);
75 unsigned int size()
const
83 template <
class F,
unsigned int d>
84 template <
class Basis,
class Matrix>
85 struct InterpolationHelper<F,d>::Helper<Basis,Matrix,false>
88 typedef std::vector< Dune::FieldVector<F,d> > Result;
89 Helper(
const Basis & basis, Matrix &matrix)
93 const F &operator()(
unsigned int row,
unsigned int col)
const
95 return matrix_(row,col);
97 F &operator()(
unsigned int row,
unsigned int col)
99 return matrix_(row,col);
102 void set(
unsigned int row,
unsigned int col,
105 assert(col<matrix_.cols());
106 assert(row<matrix_.rows());
110 void add(
unsigned int row,
unsigned int col,
113 assert(col<matrix_.cols());
114 assert(row<matrix_.rows());
115 matrix_(row,col) += val;
117 template <
class DomainVector>
118 const Result &evaluate(
const DomainVector &x)
const
120 basis_.template evaluate<0>(x,tmp_);
123 unsigned int size()
const
125 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:13
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:159