225 static bool firstCall = true ;
233 const Dune::ReferenceElement< ctype, dimension > &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 );