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