1 #ifndef ALUGRID_GRID_INLINE_HH
2 #define ALUGRID_GRID_INLINE_HH
5 #include <dune/common/stdstreams.hh>
20 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
34 , localIdSet_( *this )
35 , levelIndexVec_( 1, nullptr ) , leafIndexSet_()
37 , lockPostAdapt_( false )
42 , refinementType_( refinementType )
48 checkMacroGridFile( macroTriangFilename );
50 mygrid_.reset( createALUGrid( macroTriangFilename ) );
53 dverb <<
"************************************************" << std::endl;
54 dverb <<
"Created grid on p=" << comm().rank() << std::endl;
55 dverb <<
"************************************************" << std::endl;
63 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
76 geomTypes_.resize( dimension+1 );
88 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
94 return myGrid().indexManager(codim).getMaxIndex();
98 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
102 return myGrid().indexManager(codim).getMaxIndex();
106 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
113 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
123 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
124 template<
int cd, PartitionIteratorType pitype >
130 if( level > maxlevel_ )
131 return this->
template lend<cd,pitype> (level);
137 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
138 template<
int cd, PartitionIteratorType pitype >
148 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
153 return this->
template lbegin<cd,All_Partition>( level );
157 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
163 return this->
template lend<cd,All_Partition>( level );
172 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
173 template<
int cd, PartitionIteratorType pitype >
182 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
183 template<
int cd, PartitionIteratorType pitype >
184 inline typename ALU3dGrid< dim, dimworld, elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
185 ALU3dGrid< dim, dimworld, elType, Comm >::leafbegin (
int level )
const
187 return createLeafIteratorBegin<cd, pitype> (level) ;
191 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
193 inline typename ALU3dGrid< dim, dimworld, elType, Comm >::Traits::template Codim< cd >::LeafIterator
194 ALU3dGrid< dim, dimworld, elType, Comm >::leafbegin (
int level )
const
196 return createLeafIteratorBegin<cd, All_Partition> (level) ;
200 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
201 template<
int cd, PartitionIteratorType pitype >
202 inline typename ALU3dGrid< dim, dimworld, elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
203 ALU3dGrid< dim, dimworld, elType, Comm >::leafbegin ()
const
205 return createLeafIteratorBegin< cd, pitype > (maxlevel_) ;
209 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
211 inline typename ALU3dGrid< dim, dimworld, elType, Comm >::Traits::template Codim< cd >::LeafIterator
212 ALU3dGrid< dim, dimworld, elType, Comm >::leafbegin ()
const
214 return createLeafIteratorBegin< cd, All_Partition> (maxlevel_) ;
218 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
220 ALU3dGrid< dim, dimworld, elType, Comm >::leafbegin (
int level )
const
222 return createLeafIteratorBegin<0, All_Partition> (level) ;
226 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
228 ALU3dGrid< dim, dimworld, elType, Comm >::leafbegin ()
const
230 return createLeafIteratorBegin<0, All_Partition> (maxlevel_) ;
239 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
240 template<
int cd, PartitionIteratorType pitype >
241 inline typename ALU3dGrid< dim, dimworld, elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
242 ALU3dGrid< dim, dimworld, elType, Comm >::createLeafIteratorEnd (
int level )
const
245 return ALU3dGridLeafIterator<cd, pitype, const MyType> ( *
this, level);
249 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
250 template<
int cd, PartitionIteratorType pitype >
251 inline typename ALU3dGrid< dim, dimworld, elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
252 ALU3dGrid< dim, dimworld, elType, Comm >::leafend (
int level )
const
254 return createLeafIteratorEnd < cd, pitype> (level);
258 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
260 inline typename ALU3dGrid< dim, dimworld, elType, Comm >::Traits::template Codim< cd >::LeafIterator
261 ALU3dGrid< dim, dimworld, elType, Comm >::leafend (
int level )
const
263 return createLeafIteratorEnd < cd, All_Partition> (level);
267 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
268 template<
int cd, PartitionIteratorType pitype >
269 inline typename ALU3dGrid< dim, dimworld, elType, Comm >::Traits::template Codim< cd >::template Partition< pitype >::LeafIterator
270 ALU3dGrid< dim, dimworld, elType, Comm >::leafend ()
const
272 return createLeafIteratorEnd < cd, pitype> (maxlevel_);
276 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
278 inline typename ALU3dGrid< dim, dimworld, elType, Comm >::Traits::template Codim< cd >::LeafIterator
279 ALU3dGrid< dim, dimworld, elType, Comm >::leafend ()
const
281 return createLeafIteratorEnd < cd, All_Partition> (maxlevel_);
285 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
287 ALU3dGrid< dim, dimworld, elType, Comm >::leafend (
int level )
const
289 return createLeafIteratorEnd <0, All_Partition> (level);
293 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
295 ALU3dGrid< dim, dimworld, elType, Comm >::leafend ()
const
297 return createLeafIteratorEnd <0,All_Partition> (maxlevel_);
304 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
308 bool marked = (this->getRealImplementation( entity )).mark( ref, conformingRefinement() );
311 if(ref > 0) ++refineMarked_;
312 if(ref < 0) ++coarsenMarked_;
319 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
323 return this->getRealImplementation( entity ).getMark();
328 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
329 template<
class Gr
idImp,
class DataHandle >
332 ::globalRefine (
int refCount, AdaptDataHandleInterface< GridImp, DataHandle > &handle )
334 for(
int count = refCount; count > 0; --count )
346 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
347 template<
class Gr
idImp,
class DataHandle >
350 ::adapt ( AdaptDataHandleInterface< GridImp, DataHandle > &handle )
352 typedef AdaptDataHandleInterface< GridImp, DataHandle > AdaptDataHandle;
355 bool mightCoarse = preAdapt();
357 bool refined = false ;
362 ALU3DSPACE AdaptRestrictProlongGlSet< MyType, AdaptDataHandle, GlobalIdSetImp >
367 refined = myGrid().duneAdapt(rp);
371 ALU3DSPACE AdaptRestrictProlongImpl< MyType, AdaptDataHandle >
375 refined = myGrid().duneAdapt(rp);
378 if(refined || mightCoarse)
394 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
397 if( comm().size() <= 1 )
401 const bool changed = myGrid().loadBalance( lbData );
406 macroBoundarySegmentIndexSet_.invalidate();
416 globalIdSet_->updateIdSet();
419 if( lbData && lbData->hasUserData() )
427 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
434 mygrid_.reset( GitterImplType :: compress( mygrid_.release() ) );
445 template<
int dim,
int dimworld, ALU3dGr
idElementType elType,
class Comm >
449 return "ALUCubeGrid";
451 return "ALUSimplexGrid";
#define ALU3DSPACE
Definition: alu3dinclude.hh:24
#define alugrid_assert(EX)
Definition: alugrid_assert.hh:20
Definition: alu3dinclude.hh:80
@ hexa
Definition: topology.hh:12
@ tetra
Definition: topology.hh:12
bool checkMacroGrid(ALU3dGridElementType elType, const std::string filename)
ALUGridRefinementType
available refinement types for ALUGrid
Definition: declaration.hh:24
[ provides Dune::Grid ]
Definition: alugrid/3d/grid.hh:463
void globalRefine(int refCount)
uses the interface, mark on entity and refineLocal
Definition: grid_imp.cc:405
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Definition: grid_inline.hh:306
bool loadBalance()
Calculates load of each process and repartition by using ALUGrid's default partitioning method....
Definition: alugrid/3d/grid.hh:935
int maxLevel() const
Return maximum level defined in this grid. Levels are numbered maxLevel with 0 the coarsest level.
Definition: grid_inline.hh:107
Traits::DuneBoundaryProjectionType DuneBoundaryProjectionType
boundary projection type
Definition: alugrid/3d/grid.hh:580
int hierSetSize(int cd) const
Definition: grid_inline.hh:99
GitterImplType & myGrid() const
Definition: grid_inline.hh:115
void finalizeGridCreation()
Definition: grid_inline.hh:428
bool adapt()
Definition: grid_imp.cc:430
static std::string name()
for grid identification
Definition: grid_inline.hh:446
ALU3dGrid(const std::string ¯oTriangFilename, const MPICommunicatorType mpiComm, const DuneBoundaryProjectionType *bndPrj, const DuneBoundaryProjectionVector *bndVec, const ALUGridRefinementType refinementType)
Definition: grid_inline.hh:22
void makeGeometries()
Definition: grid_inline.hh:65
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
Definition: grid_inline.hh:126
Comm MPICommunicatorType
Definition: alugrid/3d/grid.hh:632
ALU3DSPACE GatherScatter GatherScatterType
Definition: alugrid/3d/grid.hh:898
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
Definition: grid_inline.hh:321
ALU3dImplTraits< elType, Comm >::GitterImplType GitterImplType
Definition: alugrid/3d/grid.hh:617
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Definition: grid_inline.hh:140
Traits::DuneBoundaryProjectionVector DuneBoundaryProjectionVector
boundary projection type
Definition: alugrid/3d/grid.hh:582
int global_size(int cd) const
number of grid entities on all levels for given codim
Definition: grid_inline.hh:89
Traits::template Codim< 0 >::LeafIterator LeafIteratorType
Definition: alugrid/3d/grid.hh:612
Definition: iterator.hh:554
Definition: geometry.hh:632
Leaf iterator.
Definition: iterator.hh:639
Definition: alugrid/3d/grid.hh:135
Definition: alugrid/3d/grid.hh:530
ALUGrid boundary projection implementation DuneBndProjection has to fulfil the DuneBoundaryProjection...
Definition: bndprojection.hh:11