dune-alugrid 2.8.0
Loading...
Searching...
No Matches
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 public:
39 typedef typename BaseType::MPICommunicatorType MPICommunicatorType;
40
42 typedef typename BaseType :: ALUGridVertexProjectionPairType ALUGridVertexProjectionPairType;
43
44 enum { dimension=BaseType::dimension, dimensionworld=BaseType::dimensionworld};
45 static const ALUGridRefinementType refinementType = refineType;
46 typedef typename BaseType::ctype ctype;
47 typedef typename BaseType::GridFamily GridFamily;
48 typedef typename GridFamily::Traits Traits;
49 typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
50 typedef typename Traits :: GlobalIdSet GlobalIdSet;
51 typedef typename Traits :: LocalIdSet LocalIdSet;
52 typedef typename GridFamily :: LevelIndexSetImp LevelIndexSetImp;
53 typedef typename GridFamily :: LeafIndexSetImp LeafIndexSetImp;
54 typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
55 typedef typename Traits:: template Codim<0>::LeafIterator LeafIteratorType;
56 typedef typename Traits:: template Codim<0>::LeafIterator LeafIterator;
57
68 ALUGrid(const std::string macroName,
69 const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
71 const bool verb = true ) :
72 BaseType(macroName, mpiComm, bndPrj, refineType )
73 {
74 const bool verbose = verb && this->comm().rank() == 0;
75 if( verbose )
76 {
77 std::cout << "\nCreated " << ALUGridParallelSerial< Comm >() << " " << name() << nameSuffix()
78 << " from macro grid file '" << macroName << "'. \n\n";
79 }
80 }
81
82 static std::string name () { return std::string("ALUGrid"); }
83
84 static std::string nameSuffix()
85 {
86 std::string elt ( elType == cube ? "cube," : "simplex," );
87 std::string ref ( refineType == nonconforming ? "nonconforming>" : "conforming>" );
88 std::stringstream suffix;
89 suffix << "<"<< dimension <<","<< dimensionworld <<"," << elt << ref;
90 return suffix.str();
91 }
92
93
105 const std::string macroName,
106 const bool verb = true ) :
107 BaseType("", mpiComm, bndPrj, refineType )
108 {
109 const bool verbose = verb && this->comm().rank() == 0;
110 if( verbose )
111 {
112 std::cout << "\nCreated " << ALUGridParallelSerial< Comm >() << " " << name() << nameSuffix();
113 if( macroName.empty() )
114 std::cout << " from input stream. \n";
115 else
116 std::cout << " from macro grid file '" << macroName << "'. \n";
117 std::cout << std::endl;
118 }
119 }
120
122 ALUGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
123 BaseType("", mpiComm, ALUGridVertexProjectionPairType(), refineType )
124 {
125 if(this->comm().rank() == 0)
126 {
127 std::cout << "\nCreated empty " << ALUGridParallelSerial< Comm >() << " " << name() << nameSuffix() << "." << std::endl << std::endl;
128 }
129 }
130
131 // ALUGrid only typedefs
132 typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
133 typedef typename BaseType::ObjectStreamType ObjectStreamType;
134
135 template< PartitionIteratorType pitype >
137 {
138 typedef Dune::GridView< ALU3dLevelGridViewTraits< const This, pitype > > LevelGridView;
139 typedef Dune::GridView< ALU3dLeafGridViewTraits< const This, pitype > > LeafGridView;
140 };
141
144
145 // old grid view methods
146 template< PartitionIteratorType pitype >
147 typename Partition< pitype >::LevelGridView levelView ( int level ) const { return levelGridView< pitype >( level ); }
148
149 template< PartitionIteratorType pitype >
150 typename Partition< pitype >::LeafGridView leafView () const { return leafGridView< pitype >(); }
151
152 LevelGridView levelView ( int level ) const { return levelGridView( level ); }
153
154 LeafGridView leafView () const { return leafGridView(); }
155
156 // new grid view methods
157 template< PartitionIteratorType pitype >
159 {
161 typedef typename LevelGridView::GridViewImp LevelGridViewImp;
162 return LevelGridView( LevelGridViewImp( *this, level ) );
163 }
164
165 template< PartitionIteratorType pitype >
167 {
169 typedef typename LeafGridView::GridViewImp LeafGridViewImp;
170 return LeafGridView( LeafGridViewImp( *this ) );
171 }
172
173 LevelGridView levelGridView ( int level ) const
174 {
175 typedef typename LevelGridView::GridViewImp LevelGridViewImp;
176 return LevelGridView( LevelGridViewImp( *this, level ) );
177 }
178
180 {
181 typedef typename LeafGridView::GridViewImp LeafGridViewImp;
182 return LeafGridView( LeafGridViewImp( *this ) );
183 }
184
185 private:
186 template< class > friend class ALU3dGridFactory;
187
189 ALUGrid( const ALUGrid & g ); // : BaseType(g) {}
190
192 This& operator = (const ALUGrid& g);
193 };
194
195} //end namespace Dune
196
197//#undef alu_inline
198#endif // #ifndef DUNE_ALU3DGRID_ALUGRID_HH
Capabilities for ALUGrid.
Definition: alu3dinclude.hh:33
Definition: alu3dinclude.hh:63
static const char * ALUGridParallelSerial()
Definition: alugrid.hh:23
@ cube
use only cube elements (i.e., quadrilaterals or hexahedra)
Definition: declaration.hh:19
ALUGridRefinementType
available refinement types for ALUGrid
Definition: declaration.hh:24
@ 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:46
LeafGridView leafGridView() const
Definition: alugrid.hh:179
ALUGrid(const MPICommunicatorType mpiComm=BaseType::defaultCommunicator())
constructor creating empty grid, empty string creates empty grid
Definition: alugrid.hh:122
GridFamily::LeafIndexSetImp LeafIndexSetImp
Definition: alugrid.hh:53
BaseType::LocalIdSetImp LocalIdSetImp
Definition: alugrid.hh:49
Partition< pitype >::LeafGridView leafGridView() const
Definition: alugrid.hh:166
BaseType::HierarchicIteratorImp HierarchicIteratorImp
Definition: alugrid.hh:132
BaseType::GridFamily GridFamily
Definition: alugrid.hh:47
static std::string name()
Definition: alugrid.hh:82
Partition< pitype >::LevelGridView levelGridView(int level) const
Definition: alugrid.hh:158
static std::string nameSuffix()
Definition: alugrid.hh:84
GridFamily::LevelIndexSetImp LevelIndexSetImp
Definition: alugrid.hh:52
Partition< pitype >::LevelGridView levelView(int level) const
Definition: alugrid.hh:147
BaseType::ALUGridVertexProjectionPairType ALUGridVertexProjectionPairType
type of boundary projection
Definition: alugrid.hh:42
Traits::template Codim< 0 >::LeafIterator LeafIterator
Definition: alugrid.hh:56
Partition< All_Partition >::LevelGridView LevelGridView
Definition: alugrid.hh:142
ALUGrid(const MPICommunicatorType mpiComm, const ALUGridVertexProjectionPairType &bndPrj, const std::string macroName, const bool verb=true)
constructor called from ALUGridFactory for creating ALUConformGrid from given macro grid file
Definition: alugrid.hh:103
Traits::GlobalIdSet GlobalIdSet
Definition: alugrid.hh:50
ALUGrid(const std::string macroName, const MPICommunicatorType mpiComm=BaseType::defaultCommunicator(), const ALUGridVertexProjectionPairType &bndPrj=ALUGridVertexProjectionPairType(), const bool verb=true)
constructor for creating ALUGrid from given macro grid file
Definition: alugrid.hh:68
Traits::template Codim< 0 >::LeafIterator LeafIteratorType
Definition: alugrid.hh:55
LevelGridView levelView(int level) const
Definition: alugrid.hh:152
@ dimension
Definition: alugrid.hh:44
@ dimensionworld
Definition: alugrid.hh:44
Traits::LocalIdSet LocalIdSet
Definition: alugrid.hh:51
BaseType::ObjectStreamType ObjectStreamType
Definition: alugrid.hh:133
static const ALUGridRefinementType refinementType
Definition: alugrid.hh:45
Partition< pitype >::LeafGridView leafView() const
Definition: alugrid.hh:150
LeafGridView leafView() const
Definition: alugrid.hh:154
BaseType::MPICommunicatorType MPICommunicatorType
Definition: alugrid.hh:39
BaseType::LeafIteratorImp LeafIteratorImp
Definition: alugrid.hh:54
LevelGridView levelGridView(int level) const
Definition: alugrid.hh:173
GridFamily::Traits Traits
Definition: alugrid.hh:48
Partition< All_Partition >::LeafGridView LeafGridView
Definition: alugrid.hh:143
Definition: alugrid.hh:137
Dune::GridView< ALU3dLeafGridViewTraits< const This, pitype > > LeafGridView
Definition: alugrid.hh:139
Dune::GridView< ALU3dLevelGridViewTraits< const This, pitype > > LevelGridView
Definition: alugrid.hh:138
Factory class for ALUGrids.
Definition: gridfactory.hh:30
Definition: declaration.hh:82