dune-alugrid 3.0.0
alugrid.hh
Go to the documentation of this file.
1#ifndef DUNE_ALU3DGRID_ALUGRID_HH
2#define DUNE_ALU3DGRID_ALUGRID_HH
3
4#include <type_traits>
5
6// 3d version
13
19namespace Dune
20{
21
22 template <class Comm>
23 static const char* ALUGridParallelSerial()
24 {
25 return ( std::is_same< Comm, ALUGridNoComm >::value ) ? "serial" : "parallel";
26 }
27
28 template< int dim, int dimworld, ALUGridElementType elType, ALUGridRefinementType refineType, class Comm >
29 class ALUGrid
30 : public ALUGridBaseGrid< dim, dimworld, elType, Comm > :: BaseGrid
31 {
32 // the cube version of ALUGrid only works with nonconforming refinement
33 static_assert( elType == cube ? refineType == nonconforming : true, "cube only works with nonconforming refinement");
34
36 typedef typename ALUGridBaseGrid< dim, dimworld, elType, Comm > :: BaseGrid BaseType;
37
38 typedef typename BaseType::MPICommunicatorType MPICommunicatorType;
39
40 public:
42 typedef typename BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
43
45 typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
46
47 enum { dimension=BaseType::dimension, dimensionworld=BaseType::dimensionworld};
48 typedef typename BaseType::ctype ctype;
49 typedef typename BaseType::GridFamily GridFamily;
50 typedef typename GridFamily::Traits Traits;
51 typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
52 typedef typename Traits :: GlobalIdSet GlobalIdSet;
53 typedef typename Traits :: LocalIdSet LocalIdSet;
54 typedef typename GridFamily :: LevelIndexSetImp LevelIndexSetImp;
55 typedef typename GridFamily :: LeafIndexSetImp LeafIndexSetImp;
56 typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
57 typedef typename Traits:: template Codim<0>::LeafIterator LeafIteratorType;
58 typedef typename Traits:: template Codim<0>::LeafIterator LeafIterator;
59
70 ALUGrid(const std::string macroName,
71 const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
72 const DuneBoundaryProjectionType* bndProject = 0,
73 const DuneBoundaryProjectionVector* bndVector = 0,
74 const bool verb = true ) :
75 BaseType(macroName, mpiComm, bndProject, bndVector, refineType )
76 {
77 const bool verbose = verb && this->comm().rank() == 0;
78 if( verbose )
79 {
80 std::cout << "\nCreated " << ALUGridParallelSerial< Comm >() << " " << name() << nameSuffix()
81 << " from macro grid file '" << macroName << "'. \n\n";
82 }
83 }
84
85 static std::string name () { return std::string("ALUGrid"); }
86
87 static std::string nameSuffix()
88 {
89 std::string elt ( elType == cube ? "cube," : "simplex," );
90 std::string ref ( refineType == nonconforming ? "nonconforming>" : "conforming>" );
91 std::stringstream suffix;
92 suffix << "<"<< dimension <<","<< dimensionworld <<"," << elt << ref;
93 return suffix.str();
94 }
95
96
106 ALUGrid(const MPICommunicatorType mpiComm,
107 const DuneBoundaryProjectionType* bndProject ,
108 const DuneBoundaryProjectionVector* bndVector,
109 const std::string macroName,
110 const bool verb = true ) :
111 BaseType("", mpiComm, bndProject, bndVector, refineType )
112 {
113 const bool verbose = verb && this->comm().rank() == 0;
114 if( verbose )
115 {
116 std::cout << "\nCreated " << ALUGridParallelSerial< Comm >() << " " << name() << nameSuffix();
117 if( macroName.empty() )
118 std::cout << " from input stream. \n";
119 else
120 std::cout << " from macro grid file '" << macroName << "'. \n";
121 std::cout << std::endl;
122 }
123 }
124
126 ALUGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
127 BaseType("", mpiComm,
128 (const DuneBoundaryProjectionType *) 0,
130 refineType )
131 {
132 if(this->comm().rank() == 0)
133 {
134 std::cout << "\nCreated empty " << ALUGridParallelSerial< Comm >() << " " << name() << nameSuffix() << "." << std::endl << std::endl;
135 }
136 }
137
138 // ALUGrid only typedefs
139 typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
140 typedef typename BaseType::ObjectStreamType ObjectStreamType;
141
142 template< PartitionIteratorType pitype >
144 {
145 typedef Dune::GridView< ALU3dLevelGridViewTraits< const This, pitype > > LevelGridView;
146 typedef Dune::GridView< ALU3dLeafGridViewTraits< const This, pitype > > LeafGridView;
147 };
148
151
152 // old grid view methods
153 template< PartitionIteratorType pitype >
154 typename Partition< pitype >::LevelGridView levelView ( int level ) const { return levelGridView< pitype >( level ); }
155
156 template< PartitionIteratorType pitype >
157 typename Partition< pitype >::LeafGridView leafView () const { return leafGridView< pitype >(); }
158
159 LevelGridView levelView ( int level ) const { return levelGridView( level ); }
160
161 LeafGridView leafView () const { return leafGridView(); }
162
163 // new grid view methods
164 template< PartitionIteratorType pitype >
166 {
168 typedef typename LevelGridView::GridViewImp LevelGridViewImp;
169 return LevelGridView( LevelGridViewImp( *this, level ) );
170 }
171
172 template< PartitionIteratorType pitype >
174 {
176 typedef typename LeafGridView::GridViewImp LeafGridViewImp;
177 return LeafGridView( LeafGridViewImp( *this ) );
178 }
179
180 LevelGridView levelGridView ( int level ) const
181 {
182 typedef typename LevelGridView::GridViewImp LevelGridViewImp;
183 return LevelGridView( LevelGridViewImp( *this, level ) );
184 }
185
187 {
188 typedef typename LeafGridView::GridViewImp LeafGridViewImp;
189 return LeafGridView( LeafGridViewImp( *this ) );
190 }
191
192 private:
193 template< class > friend class ALU3dGridFactory;
194
196 ALUGrid( const ALUGrid & g ); // : BaseType(g) {}
197
199 This& operator = (const ALUGrid& g);
200 };
201
202} //end namespace Dune
203
204#undef alu_inline
205#endif // #ifndef DUNE_ALU3DGRID_ALUGRID_HH
Capabilities for ALUGrid.
Definition alu3dinclude.hh:50
Definition alu3dinclude.hh:80
static const char * ALUGridParallelSerial()
Definition alugrid.hh:23
@ cube
use only cube elements (i.e., quadrilaterals or hexahedra)
Definition declaration.hh:19
@ nonconforming
use non-conforming (red) refinement
Definition declaration.hh:26
unstructured parallel implementation of the DUNE grid interface
Definition alugrid.hh:31
BaseType::ctype ctype
Definition alugrid.hh:48
LeafGridView leafGridView() const
Definition alugrid.hh:186
ALUGrid(const MPICommunicatorType mpiComm=BaseType::defaultCommunicator())
constructor creating empty grid, empty string creates empty grid
Definition alugrid.hh:126
GridFamily::LeafIndexSetImp LeafIndexSetImp
Definition alugrid.hh:55
BaseType::LocalIdSetImp LocalIdSetImp
Definition alugrid.hh:51
Partition< pitype >::LeafGridView leafGridView() const
Definition alugrid.hh:173
BaseType::HierarchicIteratorImp HierarchicIteratorImp
Definition alugrid.hh:139
BaseType::GridFamily GridFamily
Definition alugrid.hh:49
static std::string name()
Definition alugrid.hh:85
Partition< pitype >::LevelGridView levelGridView(int level) const
Definition alugrid.hh:165
static std::string nameSuffix()
Definition alugrid.hh:87
GridFamily::LevelIndexSetImp LevelIndexSetImp
Definition alugrid.hh:54
Partition< pitype >::LevelGridView levelView(int level) const
Definition alugrid.hh:154
BaseType::DuneBoundaryProjectionType DuneBoundaryProjectionType
type of boundary projection
Definition alugrid.hh:42
ALUGrid(const std::string macroName, const MPICommunicatorType mpiComm=BaseType::defaultCommunicator(), const DuneBoundaryProjectionType *bndProject=0, const DuneBoundaryProjectionVector *bndVector=0, const bool verb=true)
constructor for creating ALUGrid from given macro grid file
Definition alugrid.hh:70
Traits::template Codim< 0 >::LeafIterator LeafIterator
Definition alugrid.hh:58
Partition< All_Partition >::LevelGridView LevelGridView
Definition alugrid.hh:149
Traits::GlobalIdSet GlobalIdSet
Definition alugrid.hh:52
Traits::template Codim< 0 >::LeafIterator LeafIteratorType
Definition alugrid.hh:57
LevelGridView levelView(int level) const
Definition alugrid.hh:159
@ dimension
Definition alugrid.hh:47
@ dimensionworld
Definition alugrid.hh:47
Traits::LocalIdSet LocalIdSet
Definition alugrid.hh:53
BaseType::ObjectStreamType ObjectStreamType
Definition alugrid.hh:140
Partition< pitype >::LeafGridView leafView() const
Definition alugrid.hh:157
LeafGridView leafView() const
Definition alugrid.hh:161
BaseType::LeafIteratorImp LeafIteratorImp
Definition alugrid.hh:56
ALUGrid(const MPICommunicatorType mpiComm, const DuneBoundaryProjectionType *bndProject, const DuneBoundaryProjectionVector *bndVector, const std::string macroName, const bool verb=true)
constructor called from ALUGridFactory for creating ALUConformGrid from given macro grid file
Definition alugrid.hh:106
BaseType::DuneBoundaryProjectionVector DuneBoundaryProjectionVector
type of boundary projection
Definition alugrid.hh:45
LevelGridView levelGridView(int level) const
Definition alugrid.hh:180
GridFamily::Traits Traits
Definition alugrid.hh:50
Partition< All_Partition >::LeafGridView LeafGridView
Definition alugrid.hh:150
Definition alugrid.hh:144
Dune::GridView< ALU3dLeafGridViewTraits< const This, pitype > > LeafGridView
Definition alugrid.hh:146
Dune::GridView< ALU3dLevelGridViewTraits< const This, pitype > > LevelGridView
Definition alugrid.hh:145
Factory class for ALUGrids.
Definition gridfactory.hh:28
Definition declaration.hh:78