3#ifndef DUNE_POLYNOMIALBASIS_HH
4#define DUNE_POLYNOMIALBASIS_HH
11#include <dune/localfunctions/common/localbasis.hh>
13#include <dune/localfunctions/utility/coeffmatrix.hh>
14#include <dune/localfunctions/utility/monomialbasis.hh>
15#include <dune/localfunctions/utility/multiindex.hh>
16#include <dune/localfunctions/utility/basisevaluator.hh>
61 template<
class Eval,
class CM,
class D=
double,
class R=
double >
65 typedef Eval Evaluator;
68 typedef CM CoefficientMatrix;
70 typedef typename CoefficientMatrix::Field StorageField;
72 static const unsigned int dimension = Evaluator::dimension;
73 static const unsigned int dimRange = Evaluator::dimRange*CoefficientMatrix::blockSize;
77 typedef typename Evaluator::Basis Basis;
78 typedef typename Evaluator::DomainVector DomainVector;
81 const CoefficientMatrix &coeffMatrix,
84 coeffMatrix_(&coeffMatrix),
86 order_(basis.order()),
93 const Basis &basis ()
const
98 const CoefficientMatrix &matrix ()
const
100 return *coeffMatrix_;
103 unsigned int order ()
const
108 unsigned int size ()
const
115 std::vector<typename Traits::RangeType>& out)
const
123 std::vector<typename Traits::JacobianType>& out)
const
130 void partial (
const std::array<unsigned int, dimension>& order,
132 std::vector<typename Traits::RangeType>& out)
const
135 if (totalOrder == 0) {
142 template<
unsigned int deriv,
class F >
143 void evaluate (
const DomainVector &x, F *values )
const
145 coeffMatrix_->mult( eval_.template evaluate<deriv>( x ), size(), values);
147 template<
unsigned int deriv,
class DVector,
class F >
148 void evaluate (
const DVector &x, F *values )
const
150 assert( DVector::dimension == dimension);
152 for(
int d = 0; d < dimension; ++d )
154 evaluate<deriv>( bx, values );
157 template <
bool dummy,
class DVector>
160 static DomainVector
apply(
const DVector &x )
162 assert( DVector::dimension == dimension);
164 for(
unsigned int d = 0; d < dimension; ++d )
169 template <
bool dummy>
170 struct Convert<dummy,DomainVector>
172 static const DomainVector &
apply(
const DomainVector &x )
177 template<
unsigned int deriv,
class DVector,
class RVector >
178 void evaluate (
const DVector &x, RVector &values )
const
180 assert(values.size()>=size());
182 coeffMatrix_->mult( eval_.template evaluate<deriv>( bx ), values );
186 void evaluate (
const DomainVector &x, std::vector<FieldVector<Fy,dimRange> > &values )
const
188 evaluate<0>(x,values);
190 template<
class DVector,
class RVector >
191 void evaluate (
const DVector &x, RVector &values )
const
193 assert( DVector::dimension == dimension);
195 for(
unsigned int d = 0; d < dimension; ++d )
197 evaluate<0>( bx, values );
200 template<
unsigned int deriv,
class Vector >
201 void evaluateSingle (
const DomainVector &x, Vector &values )
const
203 assert(values.size()>=size());
204 coeffMatrix_->template mult<deriv>( eval_.template evaluate<deriv>( x ), values );
206 template<
unsigned int deriv,
class Fy >
207 void evaluateSingle (
const DomainVector &x,
208 std::vector< FieldVector<FieldVector<Fy,LFETensor<Fy,dimension,deriv>::size>,dimRange> > &values)
const
210 evaluateSingle<deriv>(x,
reinterpret_cast<std::vector< FieldVector<Fy,LFETensor<Fy,dimension,deriv>::size*dimRange
> >&>(values));
212 template<
unsigned int deriv,
class Fy >
213 void evaluateSingle (
const DomainVector &x,
214 std::vector< FieldVector<LFETensor<Fy,dimension,deriv>,dimRange> > &values)
const
216 evaluateSingle<deriv>(x,
reinterpret_cast<std::vector< FieldVector<Fy,LFETensor<Fy,dimension,deriv>::size*dimRange
> >&>(values));
220 void jacobian (
const DomainVector &x, std::vector<FieldMatrix<Fy,dimRange,dimension> > &values )
const
222 assert(values.size()>=size());
223 evaluateSingle<1>(x,
reinterpret_cast<std::vector<FieldVector<Fy,dimRange*dimension>
>&>(values));
225 template<
class DVector,
class RVector >
226 void jacobian (
const DVector &x, RVector &values )
const
228 assert( DVector::dimension == dimension);
230 for(
unsigned int d = 0; d < dimension; ++d )
232 jacobian( bx, values );
236 void integrate ( std::vector<Fy> &values )
const
238 assert(values.size()>=size());
239 coeffMatrix_->mult( eval_.template integrate(), values );
243 PolynomialBasis(
const PolynomialBasis &other)
244 : basis_(other.basis_),
245 coeffMatrix_(other.coeffMatrix_),
247 order_(basis_.order()),
250 PolynomialBasis &operator=(
const PolynomialBasis&);
252 const CoefficientMatrix* coeffMatrix_;
253 mutable Evaluator eval_;
254 unsigned int order_,size_;
263 template<
class Eval,
class CM = SparseCoeffMatrix<
typename Eval::Field,Eval::dimRange>,
264 class D=
double,
class R=
double>
269 typedef CM CoefficientMatrix;
272 typedef Eval Evaluator;
278 typedef typename Base::Basis Basis;
281 :
Base(basis,coeffMatrix_,0)
284 template <
class Matrix>
285 void fill(
const Matrix& matrix)
287 coeffMatrix_.fill(matrix);
288 this->size_ = coeffMatrix_.size();
290 template <
class Matrix>
291 void fill(
const Matrix& matrix,
int size)
293 coeffMatrix_.fill(matrix);
294 assert(size<=coeffMatrix_.size());
301 CoefficientMatrix coeffMatrix_;
A dense n x m matrix.
Definition: fmatrix.hh:68
vector space out of a tensor product of fields.
Definition: fvector.hh:93
A generic dynamic dense matrix.
Definition: matrix.hh:555
Default exception for dummy implementations.
Definition: exceptions.hh:261
Definition: polynomialbasis.hh:267
Definition: polynomialbasis.hh:63
void evaluateFunction(const typename Traits::DomainType &x, std::vector< typename Traits::RangeType > &out) const
Evaluate all shape functions.
Definition: polynomialbasis.hh:114
void evaluateJacobian(const typename Traits::DomainType &x, std::vector< typename Traits::JacobianType > &out) const
Evaluate Jacobian of all shape functions.
Definition: polynomialbasis.hh:122
void partial(const std::array< unsigned int, dimension > &order, const typename Traits::DomainType &in, std::vector< typename Traits::RangeType > &out) const
Evaluate partial derivatives of all shape functions.
Definition: polynomialbasis.hh:130
Implements a matrix constructed from a given type representing a field and compile-time given number ...
decltype(auto) apply(F &&f, ArgTuple &&args)
Apply function with arguments given as tuple.
Definition: apply.hh:58
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
T accumulate(Range &&range, T value, F &&f)
Accumulate values.
Definition: hybridutilities.hh:331
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
Type traits for LocalBasisVirtualInterface.
Definition: localbasis.hh:32
D DomainType
domain type
Definition: localbasis.hh:43