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);
48 template<
class ct,
unsigned int cdim >
49 inline static unsigned int equidistantLagrangePoints (
const GeometryType&
gt,
unsigned int codim, std::size_t order,
unsigned int *count, LagrangePoint< ct, cdim > *points )
51 const unsigned int dim =
gt.dim();
52 assert( (0 <= codim) && (codim <= dim) && (dim <= cdim) );
57 const unsigned int numBaseN = (codim < dim ? Geo::Impl::size( baseGeometryType.id(), baseGeometryType.dim(), codim ) : 0);
58 const unsigned int numBaseM = (codim > 0 ? Geo::Impl::size( baseGeometryType.id(), baseGeometryType.dim(), codim-1 ) : 0);
60 if(
gt.isPrismatic() )
62 unsigned int size = 0;
65 for(
unsigned int i = 1; i < order; ++i )
67 const unsigned int n = equidistantLagrangePoints( baseGeometryType, codim, order, count, points );
68 for(
unsigned int j = 0; j < n; ++j )
70 LocalKey &key = points->localKey_;
71 key = LocalKey( key.subEntity(), codim, key.index() );
72 points->point_[ dim-1 ] = ct( i ) / ct( order );
81 const unsigned int n = equidistantLagrangePoints( baseGeometryType, codim-1, order, count+numBaseN, points );
82 for(
unsigned int j = 0; j < n; ++j )
84 LocalKey &key = points[ j ].localKey_;
85 key = LocalKey( key.subEntity() + numBaseN, codim, key.index() );
87 points[ j + n ].point_ = points[ j ].point_;
88 points[ j + n ].point_[ dim-1 ] = ct( 1 );
89 points[ j + n ].localKey_ = LocalKey( key.subEntity() + numBaseM, codim, key.index() );
90 ++count[ key.subEntity() + numBaseM ];
99 unsigned int size = (codim > 0 ? equidistantLagrangePoints( baseGeometryType, codim-1, order, count, points ) : 0);
100 LagrangePoint< ct, cdim > *
const end = points +
size;
101 for( ; points != end; ++points )
102 points->localKey_ = LocalKey( points->localKey_.subEntity(), codim, points->localKey_.index() );
106 for(
unsigned int i = order-1; i > 0; --i )
108 const unsigned int n = equidistantLagrangePoints( baseGeometryType, codim, i, count+numBaseM, points );
109 LagrangePoint< ct, cdim > *
const end = points + n;
110 for( ; points != end; ++points )
112 points->localKey_ = LocalKey( points->localKey_.subEntity()+numBaseM, codim, points->localKey_.index() );
113 for(
unsigned int j = 0; j < dim-1; ++j )
114 points->point_[ j ] *= ct( i ) / ct( order );
115 points->point_[ dim-1 ] = ct( order - i ) / ct( order );
122 points->localKey_ = LocalKey( numBaseM, dim, count[ numBaseM ]++ );
124 points->point_[ dim-1 ] = ct( 1 );
133 points->localKey_ = LocalKey( 0, 0, count[ 0 ]++ );
144 template<
class F,
unsigned int dim >
145 class EquidistantPointSet
146 :
public EmptyPointSet< F, dim >
148 typedef EmptyPointSet< F, dim > Base;
151 static const unsigned int dimension = dim;
155 EquidistantPointSet ( std::size_t order ) : Base( order ) {}
157 void build ( GeometryType
gt )
159 assert(
gt.dim() == dimension );
160 points_.resize( numLagrangePoints(
gt, order() ) );
162 typename Base::LagrangePoint *p = points_.data();
163 std::vector< unsigned int > count;
164 for(
unsigned int mydim = 0; mydim <= dimension; ++mydim )
166 count.resize( Geo::Impl::size(
gt.id(), dimension, dimension-mydim ) );
167 std::fill( count.begin(), count.end(), 0u );
168 p += equidistantLagrangePoints(
gt, dimension-mydim, order(), count.data(), p );
170 const auto &refElement = referenceElement<F,dimension>(
gt);
171 F weight = refElement.volume()/F(
double(points_.size()));
172 for (
auto &p : points_)
176 template< GeometryType::Id geometryId >
185 return build< GeometryTypes::cube(dim) > ();
188 static bool supports ( GeometryType, std::size_t ) {
return true; }
189 template< GeometryType::Id geometryId>
190 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
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
A unique label for each type of element that can occur in a grid.