3#ifndef DUNE_ALU2DGRIDGRID_HH
4#define DUNE_ALU2DGRIDGRID_HH
7#include "alu2dinclude.hh"
12#include <dune/grid/utility/grapedataioformattypes.hh>
18#include <dune/grid/alugrid/common/declaration.hh>
21#include <dune/grid/common/defaultgridview.hh>
27#include <dune/grid/common/boundaryprojection.hh>
28#include <dune/grid/alugrid/2d/bndprojection.hh>
31#include "indexsets.hh"
32#include <dune/grid/alugrid/common/objectfactory.hh>
33#include "datahandle.hh"
38 template<
int cd,
int dim,
class Gr
idImp>
39 class ALU2dGridEntity;
40 template<
int cd, PartitionIteratorType pitype,
class Gr
idImp >
41 class ALU2dGridLevelIterator;
42 template<
int cd,
class Gr
idImp >
43 class ALU2dGridEntityPointer;
44 template<
int cd,
class Gr
idImp >
45 class ALU2dGridEntitySeed;
46 template<
int mydim,
int coorddim,
class Gr
idImp>
47 class ALU2dGridMakeableGeometry;
48 template<
int mydim,
int cdim,
class Gr
idImp>
49 class ALU2dGridGeometry;
50 template<
class Gr
idImp>
51 class ALU2dGridHierarchicIterator;
52 template<
class Gr
idImp>
53 class ALU2dGridIntersectionBase;
54 template<
class Gr
idImp>
55 class ALU2dGridLevelIntersectionIterator;
56 template<
class Gr
idImp>
57 class ALU2dGridLeafIntersectionIterator;
58 template<
int codim, PartitionIteratorType pitype,
class Gr
idImp>
59 class ALU2dGridLeafIterator;
60 template <
int mydim,
int coorddim,
class Gr
idImp>
61 class ALU2dGridMakeableEntity;
62 template <
class Gr
idImp>
63 class ALU2dGridFaceGeometryInfo;
64 template<
int dim,
int dimworld, ALU2DSPACE ElementType eltype >
65 class ALU2dGridLocalIdSet;
66 template<
int dim,
int dimworld, ALU2DSPACE ElementType eltype >
67 class ALU2dGridHierarchicIndexSet;
68 template <
class EntityImp>
69 class ALUMemoryProvider;
70 template<
int dim,
int dimworld, ALU2DSPACE ElementType eltype >
72 template <
class Gr
idImp,
class GeometryImp,
int nChild>
73 class ALULocalGeometryStorage;
75 class ALU2dObjectStream;
80 template <
int dimw,
class Comm >
81 struct ALUGridBaseGrid< 2, dimw, cube, Comm >
86 template <
int dimw,
class Comm >
87 struct ALUGridBaseGrid< 2, dimw, simplex, Comm >
98 template<
int dim,
int dimworld, ALU2DSPACE ElementType eltype >
99 struct ALU2dGridFamily
101 typedef ALU2dGrid< dim, dimworld, eltype > GridImp;
104 typedef ALU2dGridLocalIdSet<dim,dimworld,eltype> GlobalIdSetImp;
107 typedef ALU2dGridLocalIdSet<dim,dimworld,eltype> LocalIdSetImp;
109 typedef int GlobalIdType;
110 typedef int LocalIdType;
114 typedef GridImp Grid;
125 typedef DuneBoundaryProjection< dimworld > DuneBoundaryProjectionType;
126 typedef std::vector< const DuneBoundaryProjectionType *> DuneBoundaryProjectionVector;
132 typedef ALU2dGridGeometry< dim-cd, dimworld,
const GridImp > GeometryImpl;
133 typedef ALU2dGridGeometry< dim-cd, dim,
const GridImp > LocalGeometryImpl;
134 typedef Dune::Geometry< dim-cd, dimworld,
const GridImp, ALU2dGridGeometry > Geometry;
135 typedef Dune::Geometry< dim-cd, dim,
const GridImp, ALU2dGridGeometry > LocalGeometry;
140 typedef ALU2dGridEntityPointer< cd, const GridImp > EntityPointerImpl;
144 typedef ALU2dGridEntitySeed< cd , const GridImp > EntitySeed ;
146 template <PartitionIteratorType pitype>
153 typedef typename Partition< All_Partition >::LevelIterator LevelIterator;
154 typedef typename Partition< All_Partition >::LeafIterator LeafIterator;
158 template <PartitionIteratorType pitype>
168 typedef DefaultIndexSet< GridImp, typename Codim<0>::LevelIterator > LevelIndexSetImp;
170 typedef DefaultIndexSet< GridImp, typename Codim<0>::LeafIterator > LeafIndexSetImp;
172 typedef IndexSet<GridImp,LevelIndexSetImp> LevelIndexSet;
173 typedef LeafIndexSetImp LeafIndexSet;
174 typedef IdSet<GridImp,GlobalIdSetImp,GlobalIdType> GlobalIdSet;
175 typedef IdSet<GridImp,LocalIdSetImp,LocalIdType> LocalIdSet;
177#if ALU2DGRID_PARALLEL
178 typedef Dune :: CollectiveCommunication< MPI_Comm >
179 CollectiveCommunication;
181 typedef Dune :: CollectiveCommunication< GridImp >
182 CollectiveCommunication;
187 typedef typename Traits :: LevelIndexSetImp LevelIndexSetImp;
190 typedef typename Traits :: LeafIndexSetImp LeafIndexSetImp;
208 template<
int dim,
int dimworld, ALU2DSPACE ElementType eltype >
217 dune_static_assert( dim == 2,
"ALU2dGrid only implemented for grid dim 2." );
218 dune_static_assert( dimworld == 2 || dimworld == 3,
"ALU2dGrid only implemented for world dim 2 or 3." );
221 static const ALU2DSPACE ElementType elementType = eltype;
223 typedef typename ALU2dGridFamily< dim, dimworld, elementType >::Traits Traits;
226 typedef ALU2dGridLeafIntersectionIterator <const ThisType> LeafIntersectionIteratorImp;
227 typedef ALU2dGridLevelIntersectionIterator<const ThisType> LevelIntersectionIteratorImp;
229 typedef ALUGridObjectFactory< ThisType > GridObjectFactoryType;
233 typedef typename ALU2dImplTraits<dimworld, elementType >::HmeshType HmeshType ;
234 typedef typename ALU2dImplTraits<dimworld, elementType >::HElementType HElementType ;
235 typedef typename ALU2dImplTraits<dimworld, elementType >::ElementType ElementType ;
237 template<
class >
friend struct DGFBaseFactory;
244 template<
class,
class,
int >
friend class ALULocalGeometryStorage;
253 friend class ALU2dGridLevelIntersectionIterator< const
ThisType > ;
254 friend class ALU2dGridLeafIntersectionIterator< const
ThisType > ;
273 typedef ALU2dGridFamily < dim, dimworld, eltype >
GridFamily;
296 typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
297 typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
301 typedef typename Traits::template Codim<0>::LevelIterator LevelIteratorType;
302 typedef typename Traits::template Codim<0>::LevelIterator LevelIterator;
306 typedef typename Traits::CollectiveCommunication CollectiveCommunicationType;
334#ifdef ALUGRID_VERTEX_PROJECTION
336 typedef ALUGridSpace :: VertexProjection< dimworld > ALUGridVertexProjectionType;
343 friend class ALU2dGridBoundaryProjection<
ThisType >;
345 typedef ALU2dGridBoundaryProjection< ThisType > ALUGridBoundaryProjectionType;
351 const int nrOfHangingNodes,
354 std::istream* macroFile = 0);
357 HmeshType* createGrid(
const std::string&,
374 template<
int cd, PartitionIteratorType pitype>
375 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
379 template<
int cd, PartitionIteratorType pitype>
380 typename Traits::template Codim<cd>::template Partition<pitype>::LevelIterator
385 typename Traits::template Codim<cd>::
386 template Partition<All_Partition>::LevelIterator
391 typename Traits::template Codim<cd>::
392 template Partition<All_Partition>::LevelIterator
396 LevelIteratorType
lbegin (
int level)
const;
399 LevelIteratorType
lend (
int level)
const;
402 template <
int codim, PartitionIteratorType pitype>
403 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
407 template <
int codim, PartitionIteratorType pitype>
408 typename Traits::template Codim<codim>::template Partition<pitype>::LeafIterator
413 typename Traits::template Codim<codim>::LeafIterator
418 typename Traits::template Codim<codim>::LeafIterator
426 LeafIteratorType
leafend ()
const;
430 int size (
int level,
int cd)
const;
442 const std::vector<GeometryType>&
geomTypes (
int codim)
const {
return geomTypes_[codim]; }
474 HmeshType & myGrid();
475 HmeshType & myGrid()
const;
480 template<
class Gr
idImp,
class DataHandle >
481 void globalRefine (
int refCount, AdaptDataHandleInterface< GridImp, DataHandle > &hamdle );
494 template<
class Gr
idImp,
class DataHandle >
495 bool adapt ( AdaptDataHandleInterface< GridImp, DataHandle > &handle );
501 int getMark(
const typename Traits::template Codim<0>::Entity & e)
const;
504 bool mark(
int refCount ,
const typename Traits::template Codim<0>::Entity & e);
507 const CollectiveCommunicationType &
comm()
const;
509 CollectiveCommunicationType comm_;
518 void hierarchicClear( HElementType *el );
526 void makeGeomTypes ();
543 const char * checkMacroGridFile(
const std::string & filename);
549 HmeshType& mesh()
const {
554#ifdef USE_SMP_PARALLEL
555 std::vector< GridObjectFactoryType > factoryVec_;
557 GridObjectFactoryType factory_;
570 enum { numberOfGeomTypes = 1 };
571 std::vector< std::vector<GeometryType> > geomTypes_;
577 int refineMarked_ , coarsenMarked_;
578 const int nrOfHangingNodes_;
594 ALUGridBoundaryProjectionType* vertexProjection_ ;
612 assert( segmentIndex < (
int) bndVec_->size() );
613 return (*bndVec_)[ segmentIndex ];
621#ifdef ALUGRID_VERTEX_PROJECTION
622 return myGrid().numMacroBndSegments();
624 derr <<
"Method available in any version of ALUGrid > 1.14 \n";
632 return (vertexProjection_ != 0);
638 template<
class IntersectionType >
639 const typename BaseType
640 :: template ReturnImplementationType< IntersectionType>
641 :: ImplementationType &
642 getRealIntersection (
const IntersectionType &intersection )
const
647 const GridObjectFactoryType& factory()
const {
648#ifdef USE_SMP_PARALLEL
649 assert( (
int) factoryVec_.size() > GridObjectFactoryType :: threadNumber() );
650 return factoryVec_[ GridObjectFactoryType :: threadNumber() ];
659 friend class IntersectionIteratorWrapper < const ThisType, LeafIntersectionIteratorImp > ;
660 friend class IntersectionIteratorWrapper < const ThisType, LevelIntersectionIteratorImp > ;
661 friend class LeafIntersectionIteratorWrapper < const ThisType > ;
662 friend class LevelIntersectionIteratorWrapper< const ThisType > ;
664 mutable ALU2dGridMarkerVector marker_[
MAXL];
666 typedef ALU2dGridLeafMarkerVector ALU2dGridLeafMarkerVectorType;
669 mutable ALU2dGridLeafMarkerVectorType leafMarker_;
672 template <
class EntitySeed >
673 typename Traits :: template Codim< EntitySeed :: codimension > :: EntityPointer
674 entityPointer(
const EntitySeed& seed )
const
676 enum { codim = EntitySeed :: codimension };
677 typedef ALU2dGridEntityPointer < codim, const ThisType > ALUPointer ;
678 return ALUPointer( factory(), seed ) ;
686 assert( level <=
MAXL);
687 return marker_[level];
699 template <GrapeIOFileFormatType ftype>
700 bool writeGrid(
const std::string filename, alu2d_ctype time )
const ;
702 bool writeGrid_Xdr(
const std::string filename, alu2d_ctype time )
const ;
703 bool writeGrid_Ascii(
const std::string filename, alu2d_ctype time )
const ;
707 template <GrapeIOFileFormatType ftype>
708 bool readGrid(
const std::string filename, alu2d_ctype & time );
727 return (nrOfHangingNodes_ > 0);
730#if ALU2DGRID_PARALLEL
731 typedef RankManager<ThisType> RankManagerType;
732 RankManagerType rankManager_;
734 const RankManagerType& rankManager()
const
742 template<
class DataHandleImp,
class DataTypeImp>
749 template<
class DataHandleImp,
class DataTypeImp>
753 int ghostSize (
int level,
int codim )
const
755 return ghostSize( codim );
758 int ghostSize (
int codim )
const
760#if ALU2DGRID_PARALLEL
771 template<
class DataHandle>
774 void checkManager() {
775#if ALU2DGRID_PARALLEL
776 rankManager_.notifyMarking () ;
782 namespace Capabilities
784 template<
int dim,
int dimw, ALU2DSPACE ElementType eltype,
int cdim>
785 struct hasEntity<ALU2dGrid<dim,dimw,eltype>, cdim >
787 static const bool v =
true;
790 template<
int dim,
int dimw, ALU2DSPACE ElementType eltype>
791 struct isLevelwiseConforming< ALU2dGrid<dim,dimw,eltype> >
793 static const bool v =
false;
801#include "geometry.hh"
802#include <dune/grid/alugrid/2d/intersection.hh>
803#include <dune/grid/alugrid/2d/iterator.hh>
805#include "grid_imp.cc"
Definition: entity.hh:540
Definition: geometry.hh:631
hierarchic index set of ALU2dGrid
Definition: indexsets.hh:42
Hierarchic Iterator of ALU2dGrid.
Definition: iterator.hh:416
Definition: intersection.hh:102
HierarchicIndexSet hIndexSet_
the hierarchic index set
Definition: grid.hh:561
bool conformingRefinement() const
return true if grid uses conforming refinement
Definition: grid.hh:717
LevelIteratorType lend(int level) const
last entity of codim 0 on level
GridFamily::LevelIndexSetImp LevelIndexSetImp
Type of the level index set.
Definition: grid.hh:290
ALU2dGridFamily< dim, dimworld, eltype > GridFamily
my Traits class
Definition: grid.hh:273
ALU2dGrid(const std::string macroTriangFilename, const int nrOfHangingNodes, const DuneBoundaryProjectionType *, const DuneBoundaryProjectionVector *, std::istream *macroFile=0)
int size(int level, int cd) const
number of grid entities per level and codim
bool loadBalance()
Re-balances the load each process has to handle for a parallel grid,.
Traits::template Codim< codim >::LeafIterator leafbegin() const
General definiton for a leaf iterator.
ALU2dGridLeafIterator< 0, All_Partition, const ThisType > LeafIteratorImp
a standard leaf iterator
Definition: grid.hh:295
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafend() const
General definition for an end iterator on leaf level.
int getMark(const typename Traits::template Codim< 0 >::Entity &e) const
returns adaptation mark for given entity
bool hasBoundaryProjection() const
return true if boudanry projection is set
Definition: grid.hh:630
const CollectiveCommunicationType & comm() const
return dummy communication
bool preAdapt()
returns if a least one entity was marked for coarsening
bool writeGrid(const std::string filename, alu2d_ctype time) const
write Grid to file in specified FileFormatType
bool mark(int refCount, const typename Traits::template Codim< 0 >::Entity &e)
Marks an entity to be refined/coarsened in a subsequent adapt.
void postAdapt()
clear all entity new markers
LocalIdSetImp localIdSet_
out global id set
Definition: grid.hh:564
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...
const HierarchicIndexSet & hierarchicIndexSet() const
get hierarchic index set of the grid
size_t numBoundarySegments() const
return number of macro boundary segments
Definition: grid.hh:619
ALU2dGridObjectStream ObjectStreamType
dummy object stream
Definition: grid.hh:268
ALU2dGridHierarchicIndexSet< dim, dimworld, elementType > HierarchicIndexSet
Type of the hierarchic index set.
Definition: grid.hh:276
LevelIteratorType lbegin(int level) const
Iterator to first entity of codim 0 on level.
GridFamily::LeafIndexSetImp LeafIndexSetImp
Type of the leaf index set.
Definition: grid.hh:292
const std::vector< GeometryType > & geomTypes(int codim) const
deliver all geometry types used in this grid
Definition: grid.hh:442
const GlobalIdSet & globalIdSet() const
get global id set of grid
ALU2dGrid(int)
Constructor which constructs an empty ALU2dGrid.
std::vector< LevelIndexSetImp * > levelIndexVec_
the level index set ( default type )
Definition: grid.hh:567
int size(int level, GeometryType type) const
number of entities per level, codim and geometry type in this process
int hierSetSize(int cd) const
number of grid entities in the entire grid for given codim
bool readGrid(const std::string filename, alu2d_ctype &time)
read Grid from file filename and store time of mesh in time
Traits::template Codim< codim >::LeafIterator leafend() const
General definition for an end iterator on leaf level.
bool loadBalance(DataHandle &data)
Re-balances the load each process has to handle for a parallel grid,.
void backup(std::ostream &) const
backup to ostream
void restore(std::istream &)
restore from istream
void globalRefine(int refCount)
refine grid refCount times
ALU2dGridLevelIterator< 0, All_Partition, const ThisType > LevelIteratorImp
a standard leaf iterator
Definition: grid.hh:300
Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator lend(int level) const
one past the end on this level
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...
const Traits::LeafIndexSet & leafIndexSet() const
get leaf index set of the grid
SizeCache< ThisType > SizeCacheType
the type of our size cache
Definition: grid.hh:581
Traits::template Codim< codim >::template Partition< pitype >::LeafIterator leafbegin() const
General definiton for a leaf iterator.
@ refineEstimate_
if one element is refined then it causes apporximately not more than this number of new elements
Definition: grid.hh:326
@ MAXL
maximal number of levels is 64
Definition: grid.hh:312
int size(int codim) const
number of leaf entities per codim in this process
ALU2dGridLeafMarkerVectorType & getLeafMarker() const
Definition: grid.hh:692
bool nonConform() const
Definition: grid.hh:725
Traits::GlobalIdSet GlobalIdSet
Type of the global id set.
Definition: grid.hh:283
const DuneBoundaryProjectionType * boundaryProjection(const int segmentIndex) const
return boudanry projection for given segment Id
Definition: grid.hh:602
LeafIndexSetImp * leafIndexSet_
the leaf index set
Definition: grid.hh:574
Traits::template Codim< cd >::template Partition< All_Partition >::LevelIterator lbegin(int level) const
Iterator to first entity of given codim on level.
HmeshType * mygrid_
the real grid
Definition: grid.hh:546
Traits::DuneBoundaryProjectionVector DuneBoundaryProjectionVector
boundary projection type
Definition: grid.hh:332
Traits::DuneBoundaryProjectionType DuneBoundaryProjectionType
boundary projection type
Definition: grid.hh:330
const Traits::LevelIndexSet & levelIndexSet(int level) const
get level index set of the grid
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lbegin(int level) const
const LocalIdSet & localIdSet() const
get global id set of grid
Traits::template Codim< cd >::template Partition< pitype >::LevelIterator lend(int level) const
one past the end on this level
@ newElementsChunk_
normal default number of new elements for new adapt method
Definition: grid.hh:318
Traits::LocalIdSet LocalIdSet
Type of the local id set.
Definition: grid.hh:286
ALU2dGridMarkerVector & getMarkerVector(int level) const
Definition: grid.hh:683
ALU2dGridLocalIdSet< dim, dimworld, elementType > LocalIdSetImp
Type of the local id set.
Definition: grid.hh:279
int size(GeometryType type) const
number of leaf entities per codim and geometry type in this process
ALUGrid boundary projection implementation DuneBndProjection has to fulfil the DuneBoundaryProjection...
Definition: bndprojection.hh:15
CommDataHandleIF describes the features of a data handle for communication in parallel runs using the...
Definition: datahandleif.hh:75
Checks wether a type is convertible to another.
Definition: typetraits.hh:213
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:92
Wrapper class for entities.
Definition: entity.hh:57
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:25
Wrapper class for geometries.
Definition: geometry.hh:102
static ReturnImplementationType< InterfaceType >::ImplementationType & getRealImplementation(InterfaceType &i)
return real implementation of interface class
Definition: grid.hh:1223
Grid view abstract base class.
Definition: gridview.hh:57
Id Set Interface.
Definition: indexidset.hh:403
Mesh entities of codimension 0 ("elements") allow to visit all intersections with "neighboring" eleme...
Definition: intersectioniterator.hh:83
Intersection of a mesh entities of codimension 0 ("elements") with a "neighboring" element or with th...
Definition: intersection.hh:161
organizes the caching of sizes for one grid and one GeometryType
Definition: sizecache.hh:30
A set of traits classes to store static information about grid implementation.
Different resources needed by all grid implementations.
Provides default index set implementations for Level- and LeafIndexsets used by ALUGrid.
Provides a Interfaces for detection of specific behavior.
DErrType derr(std::cerr)
Stream for error messages.
Definition: stdstreams.hh:194
Provides proxy classes for IntersectionsIterators.
Dune namespace.
Definition: alignment.hh:14
CommunicationDirection
Define a type for communication direction parameter.
Definition: gridenums.hh:164
InterfaceType
Parameter to be used for the communication functions.
Definition: gridenums.hh:80
Helpers for dealing with MPI.
Provides size cache classes to implement the grids size method efficiently.
Fallback implementation of the C++0x static_assert feature.
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