dune-grid  2.3beta2
alugrid/2d/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_ALU2D_ALUGRID_HH
4 #define DUNE_ALU2D_ALUGRID_HH
5 
6 // only include this code, if ENABLE_ALUGRID is defined
7 #if HAVE_ALUGRID || DOXYGEN
8 
13 
14 namespace Dune
15 {
16 
23  template<int dimw>
24  class ALUCubeGrid< 2, dimw >
25  : public Dune::ALU2dGrid< 2, dimw, ALU2DSPACE quadrilateral >
26  {
28 
30  enum { dim = 2 };
31  enum { dimworld = dimw };
32 
33  public:
36 
38  typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
39 
49  DUNE_DEPRECATED
50  ALUCubeGrid(const std::string macroName,
51  const DuneBoundaryProjectionType* bndProject = 0,
52  const DuneBoundaryProjectionVector* bndVector = 0,
53  const bool verbose = true )
54  : BaseType(macroName,1, bndProject, bndVector)
55  {
56  if( verbose )
57  {
58  std::cout << "\nCreated serial ALUCubeGrid<"<<dim<<","<<dimworld;
59  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
60  }
61  }
62 
73  DUNE_DEPRECATED
74  ALUCubeGrid(const std::string macroName,
75  std::istream& macroFile,
76  const DuneBoundaryProjectionType* bndProject = 0,
77  const DuneBoundaryProjectionVector* bndVector = 0,
78  const bool verbose = true )
79  : BaseType("",1, bndProject, bndVector, &macroFile)
80  {
81  if( verbose )
82  {
83  std::cout << "\nCreated serial ALUCubeGrid<"<<dim<<","<<dimworld;
84  if( macroName == "" )
85  std::cout <<">. \n\n";
86  else
87  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
88  }
89  }
90 
93  DUNE_DEPRECATED
94  ALUCubeGrid( ) : BaseType(1)
95  {
96  std::cout << "\nCreated empty ALUCubeGrid<"<<dim<<","<<dimworld <<">. \n\n";
97  }
98 
99  enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
100  enum { refineStepsForHalf = 1 };
101  typedef typename BaseType::ctype ctype;
102  typedef typename BaseType::GridFamily GridFamily;
103  typedef typename GridFamily::Traits Traits;
105  typedef typename Traits :: GlobalIdSet GlobalIdSet;
106  typedef typename Traits :: LocalIdSet LocalIdSet;
107  typedef typename GridFamily :: LevelIndexSetImp LevelIndexSetImp;
108  typedef typename GridFamily :: LeafIndexSetImp LeafIndexSetImp;
110  typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
111  typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
113 
114  template< PartitionIteratorType pitype >
115  struct Partition
116  {
121  };
122 
125 
126  template< PartitionIteratorType pitype >
127  typename Partition< pitype >::LevelGridView levelView ( int level ) const
128  {
130  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
131  return LevelGridView( LevelGridViewImp( *this, level ) );
132  }
133 
134  template< PartitionIteratorType pitype >
135  typename Partition< pitype >::LeafGridView leafView () const
136  {
138  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
139  return LeafGridView( LeafGridViewImp( *this ) );
140  }
141 
142  LevelGridView levelView ( int level ) const
143  {
144  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
145  return LevelGridView( LevelGridViewImp( *this, level ) );
146  }
147 
148  LeafGridView leafView () const
149  {
150  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
151  return LeafGridView( LeafGridViewImp( *this ) );
152  }
153 
154  template< PartitionIteratorType pitype >
155  typename Partition< pitype >::LevelGridView levelGridView ( 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 leafGridView () const
164  {
166  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
167  return LeafGridView( LeafGridViewImp( *this ) );
168  }
169 
170  LevelGridView levelGridView ( int level ) const
171  {
172  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
173  return LevelGridView( LevelGridViewImp( *this, level ) );
174  }
175 
176  LeafGridView leafGridView () const
177  {
178  typedef typename 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 >
190  friend class ALU2dGridFactory;
191 
193  ALUCubeGrid( const ALUCubeGrid & g ) ; // : BaseType(g) {}
194 
196  ALUCubeGrid<dim,dimworld>&
197  operator = (const ALUCubeGrid& g);
198  };
199 
206  template<int dimw>
207  class ALUSimplexGrid< 2, dimw >
208  : public Dune::ALU2dGrid< 2, dimw, ALU2DSPACE triangle >
209  {
211 
213  enum { dim = 2 };
214  enum { dimworld = dimw };
215 
216  public:
219 
222 
232  DUNE_DEPRECATED
233  ALUSimplexGrid(const std::string macroName,
234  const DuneBoundaryProjectionType* bndProject = 0,
235  const DuneBoundaryProjectionVector* bndVector = 0,
236  const bool verbose = true )
237  : BaseType(macroName,1, bndProject, bndVector)
238  {
239  if( verbose )
240  {
241  std::cout << "\nCreated serial ALUSimplexGrid<"<<dim<<","<<dimworld;
242  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
243  }
244  }
245 
256  DUNE_DEPRECATED
257  ALUSimplexGrid(const std::string macroName,
258  std::istream& macroFile,
259  const DuneBoundaryProjectionType* bndProject = 0,
260  const DuneBoundaryProjectionVector* bndVector = 0,
261  const bool verbose = true )
262  : BaseType("",1, bndProject, bndVector, &macroFile)
263  {
264  if( verbose )
265  {
266  std::cout << "\nCreated serial ALUSimplexGrid<"<<dim<<","<<dimworld;
267  if( macroName == "" )
268  std::cout <<">. \n\n";
269  else
270  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
271  }
272  }
273 
276  DUNE_DEPRECATED
277  ALUSimplexGrid( ) : BaseType(1)
278  {
279  std::cout << "\nCreated empty ALUSimplexGrid<"<<dim<<","<<dimworld <<">. \n\n";
280  }
281 
282  enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
283  enum { refineStepsForHalf = 1 };
284  typedef typename BaseType::ctype ctype;
286  typedef typename GridFamily::Traits Traits;
293  typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
294  typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
296 
297  template< PartitionIteratorType pitype >
298  struct Partition
299  {
304  };
305 
308 
309  template< PartitionIteratorType pitype >
310  typename Partition< pitype >::LevelGridView levelView ( int level ) const
311  {
313  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
314  return LevelGridView( LevelGridViewImp( *this, level ) );
315  }
316 
317  template< PartitionIteratorType pitype >
318  typename Partition< pitype >::LeafGridView leafView () const
319  {
321  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
322  return LeafGridView( LeafGridViewImp( *this ) );
323  }
324 
325  LevelGridView levelView ( int level ) const
326  {
327  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
328  return LevelGridView( LevelGridViewImp( *this, level ) );
329  }
330 
331  LeafGridView leafView () const
332  {
333  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
334  return LeafGridView( LeafGridViewImp( *this ) );
335  }
336 
337  template< PartitionIteratorType pitype >
338  typename Partition< pitype >::LevelGridView levelGridView ( int level ) const
339  {
341  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
342  return LevelGridView( LevelGridViewImp( *this, level ) );
343  }
344 
345  template< PartitionIteratorType pitype >
346  typename Partition< pitype >::LeafGridView leafGridView () const
347  {
349  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
350  return LeafGridView( LeafGridViewImp( *this ) );
351  }
352 
353  LevelGridView levelGridView ( int level ) const
354  {
355  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
356  return LevelGridView( LevelGridViewImp( *this, level ) );
357  }
358 
359  LeafGridView leafGridView () const
360  {
361  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
362  return LeafGridView( LeafGridViewImp( *this ) );
363  }
364 
365  private:
366  friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
367  friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasObjectStream > ;
368 
369  friend class Conversion< ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
370  friend class Conversion< const ALUSimplexGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
371 
372  template< class >
373  friend class ALU2dGridFactory;
374 
376  ALUSimplexGrid( const ALUSimplexGrid & g ) ; // : BaseType(g) {}
377 
379  ALUSimplexGrid<dim,dimworld>&
380  operator = (const ALUSimplexGrid& g);
381  };
382 
411  template <int dim, int dimworld>
413  dune_static_assert((AlwaysFalse<integral_constant<int,dim> >::value),
414  "The unspecialized version of ALUConformGrid is defined "
415  "for documentation purposes only, only the "
416  "specializations can actually be used.");
417  };
418 
419  namespace Capabilities {
431  template<int dim,int dimw, int cdim >
432  struct hasEntity<Dune::ALUConformGrid<dim, dimw>, cdim >
433  {
434  static const bool v = true;
435  };
436 
440  template<int dim,int dimw>
441  struct isParallel<const ALUConformGrid<dim, dimw> > {
442  static const bool v = false;
443  };
444 
448  template<int dim,int dimw>
450  {
451  static const bool v = false;
452  };
453 
457  template<int dim,int dimw>
459  {
460  static const bool v = true;
461  };
462 
466  template<int dim,int dimw>
468  {
469  static const bool v = true;
470  };
471 
472  } // end namespace Capabilities
473 
474 
475 
482  template<int dimw>
483  class ALUConformGrid< 2, dimw >
484  : public Dune::ALU2dGrid< 2, dimw, ALU2DSPACE triangle >
485  {
487 
489  enum { dim = 2 };
490  enum { dimworld = dimw };
491  public:
494 
496  typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
497 
507  DUNE_DEPRECATED
508  ALUConformGrid(const std::string macroName,
509  const DuneBoundaryProjectionType* bndProject = 0,
510  const DuneBoundaryProjectionVector* bndVector = 0,
511  const bool verbose = true)
512  : BaseType(macroName, 0, bndProject, bndVector)
513  {
514  if( verbose )
515  {
516  std::cout << "\nCreated serial ALUConformGrid<"<<dim<<","<<dimworld;
517  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
518  }
519  }
520 
531  DUNE_DEPRECATED
532  ALUConformGrid(const std::string macroName,
533  std::istream& macroFile,
534  const DuneBoundaryProjectionType* bndProject = 0,
535  const DuneBoundaryProjectionVector* bndVector = 0,
536  const bool verbose = true )
537  : BaseType("", 0, bndProject, bndVector, &macroFile)
538  {
539  if( verbose )
540  {
541  std::cout << "\nCreated serial ALUConformGrid<"<<dim<<","<<dimworld;
542  if( macroName == "" )
543  std::cout <<">. \n\n";
544  else
545  std::cout <<"> from macro grid file '" << macroName << "'. \n\n";
546  }
547  }
548 
551  DUNE_DEPRECATED
553  {
554  std::cout << "\nCreated empty ALUConformGrid<"<<dim<<","<<dimworld <<">. \n\n";
555  }
556 
558  static inline std::string name () { return "ALUConformGrid"; }
559 
560  enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
561  enum { refineStepsForHalf = 2 };
562  typedef typename BaseType::ctype ctype;
564  typedef typename GridFamily::Traits Traits;
566  typedef typename Traits :: GlobalIdSet GlobalIdSet;
567  typedef typename Traits :: LocalIdSet LocalIdSet;
571  typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
572  typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
574 
575  template< PartitionIteratorType pitype >
576  struct Partition
577  {
582  };
583 
586 
587  template< PartitionIteratorType pitype >
588  typename Partition< pitype >::LevelGridView levelView ( int level ) const
589  {
591  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
592  return LevelGridView( LevelGridViewImp( *this, level ) );
593  }
594 
595  template< PartitionIteratorType pitype >
596  typename Partition< pitype >::LeafGridView leafView () const
597  {
599  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
600  return LeafGridView( LeafGridViewImp( *this ) );
601  }
602 
603  LevelGridView levelView ( int level ) const
604  {
605  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
606  return LevelGridView( LevelGridViewImp( *this, level ) );
607  }
608 
609  LeafGridView leafView () const
610  {
611  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
612  return LeafGridView( LeafGridViewImp( *this ) );
613  }
614 
615  template< PartitionIteratorType pitype >
616  typename Partition< pitype >::LevelGridView levelGridView ( int level ) const
617  {
619  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
620  return LevelGridView( LevelGridViewImp( *this, level ) );
621  }
622 
623  template< PartitionIteratorType pitype >
624  typename Partition< pitype >::LeafGridView leafGridView () const
625  {
627  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
628  return LeafGridView( LeafGridViewImp( *this ) );
629  }
630 
631  LevelGridView levelGridView ( int level ) const
632  {
633  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
634  return LevelGridView( LevelGridViewImp( *this, level ) );
635  }
636 
637  LeafGridView leafGridView () const
638  {
639  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
640  return LeafGridView( LeafGridViewImp( *this ) );
641  }
642 
643  private:
644  friend class Conversion< ALUConformGrid<dimension,dimensionworld> , HasObjectStream > ;
645  friend class Conversion< const ALUConformGrid<dimension,dimensionworld> , HasObjectStream > ;
646 
647  friend class Conversion< ALUConformGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
648  friend class Conversion< const ALUConformGrid<dimension,dimensionworld> , HasHierarchicIndexSet > ;
649 
650  template< class >
651  friend class ALU2dGridFactory;
652 
654  ALUConformGrid( const ALUConformGrid & g ) ; // : BaseType(g) {}
655 
658  operator = (const ALUConformGrid& g);
659  };
660 
661  /*-
662  (see ALUGrid homepage: http://www.mathematik.uni-freiburg.de/IAM/Research/alugrid/)
663 
664  \li Available Implementations
665  - quadrilateral and hexahedral elements only nonconforming refinement
666  - Dune::ALUGrid< 2, 2, cube, nonconforming >
667  - Dune::ALUGrid< 2, 3, cube, nonconforming >
668  - Dune::ALUGrid< 3, 3, cube, nonconforming >
669  - simplicial elements and nonconforming refinement
670  - Dune::ALUGrid< 2, 2, simplex, nonconforming >
671  - Dune::ALUGrid< 2, 3, simplex, nonconforming >
672  - Dune::ALUGrid< 3, 3, simplex, nonconforming >
673  - simplicial elements and bisection refinement
674  - Dune::ALUGrid< 2, 2, simplex, conforming >
675  - Dune::ALUGrid< 2, 3, simplex, conforming >
676  - Dune::ALUGrid< 3, 3, simplex, conforming > (work in progress)
677 
678  \note template parameter Comm defaults to MPI_Comm, if MPI is available, No_Comm otherwise.
679  */
680  template<int dimw, ALUGridElementType elType, ALUGridRefinementType refinementType, class Comm >
681  class ALUGrid< 2, dimw, elType, refinementType, Comm >
682  : public ALUGridBaseGrid < 2, dimw, elType, Comm > :: BaseGrid
683  {
685  typedef typename ALUGridBaseGrid < 2, dimw, elType, Comm > :: BaseGrid BaseType;
686 
687  enum { dim = 2 };
688  enum { dimworld = dimw };
689 
690  public:
692  typedef typename BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
693 
695  typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
696 
705  ALUGrid(const std::string macroName,
706  const DuneBoundaryProjectionType* bndProject = 0,
707  const DuneBoundaryProjectionVector* bndVector = 0,
708  const bool verbose = true )
709  : BaseType(macroName, hangingNodes(), bndProject, bndVector)
710  {
711  if( verbose )
712  {
713  std::cout << "\nCreated serial " << name() << nameSuffix()
714  << " from macro grid file '" << macroName << "'." << std::endl << std::endl;
715  }
716  }
717 
727  ALUGrid(const std::string macroName,
728  std::istream& macroFile,
729  const DuneBoundaryProjectionType* bndProject = 0,
730  const DuneBoundaryProjectionVector* bndVector = 0,
731  const bool verbose = true )
732  : BaseType("", hangingNodes(), bndProject, bndVector, &macroFile)
733  {
734  if( verbose )
735  {
736  std::cout << "\nCreated serial " << name() << nameSuffix();
737  if( macroName != "" )
738  std::cout <<" from macro grid file '" << macroName;
739  std::cout << "." << std::endl << std::endl;
740  }
741  }
742 
743  static std::string name () { return std::string("ALUGrid"); }
744 
746  ALUGrid( ) : BaseType( hangingNodes() )
747  {
748  std::cout << "\nCreated serial " << name() << nameSuffix() << "." << std::endl << std::endl;
749  }
750 
751  enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
752  enum { refineStepsForHalf = 1 };
753  typedef typename BaseType::ctype ctype;
754  typedef typename BaseType::GridFamily GridFamily;
755  typedef typename GridFamily::Traits Traits;
756  typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
757  typedef typename Traits :: GlobalIdSet GlobalIdSet;
758  typedef typename Traits :: LocalIdSet LocalIdSet;
759  typedef typename GridFamily :: LevelIndexSetImp LevelIndexSetImp;
760  typedef typename GridFamily :: LeafIndexSetImp LeafIndexSetImp;
761  typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
762  typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
763  typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
764  typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
765 
766  template< PartitionIteratorType pitype >
767  struct Partition
768  {
773  };
774 
775  typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
776  typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
777 
778  template< PartitionIteratorType pitype >
779  typename Partition< pitype >::LevelGridView levelView ( int level ) const
780  {
782  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
783  return LevelGridView( LevelGridViewImp( *this, level ) );
784  }
785 
786  template< PartitionIteratorType pitype >
787  typename Partition< pitype >::LeafGridView leafView () const
788  {
790  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
791  return LeafGridView( LeafGridViewImp( *this ) );
792  }
793 
794  LevelGridView levelView ( int level ) const
795  {
796  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
797  return LevelGridView( LevelGridViewImp( *this, level ) );
798  }
799 
800  LeafGridView leafView () const
801  {
802  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
803  return LeafGridView( LeafGridViewImp( *this ) );
804  }
805 
806  template< PartitionIteratorType pitype >
807  typename Partition< pitype >::LevelGridView levelGridView ( int level ) const
808  {
810  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
811  return LevelGridView( LevelGridViewImp( *this, level ) );
812  }
813 
814  template< PartitionIteratorType pitype >
815  typename Partition< pitype >::LeafGridView leafGridView () const
816  {
818  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
819  return LeafGridView( LeafGridViewImp( *this ) );
820  }
821 
822  LevelGridView levelGridView ( int level ) const
823  {
824  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
825  return LevelGridView( LevelGridViewImp( *this, level ) );
826  }
827 
828  LeafGridView leafGridView () const
829  {
830  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
831  return LeafGridView( LeafGridViewImp( *this ) );
832  }
833 
834  private:
835  static std::string nameSuffix()
836  {
837  std::string elt ( elType == cube ? "cube," : "simplex," );
838  std::string ref ( refinementType == nonconforming ? "nonconforming>" : "conforming>" );
839  std::stringstream suffix;
840  suffix << "<"<<dim<<","<<dimworld<<"," << elt << ref;
841  return suffix.str();
842  }
843 
844  // returns number of hanging nodes allowed (0 or 1)
845  int hangingNodes() const
846  {
847  return ((elType == simplex) && (refinementType == conforming)) ? 0 : 1;
848  }
849 
850  friend class Conversion< This, HasObjectStream > ;
851  friend class Conversion< const This, HasObjectStream > ;
852 
853  friend class Conversion< This, HasHierarchicIndexSet > ;
854  friend class Conversion< const This, HasHierarchicIndexSet > ;
855 
856  template< class >
857  friend class ALU2dGridFactory;
858 
860  ALUGrid( const ALUGrid & g ) ; // : BaseType(g) {}
861 
863  This& operator = (const ALUGrid& g);
864  };
865 
866 } //end namespace Dune
867 
868 #else
869 #error "Trying to use <dune/grid/alugrid.hh> without ALUGRID_CPPFLAGS."
870 #endif // #if HAVE_ALUGRID || DOXYGEN
871 
872 #endif