1#ifndef DUNE_LOCALFUNCTIONS_LAGRANGE_EQUIDISTANTPOINTS_HH
2#define DUNE_LOCALFUNCTIONS_LAGRANGE_EQUIDISTANTPOINTS_HH
9#include <dune/geometry/referenceelementimplementation.hh>
12#include <dune/localfunctions/lagrange/emptypoints.hh>
13#include <dune/localfunctions/utility/field.hh>
21 inline std::size_t numLagrangePoints (
unsigned int topologyId,
int dim,
unsigned int order )
23 assert( topologyId < Impl::numTopologies( dim ) );
27 const unsigned int baseId = Impl::baseTopologyId( topologyId, dim );
28 if( Impl::isPyramid( topologyId, dim ) )
31 for(
unsigned int o = 0; o <= order; ++o )
32 size += numLagrangePoints( baseId, dim-1, o );
36 return numLagrangePoints( baseId, dim-1, order ) * (order+1);
47 template<
class ct,
unsigned int cdim >
48 inline static unsigned int equidistantLagrangePoints (
unsigned int topologyId,
unsigned int dim,
unsigned int codim,
unsigned int order,
unsigned int *count, LagrangePoint< ct, cdim > *points )
50 assert( (0 <= codim) && (codim <= dim) && (dim <= cdim) );
51 assert( topologyId < Impl::numTopologies( dim ) );
55 const unsigned int baseId = Impl::baseTopologyId( topologyId, dim );
56 const unsigned int numBaseN = (codim < dim ? Geo::Impl::size( baseId, dim-1, codim ) : 0);
57 const unsigned int numBaseM = (codim > 0 ? Geo::Impl::size( baseId, dim-1, codim-1 ) : 0);
59 if( Impl::isPrism( topologyId, dim ) )
61 unsigned int size = 0;
64 for(
unsigned int i = 1; i < order; ++i )
66 const unsigned int n = equidistantLagrangePoints( baseId, dim-1, codim, order, count, points );
67 for(
unsigned int j = 0; j < n; ++j )
69 LocalKey &key = points->localKey_;
70 key = LocalKey( key.subEntity(), codim, key.index() );
71 points->point_[ dim-1 ] = ct( i ) / ct( order );
80 const unsigned int n = equidistantLagrangePoints( baseId, dim-1, codim-1, order, count+numBaseN, points );
81 for(
unsigned int j = 0; j < n; ++j )
83 LocalKey &key = points[ j ].localKey_;
84 key = LocalKey( key.subEntity() + numBaseN, codim, key.index() );
86 points[ j + n ].point_ = points[ j ].point_;
87 points[ j + n ].point_[ dim-1 ] = ct( 1 );
88 points[ j + n ].localKey_ = LocalKey( key.subEntity() + numBaseM, codim, key.index() );
89 ++count[ key.subEntity() + numBaseM ];
98 unsigned int size = (codim > 0 ? equidistantLagrangePoints( baseId, dim-1, codim-1, order, count, points ) : 0);
99 LagrangePoint< ct, cdim > *
const end = points + size;
100 for( ; points != end; ++points )
101 points->localKey_ = LocalKey( points->localKey_.subEntity(), codim, points->localKey_.index() );
105 for(
unsigned int i = order-1; i > 0; --i )
107 const unsigned int n = equidistantLagrangePoints( baseId, dim-1, codim, i, count+numBaseM, points );
108 LagrangePoint< ct, cdim > *
const end = points + n;
109 for( ; points != end; ++points )
111 points->localKey_ = LocalKey( points->localKey_.subEntity()+numBaseM, codim, points->localKey_.index() );
112 for(
unsigned int j = 0; j < dim-1; ++j )
113 points->point_[ j ] *= ct( i ) / ct( order );
114 points->point_[ dim-1 ] = ct( order - i ) / ct( order );
121 points->localKey_ = LocalKey( numBaseM, dim, count[ numBaseM ]++ );
123 points->point_[ dim-1 ] = ct( 1 );
132 points->localKey_ = LocalKey( 0, 0, count[ 0 ]++ );
143 template<
class F,
unsigned int dim >
144 class EquidistantPointSet
145 :
public EmptyPointSet< F, dim >
147 typedef EmptyPointSet< F, dim > Base;
150 static const unsigned int dimension = dim;
154 EquidistantPointSet (
unsigned int order ) : Base( order ) {}
156 void build ( GeometryType
gt )
158 assert(
gt.dim() == dimension );
159 points_.resize( numLagrangePoints(
gt.id(), dimension, order() ) );
161 typename Base::LagrangePoint *p = points_.data();
162 std::vector< unsigned int > count;
163 for(
unsigned int mydim = 0; mydim <= dimension; ++mydim )
165 count.resize( Geo::Impl::size(
gt.id(), dimension, dimension-mydim ) );
166 std::fill( count.begin(), count.end(), 0u );
167 p += equidistantLagrangePoints(
gt.id(), dimension, dimension-mydim, order(), count.data(), p );
179 static bool supports (
unsigned int order ) {
return true; }
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:178
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:147
Dune namespace.
Definition: alignedallocator.hh:10
A unique label for each type of element that can occur in a grid.