Dune Core Modules (2.4.1)

grid.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_ALU3DGRIDGRID_HH
4#define DUNE_ALU3DGRIDGRID_HH
5
6//- System includes
7#include <vector>
8
9//- Dune includes
10#include <dune/grid/utility/grapedataioformattypes.hh>
15
16#include <dune/geometry/referenceelements.hh>
17
23#include <dune/grid/common/defaultgridview.hh>
24
25// bnd projection stuff
26#include <dune/grid/common/boundaryprojection.hh>
27#include <dune/grid/alugrid/common/bndprojection.hh>
28#include <dune/grid/alugrid/common/objectfactory.hh>
29#include <dune/grid/alugrid/common/backuprestore.hh>
30
31//- Local includes
32#include "alu3dinclude.hh"
33#include "topology.hh"
34#include "indexsets.hh"
35#include "datahandle.hh"
36
37#include <dune/grid/alugrid/3d/lbdatahandle.hh>
38
40
41#if ALU3DGRID_PARALLEL
43#else
45#endif
46
47namespace Dune
48{
49
50 // Forward declarations
51 template<int cd, int dim, class GridImp>
52 class ALU3dGridEntity;
53 template<int cd, PartitionIteratorType pitype, class GridImp >
54 class ALU3dGridLevelIterator;
55 template<int cd, class GridImp >
56 class ALU3dGridEntityPointerBase;
57 template<int cd, class GridImp >
58 class ALU3dGridEntitySeed;
59 template<int cd, class GridImp >
60 class ALU3dGridEntityPointer;
61 template<int mydim, int coorddim, class GridImp>
62 class ALU3dGridGeometry;
63 template<class GridImp>
64 class ALU3dGridHierarchicIterator;
65 template<class GridImp>
66 class ALU3dGridIntersectionIterator;
67 template<class GridImp>
68 class ALU3dGridLevelIntersectionIterator;
69 template<int codim, PartitionIteratorType pitype, class GridImp>
70 class ALU3dGridLeafIterator;
71 template <int mydim, int coorddim, class GridImp>
72 class ALU3dGridMakeableEntity;
73 template <class GridImp>
74 class ALU3dGridFaceGeometryInfo;
75 template< ALU3dGridElementType, class >
76 class ALU3dGridGlobalIdSet;
77 template< ALU3dGridElementType, class >
78 class ALU3dGridLocalIdSet;
79 template< ALU3dGridElementType, class >
80 class ALU3dGridHierarchicIndexSet;
81 template <class EntityImp>
82 class ALUMemoryProvider;
83 template< class >
84 class ALU3dGridFactory;
85 template <class GridImp, class GeometryImp, int nChild>
86 class ALULocalGeometryStorage;
87 template< ALU3dGridElementType elType, class Comm >
88 struct ALU3dGridCommHelper;
89
90
91
92 // Internal Forward Declarations
93 // -----------------------------
94
95#if ALU3DGRID_PARALLEL
96 template< ALU3dGridElementType elType, class Comm = MPI_Comm >
97 class ALU3dGrid;
98#else // #if ALU3DGRID_PARALLEL
99 template< ALU3dGridElementType elType, class Comm = No_Comm >
100 class ALU3dGrid;
101#endif // #else // #if ALU3DGRID_PARALLEL
102
103 template < class Comm >
104 struct ALUGridBaseGrid< 3, 3, cube, Comm >
105 {
106 typedef ALU3dGrid< hexa, Comm > BaseGrid ;
107 };
108
109 template < class Comm>
110 struct ALUGridBaseGrid< 3, 3, simplex, Comm >
111 {
112 typedef ALU3dGrid< tetra, Comm > BaseGrid ;
113 };
114
115
116
117 // ALU3dGridCommunications
118 // -----------------------
119 struct ALU3dGridCommunicationsBase
120 {
121 template < class GitterImpl >
122 void checkForConformingRefinement( GitterImpl* grid,
123 const bool conformingRefinement )
124 {
125#ifdef ALUGRID_3D_CONFORMING_REFINEMENT
126 if( grid && conformingRefinement )
127 {
128 grid->enableConformingClosure();
129 grid->disableGhostCells();
130 }
131#endif
132 }
133 };
134
135
136 template< ALU3dGridElementType elType, class Comm >
137 struct ALU3dGridCommunications;
138
139 template< ALU3dGridElementType elType >
140 struct ALU3dGridCommunications< elType, No_Comm > : public ALU3dGridCommunicationsBase
141 {
142 using ALU3dGridCommunicationsBase :: checkForConformingRefinement ;
143
144 typedef ALU3dGridLocalIdSet< elType, No_Comm > GlobalIdSet;
145 typedef int GlobalId;
146
147 typedef ALU3DSPACE GitterDuneImpl GitterImplType;
148
149 typedef Dune::CollectiveCommunication< No_Comm > CollectiveCommunication;
150
151 explicit ALU3dGridCommunications ( No_Comm comm ) {}
152
153 int nlinks () const { return 0; }
154
155 GitterImplType *createALUGrid ( const std::string &macroName, ALU3DSPACE ProjectVertex *projection,
156 const bool conformingRefinement )
157 {
158 GitterImplType* grid = ( macroName.empty() ) ?
159 new GitterImplType() : new GitterImplType ( macroName.c_str(), projection );
160 // check whether conforming refinement should be enabled
161 checkForConformingRefinement( grid, conformingRefinement );
162 return grid ;
163 }
164
165 GitterImplType *createALUGrid ( std::istream& stream, ALU3DSPACE ProjectVertex *projection,
166 const bool conformingRefinement )
167 {
168#ifdef ALUGRID_CONSTRUCTION_WITH_STREAMS
169 GitterImplType* grid = new GitterImplType ( stream, projection );
170 // check whether conforming refinement should be enabled
171 checkForConformingRefinement( grid, conformingRefinement );
172 return grid ;
173#else
174 return 0;
175#endif
176 }
177
178 static No_Comm defaultComm () { return No_Comm(); }
179
180 static int getRank ( No_Comm comm ) { return 0; }
181
182 static typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder ( GitterImplType &grid )
183 {
184 ALU3DSPACE Gitter::Geometric::BuilderIF* builder =
185 dynamic_cast< ALU3DSPACE Gitter::Geometric::BuilderIF* >( &grid.container() );
186 if( ! builder )
187 DUNE_THROW(InvalidStateException,"dynamic_cast of ALUGrid builder failed");
188 return *builder;
189 }
190
191 static void duneNotifyMacroGridChanges ( GitterImplType &grid ) {}
192
193 CollectiveCommunication ccobj_;
194 };
195
196#if ALU3DGRID_PARALLEL
197 template< ALU3dGridElementType elType >
198 struct ALU3dGridCommunications< elType, MPI_Comm > : public ALU3dGridCommunicationsBase
199 {
200 using ALU3dGridCommunicationsBase :: checkForConformingRefinement ;
201
202 typedef ALU3dGridGlobalIdSet< elType, MPI_Comm > GlobalIdSet;
203 typedef ALUGridId< ALUMacroKey > GlobalId;
204
205 typedef ALU3DSPACE GitterDunePll GitterImplType;
206
207 typedef Dune::CollectiveCommunication< MPI_Comm > CollectiveCommunication;
208
209 explicit ALU3dGridCommunications ( MPI_Comm comm )
210 : ccobj_( comm ), mpAccess_( comm )
211 {}
212
213 int nlinks () const { return mpAccess_.nlinks(); }
214
215 GitterImplType *createALUGrid ( const std::string &macroName, ALU3DSPACE ProjectVertex *projection,
216 const bool conformingRefinement )
217 {
218 GitterImplType* grid = new GitterImplType( macroName.c_str(), mpAccess_, projection );
219 // check whether conforming refinement should be enabled
220 checkForConformingRefinement( grid, conformingRefinement );
221 return grid;
222 }
223
224 GitterImplType *createALUGrid ( std::istream& stream, ALU3DSPACE ProjectVertex *projection,
225 const bool conformingRefinement )
226 {
227#ifdef ALUGRID_CONSTRUCTION_WITH_STREAMS
228 GitterImplType* grid = new GitterImplType ( stream, mpAccess_, projection );
229 // check whether conforming refinement should be enabled
230 checkForConformingRefinement( grid, conformingRefinement );
231 return grid ;
232#else
233 return 0;
234#endif
235 }
236
237 static MPI_Comm defaultComm () { return MPI_COMM_WORLD; }
238
239 static int getRank ( MPI_Comm comm )
240 {
241 int rank = 0;
242 MPI_Comm_rank( comm, &rank );
243 return rank;
244 }
245
246 static typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder ( GitterImplType &grid )
247 {
248 ALU3DSPACE Gitter::Geometric::BuilderIF* builder =
249 dynamic_cast< ALU3DSPACE Gitter::Geometric::BuilderIF* >( &grid.containerPll() );
250 if( ! builder )
251 DUNE_THROW(InvalidStateException,"dynamic_cast of ALUGrid builder failed");
252 return *builder;
253 }
254
255 static void duneNotifyMacroGridChanges ( GitterImplType &grid )
256 {
257 grid.duneNotifyMacroGridChanges();
258 }
259
260 CollectiveCommunication ccobj_;
261 ALU3DSPACE MpAccessMPI mpAccess_;
262 };
263#endif // #if ALU3DGRID_PARALLEL
264
265
266
267 // ALU3dGridFamily
268 // ---------------
269
270 template< ALU3dGridElementType elType, class Comm >
271 struct ALU3dGridFamily
272 {
273 typedef ALU3dGrid< elType, Comm > GridImp;
274 typedef ALU3dGridFamily< elType, Comm > GridFamily;
275
276 static const int dim = 3;
277 static const int dimworld = 3;
278
280 typedef ALU3dGridLocalIdSet< elType, Comm > LocalIdSetImp;
281
283 typedef typename ALU3dGridCommunications< elType, Comm >::GlobalIdSet GlobalIdSetImp;
284
286 typedef typename ALU3dGridCommunications< elType, Comm >::GlobalId GlobalIdType;
287
289 typedef int LocalIdType;
290
291 struct Traits
292 {
294 typedef typename GridFamily::LocalIdType LocalIdType;
295
297 typedef typename GridFamily::GlobalIdType GlobalIdType;
298
299 typedef typename GridFamily::GridImp Grid;
300
303
304 typedef Dune::IntersectionIterator< const Grid, LeafIntersectionIteratorWrapper< const Grid >, LeafIntersectionWrapper< const Grid > > IntersectionIterator;
305
306 typedef Dune::IntersectionIterator< const Grid, LeafIntersectionIteratorWrapper< const Grid >, LeafIntersectionWrapper< const Grid > > LeafIntersectionIterator;
307 typedef Dune::IntersectionIterator< const Grid, LevelIntersectionIteratorWrapper< const Grid >, LevelIntersectionWrapper< const Grid > > LevelIntersectionIterator;
308
310
311 typedef DuneBoundaryProjection< dimworld > DuneBoundaryProjectionType;
312 typedef std::vector< const DuneBoundaryProjectionType * > DuneBoundaryProjectionVector;
313
314 template< int cd >
315 struct Codim
316 {
317 // IMPORTANT: Codim<codim>::Geometry == Geometry<dim-codim,dimw>
318 typedef ALU3dGridGeometry< dim-cd, dimworld, const Grid > GeometryImpl;
319 typedef ALU3dGridGeometry< dim-cd, dim, const Grid > LocalGeometryImpl;
320 typedef Dune::Geometry< dim-cd, dimworld, const Grid, ALU3dGridGeometry > Geometry;
321 typedef Dune::Geometry< dim-cd, dim, const Grid, ALU3dGridGeometry > LocalGeometry;
322
324
325 // minimal information to generate entities
326 typedef ALU3dGridEntitySeed< cd , const Grid> EntitySeed ;
327
328 typedef ALU3dGridEntityPointer< cd, const Grid > EntityPointerImpl;
330
331 template< PartitionIteratorType pitype >
332 struct Partition
333 {
336 }; // struct Partition
337
338 typedef typename Partition< All_Partition >::LevelIterator LevelIterator;
339 typedef typename Partition< All_Partition >::LeafIterator LeafIterator;
340 }; // struct Codim
341
342 template< PartitionIteratorType pitype >
343 struct Partition
344 {
347 }; // struct Partition
348
350 typedef DefaultIndexSet< GridImp, typename Codim< 0 > :: LevelIterator > LevelIndexSetImp;
351
353 typedef DefaultIndexSet< GridImp, typename Codim< 0 > :: LeafIterator > LeafIndexSetImp;
354
355 typedef IndexSet< Grid, LevelIndexSetImp > LevelIndexSet;
356 typedef IndexSet< Grid, LeafIndexSetImp > LeafIndexSet;
357 typedef IdSet< Grid, LocalIdSetImp, LocalIdType > LocalIdSet;
358 typedef IdSet< Grid, GlobalIdSetImp, GlobalIdType > GlobalIdSet;
359
360 typedef Dune::CollectiveCommunication< Comm > CollectiveCommunication;
361 }; // struct Traits
362
364 typedef typename Traits :: LevelIndexSetImp LevelIndexSetImp;
365
367 typedef typename Traits :: LeafIndexSetImp LeafIndexSetImp;
368
369 }; // struct ALU3dGridFamily
370
371
372
373 //**********************************************************************
374 //
375 // --ALU3dGrid
376 // --Grid
377 //
378 //**********************************************************************
379
400 template< ALU3dGridElementType elType, class Comm >
402 : public GridDefaultImplementation< 3, 3, alu3d_ctype,
403 ALU3dGridFamily< elType, Comm > >,
404 public HasObjectStream,
406 {
409
410 // for compatibility: MyType := ThisType
411 typedef ThisType MyType;
412
413 // friend declarations
414 friend class ALU3dGridEntity< 0, 3, const ThisType>;
415 friend class ALU3dGridEntity< 1, 3, const ThisType>;
416 friend class ALU3dGridEntity< 2, 3, const ThisType>;
417 friend class ALU3dGridEntity< 3, 3, const ThisType>;
418
420
421 friend class ALU3dGridEntityPointerBase< 0, const ThisType >;
422 friend class ALU3dGridEntityPointerBase< 1, const ThisType >;
423 friend class ALU3dGridEntityPointerBase< 2, const ThisType >;
424 friend class ALU3dGridEntityPointerBase< 3, const ThisType >;
425
426 friend class ALU3dGridEntityPointer< 0, const ThisType >;
427 friend class ALU3dGridEntityPointer< 1, const ThisType >;
428 friend class ALU3dGridEntityPointer< 2, const ThisType >;
429 friend class ALU3dGridEntityPointer< 3, const ThisType >;
430
431 friend class ALU3dGridIntersectionIterator< const ThisType >;
432 friend class ALU3dGridHierarchicIterator< const ThisType >;
433
434 friend class ALU3dGridHierarchicIndexSet< elType, Comm >;
435 friend class ALU3dGridGlobalIdSet< elType, Comm >;
436 friend class ALU3dGridLocalIdSet< elType, Comm >;
437
438 friend class Conversion< ThisType, HasObjectStream >;
439 friend class Conversion< const ThisType, HasObjectStream >;
440
442 friend class Conversion< const ThisType, HasHierarchicIndexSet >;
443
444 friend struct ALU3dGridCommHelper< elType, Comm >;
445
446 // new intersection iterator is a wrapper which get itersectioniteratoimp as pointers
447 public:
452 typedef ALU3dGridLevelIntersectionIterator<const ThisType>
453 LevelIntersectionIteratorImp;
454
456 friend class IntersectionIteratorWrapper < const ThisType, LevelIntersectionIteratorImp > ;
457 friend class LeafIntersectionIteratorWrapper < const ThisType > ;
458 friend class LevelIntersectionIteratorWrapper< const ThisType > ;
459
460 //**********************************************************
461 // The Interface Methods
462 //**********************************************************
463 public:
464 enum { refineStepsForHalf = 1 };
465
466 static const ALU3dGridElementType elementType = elType;
467 typedef typename ALU3DSPACE GatherScatterType::ObjectStreamType ObjectStreamType;
468 typedef ObjectStreamType InStreamType ;
469 typedef ObjectStreamType OutStreamType ;
470
471 typedef ALU3dGridFamily< elType, Comm > GridFamily;
472 typedef typename GridFamily::Traits Traits;
473
474 static const int dimension = BaseType::dimension;
475 static const int dimensionworld = BaseType::dimensionworld;
476
477 protected:
479 friend class ALULocalGeometryStorage< const ThisType, GeometryObject, 8 >;
480
481 public:
484
489
492
496 typedef typename Traits::DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
497
499 typedef ALU3DSPACE ProjectVertex ALUGridVertexProjectionType;
500
503
504 public:
509
510 typedef ALUGridObjectFactory< ThisType > GridObjectFactoryType;
511
512 protected:
513 friend class ALUGridBoundaryProjection< ThisType, alu3d_ctype >;
514 // type of ALUGrid boundary projection wrapper
516
518 typedef typename GridFamily::LocalIdSetImp LocalIdSetImp;
519
520 typedef typename GridFamily::GlobalIdSetImp GlobalIdSetImp;
521
522 public:
525
528
529 protected:
531 typedef typename Traits::template Codim< 0 >::LeafIterator LeafIteratorType;
532 typedef typename Traits::template Codim< 0 >::LeafIterator LeafIterator;
533
534 typedef ALU3dGridHierarchicIterator< const ThisType > HierarchicIteratorImp;
535
536 typedef typename ALU3dImplTraits< elType, Comm >::GitterImplType GitterImplType;
537
539 enum {
541 MAXL = 32
542 };
543
545 enum {
548 };
549
551 enum {
556 };
557
558 public:
559 typedef Comm MPICommunicatorType;
560
561 typedef ALU3dGridCommunications< elType, Comm > Communications;
562
563 protected:
564 typedef ALU3dGridVertexList< Comm > VertexListType;
565 typedef ALU3dGridLeafVertexList< Comm > LeafVertexListType;
566
569 ALU3dGrid ( const std::string &macroTriangFilename,
570 const MPICommunicatorType mpiComm,
571 const DuneBoundaryProjectionType *bndPrj,
572 const DuneBoundaryProjectionVector *bndVec,
573 const ALUGridRefinementType refinementType ) DUNE_DEPRECATED_MSG("ALUGrid is deprecated, please use the new module DUNE-ALUGrid.");
574
575 public:
577 virtual ~ALU3dGrid();
578
580 static inline std::string name ();
581
585 int maxLevel() const;
586
588 template<int cd, PartitionIteratorType pitype>
589 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
590 lbegin (int level) const;
591
593 template<int cd, PartitionIteratorType pitype>
594 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
595 lend (int level) const;
596
598 template<int cd>
599 typename Traits::template Codim<cd>::
600 template Partition<All_Partition>::LevelIterator
601 lbegin (int level) const;
602
604 template<int cd>
605 typename Traits::template Codim<cd>::
606 template Partition<All_Partition>::LevelIterator
607 lend (int level) const;
608
609 private:
611 template <int codim, PartitionIteratorType pitype>
612 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
613 leafbegin(int level) const;
614
616 template <int codim, PartitionIteratorType pitype>
617 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
618 leafend(int level) const;
619
621 template <int codim>
622 typename Traits::template Codim<codim>::LeafIterator
623 leafbegin(int level) const;
624
626 template <int codim>
627 typename Traits::template Codim<codim>::LeafIterator
628 leafend(int level) const;
629
631 LeafIteratorType leafbegin (int level) const;
632
634 LeafIteratorType leafend (int level) const;
635
637 LeafIteratorType leafbegin () const;
638
640 LeafIteratorType leafend () const;
641
642 public:
644 template <int codim, PartitionIteratorType pitype>
645 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
646 leafbegin() const;
647
649 template <int codim, PartitionIteratorType pitype>
650 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
651 leafend() const;
652
654 template <int codim>
655 typename Traits::template Codim<codim>::LeafIterator
656 leafbegin() const;
657
659 template <int codim>
660 typename Traits::template Codim<codim>::LeafIterator
661 leafend() const;
662
663 private:
665 template <int codim, PartitionIteratorType pitype>
666 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
667 createLeafIteratorBegin (int level) const;
668
670 template <int codim, PartitionIteratorType pitype>
671 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
672 createLeafIteratorEnd(int level) const;
673
674 public:
676 int size (int level, int cd) const;
677
679 int size (int codim) const;
680
682 int size (int level, GeometryType type) const;
683
685 size_t numBoundarySegments() const;
686
688 int size (GeometryType type) const;
689
691 int global_size (int cd) const ;
692
693 // (no interface method) number of grid entities in the entire grid for given codim
694 int hierSetSize (int cd) const;
695
697 const GlobalIdSet &globalIdSet () const
698 {
699 if( !globalIdSet_ )
700 globalIdSet_ = new GlobalIdSetImp( *this );
701 return *globalIdSet_;
702 }
703
705 const LocalIdSet & localIdSet () const { return localIdSet_; }
706
708 const typename Traits :: LeafIndexSet & leafIndexSet () const;
709
711 const typename Traits :: LevelIndexSet & levelIndexSet (int level) const;
712
717 bool loadBalance ();
718
745 template <class DataHandle>
746 bool loadBalance (DataHandle & data);
747
748 template< class DataHandleImpl, class Data >
750 {
751 typedef ALUGridLoadBalanceDataHandle< ThisType, DataHandleImpl, Data > LBHandle;
752 LBHandle lbHandle( *this, dataHandle );
753 return loadBalance( lbHandle );
754 }
755
757 int ghostSize (int level, int codim) const;
758
760 int overlapSize (int level, int codim) const { return 0; }
761
763 int ghostSize (int codim) const;
764
766 int overlapSize (int codim) const { return 0; }
767
769 template<class DataHandleImp,class DataTypeImp>
771 InterfaceType iftype, CommunicationDirection dir, int level) const;
772
776 template<class DataHandleImp,class DataTypeImp>
778 InterfaceType iftype, CommunicationDirection dir) const;
779
780 private:
781 typedef ALU3DSPACE GatherScatter GatherScatterType;
782
783 public:
785 const CollectiveCommunication &comm () const { return communications().ccobj_; }
786
788 bool preAdapt ( );
789
791 void postAdapt ( );
792
794 bool adapt ();
795
800 template< class GridImp, class DataHandle >
802
804 void globalRefine ( int refCount );
805
806 template< class GridImp, class DataHandle >
808
809 //**********************************************************
810 // End of Interface Methods
811 //**********************************************************
814 template <GrapeIOFileFormatType ftype>
815 bool writeGrid( const std::string filename, alu3d_ctype time ) const ;
816
817 bool writeGrid_Xdr( const std::string filename, alu3d_ctype time ) const ;
819 bool writeGrid_Ascii( const std::string filename, alu3d_ctype time, bool scientific = false ) const ;
820
823 bool writeMacroGrid( const std::string path, const std::string filename ) const ;
824
827 template <GrapeIOFileFormatType ftype>
828 bool readGrid( const std::string filename, alu3d_ctype & time );
829
831 void backup( std::ostream& ) const ;
832
834 void restore( std::istream& ) ;
835
836 // (no interface method) get hierarchic index set of the grid
837 const HierarchicIndexSet & hierarchicIndexSet () const { return hIndexSet_; }
838
839 // set max of given mxl and actual maxLevel
840 // for loadBalance
841 void setMaxLevel (int mxl);
842
843 // no interface method, but has to be public
844 void updateStatus ();
845
847 bool mark( int refCount , const typename Traits::template Codim<0>::Entity & e);
848
850 int getMark( const typename Traits::template Codim<0>::Entity & e) const;
851
852 public:
853 static MPICommunicatorType defaultCommunicator ()
854 {
855 return Communications::defaultComm();
856 }
857
858 using BaseType :: getRealImplementation ;
859
860 template< class IntersectionType >
861 static const typename BaseType
862 :: template ReturnImplementationType< IntersectionType >
863 :: ImplementationType &
864 getRealIntersection ( const IntersectionType &intersection )
865 {
866 return getRealImplementation( intersection );
867 }
868
870 const std::vector<GeometryType>& geomTypes (int codim) const { return geomTypes_[codim]; }
871
872 // return reference to org ALU3dGrid
873 // private method, but otherwise we have to friend class all possible
874 // types of LevelIterator ==> later
875 GitterImplType &myGrid () const;
876
877 virtual GitterImplType *createALUGrid ( const std::string &macroName )
878 {
879 assert( communications_ );
880 return communications_->createALUGrid( macroName, vertexProjection(), conformingRefinement() );
881 }
882
883 virtual GitterImplType *createALUGrid ( std::istream& stream )
884 {
885 assert( communications_ );
886 return communications_->createALUGrid( stream, vertexProjection(), conformingRefinement() );
887 }
888
889 ALUGridVertexProjectionType* vertexProjection() { return (ALUGridVertexProjectionType *) vertexProjection_; }
890
891 // return appropriate ALUGrid builder
892 virtual typename ALU3DSPACE Gitter::Geometric::BuilderIF &getBuilder () const
893 {
894 return Communications::getBuilder( myGrid() );
895 }
896
897 // helper function for factory
898 virtual void duneNotifyMacroGridChanges ()
899 {
900 Communications::duneNotifyMacroGridChanges( myGrid() );
901 }
902
904 const ReferenceElementType & referenceElement() const { return referenceElement_; }
905
906 template < class EntitySeed >
907 typename Traits :: template Codim< EntitySeed :: codimension > :: EntityPointer
908 entityPointer( const EntitySeed& seed ) const
909 {
910 enum { codim = EntitySeed :: codimension };
911 typedef ALU3dGridEntityPointer < codim, const ThisType > ALUPointer ;
912 return ALUPointer( factory(), seed ) ;
913 }
914
915 // number of links to other processors, for internal use only
916 int nlinks () const { return communications().nlinks(); }
917
918 LeafVertexListType & getLeafVertexList() const
919 {
920 if( !leafVertexList_.up2Date() ) leafVertexList_.setupVxList(*this);
921 return leafVertexList_;
922 }
923
924 int getLevelOfLeafVertex ( const typename ALU3dImplTraits< elType, Comm >::VertexType &vertex ) const
925 {
926 assert( leafVertexList_.up2Date() );
927 return leafVertexList_.getLevel(vertex);
928 }
929
930 VertexListType & getVertexList(int level) const
931 {
932 assert( level >= 0 );
933 assert( level <= maxLevel() );
934 VertexListType & vxList = vertexList_[level];
935 if(!vxList.up2Date()) vxList.setupVxList(*this,level);
936 return vxList;
937 }
938
939 ALU3dGridItemListType & getGhostLeafList(int codim) const
940 {
941 assert( codim >= 1 );
942 assert( codim <= 3 );
943 return ghostLeafList_[codim-1];
944 }
945
946 ALU3dGridItemListType & getGhostLevelList(int codim, int level) const
947 {
948 assert( codim >= 1 );
949 assert( codim <= 3 );
950
951 assert( level >= 0 );
952 assert( level <= maxLevel() );
953 return ghostLevelList_[codim-1][level];
954 }
955
956 ALU3dGridItemListType & getEdgeList(int level) const
957 {
958 assert( level >= 0 );
959 assert( level <= maxLevel() );
960 return levelEdgeList_[level];
961 }
962
963 protected:
965 ALU3dGrid( const ThisType & );
966
968 const ThisType &operator= ( const ThisType & );
969
972
975
978
980 void checkMacroGridFile (const std::string filename);
981
984
986 const DuneBoundaryProjectionType* boundaryProjection(const int segmentIndex) const
987 {
988 if( bndPrj_ )
989 {
990 return bndPrj_;
991 }
992 else
993 {
994 // pointer can be zero (which is emulates the identity mapping then)
995 assert( bndVec_ );
996 assert( segmentIndex < (int) bndVec_->size() );
997 return (*bndVec_)[ segmentIndex ];
998 }
999 }
1000
1001 const Communications &communications () const
1002 {
1003 assert( communications_ );
1004 return *communications_;
1005 }
1006
1007 const GridObjectFactoryType& factory() const {
1008#ifdef USE_SMP_PARALLEL
1009 assert( (int) factoryVec_.size() > GridObjectFactoryType :: threadNumber() );
1010 return factoryVec_[ GridObjectFactoryType :: threadNumber() ];
1011#else
1012 return factory_;
1013#endif
1014 }
1015
1016 public:
1017 // return true if conforming refinement is enabled
1018 bool conformingRefinement() const
1019 {
1020 return (refinementType_ == conforming) ;
1021 }
1022
1023 // return true if ghost cells are available
1024 bool ghostCellsEnabled () const
1025 {
1026#ifdef ALUGRID_3D_CONFORMING_REFINEMENT
1027 return myGrid().ghostCellsEnabled();
1028#else
1029 return true ;
1030#endif
1031 }
1032 protected:
1034 //
1035 // Internal variables
1036 //
1038
1039 // the real ALU grid
1040 mutable GitterImplType *mygrid_;
1041
1042 // max level of grid
1043 int maxlevel_;
1044
1045 // count how much elements where marked
1046 mutable int coarsenMarked_;
1047 mutable int refineMarked_;
1048
1049 // at the moment the number of different geom types is 1
1050 enum { numberOfGeomTypes = 1 };
1051 std::vector< std::vector<GeometryType> > geomTypes_;
1052
1053 // our hierarchic index set
1054 HierarchicIndexSet hIndexSet_;
1055
1056 // out global id set
1057 mutable GlobalIdSetImp *globalIdSet_;
1058
1059 // out global id set
1060 LocalIdSetImp localIdSet_;
1061
1062 // the level index set ( default type )
1063 mutable std::vector < LevelIndexSetImp * > levelIndexVec_;
1064
1065 // the leaf index set
1066 mutable LeafIndexSetImp * leafIndexSet_;
1067
1068 // the reference element
1069 const ReferenceElementType& referenceElement_;
1070
1071 mutable VertexListType vertexList_[MAXL];
1072
1073 mutable ALU3dGridItemListType ghostLeafList_[ dimension ];
1074 mutable ALU3dGridItemListType ghostLevelList_[ dimension ][MAXL];
1075
1076 mutable ALU3dGridItemListType levelEdgeList_[MAXL];
1077
1078 mutable LeafVertexListType leafVertexList_;
1079
1080 // the type of our size cache
1081 typedef SizeCache<MyType> SizeCacheType;
1082 SizeCacheType * sizeCache_;
1083
1084#ifdef USE_SMP_PARALLEL
1085 std::vector< GridObjectFactoryType > factoryVec_;
1086#else
1087 GridObjectFactoryType factory_;
1088#endif
1089
1090 // variable to ensure that postAdapt ist called after adapt
1091 bool lockPostAdapt_;
1092
1093 // pointer to Dune boundary projection
1094 const DuneBoundaryProjectionType* bndPrj_;
1095
1096 // pointer to Dune boundary projection
1097 const DuneBoundaryProjectionVector* bndVec_;
1098
1099 // boundary projection for vertices
1100 ALUGridBoundaryProjectionType* vertexProjection_ ;
1101
1102 // pointer to communications object
1103 Communications *communications_;
1104
1105 // refinement type (nonconforming or conforming)
1106 const ALUGridRefinementType refinementType_ ;
1107 }; // end class ALU3dGrid
1108
1109
1110 bool checkMacroGrid ( ALU3dGridElementType elType ,
1111 const std::string filename );
1112 const char* elType2Name( ALU3dGridElementType elType );
1113
1114 namespace Capabilities
1115 {
1116
1117 template< ALU3dGridElementType elType, class Comm, int cdim >
1118 struct hasEntity< Dune::ALU3dGrid< elType, Comm >, cdim >
1119 {
1120 static const bool v = true;
1121 };
1122
1123 template< ALU3dGridElementType elType, class Comm >
1124 struct DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") isParallel< ALU3dGrid< elType, Comm > >
1125 {
1126 static const bool DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") v = true;
1127 };
1128
1129 template< ALU3dGridElementType elType, class Comm >
1130 struct isLevelwiseConforming< ALU3dGrid< elType, Comm > >
1131 {
1132 static const bool v = true;
1133 };
1134
1135 template< ALU3dGridElementType elType, class Comm >
1136 struct hasBackupRestoreFacilities< ALU3dGrid< elType, Comm > >
1137 {
1138 static const bool v = true;
1139 };
1140
1141 } // end namespace Capabilities
1142
1143} // end namespace Dune
1144
1145#include "grid_inline.hh"
1146#if COMPILE_ALUGRID_INLINE
1147 #include "grid_imp.cc"
1148#endif
1149#endif
Portable very large unsigned integers.
Definition: entity.hh:469
Definition: entity.hh:47
hierarchic index set of ALU3dGrid
Definition: indexsets.hh:44
Definition: iterator.hh:57
Leaf iterator.
Definition: iterator.hh:585
[ provides Dune::Grid ]
Definition: grid.hh:406
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir) const
Communicate information on distributed entities on the leaf grid. Template parameter is a model of Du...
int size(int codim) const
number of leaf entities per codim in this process
int size(int level, GeometryType type) const
number of entities per level and geometry type in this process
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
Definition: grid_inline.hh:299
Traits::template Codim< codim >::LeafIterator leafbegin() const
General definiton for a leaf iterator.
bool adapt()
Refine all positive marked leaf entities, coarsen all negative marked entities if possible.
void communicate(CommDataHandleIF< DataHandleImp, DataTypeImp > &data, InterfaceType iftype, CommunicationDirection dir, int level) const
Communicate information on distributed entities on a given level Template parameter is a model of Dun...
Traits::DuneBoundaryProjectionVector DuneBoundaryProjectionVector
boundary projection type
Definition: grid.hh:496
void checkMacroGridFile(const std::string filename)
check whether macro grid format is of our type
ALU3dGrid(const ThisType &)
Copy constructor should not be used.
bool writeGrid(const std::string filename, alu3d_ctype time) const
write Grid to file in specified FileFormatType
bool readGrid(const std::string filename, alu3d_ctype &time)
read Grid from file filename and store time of mesh in time
int overlapSize(int codim) const
overlapSize is zero for this grid
Definition: grid.hh:766
void globalRefine(int refCount)
uses the interface, mark on entity and refineLocal
bool loadBalance()
Calculates load of each process and repartition the grid if neccessary. For parameters of the load ba...
Definition: grid_inline.hh:639
@ newElementsChunk_
normal default number of new elements for new adapt method
Definition: grid.hh:547
const LocalIdSet & localIdSet() const
get global id set of grid
Definition: grid.hh:705
int global_size(int cd) const
number of grid entities on all levels for given codim
Definition: grid_inline.hh:82
const ThisType & operator=(const ThisType &)
assignment operator should not be used
@ MAXL
maximal number of levels is 32
Definition: grid.hh:541
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
returns adaptation mark for given entity
Definition: grid_inline.hh:314
GridFamily::LeafIndexSetImp LeafIndexSetImp
Type of the leaf index set, needed by data handle.
Definition: grid.hh:488
int overlapSize(int level, int codim) const
overlapSize is zero for this grid
Definition: grid.hh:760
void calcExtras()
reset size and global size, update Level- and LeafIndexSet, if they exist
void backup(std::ostream &) const
backup to ostream
const Traits::LeafIndexSet & leafIndexSet() const
get leaf index set of the grid
static std::string name()
for grid identification
Definition: grid_inline.hh:678
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafend() const
General definition for an end iterator on leaf level.
bool preAdapt()
returns if a least one entity was marked for coarsening
virtual ~ALU3dGrid()
Desctructor.
int ghostSize(int codim) const
ghostSize is one for codim 0 and zero otherwise for this grid
void calcMaxLevel()
calculate maxlevel
const Traits::LevelIndexSet & levelIndexSet(int level) const
get level index set of the grid
const std::vector< GeometryType > & geomTypes(int codim) const
deliver all geometry types used in this grid
Definition: grid.hh:870
const GlobalIdSet & globalIdSet() const
get global id set of grid
Definition: grid.hh:697
void restore(std::istream &)
restore from istream
int size(GeometryType type) const
number of leaf entities per geometry type in this process
ALU3DSPACE ProjectVertex ALUGridVertexProjectionType
type of ALUGrid Vertex Projection Interface
Definition: grid.hh:499
ALU3dGrid(const std::string &macroTriangFilename, const MPICommunicatorType mpiComm, const DuneBoundaryProjectionType *bndPrj, const DuneBoundaryProjectionVector *bndVec, const ALUGridRefinementType refinementType) DUNE_DEPRECATED_MSG("ALUGrid is deprecated
Definition: grid_inline.hh:21
const CollectiveCommunication & comm() const
return const reference to a collective communication object. The return type is a model of Dune::Coll...
Definition: grid.hh:785
Traits::template Codim< codim >::LeafIterator leafend() const
General definition for an end iterator on leaf level.
Traits::CollectiveCommunication CollectiveCommunication
type of collective communication object
Definition: grid.hh:502
void postAdapt()
clear all entity new markers
int ghostSize(int level, int codim) const
ghostSize is one for codim 0 and zero otherwise for this grid
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
General definiton for a leaf iterator.
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
Definition: grid_inline.hh:133
GridFamily::LocalIdSetImp LocalIdSetImp
Type of the local id set.
Definition: grid.hh:518
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:119
ReferenceElement< alu3d_ctype, dimension > ReferenceElementType
reference element type
Definition: grid.hh:491
Traits::LocalIdSet LocalIdSet
Type of the local id set.
Definition: grid.hh:527
const DuneBoundaryProjectionType * boundaryProjection(const int segmentIndex) const
return boudanry projection for given segment Id
Definition: grid.hh:986
void checkMacroGrid()
check whether macro grid has the right element type
@ refineEstimate_
if one element is refined then it causes apporximately not more than this number of new elements
Definition: grid.hh:555
bool writeGrid_Ascii(const std::string filename, alu3d_ctype time, bool scientific=false) const
write leaf grid in macro grid format to ascii file
bool writeMacroGrid(const std::string path, const std::string filename) const
write macro grid in ALUGrid macro format to path/filename.rank
const ReferenceElementType & referenceElement() const
return reference to Dune reference element according to elType
Definition: grid.hh:904
Traits::GlobalIdSet GlobalIdSet
Type of the global id set.
Definition: grid.hh:524
ALU3dGridHierarchicIndexSet< elType, Comm > HierarchicIndexSet
Type of the hierarchic index set.
Definition: grid.hh:483
GridFamily::LevelIndexSetImp LevelIndexSetImp
Type of the level index set, needed by data handle.
Definition: grid.hh:486
int size(int level, int cd) const
number of grid entities per level and codim
void recalcGlobalSize()
make grid walkthrough and calc global size
size_t numBoundarySegments() const
number of boundary segments
int maxLevel() const
Return maximum level defined in this grid. Levels are numbered maxLevel with 0 the coarsest level.
Definition: grid_inline.hh:100
Traits::DuneBoundaryProjectionType DuneBoundaryProjectionType
boundary projection type
Definition: grid.hh:494
ALUGrid boundary projection implementation DuneBndProjection has to fulfil the DuneBoundaryProjection...
Definition: bndprojection.hh:15
Interface class for the Grid's adapt method where the parameter is a AdaptDataHandleInterface.
Definition: adaptcallback.hh:31
Specialization of CollectiveCommunication for MPI.
Definition: mpicollectivecommunication.hh:146
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:73
Checks wether a type is convertible to another.
Definition: typetraits.hh:177
DefaultIndexSet creates an index set by using the grids persistent container an a given pair of itera...
Definition: defaultindexsets.hh:68
interface class for an iterator over grid entities
Definition: entityiterator.hh:37
Wrapper class for pointers to entities.
Definition: entitypointer.hh:113
Store a reference to an entity with a minimal memory footprint.
Definition: entityseed.hh:24
Wrapper class for entities.
Definition: entity.hh:62
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Wrapper class for geometries.
Definition: geometry.hh:66
Definition: grid.hh:1030
static std::conditional< std::is_reference< InterfaceType >::value, typenamestd::add_lvalue_reference< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type, typenamestd::remove_const< typenameReturnImplementationType< typenamestd::remove_reference< InterfaceType >::type >::ImplementationType >::type >::type getRealImplementation(InterfaceType &&i)
return real implementation of interface class
Definition: grid.hh:1305
Traits::template Codim< codim >::LevelIterator DUNE_DEPRECATED_MSG("The method lbegin( level ) is superseded by levelGridView( level ).begin.") lbegin(int level) const
Iterator to first entity of given codim on level for PartitionType All_Partition.
Definition: grid.hh:1043
Grid view abstract base class.
Definition: gridview.hh:59
@ dimensionworld
The dimension of the world the grid lives in.
Definition: grid.hh:408
@ dimension
The dimension of the grid.
Definition: grid.hh:402
Id Set Interface.
Definition: indexidset.hh:414
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:19
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:84
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: intersection.hh:161
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:233
Class that wraps IntersectionIteratorImp of a grid and gets it's internal object from a object stack ...
Definition: intersectioniteratorwrapper.hh:328
This class provides access to geometric and topological properties of a reference element.
Definition: referenceelements.hh:55
Implements an utility class that provides collective communication methods for sequential programs.
A set of traits classes to store static information about grid implementation.
Different resources needed by all grid implementations.
Describes the parallel communication interface class for MessageBuffers and DataHandles.
Provides default index set implementations for Level- and LeafIndexsets used by ALUGrid.
Definition of the DUNE_DEPRECATED macro for the case that config.h is not available.
Provides a Interfaces for detection of specific behavior.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:243
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:168
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:84
struct DUNE_DEPRECATED_MSG("Capabilities::isParallel will be removed after dune-grid-2.4.") isParallel< ALU3dGrid< elType
YaspGrid is parallel.
Provides proxy classes for IntersectionsIterators.
Implements an utility class that provides MPI's collective communication methods.
Helpers for dealing with MPI.
Dune namespace.
Definition: alignment.hh:10
ALUGridRefinementType
available refinement types for ALUGrid
Definition: declaration.hh:20
Provides size cache classes to implement the grids size method efficiently.
Definition: alu3dinclude.hh:330
Definition: alu3dinclude.hh:297
Static tag representing a codimension.
Definition: dimension.hh:22
Interface class for vertex projection at the boundary.
Definition: boundaryprojection.hh:24
Tagging interface to indicate that Grid has HierarchicIndexSet.
Definition: interfaces.hh:51
Tagging interface to indicate that Grid provides typedef ObjectStreamType.
Definition: interfaces.hh:16
Definition: grid.hh:1467
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)