13#ifndef PSHAPEFUNCTIONS_HH
14#define PSHAPEFUNCTIONS_HH
23#include <boost/multi_array.hpp>
56 template <
class ctype,
int dim,
class T=
double,
int comp=1>
77 std::cerr <<
"NOT IMPLEMENTED: " << __FILE__ <<
":" << __LINE__ <<
"\n";
94 virtual std::tuple<int,int,int,int>
location()
const = 0;
107 template <
class ctype,
int dimension,
class T,
int comp=1>
152 Dune::GeometryType
type()
const {
return gt_; }
160 return Dune::referenceElement<ctype,dimension>(gt_);
178 if (!sfl ||
size()==0) {
258 for (
int j=0; j<s; ++j) {
260 for (
int i=0; i<
iNodes.size(); ++i) {
262 for (
int k=0; k<comp; ++k)
293 Dune::GeometryType gt_;
298 template <
class ctype,
int dimension,
class T,
int comp=1>
322 template <
class ShapeFunctionSet_>
329 typedef typename ShapeFunctionSet_::Scalar
Scalar;
350 this->iNodes.clear();
356 for(
int i=this->sf.size()-1; i>-1; --i)
357 if(std::find(ids_.begin(),ids_.end(),i)==ids_.end()) this->removeShapeFunction(i);
359 this->size_ = ids_.size();
373 template <
class ctype,
int dimension,
class T,
int comp=1>
400 template <
class ShapeFunctionSet>
402 int const* vPermutation,
406 assert(vPermutation);
407 assert(sfPermutation);
428 for (
int i=0; i<in.size(); ++i) {
430 for (
int j=0; j<ShapeFunctionSet::Grid::dimension; ++j)
431 in[i][j] = b[vPermutation[j]];
447 for (
int i=0; i<sfs.
size(); ++i) {
450 for (
int j=0; j<sfs.
size(); ++j) {
451 if (std::abs(P[i][j])>1e-8 && std::abs(1-std::abs(P[i][j]))>1e-8) ok =
false;
452 rowSum += std::abs(P[i][j]);
453 colSum += std::abs(P[j][i]);
455 if (std::abs(rowSum-1)>1e-8 || std::abs(colSum-1)>1e-8) ok =
false;
458 std::cout <<
"\nPermutation matrix:\n";
459 for (
int i=0; i<P.N(); ++i) {
460 for (
int j=0; j<P.M(); ++j)
461 std::cout << std::setw(2) << P[i][j] <<
" ";
469 for (
int i=0; i<sfs.
size(); ++i)
470 for (
int j=0; j<sfs.
size(); ++j)
471 if (std::abs(P[j][i])>0.5) {
472 sfPermutation[i] = j;
473 sign[i] = P[j][i]>0? 1: -1;
A LAPACK-compatible dense matrix class with shape specified at runtime.
void setSize(size_type r, size_type c)
Resizes the matrix to r x c, leaving the entries in an undefined state.
void resize(size_type r, size_type c)
Resizes the matrix to r x c, leaving the entries in an undefined state.
EmptyShapeFunctionSet(Dune::GeometryType const >)
virtual void interpolate(typename Base::SfValueArray const &A, typename Base::Matrix &IA) const
virtual Base::value_type const & operator[](int i) const
Random access to a shape function.
Restricted shape function set. Introduces a new local ordering for the shape functions....
RestrictedShapeFunctionSet(ShapeFunctionSet_ const &other)
RestrictedShapeFunctionSet(RestrictedShapeFunctionSet const &other)
void setRestriction(std::vector< int > const &ids_)
RestrictedShapeFunctionSet(int order)
ShapeFunctionSet_::value_type value_type
type of one shape function
virtual ~RestrictedShapeFunctionSet()
ShapeFunctionSet_::Scalar Scalar
Grid type.
RestrictedShapeFunctionSet(RestrictedShapeFunctionSet const &other, std::vector< int > *ids_)
Copy constructor. Resets restriction ids.
virtual Tensor< T, comp, dim, dim > evaluate2ndDerivative(Dune::FieldVector< ctype, dim > const &xi) const
Evaluates the second derivative of the shape function (all components and all directions at once).
virtual Dune::FieldMatrix< T, comp, dim > evaluateDerivative(Dune::FieldVector< ctype, dim > const &xi) const =0
Evaluates the derivative of the shape function (all components and all directions at once).
virtual Dune::FieldVector< T, comp > evaluateFunction(Dune::FieldVector< ctype, dim > const &xi) const =0
Evaluates the shape function (all components at once).
virtual std::tuple< int, int, int, int > location() const =0
Returns a tuple (nominalOrder,codim,entity,index) giving detailed information about the location of t...
Base class for sets of shape function containers.
virtual ~ShapeFunctionSetContainer()
ShapeFunctionSet< ctype, dimension, T, comp > value_type
virtual value_type const & operator()(Dune::GeometryType type, int order) const =0
access a shape function via type and order
A set of shape functions.
virtual void removeShapeFunction(size_t index)
ShapeFunctionSet(ShapeFunctionSet const &other)=default
ShapeFunctionSet(Dune::GeometryType gt)
Constructor.
T Scalar
Scalar field type.
void evaluate(InterpolationNodes const &iNodes, SfValueArray &phi) const
Evaluate shape function set at a set of points. In notation of the LocalToGlobalMapperConcept,...
Dune::GeometryType type() const
Type of geometry on which the shape functions are defined.
DynamicMatrix< Dune::FieldMatrix< T, 1, 1 > > Matrix
A matrix type mapping one-component coefficient vectors.
static int const comps
Number of components of the shape function values.
InterpolationNodes const & interpolationNodes() const
Interpolation points.
virtual ~ShapeFunctionSet()
auto referenceElement() const
InterpolationNodes iNodes
virtual int size() const
Number of shape functions in the set.
int order() const
Maximal polynomial order of shape functions.
void initHierarchicalProjection(ShapeFunctionSet< ctype, dimension, T, comp > const *sfl)
Initialize the hierarchical projection matrix based on the given lower order shape function set.
virtual value_type const & operator[](int i) const =0
Random access to a shape function.
std::vector< Dune::FieldVector< ctype, dimension > > InterpolationNodes
A container type for holding interpolation points in the reference elements.
DynamicMatrix< Dune::FieldMatrix< T, comp, 1 > > SfValueArray
ShapeFunction< ctype, dimension, T, comp > value_type
type of one shape function
virtual void interpolate(SfValueArray const &A, Matrix &IA) const =0
Left-multiplies the provided matrix with the interpolation matrix of the shape function set.
Matrix const & hierarchicProjection() const
Returns a square matrix that projects shape function coefficients to a subspace spanned by shape func...
A class for representing tensors of arbitrary static rank and extents.
This file contains various utility functions that augment the basic functionality of Dune.
Dune::FieldVector< CoordType, dim+1 > barycentric(Dune::FieldVector< CoordType, dim > const &x)
Computes the barycentric coordinates of a point in the unit simplex.
Class for transformations between ancestors and their children.
void computeSimplexSfPermutation(ShapeFunctionSet const &sfs, int const *vPermutation, int *sfPermutation, int *sign)