dune-grid  2.2.0
ghmesh.hh
Go to the documentation of this file.
1 #ifndef __GRAPE_HMESH_H__
2 #define __GRAPE_HMESH_H__
3 
4 //- system includes
5 #include <cstdlib>
6 #include <cassert>
7 #include <cstring>
8 #include <iostream>
9 #include <stack>
10 #include <set>
11 #include <list>
12 
13 //- Grape includes
14 #include "grapecommon.hh"
15 
16 #if HAVE_GRAPE
17 
18 enum { MAX_NAME_LENGTH = 32 };
19 
20 typedef struct dune_elem DUNE_ELEM;
21 typedef struct dune_fdata DUNE_FDATA;
22 typedef struct dune_dat DUNE_DAT;
23 
24 typedef void evalDof_t (DUNE_ELEM *, DUNE_FDATA *, int , double *);
25 typedef void evalCoord_t(DUNE_ELEM *, DUNE_FDATA *, const double *, double * );
26 
27 /* interface element */
28 struct dune_elem
29 {
30 
31  // default constructor
32  dune_elem()
33  : type(127)
34  , eindex(-1)
35  , level(-1)
36  , level_of_interest(-1)
37  , has_children(0)
38  , liter(0)
39  , enditer(0)
40  , hiter(0)
41  , actElement(0)
42  , gridPart(0)
43  , display(0)
44  , mesh(0)
45  {
46  // default set all coordinates to zero
47  for(int i=0; i<MAX_EL_DOF; ++i)
48  {
49  vindex [i] = -1;
50  vpointer[i] = (double *) coordinates[i];
51  for(int j=0; j<3; ++j)
52  {
53  vpointer[i][j] = 0.0;
54  }
55  }
56  for(int i=0; i<MAX_EL_FACE; ++i)
57  {
58  bnd [i] = -1;
59  }
60  }
61 
62  /*
63  * see g_eldesc.h for ElementType
64  */
65  int type;
66 
67  double * vpointer [MAX_EL_DOF];
68  double coordinates [MAX_EL_DOF][3];
69  int vindex [MAX_EL_DOF] ;
70  int bnd [MAX_EL_FACE] ;
71  int eindex;
72  int level;
73  int level_of_interest;
74  int has_children;
75 
76  /* is the pointer to LevelIterator or to LeafIterator */
77  void * liter;
78  void * enditer;
79 
80  // pointer fo hierarchic iterator */
81  void * hiter;
82 
83  /* points to actual iterator to compare an get type */
84  /* down cast to EntityPointer */
85  void * actElement;
86 
87  /* actual choosen gridPart */
88  void * gridPart;
89 
90  // pointer to my display class
91  void * display;
92 
93  // pointer to mesh
94  void * mesh;
95 };
96 
97 struct dune_fdata
98 {
99  static std::set<DUNE_FDATA*>& dataList ()
100  {
101  static std::set<DUNE_FDATA*> dList;
102  return dList;
103  }
104 
105  // default constructor
106  dune_fdata()
107  : mynum (-1)
108  , name()
109  , evalCoord(0)
110  , evalDof(0)
111  , discFunc(0)
112  , indexSet(0)
113  , allLevels(0)
114  , dimVal(0)
115  , dimRange(0)
116  , comp(0)
117  , polyOrd(0)
118  , continuous(0)
119  , compName(0)
120  , gridPart(0)
121  , setGridPartIterators(0)
122  , f_data (0)
123  , minValue(0.0)
124  , maxValue(1.0)
125  , valuesSet(false)
126  , valCache(0.0)
127  , getMinMaxValues(0)
128  {
129  // add this data to list of dune data funcs
130  dataList().insert(this);
131  }
132 
133  // default destructor
134  ~dune_fdata()
135  {
136  dataList().erase(this);
137  }
138 
139  /* my number in the data vector */
140  int mynum;
141 
142  /* name of data */
143  std::string name;
144 
145  // functions to evaluate
146  evalCoord_t * evalCoord;
147  evalDof_t * evalDof;
148 
149  /* pointer to object of discrete function or vector */
150  const void *discFunc;
151 
152  /* pointer to index set of underlying datas */
153  const void *indexSet;
154 
155  /* are all Levels occupied? */
156  int allLevels;
157 
158  /* dimension of value, i.e. the length of the vector */
159  int dimVal;
160 
161  /* dimension of data, when vectorial data is interpreted as scalar data */
162  int dimRange;
163 
164  /* index of current component */
165  /* for scalar this vec has length 1 and contains the component number */
166  /* for vector this contains the number of each component */
167  int * comp;
168 
169  /* polynonial order of basis functions */
170  int polyOrd;
171 
172  /* continuous or not */
173  int continuous;
174 
175  /* max number of components */
176  int compName;
177 
178  /* the corresponding gridPart */
179  void * gridPart;
180 
181  /* function pointer to choose grid part iterators */
182  void (*setGridPartIterators)(DUNE_DAT * , void * gridPart);
183 
184  /* pointer to f_data */
185  void * f_data;
186 
187  /* minValue of function, for colorbar */
188  double minValue;
189  /* maxValue of function, for colorbar */
190  double maxValue;
191 
192  /* true if min and max values have been calculated */
193  bool valuesSet;
194 
195  /* cache for polOrd zero functions */
196  double valCache;
197 
198  /* returns min and max values of function */
199  void (*getMinMaxValues)(DUNE_FDATA *, double * min, double * max );
200 };
201 
202 /* dune_dat */
203 struct dune_dat
204 {
205  // default constructor
206  dune_dat()
207  : first_macro(0)
208  , next_macro(0)
209  , delete_iter(0)
210  , first_child(0)
211  , next_child(0)
212  , copy(0)
213  , check_inside(0)
214  , wtoc(0)
215  , ctow(0)
216  , setIterationModus(0)
217  , partition(-1)
218  , iteratorType(-1) // g_LeafIterator
219  , partitionIteratorType(-1)
220  , gridPart(0)
221  , all (0)
222  , get_stackentry(0)
223  , free_stackentry(0) {}
224 
225  /* the actual first and next macro for Iteration */
226  int (* first_macro)(DUNE_ELEM *) ;
227  int (* next_macro)(DUNE_ELEM *) ;
228 
229  /* method to delete iterators */
230  void (* delete_iter)(DUNE_ELEM *) ;
231 
232  /* first and next child , if 0, then no child iteration */
233  int (* first_child)(DUNE_ELEM *) ;
234  int (* next_child)(DUNE_ELEM *) ;
235 
236  void * (* copy)(const void *) ;
237 
238  int (* check_inside)(DUNE_ELEM *, const double * ) ;
239  int (* wtoc)(DUNE_ELEM *, const double *, double * ) ;
240  void (* ctow)(DUNE_ELEM *, const double *, double * ) ;
241 
242 
243  /* selects the iterators, like leaf iterator .. */
244  void (* setIterationModus)(DUNE_DAT *, DUNE_FDATA *);
245 
246  /* to which processor partition the element belongs */
247  int partition;
248 
249  /* type of choosen iterator */
250  int iteratorType;
251 
252  /* type of partition to iterate */
253  int partitionIteratorType;
254 
255  /* actual gridPart */
256  void * gridPart;
257 
258  DUNE_ELEM * all;
259 
260  /* get HELEMENT */
261  void * (*get_stackentry)(DUNE_DAT * );
262  /* free HELEMENT */
263  void (*free_stackentry)(DUNE_DAT * , void *);
264 };
265 
266 /* setup hmesh with given data */
267 extern void *setupHmesh(const int noe, const int nov,
268  const int maxlev, DUNE_DAT * dune);
269 
270 /* delete given hmesh pointer */
271 extern void deleteHmesh( void * hmesh );
272 extern void deleteFunctions( void * hmesh );
273 
274 //extern void displayTimeScene(INFO * info, int procs);
275 extern void handleMesh (void *hmesh, bool gridMode );
276 
277 extern DUNE_FDATA * extractData (void *hmesh , int num );
278 
279 /* setup TimeScene Tree */
280 extern void timeSceneInit(INFO *info, const int n_info, const int procs);
281 extern void addDataToHmesh(void *hmesh, DUNE_FDATA * data);
282 
283 extern void addHmeshToTimeScene(void * timescene, double time, void *hmesh , int proc);
284 
285 extern void addHmeshToGlobalTimeScene(double time, void *hmesh , int proc);
286 extern void tsc_timebar(void *timescene, double t_start, double t_end);
287 extern void colorBarMinMax(const double min, const double max);
288 
289 #endif // #if HAVE_GRAPE
290 
291 #endif // #ifndef __GRAPE_HMESH_H__