dune-grid  2.4.1
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 
12 
13 namespace Dune
14 {
15 
16  /*-
17  (see ALUGrid homepage: http://www.mathematik.uni-freiburg.de/IAM/Research/alugrid/)
18 
19  \li Available Implementations
20  - quadrilateral and hexahedral elements only nonconforming refinement
21  - Dune::ALUGrid< 2, 2, cube, nonconforming >
22  - Dune::ALUGrid< 2, 3, cube, nonconforming >
23  - Dune::ALUGrid< 3, 3, cube, nonconforming >
24  - simplicial elements and nonconforming refinement
25  - Dune::ALUGrid< 2, 2, simplex, nonconforming >
26  - Dune::ALUGrid< 2, 3, simplex, nonconforming >
27  - Dune::ALUGrid< 3, 3, simplex, nonconforming >
28  - simplicial elements and bisection refinement
29  - Dune::ALUGrid< 2, 2, simplex, conforming >
30  - Dune::ALUGrid< 2, 3, simplex, conforming >
31  - Dune::ALUGrid< 3, 3, simplex, conforming > (work in progress)
32 
33  \note template parameter Comm defaults to MPI_Comm, if MPI is available, No_Comm otherwise.
34  */
35  template<int dimw, ALUGridElementType elType, ALUGridRefinementType refinementType, class Comm >
36  class ALUGrid< 2, dimw, elType, refinementType, Comm >
37  : public ALUGridBaseGrid < 2, dimw, elType, Comm > :: BaseGrid
38  {
40  typedef typename ALUGridBaseGrid < 2, dimw, elType, Comm > :: BaseGrid BaseType;
41 
42  enum { dim = 2 };
43  enum { dimworld = dimw };
44 
45  public:
47  typedef typename BaseType :: DuneBoundaryProjectionType DuneBoundaryProjectionType;
48 
50  typedef typename BaseType :: DuneBoundaryProjectionVector DuneBoundaryProjectionVector;
51 
60  ALUGrid(const std::string macroName,
61  const DuneBoundaryProjectionType* bndProject = 0,
62  const DuneBoundaryProjectionVector* bndVector = 0,
63  const bool verbose = true )
64  : BaseType(macroName, hangingNodes(), bndProject, bndVector)
65  {
66  if( verbose )
67  {
68  std::cout << "\nCreated serial " << name() << nameSuffix()
69  << " from macro grid file '" << macroName << "'." << std::endl << std::endl;
70  }
71  }
72 
82  ALUGrid(const std::string macroName,
83  std::istream& macroFile,
84  const DuneBoundaryProjectionType* bndProject = 0,
85  const DuneBoundaryProjectionVector* bndVector = 0,
86  const bool verbose = true )
87  : BaseType("", hangingNodes(), bndProject, bndVector, &macroFile)
88  {
89  if( verbose )
90  {
91  std::cout << "\nCreated serial " << name() << nameSuffix();
92  if( macroName != "" )
93  std::cout <<" from macro grid file '" << macroName;
94  std::cout << "." << std::endl << std::endl;
95  }
96  }
97 
98  static std::string name () { return std::string("ALUGrid"); }
99 
101  ALUGrid( ) : BaseType( hangingNodes() )
102  {
103  std::cout << "\nCreated serial " << name() << nameSuffix() << "." << std::endl << std::endl;
104  }
105 
106  enum {dimension=BaseType::dimension,dimensionworld=BaseType::dimensionworld};
107  enum { refineStepsForHalf = 1 };
108  typedef typename BaseType::ctype ctype;
109  typedef typename BaseType::GridFamily GridFamily;
110  typedef typename GridFamily::Traits Traits;
111  typedef typename BaseType::LocalIdSetImp LocalIdSetImp;
112  typedef typename Traits :: GlobalIdSet GlobalIdSet;
113  typedef typename Traits :: LocalIdSet LocalIdSet;
114  typedef typename GridFamily :: LevelIndexSetImp LevelIndexSetImp;
115  typedef typename GridFamily :: LeafIndexSetImp LeafIndexSetImp;
116  typedef typename BaseType::LeafIteratorImp LeafIteratorImp;
117  typedef typename Traits::template Codim<0>::LeafIterator LeafIteratorType;
118  typedef typename Traits::template Codim<0>::LeafIterator LeafIterator;
119  typedef typename BaseType::HierarchicIteratorImp HierarchicIteratorImp;
120 
121  template< PartitionIteratorType pitype >
122  struct Partition
123  {
128  };
129 
130  typedef typename Partition< All_Partition > :: LevelGridView LevelGridView;
131  typedef typename Partition< All_Partition > :: LeafGridView LeafGridView;
132 
133  template< PartitionIteratorType pitype >
134  typename Partition< pitype >::LevelGridView levelView ( int level ) const
135  {
136  typedef typename Partition< pitype >::LevelGridView LevelGridView;
137  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
138  return LevelGridView( LevelGridViewImp( *this, level ) );
139  }
140 
141  template< PartitionIteratorType pitype >
143  {
144  typedef typename Partition< pitype >::LeafGridView LeafGridView;
145  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
146  return LeafGridView( LeafGridViewImp( *this ) );
147  }
148 
149  LevelGridView levelView ( int level ) const
150  {
151  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
152  return LevelGridView( LevelGridViewImp( *this, level ) );
153  }
154 
155  LeafGridView leafView () const
156  {
157  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
158  return LeafGridView( LeafGridViewImp( *this ) );
159  }
160 
161  template< PartitionIteratorType pitype >
163  {
164  typedef typename Partition< pitype >::LevelGridView LevelGridView;
165  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
166  return LevelGridView( LevelGridViewImp( *this, level ) );
167  }
168 
169  template< PartitionIteratorType pitype >
171  {
172  typedef typename Partition< pitype >::LeafGridView LeafGridView;
173  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
174  return LeafGridView( LeafGridViewImp( *this ) );
175  }
176 
177  LevelGridView levelGridView ( int level ) const
178  {
179  typedef typename LevelGridView::GridViewImp LevelGridViewImp;
180  return LevelGridView( LevelGridViewImp( *this, level ) );
181  }
182 
183  LeafGridView leafGridView () const
184  {
185  typedef typename LeafGridView::GridViewImp LeafGridViewImp;
186  return LeafGridView( LeafGridViewImp( *this ) );
187  }
188 
189  private:
190  static std::string nameSuffix()
191  {
192  std::string elt ( elType == cube ? "cube," : "simplex," );
193  std::string ref ( refinementType == nonconforming ? "nonconforming>" : "conforming>" );
194  std::stringstream suffix;
195  suffix << "<"<<dim<<","<<dimworld<<"," << elt << ref;
196  return suffix.str();
197  }
198 
199  // returns number of hanging nodes allowed (0 or 1)
200  int hangingNodes() const
201  {
202  return ((elType == simplex) && (refinementType == conforming)) ? 0 : 1;
203  }
204 
205  friend class Conversion< This, HasObjectStream > ;
206  friend class Conversion< const This, HasObjectStream > ;
207 
208  friend class Conversion< This, HasHierarchicIndexSet > ;
209  friend class Conversion< const This, HasHierarchicIndexSet > ;
210 
211  template< class >
212  friend class ALU2dGridFactory;
213 
215  ALUGrid( const ALUGrid & g ) ; // : BaseType(g) {}
216 
218  This& operator = (const ALUGrid& g);
219  };
220 
221 } //end namespace Dune
222 
223 #else
224 #error "Trying to use <dune/grid/alugrid.hh> without ALUGRID_CPPFLAGS."
225 #endif // #if HAVE_ALUGRID || DOXYGEN
226 
227 #endif
GridFamily::LeafIndexSetImp LeafIndexSetImp
Definition: alugrid/2d/alugrid.hh:115
ViewTraits::GridViewImp GridViewImp
Definition: common/gridview.hh:71
BaseType::LocalIdSetImp LocalIdSetImp
Definition: alugrid/2d/alugrid.hh:111
Definition: alugrid/common/declaration.hh:18
[ provides Dune::Grid ]
Definition: alugrid/common/declaration.hh:63
BaseType::DuneBoundaryProjectionType DuneBoundaryProjectionType
type of boundary projection
Definition: alugrid/2d/alugrid.hh:47
Tagging interface to indicate that Grid has HierarchicIndexSet.
Definition: interfaces.hh:51
static std::string name()
Definition: alugrid/2d/alugrid.hh:98
Partition< pitype >::LevelGridView levelGridView(int level) const
Definition: alugrid/2d/alugrid.hh:162
BaseType::HierarchicIteratorImp HierarchicIteratorImp
Definition: alugrid/2d/alugrid.hh:119
Grid view abstract base class.
Definition: common/gridview.hh:58
LevelGridView levelView(int level) const
Definition: alugrid/2d/alugrid.hh:149
Definition: alugrid/common/declaration.hh:20
Dune::GridView< DefaultLevelGridViewTraits< const This, pitype > > LevelGridView
Definition: alugrid/2d/alugrid.hh:125
Definition: alugrid/2d/alugrid.hh:36
ALUGrid(const std::string macroName, std::istream &macroFile, const DuneBoundaryProjectionType *bndProject=0, const DuneBoundaryProjectionVector *bndVector=0, const bool verbose=true)
constructor for creating ALUGrid from given macro grid file
Definition: alugrid/2d/alugrid.hh:82
BaseType::ctype ctype
Definition: alugrid/2d/alugrid.hh:108
LevelGridView levelGridView(int level) const
Definition: alugrid/2d/alugrid.hh:177
ALUGrid()
constructor creating empty grid
Definition: alugrid/2d/alugrid.hh:101
GridFamily::Traits Traits
Definition: alugrid/2d/alugrid.hh:110
Traits::LocalIdSet LocalIdSet
Definition: alugrid/2d/alugrid.hh:113
Partition< All_Partition >::LevelGridView LevelGridView
Definition: alugrid/2d/alugrid.hh:130
ALUGrid(const std::string macroName, const DuneBoundaryProjectionType *bndProject=0, const DuneBoundaryProjectionVector *bndVector=0, const bool verbose=true)
constructor for creating ALUGrid from given macro grid file
Definition: alugrid/2d/alugrid.hh:60
Tagging interface to indicate that Grid provides typedef ObjectStreamType.
Definition: interfaces.hh:16
Traits::template Codim< 0 >::LeafIterator LeafIteratorType
Definition: alugrid/2d/alugrid.hh:117
Definition: alugrid/common/declaration.hh:18
Partition< pitype >::LeafGridView leafView() const
Definition: alugrid/2d/alugrid.hh:142
Traits::GlobalIdSet GlobalIdSet
Definition: alugrid/2d/alugrid.hh:112
Dune::GridView< DefaultLeafGridViewTraits< const This, pitype > > LeafGridView
Definition: alugrid/2d/alugrid.hh:127
BaseType::DuneBoundaryProjectionVector DuneBoundaryProjectionVector
type of boundary projection
Definition: alugrid/2d/alugrid.hh:50
GridFamily::LevelIndexSetImp LevelIndexSetImp
Definition: alugrid/2d/alugrid.hh:114
Definition: alugrid/common/declaration.hh:20
BaseType::LeafIteratorImp LeafIteratorImp
Definition: alugrid/2d/alugrid.hh:116
Definition: alugrid/common/declaration.hh:67
Traits::template Codim< 0 >::LeafIterator LeafIterator
Definition: alugrid/2d/alugrid.hh:118
BaseType::GridFamily GridFamily
Definition: alugrid/2d/alugrid.hh:109
LeafGridView leafGridView() const
Definition: alugrid/2d/alugrid.hh:183
Partition< All_Partition >::LeafGridView LeafGridView
Definition: alugrid/2d/alugrid.hh:131
Partition< pitype >::LeafGridView leafGridView() const
Definition: alugrid/2d/alugrid.hh:170
LeafGridView leafView() const
Definition: alugrid/2d/alugrid.hh:155
Include standard header files.
Definition: agrid.hh:59
Partition< pitype >::LevelGridView levelView(int level) const
Definition: alugrid/2d/alugrid.hh:134