1#ifndef DUNE_LOBATTOBASIS_HH
2#define DUNE_LOBATTOBASIS_HH
13#if HAVE_DUNE_LOCALFUNCTIONS
24 template <
class Field>
27 template <
class Po
ints1DType>
28 static int size(
const GeometryType gt,
const Points1DType &points1D)
30 if (
gt.dim()==0)
return 1;
31 else if (
gt.isPrismatic())
32 return Builder<Field>::size(Impl::getBase(gt),points1D)*points1D.size();
35 std::cout <<
"Not implemented for pyramid geometries still missing!\n";
39 template <
unsigned int dim,
class Po
ints1DType>
40 static void setup(
const GeometryType gt,
const Points1DType &points1D,
41 LagrangePoint< Field, dim > *points )
50 points->point_[0] = Zero<Field>();
53 else if (
gt.isPrismatic())
56 assert(
dim>=
gt.dim());
57 Builder<Field>::template setup<dim>(baseGt,points1D,points);
58 const unsigned int baseSize = Builder::size(baseGt,points1D);
59 for (
unsigned int i=0;i<baseSize;++i)
61 Field weight = points[i].weight_;
62 for (
unsigned int q=0;q<points1D.size();q++)
64 const unsigned int pos = q*baseSize+i;
65 for (
unsigned int d=0;d<
gt.dim()-1;++d)
66 points[pos].point_[d] = points[i].point_[d];
67 points[pos].point_[
gt.dim()-1]=points1D[q].first;
68 points[pos].weight_ = weight*points1D[q].second;
74 std::cout <<
"Not implemented for pyramid geometries still missing!\n";
81 template<
class F,
unsigned int dim >
82 struct PointSetFromQuadrature :
public EmptyPointSet<F,dim>
84 static const unsigned int dimension =
dim;
86 typedef EmptyPointSet<F,dim> Base;
87 typedef typename Base::LagrangePoint Point;
89 PointSetFromQuadrature(
unsigned int order)
90 : Base(order), quadOrder_(-1)
93 template <GeometryType::Id geometryId,
class Quad>
94 bool build (
const Quad& quadFactory)
97 unsigned int order = Base::order();
98 const auto &quad = quadFactory(order);
99 quadOrder_ = quad.order();
100 assert( quad.size() == order+1 );
101 bool withEndPoints =
false;
102 Points1DType points1D;
103 Field vertexWeight = 1;
104 for (
unsigned int i=0;i<=order;++i)
108 Field p = field_cast<Field>(quad[i].position());
112 withEndPoints =
true;
113 vertexWeight = quad[i].weight();
120 apply(gt,order,points1D,vertexWeight,points_);
122 Setup::template InitCodim<dimension>::
123 apply(gt,order,points1D,vertexWeight,points_);
126 static bool supports ( GeometryType gt,
int order )
130 template< GeometryType::Id geometryId>
134 unsigned int quadOrder()
const
140 unsigned int quadOrder_;
147 static const unsigned int codim = dimension-pdim;
148 static void apply(GeometryType gt,
const unsigned int order,
149 const Points1DType &points1D,
150 const Field &vertexWeight,
153 const unsigned int subEntities = Dune::Geo::Impl::size(
gt.id(),
gt.dim(),codim);
154 for (
unsigned int subEntity=0;subEntity<
subEntities;++subEntity)
157 unsigned int oldSize = points.
size();
158 unsigned int size = Impl::Builder<Field>::size(subGt,points1D);
159 if (
size==0)
continue;
162 Impl::Builder<Field>::template setup<dimension-codim>( subGt, points1D, &(subPoints[0]) );
164 const auto &refElement = referenceElement<Field,dimension>(gt);
165 const auto &mapping = refElement.template geometry< codim >( subEntity );
167 LagrangePoint<Field,dimension> *p = &(points[oldSize]);
168 for (
unsigned int nr = 0; nr<
size; ++nr, ++p)
170 p->point_ = mapping.global( subPoints[nr].point_ );
171 p->weight_ = subPoints[nr].weight_ *
std::pow(vertexWeight,codim)*refElement.volume();
172 p->localKey_ = LocalKey( subEntity, codim, nr );
183 template<
class F,
unsigned int dim >
188 EquidistantPointSetDerived(
unsigned int order)
195 static unsigned int quad2PolOrder(
int order) {
return order; }
196 unsigned int quadOrder()
const {
return Base::order(); }
198 static auto buildCubeQuadrature(
unsigned int quadOrder)
200 using namespace Impl;
201 EquidistantPointSetDerived ps(quad2PolOrder(quadOrder));
202 ps.template build<GeometryTypes::cube(dim)>();
211 template<
class F,
unsigned int dim >
212 struct GaussLobattoPointSet :
public PointSetFromQuadrature<F,dim>
214 static const unsigned int dimension =
dim;
216 typedef PointSetFromQuadrature<F,dim> Base;
217 typedef typename Base::LagrangePoint Point;
222 GaussLobattoPointSet(
unsigned int order)
225 template< GeometryType::Id geometryId >
229 auto quadFactory = [](
int order)
231 Dune::GeometryTypes::line, pol2QuadOrder(order),
234 return Base::template build<geometryId>(quadFactory);
236 static unsigned int pol2QuadOrder(
int order)
238 return (order>0)? 2*order-1 : 0;
240 static unsigned int quad2PolOrder(
int order)
245 static auto buildCubeQuadrature(
unsigned int quadOrder)
247 using namespace Impl;
248 GaussLobattoPointSet ps(quad2PolOrder(quadOrder));
249 ps.template build<GeometryTypes::cube(dim)>();
255 template<
class F,
unsigned int dim >
256 struct GaussLegendrePointSet :
public PointSetFromQuadrature<F,dim>
258 static const unsigned int dimension =
dim;
260 typedef PointSetFromQuadrature<F,dim> Base;
261 typedef typename Base::LagrangePoint Point;
266 GaussLegendrePointSet(
unsigned int order)
269 template< GeometryType::Id geometryId >
273 auto quadFactory = [](
int order)
277 return Base::template build<GeometryType(geometryId)>(quadFactory);
280 static unsigned int pol2QuadOrder(
int order)
284 static unsigned int quad2PolOrder(
int order)
289 static auto buildCubeQuadrature(
unsigned int quadOrder)
291 using namespace Impl;
292 GaussLegendrePointSet ps(quad2PolOrder(quadOrder));
293 ps.template build<GeometryTypes::cube(dim)>();
302 template<
class F,
unsigned int dim >
303 struct CellCentersPointSet :
public PointSetFromQuadrature<F,dim>
305 typedef PointSetFromQuadrature<F,dim> Base;
306 static const unsigned int dimension =
dim;
312 CellCentersPointSet(
unsigned int order)
319 template<
typename ct>
324 enum { highest_order=7 };
326 friend class QuadratureRuleFactory<ct,1>;
329 this->delivered_order = p;
332 const Field h = 1./Field(n);
334 for(
int i=0; i<n; ++i )
336 const Field x = 0.5*h + h*i;
337 assert( x > 0.0 && x < 1.0 );
338 this->
push_back(QuadraturePoint<ct,1>(x, h));
343 static unsigned int quad2PolOrder(
int order) {
return order; }
345 unsigned int quadOrder()
const {
return Base::order(); }
347 template< GeometryType::Id geometryId >
351 auto quadFactory = [](
int order)
353 return CellCenters<Field>(order);
355 return Base::template build<geometryId>(quadFactory);
357 static auto buildCubeQuadrature(
unsigned int quadOrder)
359 using namespace Impl;
360 CellCentersPointSet ps(quad2PolOrder(quadOrder));
361 ps.template build<GeometryTypes::cube(dim)>();
void push_back(const MemberType &item)
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon=DefaultEpsilon< T, style >::value())
void build(const R &remoteIndices, const T1 &sourceFlags, const T2 &destFlags)
IteratorRange<... > subEntities(const E &e, Codim< codim > c)
Dune::Fem::Double abs(const Dune::Fem::Double &a)
Definition double.hh:942
static const QuadratureRule & rule(const GeometryType &t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
static DUNE_PRIVATE void apply(Args &&... args)
Definition forloop.hh:23