5#ifndef DUNE_BASISEVALUATOR_HH
6#define DUNE_BASISEVALUATOR_HH
16#include <dune/localfunctions/utility/field.hh>
17#include <dune/localfunctions/utility/multiindex.hh>
18#include <dune/localfunctions/utility/tensor.hh>
30 struct MonomialEvaluator
33 typedef typename Basis::Field Field;
34 typedef typename Basis::DomainVector DomainVector;
35 static const int dimension = Basis::dimension;
36 static const int dimRange = Basis::dimRange;
38 typedef std::vector<Field> Container;
40 template<
class Deriv >
43 template <
unsigned int deriv>
46 typedef BaseIterator<Derivatives<Field,dimension,dimRange,deriv,DerivativeLayoutNS::derivative> >
All;
47 typedef BaseIterator<Derivatives<Field,dimension,1,0,DerivativeLayoutNS::value> > Integrate;
50 unsigned int size()
const
56 MonomialEvaluator(
const Basis &basis,
unsigned int order,
unsigned int size)
65 const int totalSize = Derivatives<Field,dimension,dimRange,deriv,DerivativeLayoutNS::derivative>::size*size_;
66 container_.resize(totalSize);
68 MonomialEvaluator(
const MonomialEvaluator&);
70 unsigned int order_,size_;
76 template<
class Deriv >
77 struct MonomialEvaluator< B >::BaseIterator
79 typedef Deriv Derivatives;
80 typedef typename Deriv::Field Field;
81 static const unsigned int blockSize = Deriv::size;
83 static const DerivativeLayoutNS::DerivativeLayout layout = Deriv::layout;
84 static const unsigned int dimDomain = Deriv::dimDomain;
85 static const unsigned int dimRange = Deriv::dimRange;
87 typedef std::vector<Field> Container;
88 typedef typename Container::iterator CIter;
90 explicit BaseIterator ( Container &container )
91 : pos_( container.begin() ),
92 end_( container.end() )
95 const Deriv &operator*()
const
98 return reinterpret_cast<const Deriv&
>(*pos_);
101 const Deriv *operator->()
const
103 return &(operator*());
111 BaseIterator &operator++ ()
117 BaseIterator &operator+= (
unsigned int skip )
119 pos_ += skip*blockSize;
129 struct StandardEvaluator
130 :
public MonomialEvaluator< B >
133 typedef typename Basis::Field Field;
134 typedef typename Basis::DomainVector DomainVector;
135 typedef std::vector<Field> Container;
136 static const int dimension = Basis::dimension;
137 static const int dimRange = Basis::dimRange;
138 typedef MonomialEvaluator<B> Base;
140 template <
unsigned int deriv>
141 struct Iterator :
public Base::template Iterator<deriv>
144 StandardEvaluator(
const Basis &basis)
145 : Base(basis,basis.order(),basis.
size())
147 template <
unsigned int deriv,
class DVector>
148 typename Iterator<deriv>::All evaluate(
const DVector &x)
150 Base::template resize<deriv>();
151 basis_.template evaluate<deriv>(x,&(container_[0]));
152 return typename Iterator<deriv>::All(container_);
154 typename Iterator<0>::Integrate integrate()
156 Base::template resize<0>();
157 basis_.integrate(&(container_[0]));
158 return typename Iterator<0>::Integrate(container_);
162 StandardEvaluator (
const Basis &basis,
unsigned int size )
163 : Base( basis, basis.order(),
size )
167 StandardEvaluator(
const StandardEvaluator&);
169 using Base::container_;
vector space out of a tensor product of fields.
Definition: fvector.hh:92
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:267
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
A unique label for each type of element that can occur in a grid.
Traits for type conversions and type information.