- Home
- About DUNE
- Download
- Documentation
- Community
- Development
00001 #ifndef DUNE_ALU3DGRIDGRID_HH 00002 #define DUNE_ALU3DGRIDGRID_HH 00003 00004 //- System includes 00005 #include <vector> 00006 00007 //- Dune includes 00008 #include <dune/grid/utility/grapedataioformattypes.hh> 00009 #include <dune/grid/common/capabilities.hh> 00010 #include <dune/grid/alugrid/common/interfaces.hh> 00011 #include <dune/common/bigunsignedint.hh> 00012 #include <dune/common/deprecated.hh> 00013 #include <dune/common/static_assert.hh> 00014 00015 #include <dune/grid/common/grid.hh> 00016 #include <dune/grid/common/genericreferenceelements.hh> 00017 #include <dune/grid/alugrid/common/defaultindexsets.hh> 00018 #include <dune/grid/common/sizecache.hh> 00019 #include <dune/grid/alugrid/common/intersectioniteratorwrapper.hh> 00020 #include <dune/grid/common/datahandleif.hh> 00021 #include <dune/grid/common/defaultgridview.hh> 00022 00023 // bnd projection stuff 00024 #include <dune/grid/common/boundaryprojection.hh> 00025 #include <dune/grid/alugrid/common/bndprojection.hh> 00026 #include <dune/grid/alugrid/common/objectfactory.hh> 00027 00028 //- Local includes 00029 #include "alu3dinclude.hh" 00030 #include "topology.hh" 00031 #include "indexsets.hh" 00032 #include "datahandle.hh" 00033 00034 #include <dune/grid/alugrid/3d/lbdatahandle.hh> 00035 00036 #include <dune/common/mpihelper.hh> 00037 00038 #if ALU3DGRID_PARALLEL 00039 #include <dune/common/mpicollectivecommunication.hh> 00040 #else 00041 #include <dune/common/collectivecommunication.hh> 00042 #endif 00043 00044 namespace Dune 00045 { 00046 00047 // Forward declarations 00048 template<int cd, int dim, class GridImp> 00049 class ALU3dGridEntity; 00050 template<int cd, PartitionIteratorType pitype, class GridImp > 00051 class ALU3dGridLevelIterator; 00052 template<int cd, class GridImp > 00053 class ALU3dGridEntityPointerBase; 00054 template<int cd, class GridImp > 00055 class ALU3dGridEntitySeed; 00056 template<int cd, class GridImp > 00057 class ALU3dGridEntityPointer; 00058 template<int mydim, int coorddim, class GridImp> 00059 class ALU3dGridGeometry; 00060 template<class GridImp> 00061 class ALU3dGridHierarchicIterator; 00062 template<class GridImp> 00063 class ALU3dGridIntersectionIterator; 00064 template<class GridImp> 00065 class ALU3dGridLevelIntersectionIterator; 00066 template<int codim, PartitionIteratorType pitype, class GridImp> 00067 class ALU3dGridLeafIterator; 00068 template <int mydim, int coorddim, class GridImp> 00069 class ALU3dGridMakeableEntity; 00070 template <class GridImp> 00071 class ALU3dGridFaceGeometryInfo; 00072 template< ALU3dGridElementType, class > 00073 class ALU3dGridGlobalIdSet; 00074 template< ALU3dGridElementType, class > 00075 class ALU3dGridLocalIdSet; 00076 template< ALU3dGridElementType, class > 00077 class ALU3dGridHierarchicIndexSet; 00078 template <class EntityImp> 00079 class ALUMemoryProvider; 00080 template< class > 00081 class ALU3dGridFactory; 00082 template <class GridImp, class GeometryImp, int nChild> 00083 class ALULocalGeometryStorage; 00084 template< ALU3dGridElementType elType, class Comm > 00085 struct ALU3dGridCommHelper; 00086 00087 00088 00089 // Internal Forward Declarations 00090 // ----------------------------- 00091 00092 #if ALU3DGRID_PARALLEL 00093 template< ALU3dGridElementType elType, class Comm = MPI_Comm > 00094 class ALU3dGrid; 00095 #else // #if ALU3DGRID_PARALLEL 00096 template< ALU3dGridElementType elType, class Comm = No_Comm > 00097 class ALU3dGrid; 00098 #endif // #else // #if ALU3DGRID_PARALLEL 00099 00100 00101 // ALU3dGridCommunications 00102 // ----------------------- 00103 00104 template< ALU3dGridElementType elType, class Comm > 00105 struct ALU3dGridCommunications; 00106 00107 template< ALU3dGridElementType elType > 00108 struct ALU3dGridCommunications< elType, No_Comm > 00109 { 00110 typedef ALU3dGridLocalIdSet< elType, No_Comm > GlobalIdSet; 00111 typedef int GlobalId; 00112 00113 typedef ALU3DSPACE GitterDuneImpl GitterImplType; 00114 00115 typedef Dune::CollectiveCommunication< No_Comm > CollectiveCommunication; 00116 00117 explicit ALU3dGridCommunications ( No_Comm comm ) {} 00118 00119 int nlinks () const { return 0; } 00120 00121 GitterImplType *createALUGrid ( const std::string ¯oName, ALU3DSPACE ProjectVertex *projection ) 00122 { 00123 if( macroName.empty() ) 00124 return new GitterImplType(); 00125 else 00126 return new GitterImplType ( macroName.c_str(), projection ); 00127 } 00128 00129 static No_Comm defaultComm () { return No_Comm(); } 00130 00131 static int getRank ( No_Comm comm ) { return 0; } 00132 00133 static typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder ( GitterImplType &grid ) 00134 { 00135 return dynamic_cast< ALU3DSPACE Gitter::Geometric::BuilderIF & >( grid.container() ); 00136 } 00137 00138 static void duneNotifyMacroGridChanges ( GitterImplType &gird ) {} 00139 00140 CollectiveCommunication ccobj_; 00141 }; 00142 00143 #if ALU3DGRID_PARALLEL 00144 template< ALU3dGridElementType elType > 00145 struct ALU3dGridCommunications< elType, MPI_Comm > 00146 { 00147 typedef ALU3dGridGlobalIdSet< elType, MPI_Comm > GlobalIdSet; 00148 typedef ALUGridId< ALUMacroKey > GlobalId; 00149 00150 typedef ALU3DSPACE GitterDunePll GitterImplType; 00151 00152 typedef Dune::CollectiveCommunication< MPI_Comm > CollectiveCommunication; 00153 00154 explicit ALU3dGridCommunications ( MPI_Comm comm ) 00155 : ccobj_( comm ), mpAccess_( comm ) 00156 {} 00157 00158 int nlinks () const { return mpAccess_.nlinks(); } 00159 00160 GitterImplType *createALUGrid ( const std::string ¯oName, ALU3DSPACE ProjectVertex *projection ) 00161 { 00162 return new GitterImplType( macroName.c_str(), mpAccess_, projection ); 00163 } 00164 00165 static MPI_Comm defaultComm () { return MPI_COMM_WORLD; } 00166 00167 static int getRank ( MPI_Comm comm ) 00168 { 00169 int rank = 0; 00170 MPI_Comm_rank( comm, &rank ); 00171 return rank; 00172 } 00173 00174 static typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder ( GitterImplType &grid ) 00175 { 00176 return dynamic_cast< ALU3DSPACE Gitter::Geometric::BuilderIF & >( grid.containerPll() ); 00177 } 00178 00179 static void duneNotifyMacroGridChanges ( GitterImplType &grid ) 00180 { 00181 grid.duneNotifyMacroGridChanges(); 00182 } 00183 00184 CollectiveCommunication ccobj_; 00185 ALU3DSPACE MpAccessMPI mpAccess_; 00186 }; 00187 #endif // #if ALU3DGRID_PARALLEL 00188 00189 00190 00191 // ALU3dGridFamily 00192 // --------------- 00193 00194 template< ALU3dGridElementType elType, class Comm > 00195 struct ALU3dGridFamily 00196 { 00197 typedef ALU3dGrid< elType, Comm > GridImp; 00198 typedef ALU3dGridFamily< elType, Comm > GridFamily; 00199 00200 static const int dim = 3; 00201 static const int dimworld = 3; 00202 00204 typedef ALU3dGridLocalIdSet< elType, Comm > LocalIdSetImp; 00205 00207 typedef typename ALU3dGridCommunications< elType, Comm >::GlobalIdSet GlobalIdSetImp; 00208 00210 typedef DefaultLevelIndexSet< GridImp > LevelIndexSetImp; 00212 typedef DefaultLeafIndexSet< GridImp > LeafIndexSetImp; 00213 00215 typedef typename ALU3dGridCommunications< elType, Comm >::GlobalId GlobalIdType; 00216 00218 typedef int LocalIdType; 00219 00220 struct Traits 00221 { 00223 typedef typename GridFamily::LocalIdType LocalIdType; 00224 00226 typedef typename GridFamily::GlobalIdType GlobalIdType; 00227 00228 typedef typename GridFamily::GridImp Grid; 00229 00230 typedef Dune::Intersection< const Grid, LeafIntersectionWrapper > LeafIntersection; 00231 typedef Dune::Intersection< const Grid, LevelIntersectionWrapper > LevelIntersection; 00232 00233 typedef Dune::IntersectionIterator< const Grid, LeafIntersectionIteratorWrapper, LeafIntersectionWrapper > IntersectionIterator; 00234 00235 typedef Dune::IntersectionIterator< const Grid, LeafIntersectionIteratorWrapper, LeafIntersectionWrapper > LeafIntersectionIterator; 00236 typedef Dune::IntersectionIterator< const Grid, LevelIntersectionIteratorWrapper, LevelIntersectionWrapper > LevelIntersectionIterator; 00237 00238 typedef Dune::EntityIterator< 0, const Grid, ALU3dGridHierarchicIterator< const Grid > > HierarchicIterator; 00239 00240 typedef DuneBoundaryProjection< dimworld > DuneBoundaryProjectionType; 00241 typedef std::vector< const DuneBoundaryProjectionType * > DuneBoundaryProjectionVector; 00242 00243 template< int cd > 00244 struct Codim 00245 { 00246 // IMPORTANT: Codim<codim>::Geometry == Geometry<dim-codim,dimw> 00247 typedef Dune::Geometry< dim-cd, dimworld, const Grid, ALU3dGridGeometry > Geometry; 00248 typedef Dune::Geometry< dim-cd, dim, const Grid, ALU3dGridGeometry > LocalGeometry; 00249 // we could - if needed - introduce an other struct for dimglobal of Geometry 00250 00251 typedef Dune::Entity< cd, dim, const Grid, ALU3dGridEntity > Entity; 00252 00253 // minimal information to generate entities 00254 typedef ALU3dGridEntitySeed< cd , const Grid> EntitySeed ; 00255 00256 typedef ALU3dGridEntityPointer< cd, const Grid > EntityPointerImpl; 00257 typedef Dune::EntityPointer< const Grid, EntityPointerImpl > EntityPointer; 00258 00259 template< PartitionIteratorType pitype > 00260 struct Partition 00261 { 00262 typedef Dune::EntityIterator< cd, const Grid, ALU3dGridLevelIterator< cd, pitype, const Grid > > LevelIterator; 00263 typedef Dune::EntityIterator< cd, const Grid, ALU3dGridLeafIterator< cd, pitype, const Grid > > LeafIterator; 00264 }; // struct Partition 00265 00266 typedef typename Partition< All_Partition >::LevelIterator LevelIterator; 00267 typedef typename Partition< All_Partition >::LeafIterator LeafIterator; 00268 }; // struct Codim 00269 00270 template< PartitionIteratorType pitype > 00271 struct Partition 00272 { 00273 typedef Dune::GridView<DefaultLevelGridViewTraits< const Grid, pitype > > LevelGridView; 00274 typedef Dune::GridView<DefaultLeafGridViewTraits< const Grid, pitype > > LeafGridView; 00275 }; // struct Partition 00276 00277 typedef IndexSet< Grid, LevelIndexSetImp > LevelIndexSet; 00278 typedef IndexSet< Grid, LeafIndexSetImp > LeafIndexSet; 00279 typedef IdSet< Grid, LocalIdSetImp, LocalIdType > LocalIdSet; 00280 typedef IdSet< Grid, GlobalIdSetImp, GlobalIdType > GlobalIdSet; 00281 00282 typedef Dune::CollectiveCommunication< Comm > CollectiveCommunication; 00283 }; // struct Traits 00284 }; // struct ALU3dGridFamily 00285 00286 00287 00288 //********************************************************************** 00289 // 00290 // --ALU3dGrid 00291 // --Grid 00292 // 00293 //********************************************************************** 00294 00315 template< ALU3dGridElementType elType, class Comm > 00316 class ALU3dGrid 00317 : public GridDefaultImplementation< 3, 3, alu3d_ctype, ALU3dGridFamily< elType, Comm > >, 00318 public HasObjectStream, 00319 public HasHierarchicIndexSet 00320 { 00321 typedef ALU3dGrid< elType, Comm > ThisType; 00322 typedef GridDefaultImplementation< 3, 3, alu3d_ctype, ALU3dGridFamily< elType, Comm > > BaseType; 00323 00324 // for compatibility: MyType := ThisType 00325 typedef ThisType MyType; 00326 00327 // friend declarations 00328 friend class ALU3dGridEntity< 0, 3, const ThisType>; 00329 friend class ALU3dGridEntity< 1, 3, const ThisType>; 00330 friend class ALU3dGridEntity< 2, 3, const ThisType>; 00331 friend class ALU3dGridEntity< 3, 3, const ThisType>; 00332 00333 friend class ALU3dGridIntersectionIterator< ThisType >; 00334 00335 friend class ALU3dGridEntityPointerBase< 0, const ThisType >; 00336 friend class ALU3dGridEntityPointerBase< 1, const ThisType >; 00337 friend class ALU3dGridEntityPointerBase< 2, const ThisType >; 00338 friend class ALU3dGridEntityPointerBase< 3, const ThisType >; 00339 00340 friend class ALU3dGridEntityPointer< 0, const ThisType >; 00341 friend class ALU3dGridEntityPointer< 1, const ThisType >; 00342 friend class ALU3dGridEntityPointer< 2, const ThisType >; 00343 friend class ALU3dGridEntityPointer< 3, const ThisType >; 00344 00345 friend class ALU3dGridIntersectionIterator< const ThisType >; 00346 friend class ALU3dGridHierarchicIterator< const ThisType >; 00347 00348 friend class ALU3dGridHierarchicIndexSet< elType, Comm >; 00349 friend class ALU3dGridGlobalIdSet< elType, Comm >; 00350 friend class ALU3dGridLocalIdSet< elType, Comm >; 00351 00352 friend class Conversion< ThisType, HasObjectStream >; 00353 friend class Conversion< const ThisType, HasObjectStream >; 00354 00355 friend class Conversion< ThisType, HasHierarchicIndexSet >; 00356 friend class Conversion< const ThisType, HasHierarchicIndexSet >; 00357 00358 friend class ALU3dGridCommHelper< elType, Comm >; 00359 00360 // new intersection iterator is a wrapper which get itersectioniteratoimp as pointers 00361 public: 00362 typedef ALU3dGridIntersectionIterator<const ThisType> 00363 IntersectionIteratorImp; 00364 typedef ALU3dGridIntersectionIterator<const ThisType> 00365 LeafIntersectionIteratorImp; 00366 typedef ALU3dGridLevelIntersectionIterator<const ThisType> 00367 LevelIntersectionIteratorImp; 00368 00369 friend class IntersectionIteratorWrapper < const ThisType, LeafIntersectionIteratorImp > ; 00370 friend class IntersectionIteratorWrapper < const ThisType, LevelIntersectionIteratorImp > ; 00371 friend class LeafIntersectionIteratorWrapper < const ThisType > ; 00372 friend class LevelIntersectionIteratorWrapper< const ThisType > ; 00373 00374 //********************************************************** 00375 // The Interface Methods 00376 //********************************************************** 00377 public: 00378 enum { refineStepsForHalf = 1 }; 00379 00380 static const ALU3dGridElementType elementType = elType; 00381 typedef typename ALU3DSPACE GatherScatterType::ObjectStreamType ObjectStreamType; 00382 00383 typedef ALU3dGridFamily< elType, Comm > GridFamily; 00384 typedef typename GridFamily::Traits Traits; 00385 00386 static const int dimension = BaseType::dimension; 00387 static const int dimensionworld = BaseType::dimensionworld; 00388 00389 protected: 00390 typedef MakeableInterfaceObject< typename Traits::template Codim< 0 >::Geometry > GeometryObject; 00391 friend class ALULocalGeometryStorage< const ThisType, GeometryObject, 8 >; 00392 00393 public: 00395 typedef ALU3dGridHierarchicIndexSet< elType, Comm > HierarchicIndexSet; 00396 00398 typedef typename GridFamily::LevelIndexSetImp LevelIndexSetImp; 00400 typedef typename GridFamily::LeafIndexSetImp LeafIndexSetImp; 00401 00403 typedef GenericReferenceElement< alu3d_ctype, dimension > ReferenceElementType; 00404 00406 typedef typename Traits::DuneBoundaryProjectionType DuneBoundaryProjectionType; 00408 typedef typename Traits::DuneBoundaryProjectionVector DuneBoundaryProjectionVector; 00409 00411 typedef ALU3DSPACE ProjectVertex ALUGridVertexProjectionType; 00412 00414 typedef typename Traits::CollectiveCommunication CollectiveCommunication; 00415 00416 public: 00417 typedef MakeableInterfaceObject<typename Traits::template Codim<0>::Entity> EntityObject; 00418 typedef MakeableInterfaceObject<typename Traits::template Codim<1>::Entity> FaceObject; 00419 typedef MakeableInterfaceObject<typename Traits::template Codim<2>::Entity> EdgeObject; 00420 typedef MakeableInterfaceObject<typename Traits::template Codim<3>::Entity> VertexObject; 00421 00422 typedef ALUGridObjectFactory< ThisType > GridObjectFactoryType; 00423 00424 protected: 00425 friend class ALUGridBoundaryProjection< ThisType, alu3d_ctype >; 00426 // type of ALUGrid boundary projection wrapper 00427 typedef ALUGridBoundaryProjection< ThisType, alu3d_ctype > ALUGridBoundaryProjectionType; 00428 00430 typedef typename GridFamily::LocalIdSetImp LocalIdSetImp; 00431 00433 typedef typename GridFamily::GlobalIdSetImp GlobalIdSetImp; 00434 00436 typedef typename Traits::GlobalIdSet GlobalIdSet; 00437 00439 typedef typename Traits::LocalIdSet LocalIdSet; 00440 00442 typedef ALU3dGridLeafIterator< 0, All_Partition, const ThisType > LeafIteratorImp; 00443 typedef typename Traits::template Codim< 0 >::LeafIterator LeafIteratorType; 00444 typedef typename Traits::template Codim< 0 >::LeafIterator LeafIterator; 00445 00446 typedef ALU3dGridHierarchicIterator< const ThisType > HierarchicIteratorImp; 00447 00448 typedef typename ALU3dImplTraits< elType, Comm >::GitterImplType GitterImplType; 00449 00451 enum { 00453 MAXL = 32 }; 00454 00456 enum { 00458 newElementsChunk_ = 128 }; 00459 00461 enum { 00465 refineEstimate_ = 8 }; 00466 00467 public: 00468 typedef Comm MPICommunicatorType; 00469 00470 typedef ALU3dGridCommunications< elType, Comm > Communications; 00471 00472 protected: 00473 typedef ALU3dGridVertexList< Comm > VertexListType; 00474 typedef ALU3dGridLeafVertexList< Comm > LeafVertexListType; 00475 00478 ALU3dGrid ( const std::string ¯oTriangFilename, 00479 const MPICommunicatorType mpiComm, 00480 const DuneBoundaryProjectionType *bndPrj, 00481 const DuneBoundaryProjectionVector *bndVec ); 00482 00483 public: 00485 virtual ~ALU3dGrid(); 00486 00488 static inline std::string name (); 00489 00493 int maxLevel() const; 00494 00496 template<int cd, PartitionIteratorType pitype> 00497 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator 00498 lbegin (int level) const; 00499 00501 template<int cd, PartitionIteratorType pitype> 00502 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator 00503 lend (int level) const; 00504 00506 template<int cd> 00507 typename Traits::template Codim<cd>:: 00508 template Partition<All_Partition>::LevelIterator 00509 lbegin (int level) const; 00510 00512 template<int cd> 00513 typename Traits::template Codim<cd>:: 00514 template Partition<All_Partition>::LevelIterator 00515 lend (int level) const; 00516 00517 private: 00519 template <int codim, PartitionIteratorType pitype> 00520 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 00521 leafbegin(int level) const; 00522 00524 template <int codim, PartitionIteratorType pitype> 00525 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 00526 leafend(int level) const; 00527 00529 template <int codim> 00530 typename Traits::template Codim<codim>::LeafIterator 00531 leafbegin(int level) const; 00532 00534 template <int codim> 00535 typename Traits::template Codim<codim>::LeafIterator 00536 leafend(int level) const; 00537 00539 LeafIteratorType leafbegin (int level) const; 00540 00542 LeafIteratorType leafend (int level) const; 00543 00545 LeafIteratorType leafbegin () const; 00546 00548 LeafIteratorType leafend () const; 00549 00550 public: 00552 template <int codim, PartitionIteratorType pitype> 00553 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 00554 leafbegin() const; 00555 00557 template <int codim, PartitionIteratorType pitype> 00558 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 00559 leafend() const; 00560 00562 template <int codim> 00563 typename Traits::template Codim<codim>::LeafIterator 00564 leafbegin() const; 00565 00567 template <int codim> 00568 typename Traits::template Codim<codim>::LeafIterator 00569 leafend() const; 00570 00571 private: 00573 template <int codim, PartitionIteratorType pitype> 00574 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 00575 createLeafIteratorBegin (int level) const; 00576 00578 template <int codim, PartitionIteratorType pitype> 00579 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator 00580 createLeafIteratorEnd(int level) const; 00581 00582 public: 00584 int size (int level, int cd) const; 00585 00587 int size (int codim) const; 00588 00590 int size (int level, GeometryType type) const; 00591 00593 size_t numBoundarySegments() const; 00594 00596 int size (GeometryType type) const; 00597 00599 int global_size (int cd) const ; 00600 00601 // (no interface method) number of grid entities in the entire grid for given codim 00602 int hierSetSize (int cd) const; 00603 00605 const GlobalIdSet &globalIdSet () const 00606 { 00607 if( !globalIdSet_ ) 00608 globalIdSet_ = new GlobalIdSetImp( *this ); 00609 return *globalIdSet_; 00610 } 00611 00613 const LocalIdSet & localIdSet () const { return localIdSet_; } 00614 00616 const typename Traits :: LeafIndexSet & leafIndexSet () const; 00617 00619 const typename Traits :: LevelIndexSet & levelIndexSet (int level) const; 00620 00625 bool loadBalance (); 00626 00653 template <class DataHandle> 00654 bool loadBalance (DataHandle & data); 00655 00656 template< class DataHandleImpl, class Data > 00657 bool loadBalance ( CommDataHandleIF< DataHandleImpl, Data > &dataHandle ) 00658 { 00659 typedef ALUGridLoadBalanceDataHandle< ThisType, DataHandleImpl, Data > LBHandle; 00660 LBHandle lbHandle( *this, dataHandle ); 00661 return loadBalance( lbHandle ); 00662 } 00663 00665 int ghostSize (int level, int codim) const; 00666 00668 int overlapSize (int level, int codim) const { return 0; } 00669 00671 int ghostSize (int codim) const; 00672 00674 int overlapSize (int codim) const { return 0; } 00675 00677 template<class DataHandleImp,class DataTypeImp> 00678 void communicate (CommDataHandleIF<DataHandleImp,DataTypeImp> & data, 00679 InterfaceType iftype, CommunicationDirection dir, int level) const; 00680 00684 template<class DataHandleImp,class DataTypeImp> 00685 void communicate (CommDataHandleIF<DataHandleImp,DataTypeImp> & data, 00686 InterfaceType iftype, CommunicationDirection dir) const; 00687 00688 private: 00689 typedef ALU3DSPACE GatherScatter GatherScatterType; 00690 00691 public: 00693 const CollectiveCommunication &comm () const { return communications().ccobj_; } 00694 00696 bool preAdapt ( ); 00697 00699 void postAdapt ( ); 00700 00702 bool adapt (); 00703 00708 template< class GridImp, class DataHandle > 00709 bool adapt ( AdaptDataHandleInterface< GridImp, DataHandle > &handle ); 00710 00712 void globalRefine ( int refCount ); 00713 00714 template< class GridImp, class DataHandle > 00715 void globalRefine ( int refCount, AdaptDataHandleInterface< GridImp, DataHandle > &handle ); 00716 00717 //********************************************************** 00718 // End of Interface Methods 00719 //********************************************************** 00722 template <GrapeIOFileFormatType ftype> 00723 bool writeGrid( const std::string filename, alu3d_ctype time ) const ; 00724 00725 bool writeGrid_Xdr( const std::string filename, alu3d_ctype time ) const ; 00727 bool writeGrid_Ascii( const std::string filename, alu3d_ctype time, bool scientific = false ) const ; 00728 00731 bool writeMacroGrid( const std::string path, const std::string filename ) const ; 00732 00735 template <GrapeIOFileFormatType ftype> 00736 bool readGrid( const std::string filename, alu3d_ctype & time ); 00737 00738 // (no interface method) get hierarchic index set of the grid 00739 const HierarchicIndexSet & hierarchicIndexSet () const { return hIndexSet_; } 00740 00741 // set max of given mxl and actual maxLevel 00742 // for loadBalance 00743 void setMaxLevel (int mxl); 00744 00745 // no interface method, but has to be public 00746 void updateStatus (); 00747 00749 bool mark( int refCount , const typename Traits::template Codim<0>::Entity & e); 00750 00752 int getMark( const typename Traits::template Codim<0>::Entity & e) const; 00753 00754 public: 00755 static MPICommunicatorType defaultCommunicator () 00756 { 00757 return Communications::defaultComm(); 00758 } 00759 00760 template< class IntersectionInterfaceType > 00761 const typename BaseType 00762 :: template ReturnImplementationType< IntersectionInterfaceType > 00763 :: ImplementationType & DUNE_DEPRECATED 00764 getRealIntersectionIterator ( const IntersectionInterfaceType &it ) const 00765 { 00766 return this->getRealImplementation(it); 00767 } 00768 00769 template< class IntersectionType > 00770 const typename BaseType 00771 :: template ReturnImplementationType< IntersectionType > 00772 :: ImplementationType & 00773 getRealIntersection ( const IntersectionType &intersection ) const 00774 { 00775 return this->getRealImplementation( intersection ); 00776 } 00777 00779 const std::vector<GeometryType>& geomTypes (int codim) const { return geomTypes_[codim]; } 00780 00781 // return reference to org ALU3dGrid 00782 // private method, but otherwise we have to friend class all possible 00783 // types of LevelIterator ==> later 00784 GitterImplType &myGrid () const; 00785 00786 virtual GitterImplType *createALUGrid ( const std::string ¯oName ) 00787 { 00788 return communications_->createALUGrid( macroName, vertexProjection() ); 00789 } 00790 00791 ALUGridVertexProjectionType* vertexProjection() { return (ALUGridVertexProjectionType *) vertexProjection_; } 00792 00793 // return appropriate ALUGrid builder 00794 virtual typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder () const 00795 { 00796 return Communications::getBuilder( myGrid() ); 00797 } 00798 00799 // helper function for factory 00800 virtual void duneNotifyMacroGridChanges () 00801 { 00802 Communications::duneNotifyMacroGridChanges( myGrid() ); 00803 } 00804 00806 const ReferenceElementType & referenceElement() const { return referenceElement_; } 00807 00808 template < class EntitySeed > 00809 typename Traits :: template Codim< EntitySeed :: codimension > :: EntityPointer 00810 entityPointer( const EntitySeed& seed ) const 00811 { 00812 enum { codim = EntitySeed :: codimension }; 00813 typedef typename Traits :: template Codim< codim > :: EntityPointer EntityPointer; 00814 typedef ALU3dGridEntityPointer < codim, const ThisType > ALUPointer ; 00815 return ALUPointer( factory(), seed ) ; 00816 } 00817 00818 // number of links to other processors, for internal use only 00819 int nlinks () const { return communications().nlinks(); } 00820 00821 LeafVertexListType & getLeafVertexList() const 00822 { 00823 if( !leafVertexList_.up2Date() ) leafVertexList_.setupVxList(*this); 00824 return leafVertexList_; 00825 } 00826 00827 int getLevelOfLeafVertex ( const typename ALU3dImplTraits< elType, Comm >::VertexType &vertex ) const 00828 { 00829 assert( leafVertexList_.up2Date() ); 00830 return leafVertexList_.getLevel(vertex); 00831 } 00832 00833 VertexListType & getVertexList(int level) const 00834 { 00835 assert( level >= 0 ); 00836 assert( level <= maxLevel() ); 00837 VertexListType & vxList = vertexList_[level]; 00838 if(!vxList.up2Date()) vxList.setupVxList(*this,level); 00839 return vxList; 00840 } 00841 00842 ALU3dGridItemListType & getGhostLeafList(int codim) const 00843 { 00844 assert( codim >= 1 ); 00845 assert( codim <= 3 ); 00846 return ghostLeafList_[codim-1]; 00847 } 00848 00849 ALU3dGridItemListType & getGhostLevelList(int codim, int level) const 00850 { 00851 assert( codim >= 1 ); 00852 assert( codim <= 3 ); 00853 00854 assert( level >= 0 ); 00855 assert( level <= maxLevel() ); 00856 return ghostLevelList_[codim-1][level]; 00857 } 00858 00859 ALU3dGridItemListType & getEdgeList(int level) const 00860 { 00861 assert( level >= 0 ); 00862 assert( level <= maxLevel() ); 00863 return levelEdgeList_[level]; 00864 } 00865 00866 protected: 00868 ALU3dGrid( const ThisType & ); 00869 00871 const ThisType &operator= ( const ThisType & ); 00872 00874 void calcExtras(); 00875 00877 void calcMaxLevel(); 00878 00880 void recalcGlobalSize(); 00881 00883 void checkMacroGridFile (const std::string filename); 00884 00886 void checkMacroGrid (); 00887 00889 const DuneBoundaryProjectionType* boundaryProjection(const int segmentIndex) const 00890 { 00891 if( bndPrj_ ) 00892 { 00893 return bndPrj_; 00894 } 00895 else 00896 { 00897 // pointer can be zero (which is emulates the identity mapping then) 00898 assert( bndVec_ ); 00899 assert( segmentIndex < (int) bndVec_->size() ); 00900 return (*bndVec_)[ segmentIndex ]; 00901 } 00902 } 00903 00904 const Communications &communications () const 00905 { 00906 assert( communications_ ); 00907 return *communications_; 00908 } 00909 00910 const GridObjectFactoryType& factory() const { 00911 #ifdef USE_SMP_PARALLEL 00912 assert( (int) factoryVec_.size() > GridObjectFactoryType :: threadNumber() ); 00913 return factoryVec_[ GridObjectFactoryType :: threadNumber() ]; 00914 #else 00915 return factory_; 00916 #endif 00917 } 00918 protected: 00920 // 00921 // Internal variables 00922 // 00924 00925 // the real ALU grid 00926 mutable GitterImplType *mygrid_; 00927 00928 // max level of grid 00929 int maxlevel_; 00930 00931 // count how much elements where marked 00932 mutable int coarsenMarked_; 00933 mutable int refineMarked_; 00934 00935 // at the moment the number of different geom types is 1 00936 enum { numberOfGeomTypes = 1 }; 00937 std::vector< std::vector<GeometryType> > geomTypes_; 00938 00939 // our hierarchic index set 00940 HierarchicIndexSet hIndexSet_; 00941 00942 // out global id set 00943 mutable GlobalIdSetImp *globalIdSet_; 00944 00945 // out global id set 00946 LocalIdSetImp localIdSet_; 00947 00948 // the level index set ( default type ) 00949 mutable std::vector < LevelIndexSetImp * > levelIndexVec_; 00950 00951 // the leaf index set 00952 mutable LeafIndexSetImp * leafIndexSet_; 00953 00954 // the reference element 00955 const ReferenceElementType& referenceElement_; 00956 00957 mutable VertexListType vertexList_[MAXL]; 00958 00959 mutable ALU3dGridItemListType ghostLeafList_[ dimension ]; 00960 mutable ALU3dGridItemListType ghostLevelList_[ dimension ][MAXL]; 00961 00962 mutable ALU3dGridItemListType levelEdgeList_[MAXL]; 00963 00964 mutable LeafVertexListType leafVertexList_; 00965 00966 // the type of our size cache 00967 typedef SingleTypeSizeCache<MyType> SizeCacheType; 00968 SizeCacheType * sizeCache_; 00969 00970 #ifdef USE_SMP_PARALLEL 00971 std::vector< GridObjectFactoryType > factoryVec_; 00972 #else 00973 GridObjectFactoryType factory_; 00974 #endif 00975 00976 // variable to ensure that postAdapt ist called after adapt 00977 bool lockPostAdapt_; 00978 00979 // pointer to Dune boundary projection 00980 const DuneBoundaryProjectionType* bndPrj_; 00981 00982 // pointer to Dune boundary projection 00983 const DuneBoundaryProjectionVector* bndVec_; 00984 00985 // boundary projection for vertices 00986 ALUGridBoundaryProjectionType* vertexProjection_ ; 00987 00988 // pointer to communications object 00989 Communications *communications_; 00990 }; // end class ALU3dGrid 00991 00992 00993 bool checkMacroGrid ( ALU3dGridElementType elType , 00994 const std::string filename ); 00995 const char* elType2Name( ALU3dGridElementType elType ); 00996 00997 namespace Capabilities 00998 { 00999 01000 template< ALU3dGridElementType elType, class Comm, int cdim > 01001 struct hasEntity< Dune::ALU3dGrid< elType, Comm >, cdim > 01002 { 01003 static const bool v = true; 01004 }; 01005 01006 template< ALU3dGridElementType elType, class Comm > 01007 struct isParallel< ALU3dGrid< elType, Comm > > 01008 { 01009 static const bool v = true; 01010 }; 01011 01012 template< ALU3dGridElementType elType, class Comm > 01013 struct isLevelwiseConforming< ALU3dGrid< elType, Comm > > 01014 { 01015 static const bool v = true; 01016 }; 01017 01018 template< ALU3dGridElementType elType, class Comm > 01019 struct hasBackupRestoreFacilities< ALU3dGrid< elType, Comm > > 01020 { 01021 static const bool v = true; 01022 }; 01023 01024 } // end namespace Capabilities 01025 01026 } // end namespace Dune 01027 01028 #include "grid_inline.hh" 01029 #if COMPILE_ALUGRID_INLINE 01030 #include "grid_imp.cc" 01031 #endif 01032 #endif
Generated on Fri Apr 29 2011 with Doxygen (ver 1.7.1) [doxygen-log,error-log].