3#ifndef DUNE_GEOMETRY_GENERICREFERENCEELEMENTS_HH
4#define DUNE_GEOMETRY_GENERICREFERENCEELEMENTS_HH
11#include <dune/geometry/genericgeometry/codimtable.hh>
12#include <dune/geometry/genericgeometry/subtopologies.hh>
13#include <dune/geometry/genericgeometry/referencedomain.hh>
14#include <dune/geometry/genericgeometry/hybridmapping.hh>
15#include <dune/geometry/genericgeometry/mappingprovider.hh>
23 template<
class ctype,
int dim >
24 class GenericReferenceElementContainer;
50 template<
class ctype,
int dim >
66 if(mappings_[ codim0Variable ].
size())
67 delete mappings_[ codim0Variable ][ 0 ];
71 template<
class Topology >
class CornerStorage;
72 template<
class Topology >
struct Initialize;
73 template<
int codim >
struct Destroy;
82 template<
class Topology >
90 static const GenericGeometry::EvaluationType evaluateJacobianTransposed = GenericGeometry::PreCompute;
91 static const GenericGeometry::EvaluationType evaluateJacobianInverseTransposed = GenericGeometry::PreCompute;
92 static const GenericGeometry::EvaluationType evaluateIntegrationElement = GenericGeometry::PreCompute;
93 static const GenericGeometry::EvaluationType evaluateNormal = GenericGeometry::PreCompute;
100 template<
int codim >
109 template<
int codim >
111 :
public std::vector< typename Codim< codim >::Mapping * >
115 typedef GenericGeometry::CodimTable< MappingArray, dim > MappingsTable;
117 std::vector< SubEntityInfo > info_[ dim+1 ];
121 std::vector< FieldVector< ctype, dim > > volumeNormals_;
124 MappingsTable mappings_;
133 assert( (c >= 0) && (c <= dim) );
134 return info_[ c ].size();
148 int size (
int i,
int c,
int cc )
const
150 assert( (c >= 0) && (c <= dim) );
151 return info_[ c ][ i ].size( cc );
169 assert( (c >= 0) && (c <= dim) );
170 return info_[ c ][ i ].number( ii, cc );
184 assert( (c >= 0) && (c <= dim) );
185 return info_[ c ][ i ].position();
197 return checkInside< 0 >( local, 0 );
214 template<
int codim >
217 return mapping< codim >( i ).checkInside( local );
241 template<
int codim >
247 assert( c == codim );
248 return mapping< codim >( i ).global( local );
269 template<
int codim >
273 return mapping< codim >( i ).global( local );
291 template<
int codim >
295 return *(mappings_[ codimVariable ][ i ]);
308 assert( (c >= 0) && (c <= dim) );
309 return info_[ c ][ i ].type();
330 assert( (face >= 0) && (face <
int( volumeNormals_.size())) );
331 return volumeNormals_[ face ];
340 template<
class Topology >
344 "Cannot initialize reference element for different dimension." );
345 typedef Initialize< Topology > Init;
346 typedef GenericGeometry::VirtualMapping< Topology, GeometryTraits > VirtualMapping;
350 mappings_[ codim0Variable ].resize( 1 );
351 mappings_[ codim0Variable ][ 0 ] =
new VirtualMapping( codim0Variable );
356 typedef GenericGeometry::ReferenceDomain< Topology > ReferenceDomain;
357 volume_ = ReferenceDomain::template volume< ctype >();
360 volumeNormals_.resize( ReferenceDomain::numNormals );
361 for(
unsigned int i = 0; i < ReferenceDomain::numNormals; ++i )
362 ReferenceDomain::integrationOuterNormal( i ,volumeNormals_[ i ] );
370 template<
class ctype,
int dim >
373 template<
class Topology,
int codim >
struct Initialize
375 template<
int subcodim >
struct SubCodim;
378 std::vector< int > numbering_[ dim+1 ];
383 int size (
int cc )
const
386 return numbering_[ cc ].size();
389 int number (
int ii,
int cc )
const
392 return numbering_[ cc ][ ii ];
405 template<
class Topology,
unsigned int codim,
unsigned int i >
408 typedef Initialize< Topology, codim > Init;
409 typedef GenericGeometry::ReferenceDomain< Topology > RefDomain;
411 const unsigned int iVariable = i;
414 baryCenter_ = ctype( 0 );
415 static const unsigned int numCorners =
size( dim );
416 for(
unsigned int j = 0; j < numCorners; ++j )
419 RefDomain::corner( number( j, dim ), corner );
420 baryCenter_ += corner;
422 baryCenter_ *= ctype( 1 ) / ctype( numCorners );
424 typedef typename GenericGeometry::SubTopology< Topology, codim, i >::type SubTopology;
425 type_ =
GeometryType( SubTopology::id, SubTopology::dimension );
430 template<
class ctype,
int dim >
431 template<
class Topology >
434 typedef GenericGeometry::ReferenceDomain< Topology > RefDomain;
437 static const unsigned int size = Topology::numCorners;
439 template<
class SubTopology >
442 typedef CornerStorage< SubTopology >
type;
447 for(
unsigned int i = 0; i <
size; ++i )
448 RefDomain::corner( i, coords_[ i ] );
451 template<
class Mapping,
unsigned int codim >
453 CornerStorage (
const GenericGeometry::SubMappingCoords< Mapping, codim > &coords )
455 for(
unsigned int i = 0; i <
size; ++i )
456 coords_[ i ] = coords[ i ];
469 template<
class ctype,
int dim >
470 template<
class Topology,
int codim >
471 template<
int subcodim >
472 struct GenericReferenceElement< ctype, dim >::SubEntityInfo::Initialize< Topology, codim >::SubCodim
474 typedef GenericGeometry::SubTopologySize< Topology, codim, subcodim > SubSize;
475 typedef GenericGeometry::GenericSubTopologyNumbering< Topology, codim, subcodim > SubNumbering;
477 static void apply (
unsigned int i, std::vector< int > (&numbering)[ dim+1 ] )
479 const unsigned int size = SubSize::size( i );
480 numbering[ codim+subcodim ].resize(
size );
481 for(
unsigned int j = 0; j <
size; ++j )
482 numbering[ codim+subcodim ][ j ] = SubNumbering::number( i, j );
487 template<
class ctype,
int dim >
488 template<
class Topology >
489 struct GenericReferenceElement< ctype, dim >::Initialize
495 template<
int codim >
501 static void apply ( std::vector< SubEntityInfo > &info )
503 info[ i ].template initialize< Topology, codim, i >();
508 apply ( std::vector< SubEntityInfo > (&info)[ dim+1 ],
509 MappingsTable &mappings )
511 const unsigned int size = GenericGeometry::Size< Topology, codim >::value;
512 info[ codim ].resize(
size );
517 integral_constant< int, 0 > codim0Variable;
518 const ReferenceMapping &refMapping = *(mappings[ codim0Variable ][ 0 ]);
520 typedef typename GenericGeometry::MappingProvider< ReferenceMapping, codim > MappingProvider;
522 integral_constant< int, codim > codimVariable;
523 mappings[ codimVariable ].resize(
size );
524 for(
unsigned int i = 0; i <
size; ++i ) {
525 char* storage =
new char[MappingProvider::maxMappingSize];
526 mappings[ codimVariable ][ i ] = refMapping.template trace< codim >( i, storage );
535 template<
class ctype,
int dim >
536 template<
int codim >
537 struct GenericReferenceElement< ctype, dim >::Destroy
539 static void apply ( MappingsTable &mappings )
543 integral_constant< int, codim > codimVariable;
544 for(
size_t i = 0; i < mappings[ codimVariable ].size(); ++i ) {
546 mappings[ codimVariable ][ i ]->~Mapping();
547 char* storage = (
char*)mappings[ codimVariable ][ i ];
562 template<
class ctype,
int dim >
565 static const unsigned int numTopologies = (1u << dim);
571 DUNE_DEPRECATED_MSG(
"GenericReferenceElementContainer was renamed to ReferenceElementContainer.")
579 assert( type.dim() == dim );
580 return values_[ type.id() ];
585 return values_[ GenericGeometry::SimplexTopology< dim >::type::id ];
590 return values_[ GenericGeometry::CubeTopology< dim >::type::id ];
595 return values_[ GenericGeometry::PyramidTopology< dim >::type::id ];
600 return values_[ GenericGeometry::PrismTopology< dim >::type::id ];
607 template<
int topologyId >
610 static void apply (
value_type (&values)[ numTopologies ] )
612 typedef typename GenericGeometry::Topology< topologyId, dim >::type Topology;
613 values[ topologyId ].template initializeTopology< Topology >();
635 template<
class ctype,
int dim >
648 return container() ( type );
656 return container().simplex();
664 return container().cube();
667 static Iterator begin () {
return container().begin(); }
668 static Iterator end () {
return container().end(); }
671 DUNE_EXPORT static const GenericReferenceElementContainer< ctype, dim > &container ()
673 static GenericReferenceElementContainer< ctype, dim > container;
Base class for Dune-Exceptions.
Definition: exceptions.hh:92
A static loop using TMP.
Definition: forloop.hh:223
implementation of GenericGeometry::Mapping for first order lagrange type reference mappings.
Definition: cornermapping.hh:528
abstract base class for generic mapping
Definition: hybridmapping.hh:85
Definition: genericreferenceelements.hh:564
Topological and geometric information about the subentities of a reference element.
Definition: genericreferenceelements.hh:372
This class provides access to geometric and topological properties of a reference element....
Definition: genericreferenceelements.hh:52
FieldVector< ctype, dim > global(const FieldVector< ctype, dim-codim > &local, int i, int c) const
map a local coordinate on subentity (i,codim) into the reference element
Definition: genericreferenceelements.hh:243
const FieldVector< ctype, dim > & volumeOuterNormal(int face) const
obtain the volume outer normal of the reference element
Definition: genericreferenceelements.hh:328
void initializeTopology()
initialize the reference element
Definition: genericreferenceelements.hh:341
int subEntity(int i, int c, int ii, int cc) const
obtain number of ii-th subentity with codim cc of (i,c)
Definition: genericreferenceelements.hh:167
const GeometryType & type(int i, int c) const
obtain the type of subentity (i,c)
Definition: genericreferenceelements.hh:306
Codim< codim >::Mapping & mapping(int i) const
obtain the embedding of subentity (i,codim) into the reference element
Definition: genericreferenceelements.hh:292
bool checkInside(const FieldVector< ctype, dim-codim > &local, int i) const
check if a local coordinate is in the reference element of the i-th subentity E with codimension c of...
Definition: genericreferenceelements.hh:215
int size(int c) const
number of subentities of codimension c
Definition: genericreferenceelements.hh:131
const GeometryType & type() const
obtain the type of this reference element
Definition: genericreferenceelements.hh:313
int size(int i, int c, int cc) const
number of subentities of codimension cc of subentity (i,c)
Definition: genericreferenceelements.hh:148
ctype volume() const
obtain the volume of the reference element
Definition: genericreferenceelements.hh:316
const FieldVector< ctype, dim > & position(int i, int c) const
position of the barycenter of entity (i,c)
Definition: genericreferenceelements.hh:182
bool checkInside(const FieldVector< ctype, dim > &local) const
check if a coordinate is in the reference element
Definition: genericreferenceelements.hh:195
FieldVector< ctype, dim > global(const FieldVector< ctype, dim-codim > &local, int i) const
map a local coordinate on subentity (i,codim) into the reference element
Definition: genericreferenceelements.hh:271
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
A static for loop for template meta-programming.
#define dune_static_assert(COND, MSG)
Helper template so that compilation fails if condition is not true.
Definition: static_assert.hh:79
#define DUNE_THROW(E, m)
Definition: exceptions.hh:244
Dune namespace.
Definition: alignment.hh:14
struct DUNE_DEPRECATED_MSG("Use class StaticPower from file power.hh instead") Power_m_p
Calculates m^p at compile time.
Definition: misc.hh:54
default settings for BasicGeometry
Definition: geometrytraits.hh:114
DuneCoordTraits< ctype > CoordTraits
types needed in matrix-vector operations
Definition: geometrytraits.hh:116
Collection of types depending on the codimension.
Definition: genericreferenceelements.hh:102
GenericGeometry::HybridMapping< dim-codim, GeometryTraits > Mapping
type of mapping embedding a subentity into the reference element
Definition: genericreferenceelements.hh:104
Class providing access to the singletons of the generic reference elements. Special methods are avail...
Definition: genericreferenceelements.hh:637
static const GenericReferenceElement< ctype, dim > & general(const GeometryType &type)
get general generic reference elements
Definition: genericreferenceelements.hh:646
static const GenericReferenceElement< ctype, dim > & cube()
get hypercube generic reference elements
Definition: genericreferenceelements.hh:662
static const GenericReferenceElement< ctype, dim > & simplex()
get simplex generic reference elements
Definition: genericreferenceelements.hh:654
Generate a type for a given integral constant.
Definition: typetraits.hh:457
Traits for type conversions and type information.
Definition of macros controlling symbol visibility at the ABI level.
#define DUNE_EXPORT
Export a symbol as part of the public ABI.
Definition: visibility.hh:18