13#ifndef NEDELECSHAPEFUNCTIONS_HH
14#define NEDELECSHAPEFUNCTIONS_HH
18#include <dune/common/fvector.hh>
19#include <dune/geometry/referenceelements.hh>
20#include <dune/geometry/type.hh>
44 template <
class ctype,
int dimension,
class T>
48 static int const dim = dimension;
78 Dune::ReferenceElement<CoordType,dim>
const &simplex = Dune::ReferenceElements<CoordType,dim>::simplex();
79 int p0Id = simplex.subEntity(e,
dim-1,0,
dim);
80 p0_ = p0Id==0?
dim: p0Id-1;
81 int p1Id = simplex.subEntity(e,
dim-1,1,
dim);
82 p1_ = p1Id==0?
dim: p1Id-1;
85 if (p0_==
dim) dp0_ = -1;
86 else { dp0_ = 0; dp0_[p0_] = 1; }
87 if (p1_==
dim) dp1_ = -1;
88 else { dp1_ = 0; dp1_[p1_] = 1; }
91 pos_ = simplex.position(e,
dim-1);
92 edge_ = simplex.position(p1Id,
dim) - simplex.position(p0Id,
dim);
105 return bc[p0_]*dp1_ - bc[p1_]*dp0_;
120 for (
int dir=0; dir<
dim; ++dir)
122 if (p0_ == dir) dbc0 = -1.0;
123 else dbc0[p0_] = 1.0;
124 if (p1_ == dir) dbc1 = -1.0;
125 else dbc1[p1_] = 1.0;
162 virtual std::tuple<int,int,int,int>
location()
const
164 return std::make_tuple(1,
dim-1,entity_,0);
188 template <
class ctype,
int dimension,
class T>
191 static int const dim = dimension;
192 static int const noEdges = dim*(dim+1)/2;
201 auto const& simplex = Dune::ReferenceElements<ctype,dim>::simplex();
202 assert(noEdges == simplex.size(dim-1));
205 for (
int i=0; i<noEdges; ++i)
213 this->
iNodes.reserve(noEdges);
214 tangentialComponents.reserve(noEdges);
215 for (
size_t i=0; i<noEdges; ++i) {
216 this->
iNodes.push_back(sf[i].position());
217 tangentialComponents.push_back(sf[i].edge()*sf[i].evaluateFunction(sf[i].position()));
221 this->
size_ = sf.size();
225 virtual Dune::GeometryType
type()
const {
return Dune::GeometryType(Dune::GeometryType::simplex,dim); }
241 assert(A.N()==noEdges);
243 IA.setSize(noEdges,A.M());
244 for (
int i=0; i<noEdges; ++i)
245 for (
int j=0; j<A.M(); ++j)
246 IA[i][j] = sf[i].edge()*
asVector(A[i][j])/tangentialComponents[i];
251 std::vector<value_type> sf;
252 std::vector<T> tangentialComponents;
258 template <
class ctype,
int dimension,
class T>
265 typedef std::map<std::pair<Dune::GeometryType,int>,
value_type const*> Container;
276 Dune::GeometryType simplex(Dune::GeometryType::simplex,dimension);
283 for (
typename Container::iterator i=container.begin(); i!=container.end(); ++i)
289 typename Container::const_iterator i = container.find(std::make_pair(type,order));
290 assert(i!=container.end());
308 template <
class ctype,
int dimension,
class T>
315 return container(type,order);
332 template <
class ctype,
int dimension,
class T>
336 static int const dim = dimension;
356 template <
class Coefficients>
360 assert(coeff.size() == lsfs.
size());
363 virtual std::unique_ptr<ShapeFunction<ctype,dim,T,dim>>
clone()
const
378 for (
int i=0; i<coeff.size(); ++i)
392 for (
int i=0; i<coeff.size(); ++i)
394 auto lsf = lsfs[i].evaluateDerivative(xi)[0];
395 for (
int j=0; j<
dim; ++j)
396 dphi[j] += coeff[i][j] * lsf;
412 for (
int i=0; i<coeff.size(); ++i)
414 auto lsf = lsfs[i].evaluate2ndDerivative(xi)[0];
415 for (
int j=0; j<
dim; ++j)
416 ddphi[j] += coeff[i][j] * lsf;
421 virtual std::tuple<int,int,int,int>
location()
const
427 std::vector<Dune::FieldVector<T,comps>> coeff;
428 std::tuple<int,int,int,int> loc;
445 template <
class ctype,
int dimension,
class T=
double>
448 static int const dim = dimension;
462 virtual Dune::GeometryType
type()
const {
return Dune::GeometryType(Dune::GeometryType::simplex,dim); }
478 std::cerr <<
"not implemented\n";
484 std::vector<value_type> sf;
490 template <
class ctype,
int dimension,
class T>
497 typedef std::map<std::pair<Dune::GeometryType,int>,
value_type const*> Container;
508 Dune::GeometryType simplex(Dune::GeometryType::simplex,dimension);
509 for (
int order=1; order<6; ++order)
516 for (
typename Container::iterator i=container.begin(); i!=container.end(); ++i)
522 typename Container::const_iterator i = container.find(std::make_pair(type,order));
523 assert(i!=container.end());
541 template <
class ctype,
int dimension,
class T=
double>
548 return container(type,order);
A LAPACK-compatible dense matrix class with shape specified at runtime.
virtual value_type const & operator()(Dune::GeometryType type, int order) const
access a shape function via type and order
virtual ~HdivShapeFunctionSetContainer()
ShapeFunctionSet< ctype, dimension, T, dimension > value_type
HdivShapeFunctionSetContainer()
Vectorial conforming shape functions on the unit simplex.
virtual Dune::FieldMatrix< T, dim, dim > evaluateDerivative(Dune::FieldVector< CoordType, dim > const &xi) const
Evaluates the derivative of the shape function.
virtual Tensor< T, dim, dim, dim > evaluate2ndDerivative(Dune::FieldVector< CoordType, dim > const &xi) const
Evaluates the second derivative of the shape function.
virtual Dune::FieldVector< T, dim > evaluateFunction(Dune::FieldVector< ctype, dim > const &xi) const
Evaluates the shape function at point xi.
HdivSimplexShapeFunction(Coefficients const &coeff_, std::tuple< int, int, int, int > loc_)
Creates a shape function as a linear combination of Lagrangian shape functions.
virtual std::unique_ptr< ShapeFunction< ctype, dim, T, dim > > clone() const
virtual std::tuple< int, int, int, int > location() const
Returns a tuple (nominalOrder,codim,entity,index) giving detailed information about the location of t...
HdivSimplexShapeFunction()=default
Default constructor. Constructs a vanishing "shape function". Not particularly useful,...
A shape function set of conforming functions.
virtual Dune::GeometryType type() const
virtual value_type const & operator[](int i) const
Random access to a shape function.
HdivSimplexShapeFunctionSet(int order)
Constructs a conforming shape function set of given polynomial order.
virtual void interpolate(typename ShapeFunctionSet< ctype, dim, T, dim >::SfValueArray const &A, DynamicMatrix< Dune::FieldMatrix< T, 1, 1 > > &IA) const
Left-multiplies the provided matrix with the interpolation matrix of the shape function set.
HdivSimplexShapeFunction< ctype, dim, T > value_type
ShapeFunctionSet< ctype, dimension, T, dimension > value_type
NedelecShapeFunctionSetContainer()
virtual ~NedelecShapeFunctionSetContainer()
virtual value_type const & operator()(Dune::GeometryType type, int order) const
access a shape function via type and order
Vectorial Nedelec shape functions on the unit simplex.
virtual Dune::FieldMatrix< ResultType, dim, dim > evaluateDerivative(Dune::FieldVector< CoordType, dim > const &x) const
Evaluates the derivative of the shape function.
Dune::FieldVector< CoordType, dim > position() const
Returns the element-local position of the node associated to the shape function.
NedelecSimplexShapeFunction()
virtual std::tuple< int, int, int, int > location() const
Returns a tuple (nominalOrder,codim,entity,index) giving detailed information about the location of t...
Dune::FieldVector< CoordType, dim > edge() const
Returns the edge vector of the edge associated to this shape function.
virtual Tensor< ResultType, 1, dim, dim > evaluate2ndDerivative(Dune::FieldVector< CoordType, dim > const &x) const
Evaluates the second derivative of the shape function.
NedelecSimplexShapeFunction(int e)
virtual Dune::FieldVector< T, dim > evaluateFunction(Dune::FieldVector< ctype, dim > const &x) const
Evaluates the shape function at point x.
virtual Dune::GeometryType type() const
virtual value_type const & operator[](int i) const
Random access to a shape function.
virtual void interpolate(typename ShapeFunctionSet< ctype, dim, T, dim >::SfValueArray const &A, DynamicMatrix< Dune::FieldMatrix< T, 1, 1 > > &IA) const
Left-multiplies the provided matrix with the interpolation matrix of the shape function set.
NedelecSimplexShapeFunctionSet()
NedelecSimplexShapeFunction< ctype, dim, T > value_type
Base class for sets of shape function containers.
A set of shape functions.
InterpolationNodes iNodes
virtual int size() const
Number of shape functions in the set.
int order() const
Maximal polynomial order of shape functions.
A class for representing tensors of arbitrary static rank and extents.
Dune::FieldVector< CoordType, dim+1 > barycentric(Dune::FieldVector< CoordType, dim > const &x)
Computes the barycentric coordinates of a point in the unit simplex.
Dune::FieldMatrix< T, n, m > outerProduct(Dune::FieldVector< T, n > const &x, Dune::FieldVector< T, m > const &y)
outer vector product .
Dune::FieldVector< T, n *m > asVector(Dune::FieldMatrix< T, n, m > const &x)
Converts a matrix of size n x m to a vector of size n*m by concatenating all the columns.
define Lagrange type shape functions for simplicial elements of arbitrary dimension and order
NedelecShapeFunctionSetContainer< ctype, dimension, T >::value_type const & nedelecShapeFunctionSet(Dune::GeometryType type, int order)
LagrangeShapeFunctionSetContainer< ctype, dimension, Scalar, restricted >::value_type const & lagrangeShapeFunctionSet(Dune::GeometryType type, int order)
Returns a Lagrange shape function set for given reference element type and given polynomial order....
HdivShapeFunctionSetContainer< ctype, dimension, T >::value_type const & hdivShapeFunctionSet(Dune::GeometryType type, int order)
Returns a Hdiv shape function set for given reference element type and given polynomial order....