3#ifndef GENERIC_INTERPOLATIONHELPER_HH
4#define GENERIC_INTERPOLATIONHELPER_HH
9#include <dune/localfunctions/utility/field.hh>
16 template<
class F,
unsigned int dimension >
17 struct InterpolationHelper
19 template <
class Func,
class Container,
bool type>
22 template <
class F,
unsigned int d>
23 template <
class Func,
class Vector>
24 struct InterpolationHelper<F,d>::Helper<Func,Vector,true>
27 typedef std::vector< Dune::FieldVector<F,d> > Result;
28 Helper(
const Func & func, Vector &vec)
33 const typename Vector::value_type &operator()(
unsigned int row,
unsigned int col)
38 void set(
unsigned int row,
unsigned int col,
42 assert(row<vec_.size());
46 void add(
unsigned int row,
unsigned int col,
50 assert(row<vec_.size());
51 vec_[row] += field_cast<typename Vector::value_type>(val);
53 template <
class DomainVector>
54 const Result &evaluate(
const DomainVector &x)
const
56 typename Func::DomainType xx ;
57 typename Func::RangeType ff ;
59 func_.evaluate(xx,ff);
63 unsigned int size()
const
71 template <
class F,
unsigned int d>
72 template <
class Basis,
class Matrix>
73 struct InterpolationHelper<F,d>::Helper<Basis,Matrix,false>
76 typedef std::vector< Dune::FieldVector<F,d> > Result;
77 Helper(
const Basis & basis, Matrix &matrix)
81 const F &operator()(
unsigned int row,
unsigned int col)
const
83 return matrix_(row,col);
85 F &operator()(
unsigned int row,
unsigned int col)
87 return matrix_(row,col);
90 void set(
unsigned int row,
unsigned int col,
93 assert(col<matrix_.cols());
94 assert(row<matrix_.rows());
98 void add(
unsigned int row,
unsigned int col,
101 assert(col<matrix_.cols());
102 assert(row<matrix_.rows());
103 matrix_(row,col) += val;
105 template <
class DomainVector>
106 const Result &evaluate(
const DomainVector &x)
const
108 basis_.template evaluate<0>(x,tmp_);
111 unsigned int size()
const
113 return basis_.size();
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:10
void field_cast(const F1 &f1, F2 &f2)
a helper class to cast from one field to another
Definition: field.hh:157