Dune Core Modules (2.4.2)

alugrid.hh
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
9#include <dune/grid/alugrid/common/declaration.hh>
10#include <dune/grid/alugrid/common/capabilities.hh>
11#include <dune/grid/alugrid/2d/grid.hh>
12
13namespace 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 {
39 typedef ALUGrid< 2, dimw, elType, refinementType, Comm > This;
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 {
125 LevelGridView;
127 LeafGridView;
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 >
142 typename Partition< pitype >::LeafGridView leafView () const
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 >
162 typename Partition< pitype >::LevelGridView levelGridView ( int level ) const
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 >
170 typename Partition< pitype >::LeafGridView leafGridView () const
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
Grid view abstract base class.
Definition: gridview.hh:59
Dune namespace.
Definition: alignment.hh:10
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 21, 23:30, 2024)