3#ifndef DUNE_ALU2DGRID_INCLUDE_HH
4#define DUNE_ALU2DGRID_INCLUDE_HH
6#define ALU2DGRID_COMPATIBILITY_LEVEL 2
14#define COMPILE_ALU2DGRID_LIB 0
16#if COMPILE_ALU2DGRID_LIB
17 #define COMPILE_ALU2DGRID_INLINE 0
19 #define COMPILE_ALU2DGRID_INLINE 1
22#if COMPILE_ALU2DGRID_INLINE
23#define alu2d_inline inline
30#ifndef ALUGRID_VERTEX_PROJECTION
31#include <alugrid_serial.h>
34#define ALU2DSPACE ALU2DSPACENAME ::
36#define ALU2DSPACENAME ALU2DGrid
37#define ALU2DDIMWORLD(dimw,eltype) < dimw,(eltype == ALU2DSPACE triangle ? 3 : 4) >
40#include <dune/grid/alugrid/common/checkparallel.hh>
42#define ALU2DGRID_PARALLEL 0
48#warning "Using ALU2dGrid in parallel"
52namespace ALU2DSPACENAME
55 enum ElementType { triangle, quadrilateral, mixed };
63 typedef double alu2d_ctype;
70 template<
int dim,
int dimw, ALU2DSPACE ElementType eltype >
71 struct ALU2dImplInterface;
73 template<
int dimw, ALU2DSPACE ElementType eltype >
74 struct ALU2dImplInterface< 0, dimw, eltype >
76 typedef typename ALU2DSPACE Hmesh_basic ALU2DDIMWORLD (dimw,eltype) ::vertex_t Type;
79 template<
int dimw, ALU2DSPACE ElementType eltype >
80 struct ALU2dImplInterface< 1, dimw, eltype >
82 typedef typename ALU2DSPACE Hmesh_basic ALU2DDIMWORLD (dimw,eltype) ::helement_t Type;
85 template<
int dimw, ALU2DSPACE ElementType eltype >
86 struct ALU2dImplInterface< 2, dimw, eltype >
88 typedef typename ALU2DSPACE Hmesh_basic ALU2DDIMWORLD (dimw,eltype) ::helement_t Type;
96 template<
int dimw, ALU2DSPACE ElementType eltype >
97 struct ALU2dImplTraits
102 typedef typename ALU2dImplInterface< 2-cdim, dimw, eltype >::Type
InterfaceType;
105 typedef ALU2DSPACE Hmesh ALU2DDIMWORLD (dimw,eltype) HmeshType;
106 typedef ALU2DSPACE Thinelement ALU2DDIMWORLD (dimw,eltype) ThinelementType;
107 typedef ALU2DSPACE Element ALU2DDIMWORLD (dimw,eltype) ElementType;
108 typedef typename HmeshType::helement_t HElementType;
109 typedef typename HmeshType::hbndel_t HBndElType;
110 typedef ALU2DSPACE Bndel_periodic ALU2DDIMWORLD (dimw,eltype) PeriodicBndElType;
118 class ALU2dGridMarkerVector
120 typedef std::vector< int > VectorType;
122 ALU2dGridMarkerVector() : valid_(false) {}
124 bool valid()
const {
return valid_; }
126 void invalidate() { valid_ =
false; }
128 bool isOnElement(
int elementIndex,
int idx,
int codim)
const
130 return marker_[codim-1][idx] == elementIndex;
133 template <
class Gr
idType>
134 void update (
const GridType & grid,
int level )
136 enum { dim = GridType::dimension };
137 static const int dimworld = GridType::dimensionworld;
138 static const ALU2DSPACE ElementType eltype = GridType::elementType;
141 typedef ALU2DSPACE Listwalkptr< ElementType > IteratorType;
144 for(
int i=0; i<2; ++i)
146 int s = grid.hierSetSize(i+1);
147 if((
int) marker_[i].size() < s ) marker_[i].resize(s);
149 size_t markerSize = marker_[i].size();
151 for(
size_t k=0; k<markerSize; ++k) marker_[i][k] = -1;
154 IteratorType iter(grid.myGrid(), level);
156 for(iter->first(); !iter->done(); iter->next())
158 ElementType & elem = iter->getitem();
159 int elIdx = elem.getIndex();
162#if ALU2DGRID_PARALLEL
163 if( ! grid.rankManager().isValid( elIdx ,
All_Partition ) )
continue;
165 for(
int i=0; i<elem.numvertices(); ++i)
167 enum { vxCodim = 1 };
168 int vxIdx = elem.getVertex(i)->getIndex();
169 if( marker_[vxCodim][vxIdx] < 0) marker_[vxCodim][vxIdx] = elIdx;
171 enum { edgeCodim = 0 };
172 int edgeIdx = elem.edge_idx(i);
173 if( marker_[edgeCodim][edgeIdx] < 0) marker_[edgeCodim][edgeIdx] = elIdx;
180 VectorType marker_[2];
185 class ALU2dGridLeafMarkerVector
187 typedef std::vector< int > VectorType;
189 ALU2dGridLeafMarkerVector() : valid_(false) {}
191 bool valid()
const {
return valid_; }
193 void invalidate() { valid_ =
false; }
196 bool isOnElement(
int elementIndex,
int idx,
int codim)
const
200 assert( codim == 1 );
201 return marker_[idx] == elementIndex;
205 template <
class Gr
idType>
206 void update (
const GridType & grid)
208 static const int dimworld = GridType::dimensionworld;
209 static const ALU2DSPACE ElementType eltype = GridType::elementType;
212 typedef ALU2DSPACE Listwalkptr< ElementType > IteratorType;
216 int s = grid.hierSetSize(1);
217 if((
int) marker_.size() < s ) marker_.resize(s);
219 size_t markerSize = marker_.size();
221 for(
size_t k=0; k<markerSize; ++k) marker_[k] = -1;
226 int s = grid.hierSetSize(2);
227 if((
int) vertexLevels_.size() < s ) vertexLevels_.resize(s);
230 size_t vxSize = vertexLevels_.size();
231 for(
size_t k=0; k<vxSize; ++k) vertexLevels_[k] = -1;
234 enum { dim = GridType::dimension };
235 IteratorType iter(grid.myGrid());
237 for(iter->first(); !iter->done(); iter->next())
239 ElementType & elem = iter->getitem();
240 int elIdx = elem.getIndex();
242#if ALU2DGRID_PARALLEL
244 if( ! grid.rankManager().isValid( elIdx ,
All_Partition ) )
continue;
246 int level = elem.level();
248 for(
int i=0; i<elem.numvertices(); ++i)
250 int vxIdx = elem.getVertex(i)->getIndex();
253 if(level > vertexLevels_[vxIdx]) vertexLevels_[vxIdx] = level;
255 int edgeIdx = elem.edge_idx(i);
256 if( marker_[edgeIdx] < 0) marker_[edgeIdx] = elIdx;
263 int levelOfVertex(
const int vxIdx)
const
266 assert( vxIdx >= 0 && vxIdx < (
int) vertexLevels_.size());
268 assert( vertexLevels_[vxIdx] >= 0 );
269 return vertexLevels_[vxIdx];
273 bool isValidVertex(
const int vxIdx)
const
276 assert( vxIdx >= 0 && vxIdx < (
int) vertexLevels_.size());
277 return (vertexLevels_[vxIdx] >= 0);
282 VectorType vertexLevels_;
288 class ALU2dGridObjectStream
291 class EOFException {} ;
293 void readObject (T &) {}
294 void readObject (
int) {}
295 void readObject (
double) {}
297 void writeObject (T &) {}
298 void writeObject (
int) {}
299 void writeObject (
double) {}
302 void read (T &)
const {}
304 void write (
const T &) {}
Implements an utility class that provides collective communication methods for sequential programs.
Dune namespace.
Definition: alignment.hh:10