dune-grid  2.2.0
alugrid/3d/alugrid.hh
Go to the documentation of this file.
1 #ifndef DUNE_ALU3DGRID_ALUGRID_HH
2 #define DUNE_ALU3DGRID_ALUGRID_HH
3 
4 // only include this code, if ENABLE_ALUGRID is defined
5 #ifdef ENABLE_ALUGRID
6 
7 // 3d version
15 
21 namespace Dune
22 {
23 
24  template< int dim, int dimworld >
25  class ALUCubeGrid;
26 
27  template< int dim, int dimworld >
28  class ALUSimplexGrid;
29 
30  static const char* ALUGridParallelSerial()
31  {
32 #if ALU3DGRID_PARALLEL
33  return "parallel";
34 #else
35  return "serial";
36 #endif
37  }
38 
44  template<>
45  class ALUCubeGrid< 3, 3 >
46  : public Dune::ALU3dGrid< hexa >
47  {
48  typedef ALUCubeGrid< 3, 3 > This;
50 
51  enum { dim = 3 };
52  enum { dimworld = 3 };
53 
54  typedef BaseType::MPICommunicatorType MPICommunicatorType;
55 
56  public:
59 
61  typedef BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
62 
73  ALUCubeGrid(const std::string macroName,
74  const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
75  const DuneBoundaryProjectionType* bndProject = 0,
76  const DuneBoundaryProjectionVector* bndVector= 0,
77  const bool verb = true ) :
78  BaseType(macroName,mpiComm,bndProject, bndVector, nonconforming )
79  {
80  const bool verbose = verb && this->comm().rank() == 0;
81  if( verbose )
82  {
83  std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUCubeGrid<"<<dim<<","<<dimworld;
84  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
85  }
86  }
87 
97  ALUCubeGrid(const MPICommunicatorType mpiComm,
98  const DuneBoundaryProjectionType* bndProject ,
99  const DuneBoundaryProjectionVector* bndVector,
100  const std::string macroName,
101  const bool verb = true ) :
102  BaseType("", mpiComm, bndProject, bndVector, nonconforming )
103  {
104  const bool verbose = verb && this->comm().rank() == 0;
105  if( verbose )
106  {
107  std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUCubeGrid<"<<dim<<","<<dimworld;
108  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
109  }
110  }
111 
113  ALUCubeGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator() ) :
114  BaseType("", mpiComm,
115  (const DuneBoundaryProjectionType *) 0,
116  (const DuneBoundaryProjectionVector* ) 0,
117  nonconforming )
118  {
119  if(this->comm().rank() == 0)
120  {
121  std::cout << "\nCreated empty ALUCubeGrid<"<<dim<<","<<dimworld <<">. \n\n";
122  }
123  }
124 
125  enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
137 
138  // ALUGrid only typedefs
141 
142  template< PartitionIteratorType pitype >
143  struct Partition
144  {
149  };
150 
153 
154  template< PartitionIteratorType pitype >
155  typename Partition< pitype >::LevelGridView levelView ( int level ) const
156  {
158  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
159  return LevelGridView( LevelGridViewImp( *this, level ) );
160  }
161 
162  template< PartitionIteratorType pitype >
163  typename Partition< pitype >::LeafGridView leafView () const
164  {
166  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
167  return LeafGridView( LeafGridViewImp( *this ) );
168  }
169 
170  LevelGridView levelView ( int level ) const
171  {
172  typedef LevelGridView::GridViewImp LevelGridViewImp;
173  return LevelGridView( LevelGridViewImp( *this, level ) );
174  }
175 
176  LeafGridView leafView () const
177  {
178  typedef LeafGridView::GridViewImp LeafGridViewImp;
179  return LeafGridView( LeafGridViewImp( *this ) );
180  }
181 
182  private:
183  friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
184  friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
185 
186  friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
187  friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
188 
189  template< class > friend class ALU3dGridFactory;
190 
192  ALUCubeGrid( const ALUCubeGrid & g ) ; // : BaseType(g) {}
193 
195  ALUCubeGrid<dim,dimworld>&
196  operator = (const ALUCubeGrid& g);
197  };
198 
199 
200 
206  template<>
207  class ALUSimplexGrid< 3, 3 >
208  : public Dune::ALU3dGrid< tetra >
209  {
212 
213  enum { dim = 3 };
214  enum { dimworld = 3 };
215 
216  typedef BaseType::MPICommunicatorType MPICommunicatorType;
217 
218  public:
221 
223  typedef BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
224 
235  ALUSimplexGrid(const std::string macroName,
236  const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
237  const DuneBoundaryProjectionType* bndProject = 0,
238  const DuneBoundaryProjectionVector* bndVector = 0,
239  const bool verb = true ) :
240  BaseType(macroName, mpiComm, bndProject, bndVector, nonconforming )
241  {
242  const bool verbose = verb && this->comm().rank() == 0;
243  if( verbose )
244  {
245  std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUSimplexGrid<"<<dim<<","<<dimworld;
246  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
247  }
248  }
249 
259  ALUSimplexGrid(const MPICommunicatorType mpiComm,
260  const DuneBoundaryProjectionType* bndProject ,
261  const DuneBoundaryProjectionVector* bndVector,
262  const std::string macroName,
263  const bool verb = true ) :
264  BaseType("", mpiComm, bndProject, bndVector, nonconforming )
265  {
266  const bool verbose = verb && this->comm().rank() == 0;
267  if( verbose )
268  {
269  std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUSimplexGrid<"<<dim<<","<<dimworld;
270  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
271  }
272  }
273 
275  ALUSimplexGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
276  BaseType("", mpiComm,
277  (const DuneBoundaryProjectionType *) 0,
278  (const DuneBoundaryProjectionVector* ) 0,
279  nonconforming )
280  {
281  if(this->comm().rank() == 0)
282  {
283  std::cout << "\nCreated empty ALUSimplexGrid<"<<dim<<","<<dimworld <<">. \n\n";
284  }
285  }
286 
287  enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
294  typedef GridFamily :: LevelIndexSetImp LevelIndexSetImp;
299 
300  // ALUGrid only typedefs
303 
304  template< PartitionIteratorType pitype >
305  struct Partition
306  {
311  };
312 
315 
316  template< PartitionIteratorType pitype >
317  typename Partition< pitype >::LevelGridView levelView ( int level ) const
318  {
320  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
321  return LevelGridView( LevelGridViewImp( *this, level ) );
322  }
323 
324  template< PartitionIteratorType pitype >
325  typename Partition< pitype >::LeafGridView leafView () const
326  {
328  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
329  return LeafGridView( LeafGridViewImp( *this ) );
330  }
331 
332  LevelGridView levelView ( int level ) const
333  {
334  typedef LevelGridView::GridViewImp LevelGridViewImp;
335  return LevelGridView( LevelGridViewImp( *this, level ) );
336  }
337 
338  LeafGridView leafView () const
339  {
340  typedef LeafGridView::GridViewImp LeafGridViewImp;
341  return LeafGridView( LeafGridViewImp( *this ) );
342  }
343 
344  private:
345  friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
346  friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
347 
348  friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
349  friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
350 
351  template< class > friend class ALU3dGridFactory;
352 
354  ALUSimplexGrid( const ALUSimplexGrid & g ); // : BaseType(g) {}
355 
357  ALUSimplexGrid<dim,dimworld>&
358  operator = (const ALUSimplexGrid& g);
359  };
360 
361 /*-
362  (see ALUGrid homepage: http://www.mathematik.uni-freiburg.de/IAM/Research/alugrid/)
363 
364  \li Available Implementations
365  - quadrilateral and hexahedral elements only nonconforming refinement
366  - Dune::ALUGrid< 2, 2, cube, nonconforming >
367  - Dune::ALUGrid< 2, 3, cube, nonconforming >
368  - Dune::ALUGrid< 3, 3, cube, nonconforming >
369  - simplicial elements and nonconforming refinement
370  - Dune::ALUGrid< 2, 2, simplex, nonconforming >
371  - Dune::ALUGrid< 2, 3, simplex, nonconforming >
372  - Dune::ALUGrid< 3, 3, simplex, nonconforming >
373  - simplicial elements and bisection refinement
374  - Dune::ALUGrid< 2, 2, simplex, conforming >
375  - Dune::ALUGrid< 2, 3, simplex, conforming >
376  - Dune::ALUGrid< 3, 3, simplex, conforming > (work in progress)
377 
378  \note template parameter Comm defaults to MPI_Comm, if MPI is available, No_Comm otherwise.
379 */
380  template< ALUGridElementType elType, ALUGridRefinementType refineType, class Comm >
381  class ALUGrid< 3, 3, elType, refineType, Comm >
382  : public ALUGridBaseGrid< 3, 3, elType, Comm > :: BaseGrid
383  {
385  typedef typename ALUGridBaseGrid< 3, 3, elType, Comm > :: BaseGrid BaseType;
386 
387  enum { dim = 3 };
388  enum { dimworld = 3 };
389 
390  typedef typename BaseType::MPICommunicatorType MPICommunicatorType;
391 
392  public:
394  typedef typename BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
395 
397  typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
398 
409  ALUGrid(const std::string macroName,
410  const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
411  const DuneBoundaryProjectionType* bndProject = 0,
412  const DuneBoundaryProjectionVector* bndVector = 0,
413  const bool verb = true ) :
414  BaseType(macroName, mpiComm, bndProject, bndVector, refineType )
415  {
416  const bool verbose = verb && this->comm().rank() == 0;
417  if( verbose )
418  {
419  std::cout << "\nCreated " << ALUGridParallelSerial() << " " << name() << nameSuffix()
420  << " from macro grid file '" << macroName << "'. \n\n";
421  }
422  }
423 
424  static std::string name () { return std::string("ALUGrid"); }
425 
426  static std::string nameSuffix()
427  {
428  std::string elt ( elType == cube ? "cube," : "simplex," );
429  std::string ref ( refineType == nonconforming ? "nonconforming>" : "conforming>" );
430  std::stringstream suffix;
431  suffix << "<"<<dim<<","<<dimworld<<"," << elt << ref;
432  return suffix.str();
433  }
434 
435 
445  ALUGrid(const MPICommunicatorType mpiComm,
446  const DuneBoundaryProjectionType* bndProject ,
447  const DuneBoundaryProjectionVector* bndVector,
448  const std::string macroName,
449  const bool verb = true ) :
450  BaseType("", mpiComm, bndProject, bndVector, refineType )
451  {
452  const bool verbose = verb && this->comm().rank() == 0;
453  if( verbose )
454  {
455  std::cout << "\nCreated " << ALUGridParallelSerial() << " " << name() << nameSuffix()
456  << " from macro grid file '" << macroName << "'. \n\n";
457  }
458  }
459 
461  ALUGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
462  BaseType("", mpiComm,
463  (const DuneBoundaryProjectionType *) 0,
464  (const DuneBoundaryProjectionVector* ) 0,
465  refineType )
466  {
467  if(this->comm().rank() == 0)
468  {
469  std::cout << "\nCreated empty " << ALUGridParallelSerial() << " " << name() << nameSuffix() << "." << std::endl << std::endl;
470  }
471  }
472 
473  enum { dimension=BaseType::dimension, dimensionworld=BaseType::dimensionworld};
474  typedef typename BaseType::ctype ctype;
475  typedef typename BaseType::GridFamily GridFamily;
476  typedef typename GridFamily::Traits Traits;
477  typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
478  typedef typename Traits :: GlobalIdSet GlobalIdSet;
479  typedef typename Traits :: LocalIdSet LocalIdSet;
480  typedef typename GridFamily :: LevelIndexSetImp LevelIndexSetImp;
481  typedef typename GridFamily :: LeafIndexSetImp LeafIndexSetImp;
482  typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
483  typedef typename Traits:: template Codim<0>::LeafIterator LeafIteratorType;
484  typedef typename Traits:: template Codim<0>::LeafIterator LeafIterator;
485 
486  // ALUGrid only typedefs
487  typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
488  typedef typename BaseType::ObjectStreamType ObjectStreamType;
489 
490  template< PartitionIteratorType pitype >
491  struct Partition
492  {
497  };
498 
499  typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
500  typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
501 
502  template< PartitionIteratorType pitype >
503  typename Partition< pitype >::LevelGridView levelView ( int level ) const
504  {
506  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
507  return LevelGridView( LevelGridViewImp( *this, level ) );
508  }
509 
510  template< PartitionIteratorType pitype >
511  typename Partition< pitype >::LeafGridView leafView () const
512  {
514  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
515  return LeafGridView( LeafGridViewImp( *this ) );
516  }
517 
518  LevelGridView levelView ( int level ) const
519  {
520  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
521  return LevelGridView( LevelGridViewImp( *this, level ) );
522  }
523 
524  LeafGridView leafView () const
525  {
526  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
527  return LeafGridView( LeafGridViewImp( *this ) );
528  }
529 
530  private:
531  friend class Conversion< This , HasObjectStream > ;
532  friend class Conversion< const This, HasObjectStream > ;
533 
534  friend class Conversion< This, HasHierarchicIndexSet > ;
535  friend class Conversion< const This, HasHierarchicIndexSet > ;
536 
537  template< class > friend class ALU3dGridFactory;
538 
540  ALUGrid( const ALUGrid & g ); // : BaseType(g) {}
541 
543  This& operator = (const ALUGrid& g);
544  };
545 
546 } //end namespace Dune
547 
548 #endif // #ifdef ENABLE_ALUGRID
549 
550 #undef alu_inline
551 #endif