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
12 #include <dune/alugrid/3d/grid.hh>
13 
19 namespace 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,
129  (const DuneBoundaryProjectionVector* ) 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 >
143  struct Partition
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
geometry.hh
Dune::ALUGrid::ctype
BaseType::ctype ctype
Definition: alugrid.hh:48
iterator.hh
Dune::ALUGrid::LevelGridView
Partition< All_Partition >::LevelGridView LevelGridView
Definition: alugrid.hh:149
Dune::ALUGrid::LeafGridView
Partition< All_Partition >::LeafGridView LeafGridView
Definition: alugrid.hh:150
Dune::ALUGrid::Partition
Definition: alugrid.hh:143
Dune::ALUGrid::LeafIteratorImp
BaseType::LeafIteratorImp LeafIteratorImp
Definition: alugrid.hh:56
Dune::ALUGrid::name
static std::string name()
Definition: alugrid.hh:85
Dune::ALUGrid::LocalIdSet
Traits ::LocalIdSet LocalIdSet
Definition: alugrid.hh:53
Dune::ALUGrid::LeafIteratorType
Traits::template Codim< 0 >::LeafIterator LeafIteratorType
Definition: alugrid.hh:57
capabilities.hh
Capabilities for ALUGrid.
Dune::ALUGrid::LevelIndexSetImp
GridFamily ::LevelIndexSetImp LevelIndexSetImp
Definition: alugrid.hh:54
Dune::ALUGrid::leafView
LeafGridView leafView() const
Definition: alugrid.hh:161
Dune::ALUGrid::HierarchicIteratorImp
BaseType::HierarchicIteratorImp HierarchicIteratorImp
Definition: alugrid.hh:139
Dune::ALUGrid::GridFamily
BaseType::GridFamily GridFamily
Definition: alugrid.hh:49
Dune::ALUGridParallelSerial
static const char * ALUGridParallelSerial()
Definition: alugrid.hh:23
Dune::nonconforming
use non-conforming (red) refinement
Definition: declaration.hh:26
Dune::ALUGrid::GlobalIdSet
Traits ::GlobalIdSet GlobalIdSet
Definition: alugrid.hh:52
Dune::ALUGrid::leafView
Partition< pitype >::LeafGridView leafView() const
Definition: alugrid.hh:157
Dune::ALUGrid::nameSuffix
static std::string nameSuffix()
Definition: alugrid.hh:87
Dune::ALUGrid::leafGridView
Partition< pitype >::LeafGridView leafGridView() const
Definition: alugrid.hh:173
Dune::ALUGrid::levelView
Partition< pitype >::LevelGridView levelView(int level) const
Definition: alugrid.hh:154
Dune::ALUGrid::Partition::LevelGridView
Dune::GridView< ALU3dLevelGridViewTraits< const This, pitype > > LevelGridView
Definition: alugrid.hh:145
Dune::ALUGrid::ALUGrid
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
Dune::ALUGrid::dimension
Definition: alugrid.hh:47
Dune::ALUGrid::Partition::LeafGridView
Dune::GridView< ALU3dLeafGridViewTraits< const This, pitype > > LeafGridView
Definition: alugrid.hh:146
Dune::ALUGrid::ALUGrid
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
Dune::ALUGrid::LeafIndexSetImp
GridFamily ::LeafIndexSetImp LeafIndexSetImp
Definition: alugrid.hh:55
Dune::cube
use only cube elements (i.e., quadrilaterals or hexahedra)
Definition: declaration.hh:19
indexsets.hh
Dune::ALUGrid::levelGridView
Partition< pitype >::LevelGridView levelGridView(int level) const
Definition: alugrid.hh:165
Dune::ALUGrid::levelView
LevelGridView levelView(int level) const
Definition: alugrid.hh:159
Dune::ALUGrid::ALUGrid
ALUGrid(const MPICommunicatorType mpiComm=BaseType::defaultCommunicator())
constructor creating empty grid, empty string creates empty grid
Definition: alugrid.hh:126
Dune::ALUGrid::dimensionworld
Definition: alugrid.hh:47
Dune::ALUGridBaseGrid
Definition: declaration.hh:78
Dune::ALU3dGridFactory
Factory class for ALUGrids.
Definition: 3d/grid.hh:84
Dune::ALUGrid::Traits
GridFamily::Traits Traits
Definition: alugrid.hh:50
Dune::ALUGrid::DuneBoundaryProjectionVector
BaseType ::DuneBoundaryProjectionVector DuneBoundaryProjectionVector
type of boundary projection
Definition: alugrid.hh:45
Dune::ALUGrid::ObjectStreamType
BaseType::ObjectStreamType ObjectStreamType
Definition: alugrid.hh:140
ALUGrid
Definition: alu3dinclude.hh:49
Dune::ALUGrid::LocalIdSetImp
BaseType::LocalIdSetImp LocalIdSetImp
Definition: alugrid.hh:51
Dune::ALUGrid
unstructured parallel implementation of the DUNE grid interface
Definition: alugrid.hh:29
Dune::ALUGrid::LeafIterator
Traits::template Codim< 0 >::LeafIterator LeafIterator
Definition: alugrid.hh:58
grid.hh
Dune::ALUGrid::levelGridView
LevelGridView levelGridView(int level) const
Definition: alugrid.hh:180
Dune::ALUGrid::leafGridView
LeafGridView leafGridView() const
Definition: alugrid.hh:186
Dune::ALUGrid::DuneBoundaryProjectionType
BaseType ::DuneBoundaryProjectionType DuneBoundaryProjectionType
type of boundary projection
Definition: alugrid.hh:42
entity.hh
Dune
Definition: alu3dinclude.hh:79