3#ifndef DUNE_BASISEVALUATOR_HH
4#define DUNE_BASISEVALUATOR_HH
14#include <dune/localfunctions/utility/field.hh>
15#include <dune/localfunctions/utility/multiindex.hh>
16#include <dune/localfunctions/utility/tensor.hh>
28 struct MonomialEvaluator
31 typedef typename Basis::Field Field;
32 typedef typename Basis::DomainVector DomainVector;
33 static const int dimension = Basis::dimension;
34 static const int dimRange = Basis::dimRange;
36 typedef std::vector<Field> Container;
38 template<
class Deriv >
41 template <
unsigned int deriv>
44 typedef BaseIterator<Derivatives<Field,dimension,dimRange,deriv,DerivativeLayoutNS::derivative> >
All;
45 typedef BaseIterator<Derivatives<Field,dimension,1,0,DerivativeLayoutNS::value> > Integrate;
48 unsigned int size()
const
54 MonomialEvaluator(
const Basis &basis,
unsigned int order,
unsigned int size)
63 const int totalSize = Derivatives<Field,dimension,dimRange,deriv,DerivativeLayoutNS::derivative>::size*size_;
64 container_.resize(totalSize);
66 MonomialEvaluator(
const MonomialEvaluator&);
68 unsigned int order_,size_;
74 template<
class Deriv >
75 struct MonomialEvaluator< B >::BaseIterator
77 typedef Deriv Derivatives;
78 typedef typename Deriv::Field Field;
79 static const unsigned int blockSize = Deriv::size;
81 static const DerivativeLayoutNS::DerivativeLayout layout = Deriv::layout;
82 static const unsigned int dimDomain = Deriv::dimDomain;
83 static const unsigned int dimRange = Deriv::dimRange;
85 typedef std::vector<Field> Container;
86 typedef typename Container::iterator CIter;
88 explicit BaseIterator ( Container &container )
89 : pos_( container.begin() ),
90 end_( container.end() )
93 const Deriv &operator*()
const
96 return reinterpret_cast<const Deriv&
>(*pos_);
99 const Deriv *operator->()
const
101 return &(operator*());
109 BaseIterator &operator++ ()
115 BaseIterator &operator+= (
unsigned int skip )
117 pos_ += skip*blockSize;
127 struct StandardEvaluator
128 :
public MonomialEvaluator< B >
131 typedef typename Basis::Field Field;
132 typedef typename Basis::DomainVector DomainVector;
133 typedef std::vector<Field> Container;
134 static const int dimension = Basis::dimension;
135 static const int dimRange = Basis::dimRange;
136 typedef MonomialEvaluator<B> Base;
138 template <
unsigned int deriv>
139 struct Iterator :
public Base::template Iterator<deriv>
142 StandardEvaluator(
const Basis &basis)
143 : Base(basis,basis.order(),basis.size())
145 template <
unsigned int deriv,
class DVector>
146 typename Iterator<deriv>::All evaluate(
const DVector &x)
148 Base::template resize<deriv>();
149 basis_.template evaluate<deriv>(x,&(container_[0]));
150 return typename Iterator<deriv>::All(container_);
152 typename Iterator<0>::Integrate integrate()
154 Base::template resize<0>();
155 basis_.integrate(&(container_[0]));
156 return typename Iterator<0>::Integrate(container_);
160 StandardEvaluator (
const Basis &basis,
unsigned int size )
161 : Base( basis, basis.order(), size )
165 StandardEvaluator(
const StandardEvaluator&);
167 using Base::container_;
vector space out of a tensor product of fields.
Definition: fvector.hh:95
Traits for type conversions and type information.
Implements a matrix constructed from a given type representing a field and compile-time given number ...
Implements a vector constructed from a given type representing a field and a compile-time given size.
PartitionSet<... > All
Type of PartitionSet for all partitions.
Definition: partitionset.hh:266
Dune namespace.
Definition: alignedallocator.hh:11
A unique label for each type of element that can occur in a grid.