3#ifndef DUNE_LOCALFUNCTIONS_LAGRANGE_EQUIDISTANTPOINTS_HH
4#define DUNE_LOCALFUNCTIONS_LAGRANGE_EQUIDISTANTPOINTS_HH
11#include <dune/geometry/referenceelements.hh>
14#include <dune/localfunctions/lagrange/emptypoints.hh>
15#include <dune/localfunctions/utility/field.hh>
23 inline std::size_t numLagrangePoints (
const GeometryType&
gt, std::size_t order )
25 const int dim =
gt.dim();
32 for(
unsigned int o = 0; o <= order; ++o )
33 size += numLagrangePoints( baseGeometryType, o );
37 return numLagrangePoints( baseGeometryType, order ) * (order+1);
43 [[deprecated(
"Use numLagrangePoints(const GeometryType& gt, std::size_t order ) instead.")]]
44 inline std::size_t numLagrangePoints (
unsigned int topologyId,
unsigned int dim, std::size_t order )
46 return numLagrangePoints (
GeometryType(topologyId, dim), order);
54 template<
class ct,
unsigned int cdim >
55 inline static unsigned int equidistantLagrangePoints (
const GeometryType&
gt,
unsigned int codim, std::size_t order,
unsigned int *count, LagrangePoint< ct, cdim > *points )
57 const unsigned int dim =
gt.dim();
58 assert( (0 <= codim) && (codim <= dim) && (dim <= cdim) );
63 const unsigned int numBaseN = (codim < dim ? Geo::Impl::size( baseGeometryType.id(), baseGeometryType.dim(), codim ) : 0);
64 const unsigned int numBaseM = (codim > 0 ? Geo::Impl::size( baseGeometryType.id(), baseGeometryType.dim(), codim-1 ) : 0);
66 if(
gt.isPrismatic() )
68 unsigned int size = 0;
71 for(
unsigned int i = 1; i < order; ++i )
73 const unsigned int n = equidistantLagrangePoints( baseGeometryType, codim, order, count, points );
74 for(
unsigned int j = 0; j < n; ++j )
76 LocalKey &key = points->localKey_;
77 key = LocalKey( key.subEntity(), codim, key.index() );
78 points->point_[ dim-1 ] = ct( i ) / ct( order );
87 const unsigned int n = equidistantLagrangePoints( baseGeometryType, codim-1, order, count+numBaseN, points );
88 for(
unsigned int j = 0; j < n; ++j )
90 LocalKey &key = points[ j ].localKey_;
91 key = LocalKey( key.subEntity() + numBaseN, codim, key.index() );
93 points[ j + n ].point_ = points[ j ].point_;
94 points[ j + n ].point_[ dim-1 ] = ct( 1 );
95 points[ j + n ].localKey_ = LocalKey( key.subEntity() + numBaseM, codim, key.index() );
96 ++count[ key.subEntity() + numBaseM ];
105 unsigned int size = (codim > 0 ? equidistantLagrangePoints( baseGeometryType, codim-1, order, count, points ) : 0);
106 LagrangePoint< ct, cdim > *
const end = points + size;
107 for( ; points != end; ++points )
108 points->localKey_ = LocalKey( points->localKey_.subEntity(), codim, points->localKey_.index() );
112 for(
unsigned int i = order-1; i > 0; --i )
114 const unsigned int n = equidistantLagrangePoints( baseGeometryType, codim, i, count+numBaseM, points );
115 LagrangePoint< ct, cdim > *
const end = points + n;
116 for( ; points != end; ++points )
118 points->localKey_ = LocalKey( points->localKey_.subEntity()+numBaseM, codim, points->localKey_.index() );
119 for(
unsigned int j = 0; j < dim-1; ++j )
120 points->point_[ j ] *= ct( i ) / ct( order );
121 points->point_[ dim-1 ] = ct( order - i ) / ct( order );
128 points->localKey_ = LocalKey( numBaseM, dim, count[ numBaseM ]++ );
130 points->point_[ dim-1 ] = ct( 1 );
139 points->localKey_ = LocalKey( 0, 0, count[ 0 ]++ );
145 template<
class ct,
unsigned int cdim >
146 [[deprecated(
"Use equidistantLagrangePoints ( GeometryType gt, ... ) instead.")]]
147 inline static unsigned int equidistantLagrangePoints (
unsigned int topologyId,
unsigned int dim,
unsigned int codim, std::size_t order,
unsigned int *count, LagrangePoint< ct, cdim > *points )
149 return equidistantLagrangePoints (
GeometryType(topologyId, dim), codim, order, *count, *points );
157 template<
class F,
unsigned int dim >
158 class EquidistantPointSet
159 :
public EmptyPointSet< F, dim >
161 typedef EmptyPointSet< F, dim > Base;
164 static const unsigned int dimension = dim;
168 EquidistantPointSet ( std::size_t order ) : Base( order ) {}
170 void build ( GeometryType
gt )
172 assert(
gt.dim() == dimension );
173 points_.resize( numLagrangePoints(
gt, order() ) );
175 typename Base::LagrangePoint *p = points_.data();
176 std::vector< unsigned int > count;
177 for(
unsigned int mydim = 0; mydim <= dimension; ++mydim )
179 count.resize( Geo::Impl::size(
gt.id(), dimension, dimension-mydim ) );
180 std::fill( count.begin(), count.end(), 0u );
181 p += equidistantLagrangePoints(
gt, dimension-mydim, order(), count.data(), p );
183 const auto &refElement = referenceElement<F,dimension>(
gt);
184 F weight = refElement.volume()/F(
double(points_.size()));
185 for (
auto &p : points_)
189 template< GeometryType::Id geometryId >
198 return build< GeometryTypes::cube(dim) > ();
201 static bool supports ( GeometryType, std::size_t ) {
return true; }
202 template< GeometryType::Id geometryId>
203 static bool supports ( std::size_t order ) {
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:158
Dune namespace.
Definition: alignedallocator.hh:13
A unique label for each type of element that can occur in a grid.