dune-grid  2.3beta2
alugrid/3d/alugrid.hh
Go to the documentation of this file.
1 // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi: set et ts=4 sw=2 sts=2:
3 #ifndef DUNE_ALU3DGRID_ALUGRID_HH
4 #define DUNE_ALU3DGRID_ALUGRID_HH
5 
6 // only include this code, if ENABLE_ALUGRID is defined
7 #if HAVE_ALUGRID || DOXYGEN
8 
9 // 3d version
17 
23 namespace Dune
24 {
25 
26  template< int dim, int dimworld >
27  class ALUCubeGrid;
28 
29  template< int dim, int dimworld >
30  class ALUSimplexGrid;
31 
32  static const char* ALUGridParallelSerial()
33  {
34 #if ALU3DGRID_PARALLEL
35  return "parallel";
36 #else
37  return "serial";
38 #endif
39  }
40 
47  template<>
48  class ALUCubeGrid< 3, 3 >
49  : public Dune::ALU3dGrid< hexa >
50  {
51  typedef ALUCubeGrid< 3, 3 > This;
53 
54  enum { dim = 3 };
55  enum { dimworld = 3 };
56 
57  typedef BaseType::MPICommunicatorType MPICommunicatorType;
58 
59  public:
62 
64  typedef BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
65 
77  DUNE_DEPRECATED
78  ALUCubeGrid(const std::string macroName,
79  const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
80  const DuneBoundaryProjectionType* bndProject = 0,
81  const DuneBoundaryProjectionVector* bndVector= 0,
82  const bool verb = true ) :
83  BaseType(macroName,mpiComm,bndProject, bndVector, nonconforming )
84  {
85  const bool verbose = verb && this->comm().rank() == 0;
86  if( verbose )
87  {
88  std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUCubeGrid<"<<dim<<","<<dimworld;
89  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
90  }
91  }
92 
103  DUNE_DEPRECATED
104  ALUCubeGrid(const MPICommunicatorType mpiComm,
105  const DuneBoundaryProjectionType* bndProject ,
106  const DuneBoundaryProjectionVector* bndVector,
107  const std::string macroName,
108  const bool verb = true ) :
109  BaseType("", mpiComm, bndProject, bndVector, nonconforming )
110  {
111  const bool verbose = verb && this->comm().rank() == 0;
112  if( verbose )
113  {
114  std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUCubeGrid<"<<dim<<","<<dimworld;
115  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
116  }
117  }
118 
121  DUNE_DEPRECATED
122  ALUCubeGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator() ) :
123  BaseType("", mpiComm,
124  (const DuneBoundaryProjectionType *) 0,
125  (const DuneBoundaryProjectionVector* ) 0,
126  nonconforming )
127  {
128  if(this->comm().rank() == 0)
129  {
130  std::cout << "\nCreated empty ALUCubeGrid<"<<dim<<","<<dimworld <<">. \n\n";
131  }
132  }
133 
134  enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
136  typedef BaseType::GridFamily GridFamily;
137  typedef GridFamily::Traits Traits;
139  typedef Traits :: GlobalIdSet GlobalIdSet;
140  typedef Traits :: LocalIdSet LocalIdSet;
141  typedef GridFamily :: LevelIndexSetImp LevelIndexSetImp;
142  typedef GridFamily :: LeafIndexSetImp LeafIndexSetImp;
144  typedef Traits::Codim<0>::LeafIterator LeafIteratorType;
145  typedef Traits::Codim<0>::LeafIterator LeafIterator;
146 
147  // ALUGrid only typedefs
150 
151  template< PartitionIteratorType pitype >
152  struct Partition
153  {
158  };
159 
162 
163  template< PartitionIteratorType pitype >
164  typename Partition< pitype >::LevelGridView levelView ( int level ) const
165  {
167  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
168  return LevelGridView( LevelGridViewImp( *this, level ) );
169  }
170 
171  template< PartitionIteratorType pitype >
172  typename Partition< pitype >::LeafGridView leafView () const
173  {
175  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
176  return LeafGridView( LeafGridViewImp( *this ) );
177  }
178 
179  LevelGridView levelView ( int level ) const
180  {
181  typedef LevelGridView::GridViewImp LevelGridViewImp;
182  return LevelGridView( LevelGridViewImp( *this, level ) );
183  }
184 
185  LeafGridView leafView () const
186  {
187  typedef LeafGridView::GridViewImp LeafGridViewImp;
188  return LeafGridView( LeafGridViewImp( *this ) );
189  }
190 
191  template< PartitionIteratorType pitype >
192  typename Partition< pitype >::LevelGridView levelGridView ( int level ) const
193  {
195  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
196  return LevelGridView( LevelGridViewImp( *this, level ) );
197  }
198 
199  template< PartitionIteratorType pitype >
200  typename Partition< pitype >::LeafGridView leafGridView () const
201  {
203  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
204  return LeafGridView( LeafGridViewImp( *this ) );
205  }
206 
207  LevelGridView levelGridView ( int level ) const
208  {
209  typedef LevelGridView::GridViewImp LevelGridViewImp;
210  return LevelGridView( LevelGridViewImp( *this, level ) );
211  }
212 
213  LeafGridView leafGridView () const
214  {
215  typedef LeafGridView::GridViewImp LeafGridViewImp;
216  return LeafGridView( LeafGridViewImp( *this ) );
217  }
218 
219  private:
220  friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
221  friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasObjectStream > ;
222 
223  friend class Conversion< ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
224  friend class Conversion< const ALUCubeGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
225 
226  template< class > friend class ALU3dGridFactory;
227 
229  ALUCubeGrid( const ALUCubeGrid & g ) ; // : BaseType(g) {}
230 
232  ALUCubeGrid<dim,dimworld>&
233  operator = (const ALUCubeGrid& g);
234  };
235 
236 
237 
244  template<>
245  class ALUSimplexGrid< 3, 3 >
246  : public Dune::ALU3dGrid< tetra >
247  {
250 
251  enum { dim = 3 };
252  enum { dimworld = 3 };
253 
254  typedef BaseType::MPICommunicatorType MPICommunicatorType;
255 
256  public:
259 
261  typedef BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
262 
274  DUNE_DEPRECATED
275  ALUSimplexGrid(const std::string macroName,
276  const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
277  const DuneBoundaryProjectionType* bndProject = 0,
278  const DuneBoundaryProjectionVector* bndVector = 0,
279  const bool verb = true ) :
280  BaseType(macroName, mpiComm, bndProject, bndVector, nonconforming )
281  {
282  const bool verbose = verb && this->comm().rank() == 0;
283  if( verbose )
284  {
285  std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUSimplexGrid<"<<dim<<","<<dimworld;
286  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
287  }
288  }
289 
300  DUNE_DEPRECATED
301  ALUSimplexGrid(const MPICommunicatorType mpiComm,
302  const DuneBoundaryProjectionType* bndProject ,
303  const DuneBoundaryProjectionVector* bndVector,
304  const std::string macroName,
305  const bool verb = true ) :
306  BaseType("", mpiComm, bndProject, bndVector, nonconforming )
307  {
308  const bool verbose = verb && this->comm().rank() == 0;
309  if( verbose )
310  {
311  std::cout << "\nCreated " << ALUGridParallelSerial() << " ALUSimplexGrid<"<<dim<<","<<dimworld;
312  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
313  }
314  }
315 
318  DUNE_DEPRECATED
319  ALUSimplexGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
320  BaseType("", mpiComm,
321  (const DuneBoundaryProjectionType *) 0,
322  (const DuneBoundaryProjectionVector* ) 0,
323  nonconforming )
324  {
325  if(this->comm().rank() == 0)
326  {
327  std::cout << "\nCreated empty ALUSimplexGrid<"<<dim<<","<<dimworld <<">. \n\n";
328  }
329  }
330 
331  enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
338  typedef GridFamily :: LevelIndexSetImp LevelIndexSetImp;
343 
344  // ALUGrid only typedefs
347 
348  template< PartitionIteratorType pitype >
349  struct Partition
350  {
355  };
356 
359 
360  template< PartitionIteratorType pitype >
361  typename Partition< pitype >::LevelGridView levelView ( int level ) const
362  {
364  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
365  return LevelGridView( LevelGridViewImp( *this, level ) );
366  }
367 
368  template< PartitionIteratorType pitype >
369  typename Partition< pitype >::LeafGridView leafView () const
370  {
372  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
373  return LeafGridView( LeafGridViewImp( *this ) );
374  }
375 
376  LevelGridView levelView ( int level ) const
377  {
378  typedef LevelGridView::GridViewImp LevelGridViewImp;
379  return LevelGridView( LevelGridViewImp( *this, level ) );
380  }
381 
382  LeafGridView leafView () const
383  {
384  typedef LeafGridView::GridViewImp LeafGridViewImp;
385  return LeafGridView( LeafGridViewImp( *this ) );
386  }
387 
388  template< PartitionIteratorType pitype >
389  typename Partition< pitype >::LevelGridView levelGridView ( int level ) const
390  {
392  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
393  return LevelGridView( LevelGridViewImp( *this, level ) );
394  }
395 
396  template< PartitionIteratorType pitype >
397  typename Partition< pitype >::LeafGridView leafGridView () const
398  {
400  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
401  return LeafGridView( LeafGridViewImp( *this ) );
402  }
403 
404  LevelGridView levelGridView ( int level ) const
405  {
406  typedef LevelGridView::GridViewImp LevelGridViewImp;
407  return LevelGridView( LevelGridViewImp( *this, level ) );
408  }
409 
410  LeafGridView leafGridView () const
411  {
412  typedef LeafGridView::GridViewImp LeafGridViewImp;
413  return LeafGridView( LeafGridViewImp( *this ) );
414  }
415 
416  private:
417  friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
418  friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
419 
420  friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
421  friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
422 
423  template< class > friend class ALU3dGridFactory;
424 
426  ALUSimplexGrid( const ALUSimplexGrid & g ); // : BaseType(g) {}
427 
429  ALUSimplexGrid<dim,dimworld>&
430  operator = (const ALUSimplexGrid& g);
431  };
432 
433  /*-
434  (see ALUGrid homepage: http://www.mathematik.uni-freiburg.de/IAM/Research/alugrid/)
435 
436  \li Available Implementations
437  - quadrilateral and hexahedral elements only nonconforming refinement
438  - Dune::ALUGrid< 2, 2, cube, nonconforming >
439  - Dune::ALUGrid< 2, 3, cube, nonconforming >
440  - Dune::ALUGrid< 3, 3, cube, nonconforming >
441  - simplicial elements and nonconforming refinement
442  - Dune::ALUGrid< 2, 2, simplex, nonconforming >
443  - Dune::ALUGrid< 2, 3, simplex, nonconforming >
444  - Dune::ALUGrid< 3, 3, simplex, nonconforming >
445  - simplicial elements and bisection refinement
446  - Dune::ALUGrid< 2, 2, simplex, conforming >
447  - Dune::ALUGrid< 2, 3, simplex, conforming >
448  - Dune::ALUGrid< 3, 3, simplex, conforming > (work in progress)
449 
450  \note template parameter Comm defaults to MPI_Comm, if MPI is available, No_Comm otherwise.
451  */
452  template< ALUGridElementType elType, ALUGridRefinementType refineType, class Comm >
453  class ALUGrid< 3, 3, elType, refineType, Comm >
454  : public ALUGridBaseGrid< 3, 3, elType, Comm > :: BaseGrid
455  {
457  typedef typename ALUGridBaseGrid< 3, 3, elType, Comm > :: BaseGrid BaseType;
458 
459  enum { dim = 3 };
460  enum { dimworld = 3 };
461 
462  typedef typename BaseType::MPICommunicatorType MPICommunicatorType;
463 
464  public:
466  typedef typename BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
467 
469  typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
470 
481  ALUGrid(const std::string macroName,
482  const MPICommunicatorType mpiComm = BaseType::defaultCommunicator(),
483  const DuneBoundaryProjectionType* bndProject = 0,
484  const DuneBoundaryProjectionVector* bndVector = 0,
485  const bool verb = true ) :
486  BaseType(macroName, mpiComm, bndProject, bndVector, refineType )
487  {
488  const bool verbose = verb && this->comm().rank() == 0;
489  if( verbose )
490  {
491  std::cout << "\nCreated " << ALUGridParallelSerial() << " " << name() << nameSuffix()
492  << " from macro grid file '" << macroName << "'. \n\n";
493  }
494  }
495 
496  static std::string name () { return std::string("ALUGrid"); }
497 
498  static std::string nameSuffix()
499  {
500  std::string elt ( elType == cube ? "cube," : "simplex," );
501  std::string ref ( refineType == nonconforming ? "nonconforming>" : "conforming>" );
502  std::stringstream suffix;
503  suffix << "<"<<dim<<","<<dimworld<<"," << elt << ref;
504  return suffix.str();
505  }
506 
507 
517  ALUGrid(const MPICommunicatorType mpiComm,
518  const DuneBoundaryProjectionType* bndProject ,
519  const DuneBoundaryProjectionVector* bndVector,
520  const std::string macroName,
521  const bool verb = true ) :
522  BaseType("", mpiComm, bndProject, bndVector, refineType )
523  {
524  const bool verbose = verb && this->comm().rank() == 0;
525  if( verbose )
526  {
527  std::cout << "\nCreated " << ALUGridParallelSerial() << " " << name() << nameSuffix()
528  << " from macro grid file '" << macroName << "'. \n\n";
529  }
530  }
531 
533  ALUGrid(const MPICommunicatorType mpiComm = BaseType::defaultCommunicator()) :
534  BaseType("", mpiComm,
535  (const DuneBoundaryProjectionType *) 0,
536  (const DuneBoundaryProjectionVector* ) 0,
537  refineType )
538  {
539  if(this->comm().rank() == 0)
540  {
541  std::cout << "\nCreated empty " << ALUGridParallelSerial() << " " << name() << nameSuffix() << "." << std::endl << std::endl;
542  }
543  }
544 
545  enum { dimension=BaseType::dimension, dimensionworld=BaseType::dimensionworld};
546  typedef typename BaseType::ctype ctype;
547  typedef typename BaseType::GridFamily GridFamily;
548  typedef typename GridFamily::Traits Traits;
549  typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
550  typedef typename Traits :: GlobalIdSet GlobalIdSet;
551  typedef typename Traits :: LocalIdSet LocalIdSet;
552  typedef typename GridFamily :: LevelIndexSetImp LevelIndexSetImp;
553  typedef typename GridFamily :: LeafIndexSetImp LeafIndexSetImp;
554  typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
555  typedef typename Traits:: template Codim<0>::LeafIterator LeafIteratorType;
556  typedef typename Traits:: template Codim<0>::LeafIterator LeafIterator;
557 
558  // ALUGrid only typedefs
559  typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
560  typedef typename BaseType::ObjectStreamType ObjectStreamType;
561 
562  template< PartitionIteratorType pitype >
563  struct Partition
564  {
569  };
570 
571  typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
572  typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
573 
574  template< PartitionIteratorType pitype >
575  typename Partition< pitype >::LevelGridView levelView ( int level ) const
576  {
578  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
579  return LevelGridView( LevelGridViewImp( *this, level ) );
580  }
581 
582  template< PartitionIteratorType pitype >
583  typename Partition< pitype >::LeafGridView leafView () const
584  {
586  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
587  return LeafGridView( LeafGridViewImp( *this ) );
588  }
589 
590  LevelGridView levelView ( int level ) const
591  {
592  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
593  return LevelGridView( LevelGridViewImp( *this, level ) );
594  }
595 
596  LeafGridView leafView () const
597  {
598  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
599  return LeafGridView( LeafGridViewImp( *this ) );
600  }
601 
602  template< PartitionIteratorType pitype >
603  typename Partition< pitype >::LevelGridView levelGridView ( int level ) const
604  {
606  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
607  return LevelGridView( LevelGridViewImp( *this, level ) );
608  }
609 
610  template< PartitionIteratorType pitype >
611  typename Partition< pitype >::LeafGridView leafGridView () const
612  {
614  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
615  return LeafGridView( LeafGridViewImp( *this ) );
616  }
617 
618  LevelGridView levelGridView ( int level ) const
619  {
620  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
621  return LevelGridView( LevelGridViewImp( *this, level ) );
622  }
623 
624  LeafGridView leafGridView () const
625  {
626  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
627  return LeafGridView( LeafGridViewImp( *this ) );
628  }
629 
630  private:
631  friend class Conversion< This , HasObjectStream > ;
632  friend class Conversion< const This, HasObjectStream > ;
633 
634  friend class Conversion< This, HasHierarchicIndexSet > ;
635  friend class Conversion< const This, HasHierarchicIndexSet > ;
636 
637  template< class > friend class ALU3dGridFactory;
638 
640  ALUGrid( const ALUGrid & g ); // : BaseType(g) {}
641 
643  This& operator = (const ALUGrid& g);
644  };
645 
646 } //end namespace Dune
647 
648 #endif // #if HAVE_ALUGRID || DOXYGEN
649 
650 #undef alu_inline
651 #endif