1#ifndef DUNE_SPGRID_GEOMETRICGRIDLEVEL_HH
2#define DUNE_SPGRID_GEOMETRICGRIDLEVEL_HH
7#include <dune/common/hybridutilities.hh>
9#include <dune/geometry/dimension.hh>
11#include <dune/grid/spgrid/direction.hh>
12#include <dune/grid/spgrid/geometrycache.hh>
13#include <dune/grid/spgrid/normal.hh>
14#include <dune/grid/spgrid/referencecube.hh>
22 template<
class ct,
int dim >
23 class SPGeometricGridLevel
25 typedef SPGeometricGridLevel< ct, dim > This;
28 typedef SPReferenceCubeContainer< ct, dim > ReferenceCubeContainer;
30 typedef typename ReferenceCubeContainer::ReferenceCube ReferenceCube;
32 typedef typename ReferenceCube::ctype ctype;
33 static const int dimension = ReferenceCube::dimension;
35 typedef typename ReferenceCube::GlobalVector GlobalVector;
37 static const unsigned int numDirections = ReferenceCube::numCorners;
39 typedef SPDirection< dimension > Direction;
44 typedef typename ReferenceCubeContainer::template Codim< codim >::ReferenceCube ReferenceCube;
45 typedef SPGeometryCache< ctype, dimension, codim > GeometryCache;
48 SPGeometricGridLevel (
const ReferenceCubeContainer &refCubes,
const GlobalVector &h );
49 SPGeometricGridLevel (
const This &other );
51 ~SPGeometricGridLevel ();
53 const ReferenceCube &referenceCube ()
const {
return refCubes_.get(); }
56 const typename Codim< codim >::ReferenceCube &
57 referenceCube ()
const {
return refCubes_.template get< codim >(); }
59 const GlobalVector &h ()
const {
return h_; }
62 const typename Codim< codim >::GeometryCache &
65 assert( dir.mydimension() == dimension - codim );
66 return *
static_cast< const typename Codim< codim >::GeometryCache *
>( geometryCache_[ dir.bits() ] );
69 const typename Codim< 0 >::GeometryCache &geometryCache (
Dune::Codim< 0 > )
const
71 SPDirectionIterator< dimension, 0 > dirIt;
72 return geometryCache< 0 >( *dirIt );
75 ctype faceVolume (
int i )
const { assert( (i >= 0) && (i < ReferenceCube::numFaces) );
return faceVolume_[ i ]; }
78 void buildGeometry ();
80 const ReferenceCubeContainer &refCubes_;
83 std::array< void *, numDirections > geometryCache_;
84 std::array< ctype, ReferenceCube::numFaces > faceVolume_;
92 template<
class ct,
int dim >
93 inline SPGeometricGridLevel< ct, dim >
94 ::SPGeometricGridLevel (
const ReferenceCubeContainer &refCubes,
const GlobalVector &h )
95 : refCubes_( refCubes ),
102 template<
class ct,
int dim >
103 inline SPGeometricGridLevel< ct, dim >::SPGeometricGridLevel (
const This &other )
104 : refCubes_( other.refCubes_ ),
111 template<
class ct,
int dim >
112 inline SPGeometricGridLevel< ct, dim >::~SPGeometricGridLevel ()
114 Hybrid::forEach( std::make_integer_sequence< int, dimension+1 >(), [
this ] (
auto codim ) {
115 for( SPDirectionIterator< dimension, codim > dirIt; dirIt; ++dirIt )
117 delete static_cast< typename Codim< codim >::GeometryCache *
>( geometryCache_[ (*dirIt).bits() ] );
118 geometryCache_[ (*dirIt).bits() ] =
nullptr;
124 template<
class ct,
int dim >
125 inline void SPGeometricGridLevel< ct, dim >::buildGeometry ()
127 Hybrid::forEach( std::make_integer_sequence< int, dimension+1 >(), [
this ] (
auto codim ) {
128 typedef typename Codim< codim >::GeometryCache GeometryCache;
129 for( SPDirectionIterator< dimension, codim > dirIt; dirIt; ++dirIt )
130 geometryCache_[ (*dirIt).bits() ] =
new GeometryCache( h_, *dirIt );
134 for(
int face = 0; face < ReferenceCube::numFaces; ++face )
136 SPNormalId< dimension > normalId( face );
137 SPNormalVector< ctype, dimension > normal( normalId );
138 faceVolume_[ face ] = std::abs( volume / (normal * h_) );
constexpr void forEach(Range &&range, F &&f)
Range based for loop.
Definition: hybridutilities.hh:268
Dune namespace.
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24