1#ifndef DUNE_ALUGRIDGEOMETRYSTORAGE_HH
2#define DUNE_ALUGRIDGEOMETRYSTORAGE_HH
7#include <dune/common/exceptions.hh>
9#include <dune/grid/common/grid.hh>
10#include <dune/grid/common/gridfactory.hh>
17 template<
class Gr
id >
18 class ReferenceGridFactory;
21 template<
class Gr
idImp,
class GeometryImpl,
int nChild >
27 std::array< GeometryImpl, nChild > geoms_;
36 typedef typename GridImp :: ctype ctype;
37 enum{ dimension = GridImp :: dimension };
38 enum{ dimensionworld = GridImp :: dimensionworld };
40 template <
int dummy,
int dim,
int dimworld,
int >
41 struct CreateGeometries;
43 template <
int dummy,
int dimworld>
44 struct CreateGeometries<dummy, 2, dimworld,
ALU3DSPACE triangle >
46 template <
class Storage>
48 const GeometryType& type,
49 const bool nonConform )
54 storage.template createGeometries< Grid > (type);
59 storage.template createGeometries< Grid > (type);
64 template <
int dummy,
int dimworld>
67 template <
class Storage>
69 const GeometryType& type,
70 const bool nonConform )
75 storage.template createGeometries< Grid > (type);
80 storage.template createGeometries< Grid > (type);
88 template <
class Storage>
90 const GeometryType& type,
91 const bool nonConform )
96 storage.template createGeometries< Grid > (type);
109 template <
int dummy,
int dimworld>
110 struct CreateGeometries<dummy, 2, dimworld,
ALU3DSPACE quadrilateral >
112 template <
class Storage>
114 const GeometryType& type,
115 const bool nonConform )
120 storage.template createGeometries< Grid > (type);
125 template <
int dummy,
int dimworld>
128 template <
class Storage>
130 const GeometryType& type,
131 const bool nonConform )
136 storage.template createGeometries< Grid > (type);
144 template <
class Storage>
146 const GeometryType& type,
147 const bool nonConform )
152 storage.template createGeometries< Grid > (type);
160 : count_( 0 ), initialized_( false )
168 : count_( 0 ), initialized_( false )
177 return geoms_[child];
181 static inline const ThisType&
storage(
const GeometryType type,
const bool nonConforming )
183 if( type.isSimplex() )
186 static ThisType simplexGeoms( type, nonConforming );
187 return simplexGeoms ;
195 static ThisType cubeGeoms( type, nonConforming );
202 inline bool geomCreated(
int child)
const {
return geoms_[child].valid(); }
205 inline bool initialize(
const GeometryType type,
const bool nonConform )
211 initialized_ = true ;
215 CreateGeometries<0, dimension, dimensionworld, GridImp :: elementType >
216 ::createGeometries(*
this, type, nonConform);
222 template <
class Gr
id >
225 static bool firstCall = true ;
233 const auto& refElem =
234 Dune::ReferenceElements< ctype, dimension >::general( type );
237 FieldVector<ctype, dimensionworld> pos( 0 );
238 const int vxSize = refElem.size(dimension);
239 for(
int i=0; i<vxSize; ++i)
241 FieldVector<ctype, dimension> position = refElem.position(i, dimension );
243 for(
int d = 0; d<dimension; ++d )
244 pos[ d ] = position[ d ];
246 factory.insertVertex( pos );
249 std::vector< unsigned int > vertices( vxSize );
251 for(
size_t i=0; i<vertices.size(); ++i) vertices[ i ] = i;
252 factory.insertElement(type, vertices);
254 std::unique_ptr< Grid > gridPtr( factory.createGrid() );
255 Grid& grid = *gridPtr;
259 grid.globalRefine( level );
263 MacroGridView macroView = grid.template macroGridView< All_Partition > ();
264 typedef typename MacroGridView :: template Codim< 0 > :: Iterator Iterator;
266 Iterator it = macroView.template begin<0> ();
268 if( it == macroView.template end<0>() )
269 DUNE_THROW(InvalidStateException,
"Empty Grid, should contain at least 1 element");
271 typedef typename Iterator :: Entity EntityType;
273 const EntityType& entity = *it;
274 const typename EntityType :: Geometry& geo = entity.geometry();
275 typedef typename EntityType :: HierarchicIterator HierarchicIteratorType;
276 const HierarchicIteratorType end = entity.hend( level );
279 for( HierarchicIteratorType child = entity.hbegin( level );
280 child != end; ++child, ++childNum )
282 create( geo, child->geometry(), childNum );
289 template<
class Geometry >
290 inline void create (
const Geometry &father,
300 geoms_[ child ].buildGeomInFather( father, son );
#define alugrid_assert(EX)
Definition: alugrid_assert.hh:20
#define ALU3DSPACE
Definition: alu3dinclude.hh:7
Definition: alu3dinclude.hh:63
@ hexa
Definition: topology.hh:12
@ tetra
Definition: topology.hh:12
unstructured parallel implementation of the DUNE grid interface
Definition: alugrid.hh:31
Definition: geostorage.hh:23
bool geomCreated(int child) const
Definition: geostorage.hh:202
ALULocalGeometryStorage(const GeometryType type, const bool nonConform)
Definition: geostorage.hh:159
const GeometryImpl & operator[](int child) const
Definition: geostorage.hh:173
bool initialize(const GeometryType type, const bool nonConform)
initialize local geometries
Definition: geostorage.hh:205
static const ThisType & storage(const GeometryType type, const bool nonConforming)
access local geometry storage
Definition: geostorage.hh:181
ALULocalGeometryStorage()
Definition: geostorage.hh:167
void create(const Geometry &father, const Geometry &son, const int child)
Definition: geostorage.hh:290
void createGeometries(const GeometryType &type)
Definition: geostorage.hh:223
Definition: gridfactory.hh:494
Definition: macrogridview.hh:71