1#ifndef DUNE_FEM_SPACE_LAGRANGE_GENERICBASEFUNCTIONS_HH
2#define DUNE_FEM_SPACE_LAGRANGE_GENERICBASEFUNCTIONS_HH
6#include "genericlagrangepoints.hh"
14 template<
class FunctionSpace,
class GeometryType,
unsigned int order >
15 class GenericLagrangeBaseFunction;
18 template<
class FunctionSpace,
unsigned int order >
19 class GenericLagrangeBaseFunction< FunctionSpace, PointGeometry, order >
21 typedef GenericLagrangeBaseFunction< FunctionSpace, PointGeometry, order > ThisType;
30 static constexpr unsigned int polynomialOrder = order;
32 typedef GenericLagrangePoint< GeometryType, polynomialOrder >
34 static const unsigned int numBaseFunctions = LagrangePointType :: numLagrangePoints;
41 typedef typename Dune::FieldTraits< RangeFieldType >::real_type RealType;
44 const LagrangePointType lagrangePoint_;
47 explicit GenericLagrangeBaseFunction (
unsigned int baseNum )
48 : lagrangePoint_( baseNum )
51 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
52 inline static void evaluate ( LocalDofCoordinateType &dofCoordinate,
53 const FieldVector< int, 0 > &diffVariable,
54 DomainFieldType factor,
55 const LocalCoordinateType &x,
61 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
62 inline static void evaluate ( LocalDofCoordinateType &dofCoordinate,
63 const FieldVector< int, 1 > &diffVariable,
64 DomainFieldType factor,
65 const LocalCoordinateType &x,
71 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
72 inline static void evaluate ( LocalDofCoordinateType &dofCoordinate,
73 const FieldVector< int, 2 > &diffVariable,
74 DomainFieldType factor,
75 const LocalCoordinateType &x,
81 template<
int diffOrder >
83 evaluate (
const FieldVector< int, diffOrder > &diffVariable,
85 RangeType &phi )
const
87 const LocalCoordinate< GeometryType, DomainFieldType > xlocal( x );
88 LagrangePointType point( lagrangePoint_ );
89 evaluate( point.dofCoordinate_, diffVariable, 1, xlocal, phi );
94 template<
class FunctionSpace,
class BaseGeometryType >
95 class GenericLagrangeBaseFunction< FunctionSpace, PyramidGeometry< BaseGeometryType >, 0 >
97 typedef GenericLagrangeBaseFunction< FunctionSpace, PyramidGeometry< BaseGeometryType >, 0 > ThisType;
104 typedef PyramidGeometry< BaseGeometryType >
GeometryType;
106 enum { polynomialOrder = 0 };
108 typedef GenericLagrangePoint< GeometryType, polynomialOrder > LagrangePointType;
109 static const unsigned int numBaseFunctions = LagrangePointType :: numLagrangePoints;
117 typedef typename Dune::FieldTraits< RangeFieldType >::real_type RealType;
120 const LagrangePointType lagrangePoint_;
123 explicit GenericLagrangeBaseFunction (
unsigned int baseNum )
124 : lagrangePoint_( baseNum )
127 template<
unsigned int porder,
class LocalDofCoordinateType,
class LocalCoordinateType >
128 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
129 const FieldVector< int, 0 > &diffVariable,
130 DomainFieldType factor,
131 const LocalCoordinateType &x,
137 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
138 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
139 const FieldVector< int, 0 > &diffVariable,
140 DomainFieldType factor,
141 const LocalCoordinateType &x,
144 return evaluate< polynomialOrder >( dofCoordinate, diffVariable, factor, x, phi );
147 template<
unsigned int porder,
class LocalDofCoordinateType,
class LocalCoordinateType >
148 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
149 const FieldVector< int, 1 > &diffVariable,
150 DomainFieldType factor,
151 const LocalCoordinateType &x,
157 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
158 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
159 const FieldVector< int, 1 > &diffVariable,
160 DomainFieldType factor,
161 const LocalCoordinateType &x,
164 return evaluate< polynomialOrder >( dofCoordinate, diffVariable, factor, x, phi );
167 template<
unsigned int porder,
class LocalDofCoordinateType,
class LocalCoordinateType >
168 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
169 const FieldVector< int, 2 > &diffVariable,
170 DomainFieldType factor,
171 const LocalCoordinateType &x,
177 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
178 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
179 const FieldVector< int, 2 > &diffVariable,
180 DomainFieldType factor,
181 const LocalCoordinateType &x,
184 return evaluate< polynomialOrder >( dofCoordinate, diffVariable, factor, x, phi );
187 template<
int diffOrder >
188 void evaluate (
const FieldVector< int, diffOrder > &diffVariable,
190 RangeType &phi )
const
192 const LocalCoordinate< GeometryType, DomainFieldType > xlocal( x );
193 LagrangePointType point( lagrangePoint_ );
194 evaluate( point.dofCoordinate_, diffVariable, 1, xlocal, phi );
199 template<
class FunctionSpace,
class BaseGeometryType,
unsigned int order >
200 class GenericLagrangeBaseFunction< FunctionSpace, PyramidGeometry< BaseGeometryType >, order >
202 typedef GenericLagrangeBaseFunction< FunctionSpace, PyramidGeometry< BaseGeometryType >, order > ThisType;
209 typedef PyramidGeometry< BaseGeometryType >
GeometryType;
211 static constexpr unsigned int polynomialOrder = order;
213 typedef GenericLagrangePoint< GeometryType, polynomialOrder >
215 static const unsigned int numBaseFunctions = LagrangePointType :: numLagrangePoints;
223 typedef typename Dune::FieldTraits< RangeFieldType >::real_type RealType;
226 typedef GenericLagrangeBaseFunction
228 DimensionReductionType;
229 typedef GenericLagrangeBaseFunction
234 const LagrangePointType lagrangePoint_;
237 explicit GenericLagrangeBaseFunction (
unsigned int baseNum )
238 : lagrangePoint_( baseNum )
241 template<
unsigned int porder,
class LocalDofCoordinateType,
class LocalCoordinateType >
242 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
243 const FieldVector< int, 0 > &diffVariable,
244 DomainFieldType factor,
245 const LocalCoordinateType &x,
248 const DomainFieldType divisor = DomainFieldType( 1 ) / ((DomainFieldType)polynomialOrder);
249 const DomainFieldType myfactor = porder * divisor;
250 const RealType myshift = (porder - polynomialOrder) * divisor;
252 if( LagrangePointType :: useDimReduction( dofCoordinate ) )
254 DimensionReductionType::evaluate( dofCoordinate.base(), diffVariable, myfactor * factor, x.base(), phi );
256 const unsigned int height
257 = LagrangePointType :: height( dofCoordinate );
258 for(
unsigned int i = 0; i < height; ++i )
262 evaluate< porder >( dofCoordinate, diffVariable, factor, x, psi );
265 (*dofCoordinate) -= height;
270 OrderReductionType::template evaluate< porder >( dofCoordinate, diffVariable, factor, x, phi );
272 phi[ 0 ] *= (polynomialOrder / ((RealType)(*dofCoordinate)))
273 * (myfactor * factor * (*x) - myshift);
277 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
278 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
279 const FieldVector< int, 0 > &diffVariable,
280 DomainFieldType factor,
281 const LocalCoordinateType &x,
284 return evaluate< polynomialOrder >( dofCoordinate, diffVariable, factor, x, phi );
287 template<
unsigned int porder,
class LocalDofCoordinateType,
class LocalCoordinateType >
288 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
289 const FieldVector< int, 1 > &diffVariable,
290 DomainFieldType factor,
291 const LocalCoordinateType &x,
294 const DomainFieldType divisor = polynomialOrder;
295 const DomainFieldType myfactor = porder / divisor;
296 const RealType myshift = (porder - polynomialOrder) / divisor;
298 FieldVector< int, 0 > dv;
300 if( LagrangePointType :: useDimReduction( dofCoordinate ) )
302 if( (
unsigned int)diffVariable[ 0 ] != LocalDofCoordinateType::index )
303 DimensionReductionType::evaluate( dofCoordinate.base(), diffVariable, myfactor * factor, x.base(), phi );
307 const unsigned int height
308 = LagrangePointType :: height( dofCoordinate );
309 for(
unsigned int i = 0; i < height; ++i )
313 evaluate< porder >( dofCoordinate, diffVariable, factor, x, psi );
316 (*dofCoordinate) -= height;
321 OrderReductionType::template evaluate< porder >( dofCoordinate, diffVariable, factor, x, phi );
322 phi *= (myfactor * factor * (*x) - myshift);
324 if( (
unsigned int)diffVariable[ 0 ] == LocalDofCoordinateType::index )
327 OrderReductionType::template evaluate< porder >( dofCoordinate, dv, factor, x, psi );
328 phi.axpy( myfactor * factor, psi );
331 phi *= (polynomialOrder) / ((RealType)(*dofCoordinate));
335 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
336 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
337 const FieldVector< int, 1 > &diffVariable,
338 DomainFieldType factor,
339 const LocalCoordinateType &x,
342 return evaluate< polynomialOrder >( dofCoordinate, diffVariable, factor, x, phi );
345 template<
unsigned int porder,
class LocalDofCoordinateType,
class LocalCoordinateType >
346 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
347 const FieldVector< int, 2 > &diffVariable,
348 DomainFieldType factor,
349 const LocalCoordinateType &x,
352 const DomainFieldType divisor = polynomialOrder;
353 const DomainFieldType myfactor = porder / divisor;
354 const RealType myshift = (porder - polynomialOrder) / divisor;
356 FieldVector< int, 1 > dv0( diffVariable[ 0 ] );
357 FieldVector< int, 1 > dv1( diffVariable[ 1 ] );
359 if( LagrangePointType :: useDimReduction( dofCoordinate ) )
361 if( ((
unsigned int)diffVariable[ 0 ] != LocalDofCoordinateType::index)
362 && ((
unsigned int)diffVariable[ 1 ] != LocalDofCoordinateType::index) )
363 DimensionReductionType::evaluate( dofCoordinate.base(), diffVariable, myfactor * factor, x.base(), phi );
367 const unsigned int height = LagrangePointType::height( dofCoordinate );
368 for(
unsigned int i = 0; i < height; ++i )
372 evaluate< porder >( dofCoordinate, diffVariable, factor, x, psi );
375 (*dofCoordinate) -= height;
381 OrderReductionType::template evaluate< porder >( dofCoordinate, diffVariable, factor, x, phi );
382 phi *= (myfactor * factor * (*x) - myshift);
384 if( (
unsigned int)diffVariable[ 0 ] == LocalDofCoordinateType::index )
386 OrderReductionType::template evaluate< porder >( dofCoordinate, dv1, factor, x, psi );
387 phi.axpy( myfactor * factor, psi );
390 if( (
unsigned int)diffVariable[ 1 ] == LocalDofCoordinateType::index )
392 OrderReductionType::template evaluate< porder >( dofCoordinate, dv0, factor, x, psi );
393 phi.axpy( myfactor * factor, psi );
397 phi *= (polynomialOrder) / ((RealType)(*dofCoordinate));
401 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
402 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
403 const FieldVector< int, 2 > &diffVariable,
404 DomainFieldType factor,
405 const LocalCoordinateType &x,
408 return evaluate< polynomialOrder >( dofCoordinate, diffVariable, factor, x, phi );
411 template<
int diffOrder >
412 void evaluate (
const FieldVector< int, diffOrder > &diffVariable,
414 RangeType &phi )
const
416 const LocalCoordinate< GeometryType, DomainFieldType > xlocal( x );
417 LagrangePointType point( lagrangePoint_ );
418 evaluate( point.dofCoordinate_, diffVariable, 1, xlocal, phi );
423 template<
class FunctionSpace,
class FirstGeometryType,
class SecondGeometryType,
unsigned int order >
424 class GenericLagrangeBaseFunction< FunctionSpace, ProductGeometry< FirstGeometryType, SecondGeometryType >, order >
426 typedef GenericLagrangeBaseFunction< FunctionSpace, ProductGeometry< FirstGeometryType, SecondGeometryType >, order > ThisType;
433 typedef ProductGeometry< FirstGeometryType, SecondGeometryType >
GeometryType;
435 static constexpr unsigned int polynomialOrder = order;
437 typedef GenericLagrangePoint< GeometryType, polynomialOrder > LagrangePointType;
438 static const unsigned int numBaseFunctions = LagrangePointType :: numLagrangePoints;
445 typedef typename Dune::FieldTraits< RangeFieldType >::real_type RealType;
448 typedef GenericLagrangeBaseFunction
451 typedef GenericLagrangeBaseFunction
456 const LagrangePointType lagrangePoint_;
459 explicit GenericLagrangeBaseFunction (
unsigned int baseNum )
460 : lagrangePoint_( baseNum )
463 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
464 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
465 const FieldVector< int, 0 > &diffVariable,
466 DomainFieldType factor,
467 const LocalCoordinateType &x,
471 FirstReductionType::evaluate( dofCoordinate.first(), diffVariable, factor, x.first(), phi );
472 SecondReductionType::evaluate( dofCoordinate.second(), diffVariable, factor, x.second(), psi );
473 phi[ 0 ] *= psi[ 0 ];
476 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
477 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
478 const FieldVector< int, 1 > &diffVariable,
479 DomainFieldType factor,
480 const LocalCoordinateType &x,
483 FieldVector< int, 0 > dv;
484 RangeType psi1, psi2;
486 FirstReductionType::evaluate( dofCoordinate.first(), diffVariable, factor, x.first(), psi1 );
487 SecondReductionType::evaluate( dofCoordinate.second(), dv, factor, x.second(), psi2 );
488 phi[ 0 ] = psi1[ 0 ] * psi2[ 0 ];
490 FirstReductionType::evaluate( dofCoordinate.first(), dv, factor, x.first(), psi1 );
491 SecondReductionType::evaluate( dofCoordinate.second(), diffVariable, factor, x.second(), psi2 );
492 phi[ 0 ] += psi1[ 0 ] * psi2[ 0 ];
495 template<
class LocalDofCoordinateType,
class LocalCoordinateType >
496 static void evaluate ( LocalDofCoordinateType &dofCoordinate,
497 const FieldVector< int, 2 > &diffVariable,
498 DomainFieldType factor,
499 const LocalCoordinateType &x,
502 FieldVector< int, 0 > dv;
503 FieldVector< int, 1 > dv0( diffVariable[ 0 ] );
504 FieldVector< int, 1 > dv1( diffVariable[ 1 ] );
505 RangeType psi1, psi2;
507 FirstReductionType::evaluate( dofCoordinate.first(), diffVariable, factor, x.first(), psi1 );
508 SecondReductionType::evaluate( dofCoordinate.second(), dv, factor, x.second(), psi2 );
509 phi[ 0 ] = psi1[ 0 ] * psi2[ 0 ];
511 FirstReductionType::evaluate( dofCoordinate.first(), dv0, factor, x.first(), psi1 );
512 SecondReductionType::evaluate( dofCoordinate.second(), dv1, factor, x.second(), psi2 );
513 phi[ 0 ] += psi1[ 0 ] * psi2[ 0 ];
515 FirstReductionType::evaluate( dofCoordinate.first(), dv1, factor, x.first(), psi1 );
516 SecondReductionType::evaluate( dofCoordinate.second(), dv0, factor, x.second(), psi2 );
517 phi[ 0 ] += psi1[ 0 ] * psi2[ 0 ];
519 FirstReductionType::evaluate( dofCoordinate.first(), dv, factor, x.first(), psi1 );
520 SecondReductionType::evaluate( dofCoordinate.second(), diffVariable, factor, x.second(), psi2 );
521 phi[ 0 ] += psi1[ 0 ] * psi2[ 0 ];
524 template<
int diffOrder >
525 void evaluate (
const FieldVector< int, diffOrder > &diffVariable,
527 RangeType &phi )
const
529 const LocalCoordinate< GeometryType, DomainFieldType > xlocal( x );
530 LagrangePointType point( lagrangePoint_ );
531 evaluate( point.dofCoordinate_, diffVariable, 1, xlocal, phi );
FunctionSpaceTraits::DomainFieldType DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspaceinterface.hh:60
FunctionSpaceTraits::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:71
@ dimRange
dimension of range vector space
Definition: functionspaceinterface.hh:48
FunctionSpaceTraits::DomainType DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:67
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63
A vector valued function space.
Definition: functionspace.hh:60
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
Implements a vector constructed from a given type representing a field and a compile-time given size.
Dune namespace.
Definition: alignedallocator.hh:13