1 #ifndef DUNE_ALBERTA_REFINEMENT_HH
2 #define DUNE_ALBERTA_REFINEMENT_HH
26 template<
int dim,
int codim >
27 struct ForEachInteriorSubChild;
39 dune_static_assert( ((dim >= 1) && (dim <= 3)),
40 "Alberta supports only dimensions 1, 2, 3" );
68 template<
class LevelProv
ider >
75 template<
class Functor >
78 for(
int i = 0; i <
count(); ++i )
79 functor( (*
this)[ i ] );
82 template<
int codim,
class Functor >
85 ForEachInteriorSubChild< dim, codim >::apply( functor, *
this );
93 assert( (i >= 0) && (i < count()) );
94 return list_[ i ].el_info.el;
99 template<
class LevelProv
ider >
103 assert( (i >= 0) && (i < count()) );
108 template<
class LevelProv
ider >
112 assert( (i >= 0) && (i < count()) );
114 const Element *element = (*this)[ i ];
115 const int level = levelProvider( element );
123 assert( (i >= 0) && (i < count()) );
124 return list_[ i ].el_info.el_type;
131 return (list_[ i ].neigh[ neighbor ] != NULL);
137 assert( hasNeighbor( i, neighbor ) );
138 return (list_[ i ].neigh[ neighbor ]->no);
147 struct ForEachInteriorSubChild< dim, 0 >
149 template<
class Functor >
152 for(
int i = 0; i < patch.
count(); ++i )
154 Element *
const father = patch[ i ];
155 functor( father->child[ 0 ], 0 );
156 functor( father->child[ 1 ], 0 );
162 struct ForEachInteriorSubChild< dim, dim >
164 template<
class Functor >
167 functor( patch[ 0 ]->child[ 0 ], dim );
172 struct ForEachInteriorSubChild< 2, 1 >
174 template<
class Functor >
175 static void apply ( Functor &functor,
const Patch< 2 > &patch )
178 Element *
const firstFather = patch[ 0 ];
180 Element *
const firstChild = firstFather->child[ 0 ];
181 functor( firstChild, 0 );
182 functor( firstChild, 1 );
184 functor( firstFather->child[ 1 ], 1 );
186 if( patch.
count() > 1 )
188 Element *
const father = patch[ 1 ];
189 functor( father->child[ 0 ], 1 );
195 struct ForEachInteriorSubChild< 3, 1 >
197 template<
class Functor >
198 static void apply ( Functor &functor,
const Patch< 3 > &patch )
201 Element *
const firstFather = patch[ 0 ];
203 Element *
const firstChild = firstFather->child[ 0 ];
204 functor( firstChild, 0 );
205 functor( firstChild, 1 );
206 functor( firstChild, 2 );
208 Element *
const secondChild = firstFather->child[ 1 ];
209 functor( secondChild, 1 );
210 functor( secondChild, 2 );
212 for(
int i = 1; i < patch.
count(); ++i )
214 Element *
const father = patch[ i ];
222 assert( lr_set != 0 );
224 functor( father->child[ 0 ], 0 );
228 functor( father->child[ 0 ], 2 );
229 functor( father->child[ 1 ], (type == 0 ? 1 : 2) );
233 functor( father->child[ 0 ], 1 );
234 functor( father->child[ 1 ], (type == 0 ? 2 : 1) );
242 struct ForEachInteriorSubChild< 3, 2 >
244 template<
class Functor >
245 static void apply ( Functor &functor,
const Patch< 3 > &patch )
248 Element *
const firstFather = patch[ 0 ];
250 Element *
const firstChild = firstFather->child[ 0 ];
251 functor( firstChild, 2 );
252 functor( firstChild, 4 );
253 functor( firstChild, 5 );
255 functor( firstFather->child[ 1 ], 2 );
257 for(
int i = 1; i < patch.
count(); ++i )
259 Element *
const father = patch[ i ];
266 assert( lr_set != 0 );
271 functor( father->child[ 0 ], 4 );
275 functor( father->child[ 0 ], 5 );
288 struct GeometryInFather;
291 struct GeometryInFather< 1 >
293 static const int dim = 1;
298 coordinate (
int child,
int orientation,
int i )
300 static const Real coords[ 2 ][ dim+1 ][ dim ]
301 = { { {0.0}, {0.5} }, { {0.5}, {1.0} } };
302 assert( (i >= 0) && (i <= dim) );
303 return coords[ child ][ i ];
308 struct GeometryInFather< 2 >
310 static const int dim = 2;
315 coordinate (
int child,
int orientation,
int i )
317 static const Real coords[ 2 ][ dim+1 ][ dim ]
318 = { { {0.0, 1.0}, {0.0, 0.0}, {0.5, 0.0} },
319 { {1.0, 0.0}, {0.0, 1.0}, {0.5, 0.0} } };
320 assert( (i >= 0) && (i <= dim) );
321 return coords[ child ][ i ];
326 struct GeometryInFather< 3 >
328 static const int dim = 3;
333 coordinate (
int child,
int orientation,
int i )
335 static const Real coords[ 2 ][ dim+1 ][ dim ]
336 = { { {0.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}, {0.5, 0.0, 0.0} },
337 { {1.0, 0.0, 0.0}, {0.0, 1.0, 0.0}, {0.0, 0.0, 1.0}, {0.5, 0.0, 0.0} } };
338 static const int flip[ 2 ][ 2 ][ dim+1 ]
339 = { { {0, 1, 2, 3}, {0, 1, 2, 3} }, { {0, 2, 1, 3}, {0, 1, 2, 3} } };
340 assert( (i >= 0) && (i <= dim) );
341 i = flip[ child ][ orientation ][ i ];
342 return coords[ child ][ i ];
350 #endif // #if HAVE_ALBERTA