ghmesh.hh

00001 #ifndef __GRAPE_HMESH_H__
00002 #define __GRAPE_HMESH_H__
00003 
00004 enum { MAX_NAME_LENGTH = 32 };
00005 
00006 typedef struct dune_elem  DUNE_ELEM;
00007 typedef struct dune_fdata DUNE_FDATA;
00008 typedef struct dune_dat  DUNE_DAT;
00009 
00010 typedef void evalDof_t  (DUNE_ELEM *, DUNE_FDATA *, int , double *);
00011 typedef void evalCoord_t(DUNE_ELEM *, DUNE_FDATA *, const double *, double * );
00012 
00013 /* interface element */
00014 typedef struct dune_elem 
00015 {
00016 
00017   // default constructor 
00018   dune_elem() 
00019     : type(127) 
00020     , eindex(-1)
00021     , level(-1)
00022     , level_of_interest(-1)
00023     , has_children(0) 
00024     , liter(0)
00025     , enditer(0) 
00026     , hiter(0) 
00027     , actElement(0) 
00028     , gridPart(0) 
00029     , display(0) 
00030     , mesh(0) 
00031   {
00032     // default set all coordinates to zero
00033     for(int i=0; i<MAX_EL_DOF; ++i)
00034     {
00035       vindex [i] = -1;
00036       vpointer[i] = (double *) coordinates[i];
00037       for(int j=0; j<3; ++j)
00038       {
00039         vpointer[i][j] = 0.0;
00040       }
00041     }
00042     for(int i=0; i<MAX_EL_FACE; ++i)
00043     {
00044       bnd [i] = -1;
00045     }
00046   }
00047   
00048   /* 
00049    *  see g_eldesc.h for ElementType 
00050    */
00051   int       type; 
00052 
00053   double *        vpointer [MAX_EL_DOF];
00054   double          coordinates [MAX_EL_DOF][3];
00055   int             vindex [MAX_EL_DOF] ;
00056   int             bnd [MAX_EL_FACE] ;
00057   int             eindex;
00058   int             level;
00059   int             level_of_interest;
00060   int             has_children;
00061   
00062   /* is the pointer to LevelIterator or to LeafIterator */
00063   void          * liter;
00064   void          * enditer;
00065 
00066   // pointer fo hierarchic iterator */
00067   void          * hiter;
00068 
00069   /* points to actual iterator to compare an get type */
00070   /* down cast to EntityPointer */
00071   void          * actElement;
00072 
00073   /* actual choosen gridPart */
00074   void          * gridPart; 
00075 
00076   // pointer to my display class 
00077   void          * display;
00078 
00079   // pointer to mesh 
00080   void          * mesh; 
00081 };
00082 
00083 typedef struct dune_fdata 
00084 {
00085   static std::set<DUNE_FDATA*>& dataList () 
00086   {
00087     static std::set<DUNE_FDATA*> dList;
00088     return dList;
00089   }
00090   
00091   // default constructor 
00092   dune_fdata() 
00093     : mynum (-1) 
00094     , name() 
00095     , evalCoord(0) 
00096     , evalDof(0)
00097     , discFunc(0) 
00098     , indexSet(0)
00099     , allLevels(0)
00100     , dimVal(0)
00101     , dimRange(0) 
00102     , comp(0) 
00103     , polyOrd(0)
00104     , continuous(0)
00105     , compName(0)
00106     , gridPart(0) 
00107     , setGridPartIterators(0)
00108     , f_data (0)
00109     , minValue(0.0)
00110     , maxValue(1.0)
00111     , valuesSet(false)
00112     , getMinMaxValues(0)
00113   {
00114     // add this data to list of dune data funcs 
00115     dataList().insert(this);
00116   }
00117   
00118   // default destructor  
00119   ~dune_fdata() 
00120   { 
00121     dataList().erase(this);
00122   }
00123   
00124   /* my number in the data vector */
00125   int mynum; 
00126 
00127   /* name of data */
00128   std::string name; 
00129   
00130   // functions to evaluate 
00131   evalCoord_t * evalCoord; 
00132   evalDof_t   * evalDof; 
00133   
00134   /* pointer to object of discrete function or vector */
00135   const void *discFunc;
00136 
00137   /* pointer to index set of underlying datas */
00138   const void *indexSet;
00139 
00140   /* are all Levels occupied? */
00141   int allLevels; 
00142 
00143   /* dimension of value, i.e. the length of the vector  */
00144   int dimVal;
00145 
00146   /* dimension of data, when vectorial data is interpreted as scalar data */
00147   int dimRange; 
00148   
00149   /* index of current component */
00150   /* for scalar this vec has length 1 and contains the component number */ 
00151   /* for vector this contains the number of each component */
00152   int * comp;
00153 
00154   /* polynonial order of basis functions */
00155   int polyOrd; 
00156   
00157   /* continuous or not */
00158   int continuous;
00159 
00160   /* max number of components */
00161   int compName;
00162 
00163   /* the corresponding gridPart */
00164   void * gridPart; 
00165 
00166   /* function pointer to choose grid part iterators */
00167   void (*setGridPartIterators)(DUNE_DAT * , void * gridPart);
00168 
00169   /* pointer to f_data */
00170   void * f_data; 
00171 
00172   /* minValue of function, for colorbar */
00173   double minValue;
00174   /* maxValue of function, for colorbar */
00175   double maxValue;
00176 
00177   /* true if min and max values have been calculated */
00178   bool valuesSet;
00179   
00180   /* returns min and max values of function */
00181   void (*getMinMaxValues)(DUNE_FDATA *, double * min, double * max );
00182 };
00183 
00184 /* dune_dat */
00185 struct dune_dat
00186 {
00187   // default constructor 
00188   dune_dat() 
00189     : first_macro(0)
00190     , next_macro(0) 
00191     , delete_iter(0) 
00192     , first_child(0) 
00193     , next_child(0)
00194     , copy(0)
00195     , check_inside(0)
00196     , wtoc(0) 
00197     , ctow(0)
00198     , setIterationModus(0)
00199     , partition(-1)
00200     , iteratorType(-1) // g_LeafIterator
00201     , partitionIteratorType(-1)
00202     , gridPart(0)
00203     , all (0) 
00204     , get_stackentry(0) 
00205     , free_stackentry(0) {}
00206 
00207   /* the actual first and next macro for Iteration  */
00208   int (* first_macro)(DUNE_ELEM *) ;
00209   int (* next_macro)(DUNE_ELEM *) ;
00210 
00211   /* method to delete iterators */
00212   void (* delete_iter)(DUNE_ELEM *) ;
00213 
00214   /* first and next child , if 0, then no child iteration */
00215   int (* first_child)(DUNE_ELEM *) ;
00216   int (* next_child)(DUNE_ELEM *) ;
00217 
00218   void * (* copy)(const void *) ;
00219 
00220   int  (* check_inside)(DUNE_ELEM *, const double * ) ;
00221   int  (* wtoc)(DUNE_ELEM *, const double *, double * ) ;
00222   void (* ctow)(DUNE_ELEM *, const double *, double * ) ;
00223 
00224   
00225   /* selects the iterators, like leaf iterator .. */
00226   void (* setIterationModus)(DUNE_DAT *, DUNE_FDATA *);  
00227 
00228   /* to which processor partition the element belongs */
00229   int partition;
00230 
00231   /* type of choosen iterator */
00232   int iteratorType; 
00233 
00234   /* type of partition to iterate */
00235   int partitionIteratorType; 
00236 
00237   /* actual gridPart */
00238   void * gridPart;
00239 
00240   DUNE_ELEM * all;
00241 
00242   /* get HELEMENT */
00243   void * (*get_stackentry)(DUNE_DAT * ); 
00244   /* free HELEMENT */
00245   void   (*free_stackentry)(DUNE_DAT * , void *); 
00246 };
00247 
00248 /* setup hmesh with given data */
00249 extern void *setupHmesh(const int noe, const int nov, 
00250                         const int maxlev, DUNE_DAT * dune);
00251 
00252 /* delete given hmesh pointer */
00253 extern void deleteHmesh( void * hmesh ); 
00254 extern void deleteFunctions( void * hmesh ); 
00255 
00256 extern void displayTimeScene(INFO * info);
00257 extern void handleMesh (void *hmesh, bool gridMode );
00258 
00259 extern DUNE_FDATA * extractData (void *hmesh , int num );
00260 
00261 /* setup TimeScene Tree  */
00262 extern void timeSceneInit(INFO *info, const int n_info, const int procs);
00263 extern void addDataToHmesh(void  *hmesh, DUNE_FDATA * data);
00264 
00265 extern void addHmeshToTimeScene(void * timescene, double time, void  *hmesh , int proc);
00266 
00267 extern void addHmeshToGlobalTimeScene(double time, void  *hmesh , int proc);
00268 extern void tsc_timebar(void *timescene, double t_start, double t_end);
00269 extern void colorBarMinMax(const double min, const double max);
00270 
00271 #endif

Generated on 12 Dec 2007 with Doxygen (ver 1.5.1)