3 #ifndef DUNE_ALU3DGRIDGRID_HH
4 #define DUNE_ALU3DGRIDGRID_HH
13 #include <dune/common/bigunsignedint.hh>
14 #include <dune/common/static_assert.hh>
16 #include <dune/geometry/referenceelements.hh>
34 #include "indexsets.hh"
35 #include "datahandle.hh"
39 #include <dune/common/parallel/mpihelper.hh>
41 #if ALU3DGRID_PARALLEL
42 #include <dune/common/parallel/mpicollectivecommunication.hh>
44 #include <dune/common/parallel/collectivecommunication.hh>
51 template<
int cd,
int dim,
class Gr
idImp>
52 class ALU3dGridEntity;
53 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp >
54 class ALU3dGridLevelIterator;
55 template<
int cd,
class Gr
idImp >
56 class ALU3dGridEntityPointerBase;
57 template<
int cd,
class Gr
idImp >
58 class ALU3dGridEntitySeed;
59 template<
int cd,
class Gr
idImp >
60 class ALU3dGridEntityPointer;
61 template<
int mydim,
int coorddim,
class Gr
idImp>
62 class ALU3dGridGeometry;
63 template<
class Gr
idImp>
64 class ALU3dGridHierarchicIterator;
65 template<
class Gr
idImp>
66 class ALU3dGridIntersectionIterator;
67 template<
class Gr
idImp>
68 class ALU3dGridLevelIntersectionIterator;
69 template<
int codim, PartitionIteratorType pitype,
class Gr
idImp>
70 class ALU3dGridLeafIterator;
71 template <
int mydim,
int coorddim,
class Gr
idImp>
72 class ALU3dGridMakeableEntity;
73 template <
class Gr
idImp>
74 class ALU3dGridFaceGeometryInfo;
75 template< ALU3dGr
idElementType,
class >
76 class ALU3dGridGlobalIdSet;
77 template< ALU3dGr
idElementType,
class >
78 class ALU3dGridLocalIdSet;
79 template< ALU3dGr
idElementType,
class >
80 class ALU3dGridHierarchicIndexSet;
81 template <
class EntityImp>
82 class ALUMemoryProvider;
84 class ALU3dGridFactory;
85 template <
class Gr
idImp,
class GeometryImp,
int nChild>
86 class ALULocalGeometryStorage;
87 template< ALU3dGr
idElementType elType,
class Comm >
88 struct ALU3dGridCommHelper;
95 #if ALU3DGRID_PARALLEL
96 template< ALU3dGr
idElementType elType,
class Comm = MPI_Comm >
98 #else // #if ALU3DGRID_PARALLEL
99 template< ALU3dGr
idElementType elType,
class Comm = No_Comm >
101 #endif // #else // #if ALU3DGRID_PARALLEL
103 template <
class Comm >
104 struct ALUGridBaseGrid< 3, 3,
cube, Comm >
109 template <
class Comm>
121 template <
class GitterImpl >
123 const bool conformingRefinement )
125 #ifdef ALUGRID_3D_CONFORMING_REFINEMENT
126 if( grid && conformingRefinement )
128 grid->enableConformingClosure();
129 grid->disableGhostCells();
136 template< ALU3dGr
idElementType elType,
class Comm >
137 struct ALU3dGridCommunications;
139 template< ALU3dGr
idElementType elType >
156 const bool conformingRefinement )
161 checkForConformingRefinement( grid, conformingRefinement );
166 const bool conformingRefinement )
168 #ifdef ALUGRID_CONSTRUCTION_WITH_STREAMS
171 checkForConformingRefinement( grid, conformingRefinement );
180 static int getRank ( No_Comm comm ) {
return 0; }
184 ALU3DSPACE Gitter::Geometric::BuilderIF* builder =
185 dynamic_cast< ALU3DSPACE Gitter::Geometric::BuilderIF*
>( &grid.container() );
187 DUNE_THROW(InvalidStateException,
"dynamic_cast of ALUGrid builder failed");
196 #if ALU3DGRID_PARALLEL
197 template< ALU3dGr
idElementType elType >
202 typedef ALU3dGridGlobalIdSet< elType, MPI_Comm > GlobalIdSet;
205 typedef ALU3DSPACE GitterDunePll GitterImplType;
207 typedef Dune::CollectiveCommunication< MPI_Comm > CollectiveCommunication;
209 explicit ALU3dGridCommunications ( MPI_Comm comm )
210 : ccobj_( comm ), mpAccess_( comm )
213 int nlinks ()
const {
return mpAccess_.nlinks(); }
215 GitterImplType *createALUGrid (
const std::string ¯oName,
ALU3DSPACE ProjectVertex *projection,
216 const bool conformingRefinement )
218 GitterImplType* grid =
new GitterImplType( macroName.c_str(), mpAccess_, projection );
220 checkForConformingRefinement( grid, conformingRefinement );
224 GitterImplType *createALUGrid ( std::istream& stream,
ALU3DSPACE ProjectVertex *projection,
225 const bool conformingRefinement )
227 #ifdef ALUGRID_CONSTRUCTION_WITH_STREAMS
228 GitterImplType* grid =
new GitterImplType ( stream, mpAccess_, projection );
230 checkForConformingRefinement( grid, conformingRefinement );
237 static MPI_Comm defaultComm () {
return MPI_COMM_WORLD; }
239 static int getRank ( MPI_Comm comm )
242 MPI_Comm_rank( comm, &rank );
246 static typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder ( GitterImplType &grid )
248 ALU3DSPACE Gitter::Geometric::BuilderIF* builder =
249 dynamic_cast< ALU3DSPACE Gitter::Geometric::BuilderIF*
>( &grid.containerPll() );
251 DUNE_THROW(InvalidStateException,
"dynamic_cast of ALUGrid builder failed");
255 static void duneNotifyMacroGridChanges ( GitterImplType &grid )
257 grid.duneNotifyMacroGridChanges();
260 CollectiveCommunication ccobj_;
263 #endif // #if ALU3DGRID_PARALLEL
270 template< ALU3dGr
idElementType elType,
class Comm >
283 typedef typename ALU3dGridCommunications< elType, Comm >::GlobalIdSet
GlobalIdSetImp;
286 typedef typename ALU3dGridCommunications< elType, Comm >::GlobalId
GlobalIdType;
331 template< PartitionIteratorType pitype >
342 template< PartitionIteratorType pitype >
400 template< ALU3dGr
idElementType elType,
class Comm >
403 ALU3dGridFamily< elType, Comm > >,
435 friend class ALU3dGridGlobalIdSet< elType, Comm >;
436 friend class ALU3dGridLocalIdSet< elType, Comm >;
444 friend struct ALU3dGridCommHelper< elType, Comm >;
569 ALU3dGrid (
const std::string ¯oTriangFilename,
580 static inline std::string
name ();
588 template<
int cd, PartitionIteratorType pitype>
593 template<
int cd, PartitionIteratorType pitype>
595 lend (
int level)
const;
607 lend (
int level)
const;
611 template <
int codim, PartitionIteratorType pitype>
613 leafbegin(
int level)
const;
616 template <
int codim, PartitionIteratorType pitype>
618 leafend(
int level)
const;
623 leafbegin(
int level)
const;
628 leafend(
int level)
const;
644 template <
int codim, PartitionIteratorType pitype>
649 template <
int codim, PartitionIteratorType pitype>
665 template <
int codim, PartitionIteratorType pitype>
667 createLeafIteratorBegin (
int level)
const;
670 template <
int codim, PartitionIteratorType pitype>
672 createLeafIteratorEnd(
int level)
const;
676 int size (
int level,
int cd)
const;
679 int size (
int codim)
const;
745 template <
class DataHandle>
748 template<
class DataHandleImpl,
class Data >
752 LBHandle lbHandle( *
this, dataHandle );
757 int ghostSize (
int level,
int codim)
const;
769 template<
class DataHandleImp,
class DataTypeImp>
776 template<
class DataHandleImp,
class DataTypeImp>
800 template<
class Gr
idImp,
class DataHandle >
806 template<
class Gr
idImp,
class DataHandle >
814 template <GrapeIOFileFormatType ftype>
823 bool writeMacroGrid(
const std::string path,
const std::string filename )
const ;
827 template <GrapeIOFileFormatType ftype>
831 void backup( std::ostream& )
const ;
834 void restore( std::istream& ) ;
847 bool mark(
int refCount ,
const typename Traits::template Codim<0>::Entity & e);
850 int getMark(
const typename Traits::template Codim<0>::Entity & e)
const;
855 return Communications::defaultComm();
860 template<
class IntersectionType >
861 static const typename BaseType
862 :: template ReturnImplementationType< IntersectionType >
863 :: ImplementationType &
906 template <
class EntitySeed >
907 typename Traits :: template Codim< EntitySeed :: codimension >
:: EntityPointer
912 return ALUPointer(
factory(), seed ) ;
932 assert( level >= 0 );
941 assert( codim >= 1 );
942 assert( codim <= 3 );
948 assert( codim >= 1 );
949 assert( codim <= 3 );
951 assert( level >= 0 );
958 assert( level >= 0 );
968 const ThisType &
operator= (
const ThisType & );
996 assert( segmentIndex < (
int)
bndVec_->size() );
997 return (*
bndVec_)[ segmentIndex ];
1008 #ifdef USE_SMP_PARALLEL
1026 #ifdef ALUGRID_3D_CONFORMING_REFINEMENT
1027 return myGrid().ghostCellsEnabled();
1084 #ifdef USE_SMP_PARALLEL
1085 std::vector< GridObjectFactoryType > factoryVec_;
1111 const std::string filename );
1114 namespace Capabilities
1117 template< ALU3dGr
idElementType elType,
class Comm,
int cdim >
1120 static const bool v =
true;
1123 template< ALU3dGr
idElementType elType,
class Comm >
1126 static const bool v =
true;
1129 template< ALU3dGr
idElementType elType,
class Comm >
1132 static const bool v =
true;
1135 template< ALU3dGr
idElementType elType,
class Comm >
1138 static const bool v =
true;
1146 #if COMPILE_ALUGRID_INLINE
1147 #include "grid_imp.cc"