3 #ifndef DUNE_GEOMETRY_GENERICREFERENCEELEMENTS_HH
4 #define DUNE_GEOMETRY_GENERICREFERENCEELEMENTS_HH
6 #include <dune/common/deprecated.hh>
7 #include <dune/common/forloop.hh>
8 #include <dune/common/typetraits.hh>
9 #include <dune/common/visibility.hh>
23 template<
class ctype,
int dim >
50 template<
class ctype,
int dim >
64 ForLoop< Destroy, 0, dim >::apply( mappings_ );
65 integral_constant< int, 0 > codim0Variable;
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;
76 :
public GenericGeometry::DefaultGeometryTraits< ctype, dim, dim >
78 typedef GenericGeometry::DefaultGeometryTraits< ctype, dim, dim > Base;
82 template<
class Topology >
100 template<
int codim >
109 template<
int codim >
111 :
public std::vector< typename Codim< codim >::Mapping * >
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 );
182 const FieldVector< ctype, dim > &
position(
int i,
int c )
const
184 assert( (c >= 0) && (c <= dim) );
185 return info_[ c ][ i ].position();
197 return checkInside< 0 >( local, 0 );
214 template<
int codim >
215 bool checkInside (
const FieldVector< ctype, dim-codim > &local,
int i )
const
241 template<
int codim >
242 FieldVector< ctype, dim >
243 global(
const FieldVector< ctype, dim-codim > &local,
int i,
int c )
const
246 DUNE_THROW( Exception,
"Local Coordinate Type does not correspond to codimension c." );
247 assert( c == codim );
248 return mapping< codim >( i ).
global( local );
269 template<
int codim >
270 FieldVector< ctype, dim >
271 global(
const FieldVector< ctype, dim-codim > &local,
int i )
const
273 return mapping< codim >( i ).
global( local );
291 template<
int codim >
294 integral_constant< int, codim > codimVariable;
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 >
343 dune_static_assert( (Topology::dimension == dim),
344 "Cannot initialize reference element for different dimension." );
345 typedef Initialize< Topology > Init;
349 integral_constant< int, 0 > codim0Variable;
350 mappings_[ codim0Variable ].resize( 1 );
351 mappings_[ codim0Variable ][ 0 ] =
new VirtualMapping( codim0Variable );
353 Dune::ForLoop< Init::template Codim, 0, dim >::apply( info_, mappings_ );
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
378 std::vector< int > numbering_[ dim+1 ];
379 FieldVector< ctype, dim > baryCenter_;
386 return numbering_[ cc ].size();
392 return numbering_[ cc ][ ii ];
405 template<
class Topology,
unsigned int codim,
unsigned int i >
411 const unsigned int iVariable = i;
412 Dune::ForLoop< Init::template SubCodim, 0, dim-codim >::apply( iVariable, numbering_ );
414 baryCenter_ = ctype( 0 );
415 static const unsigned int numCorners =
size( dim );
416 for(
unsigned int j = 0; j < numCorners; ++j )
418 FieldVector< ctype, dim > corner;
419 RefDomain::corner( number( j, dim ), corner );
420 baryCenter_ += corner;
422 baryCenter_ *= ctype( 1 ) / ctype( numCorners );
425 type_ =
GeometryType( SubTopology::id, SubTopology::dimension );
430 template<
class ctype,
int dim >
431 template<
class Topology >
437 static const unsigned int size = Topology::numCorners;
439 template<
class SubTopology >
442 typedef CornerStorage< SubTopology >
type;
445 explicit CornerStorage (
const integral_constant< int, 0 > & )
447 for(
unsigned int i = 0; i <
size; ++i )
448 RefDomain::corner( i, coords_[ i ] );
451 template<
class Mapping,
unsigned int codim >
455 for(
unsigned int i = 0; i <
size; ++i )
456 coords_[ i ] = coords[ i ];
459 const FieldVector< ctype, dim > &operator[] (
unsigned int i )
const
465 FieldVector< ctype, dim > coords_[
size ];
469 template<
class ctype,
int dim >
470 template<
class Topology,
int codim >
471 template<
int subcodim >
477 static void apply (
unsigned int i, std::vector< int > (&numbering)[ dim+1 ] )
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 >
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 ],
512 info[ codim ].resize( size );
513 Dune::ForLoop< SubTopology, 0, size-1 >::apply( info[ codim ] );
517 integral_constant< int, 0 > codim0Variable;
518 const ReferenceMapping &refMapping = *(mappings[ codim0Variable ][ 0 ]);
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 >
539 static void apply ( MappingsTable &mappings )
543 integral_constant< int, codim > codimVariable;
544 for(
size_t i = 0; i < mappings[ codimVariable ].size(); ++i ) {
545 typedef typename Codim<codim>::Mapping Mapping;
546 mappings[ codimVariable ][ i ]->~Mapping();
547 char* storage = (
char*)mappings[ codimVariable ][ i ];
562 template<
class ctype,
int dim >
563 class GenericReferenceElementContainer
565 static const unsigned int numTopologies = (1u << dim);
571 DUNE_DEPRECATED_MSG(
"GenericReferenceElementContainer was renamed to ReferenceElementContainer.")
574 ForLoop< Builder, 0, numTopologies-1 >::apply( values_ );
579 assert( type.
dim() == dim );
580 return values_[ type.
id() ];
607 template<
int topologyId >
610 static void apply (
value_type (&values)[ numTopologies ] )
613 values[ topologyId ].template initializeTopology< Topology >();
635 template<
class ctype,
int dim >
640 DUNE_DEPRECATED_MSG(
"GenericReferenceElements was renamed to ReferenceElements.")
645 DUNE_DEPRECATED_MSG(
"GenericReferenceElements was renamed to ReferenceElements.")
648 return container() ( type );
653 DUNE_DEPRECATED_MSG(
"GenericReferenceElements was renamed to ReferenceElements.")
656 return container().simplex();
661 DUNE_DEPRECATED_MSG(
"GenericReferenceElements was renamed to ReferenceElements.")
664 return container().cube();
680 #endif // #ifndef DUNE_GEOMETRY_GENERICREFERENCEELEMENTS_HH
SubTopologyImpl< Topology, Topology::dimension, codim, i >::type type
Definition: subtopologies.hh:269
void initializeTopology()
initialize the reference element
Definition: genericreferenceelements.hh:341
const value_type * const_iterator
Definition: genericreferenceelements.hh:569
static void apply(std::vector< SubEntityInfo >(&info)[dim+1], MappingsTable &mappings)
Definition: genericreferenceelements.hh:508
const value_type & operator()(const GeometryType &type) const
Definition: genericreferenceelements.hh:577
Definition: hybridmapping.hh:27
int size(int c) const
number of subentities of codimension c
Definition: genericreferenceelements.hh:131
int size(int cc) const
Definition: genericreferenceelements.hh:383
const GeometryType & type(int i, int c) const
obtain the type of subentity (i,c)
Definition: genericreferenceelements.hh:306
GenericGeometry::HybridMapping< dim-codim, GeometryTraits > Mapping
type of mapping embedding a subentity into the reference element
Definition: genericreferenceelements.hh:104
const value_type & pyramid() const
Definition: genericreferenceelements.hh:593
EvaluationType
If not affine only volume is cached (based on intElCompute) otherwise all quantities can be cached...
Definition: geometrytraits.hh:76
static void apply(std::vector< SubEntityInfo > &info)
Definition: genericreferenceelements.hh:501
Codim< codim >::Mapping & mapping(int i) const
obtain the embedding of subentity (i,codim) into the reference element
Definition: genericreferenceelements.hh:292
GenericReferenceElement< ctype, dim > value_type
Definition: genericreferenceelements.hh:568
Definition: genericreferenceelements.hh:496
Definition: mappingprovider.hh:178
conditional< isPrism, Prism< true >, Pyramid< false > >::type::type type
Definition: topologytypes.hh:295
Class providing access to the singletons of the generic reference elements. Special methods are avail...
Definition: genericreferenceelements.hh:636
Topological and geometric information about the subentities of a reference element.
Definition: genericreferenceelements.hh:371
Statically compute the number of subentities of a given codimension.
Definition: subtopologies.hh:24
Definition: genericreferenceelements.hh:88
Definition: topologytypes.hh:215
Definition: topologytypes.hh:249
Definition: subtopologies.hh:30
Definition: topologytypes.hh:260
static Iterator begin()
Definition: genericreferenceelements.hh:667
const FieldVector< ctype, dim > & position(int i, int c) const
position of the barycenter of entity (i,c)
Definition: genericreferenceelements.hh:182
static const GenericGeometry::EvaluationType evaluateJacobianInverseTransposed
Definition: genericreferenceelements.hh:91
DUNE_EXPORT void initialize()
Definition: genericreferenceelements.hh:406
bool checkInside(const FieldVector< ctype, dim > &local) const
check if a coordinate is in the reference element
Definition: genericreferenceelements.hh:195
const FieldVector< ctype, dim > & position() const
Definition: genericreferenceelements.hh:395
const GeometryType & type() const
Definition: genericreferenceelements.hh:400
assign in constructor using barycenter
Definition: geometrytraits.hh:81
abstract base class for generic mapping
Definition: hybridmapping.hh:24
static const GenericReferenceElement< ctype, dim > & general(const GeometryType &type)
get general generic reference elements
Definition: genericreferenceelements.hh:646
unsigned int size(unsigned int topologyId, int dim, int codim)
Compute the number of subentities of a given codimension.
Definition: subtopologies.cc:16
Definition: genericreferenceelements.hh:375
Definition: cornermapping.hh:405
unsigned int id() const
Return the topology id the type.
Definition: type.hh:327
Definition: genericreferenceelements.hh:499
ctype volume() const
obtain the volume of the reference element
Definition: genericreferenceelements.hh:316
Collection of types depending on the codimension.
Definition: genericreferenceelements.hh:101
unsigned int dim() const
Return dimension of the type.
Definition: type.hh:322
Definition: genericreferenceelements.hh:24
static Iterator end()
Definition: genericreferenceelements.hh:668
static void apply(unsigned int i, std::vector< int >(&numbering)[dim+1])
Definition: genericreferenceelements.hh:477
const_iterator end() const
Definition: genericreferenceelements.hh:604
static const GenericGeometry::EvaluationType evaluateJacobianTransposed
Definition: genericreferenceelements.hh:90
int number(int ii, int cc) const
Definition: genericreferenceelements.hh:389
GenericGeometry::SubTopologySize< Topology, codim, subcodim > SubSize
Definition: genericreferenceelements.hh:474
Definition: topologytypes.hh:232
implementation of GenericGeometry::Mapping for first order lagrange type reference mappings...
Definition: cornermapping.hh:527
static const GenericReferenceElement< ctype, dim > & cube()
get hypercube generic reference elements
Definition: genericreferenceelements.hh:662
const value_type & cube() const
Definition: genericreferenceelements.hh:588
Definition: genericreferenceelements.hh:472
GenericReferenceElementContainer< ctype, dim >::const_iterator Iterator
Definition: genericreferenceelements.hh:638
const value_type & prism() const
Definition: genericreferenceelements.hh:598
int size(int i, int c, int cc) const
number of subentities of codimension cc of subentity (i,c)
Definition: genericreferenceelements.hh:148
DuneCoordTraits< ctype > CoordTraits
types needed in matrix-vector operations
Definition: geometrytraits.hh:116
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
static const GenericGeometry::EvaluationType evaluateNormal
Definition: genericreferenceelements.hh:93
const value_type & simplex() const
Definition: genericreferenceelements.hh:583
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:24
This class provides access to geometric and topological properties of a reference element...
Definition: genericreferenceelements.hh:51
const_iterator begin() const
Definition: genericreferenceelements.hh:603
GenericGeometry::GenericSubTopologyNumbering< Topology, codim, subcodim > SubNumbering
Definition: genericreferenceelements.hh:475
const FieldVector< ctype, dim > & volumeOuterNormal(int face) const
obtain the volume outer normal of the reference element
Definition: genericreferenceelements.hh:328
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
Definition: referencedomain.hh:27
Definition: subtopologies.hh:33
static const GenericGeometry::EvaluationType evaluateIntegrationElement
Definition: genericreferenceelements.hh:92
Definition: genericreferenceelements.hh:440
CornerStorage< SubTopology > type
Definition: genericreferenceelements.hh:442
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
Definition: genericreferenceelements.hh:83
GenericGeometry::CornerMapping< CoordTraits, Topology, dim, CornerStorage< Topology >, true > type
Definition: genericreferenceelements.hh:85
const GeometryType & type() const
obtain the type of this reference element
Definition: genericreferenceelements.hh:313
static const GenericReferenceElement< ctype, dim > & simplex()
get simplex generic reference elements
Definition: genericreferenceelements.hh:654
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