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     , valCache(0.0)
00113     , getMinMaxValues(0)
00114   {
00115     // add this data to list of dune data funcs 
00116     dataList().insert(this);
00117   }
00118   
00119   // default destructor  
00120   ~dune_fdata() 
00121   { 
00122     dataList().erase(this);
00123   }
00124   
00125   /* my number in the data vector */
00126   int mynum; 
00127 
00128   /* name of data */
00129   std::string name; 
00130   
00131   // functions to evaluate 
00132   evalCoord_t * evalCoord; 
00133   evalDof_t   * evalDof; 
00134   
00135   /* pointer to object of discrete function or vector */
00136   const void *discFunc;
00137 
00138   /* pointer to index set of underlying datas */
00139   const void *indexSet;
00140 
00141   /* are all Levels occupied? */
00142   int allLevels; 
00143 
00144   /* dimension of value, i.e. the length of the vector  */
00145   int dimVal;
00146 
00147   /* dimension of data, when vectorial data is interpreted as scalar data */
00148   int dimRange; 
00149   
00150   /* index of current component */
00151   /* for scalar this vec has length 1 and contains the component number */ 
00152   /* for vector this contains the number of each component */
00153   int * comp;
00154 
00155   /* polynonial order of basis functions */
00156   int polyOrd; 
00157   
00158   /* continuous or not */
00159   int continuous;
00160 
00161   /* max number of components */
00162   int compName;
00163 
00164   /* the corresponding gridPart */
00165   void * gridPart; 
00166 
00167   /* function pointer to choose grid part iterators */
00168   void (*setGridPartIterators)(DUNE_DAT * , void * gridPart);
00169 
00170   /* pointer to f_data */
00171   void * f_data; 
00172 
00173   /* minValue of function, for colorbar */
00174   double minValue;
00175   /* maxValue of function, for colorbar */
00176   double maxValue;
00177 
00178   /* true if min and max values have been calculated */
00179   bool valuesSet;
00180   
00181   /* cache for polOrd zero functions */
00182   double valCache;
00183 
00184   /* returns min and max values of function */
00185   void (*getMinMaxValues)(DUNE_FDATA *, double * min, double * max );
00186 };
00187 
00188 /* dune_dat */
00189 struct dune_dat
00190 {
00191   // default constructor 
00192   dune_dat() 
00193     : first_macro(0)
00194     , next_macro(0) 
00195     , delete_iter(0) 
00196     , first_child(0) 
00197     , next_child(0)
00198     , copy(0)
00199     , check_inside(0)
00200     , wtoc(0) 
00201     , ctow(0)
00202     , setIterationModus(0)
00203     , partition(-1)
00204     , iteratorType(-1) // g_LeafIterator
00205     , partitionIteratorType(-1)
00206     , gridPart(0)
00207     , all (0) 
00208     , get_stackentry(0) 
00209     , free_stackentry(0) {}
00210 
00211   /* the actual first and next macro for Iteration  */
00212   int (* first_macro)(DUNE_ELEM *) ;
00213   int (* next_macro)(DUNE_ELEM *) ;
00214 
00215   /* method to delete iterators */
00216   void (* delete_iter)(DUNE_ELEM *) ;
00217 
00218   /* first and next child , if 0, then no child iteration */
00219   int (* first_child)(DUNE_ELEM *) ;
00220   int (* next_child)(DUNE_ELEM *) ;
00221 
00222   void * (* copy)(const void *) ;
00223 
00224   int  (* check_inside)(DUNE_ELEM *, const double * ) ;
00225   int  (* wtoc)(DUNE_ELEM *, const double *, double * ) ;
00226   void (* ctow)(DUNE_ELEM *, const double *, double * ) ;
00227 
00228   
00229   /* selects the iterators, like leaf iterator .. */
00230   void (* setIterationModus)(DUNE_DAT *, DUNE_FDATA *);  
00231 
00232   /* to which processor partition the element belongs */
00233   int partition;
00234 
00235   /* type of choosen iterator */
00236   int iteratorType; 
00237 
00238   /* type of partition to iterate */
00239   int partitionIteratorType; 
00240 
00241   /* actual gridPart */
00242   void * gridPart;
00243 
00244   DUNE_ELEM * all;
00245 
00246   /* get HELEMENT */
00247   void * (*get_stackentry)(DUNE_DAT * ); 
00248   /* free HELEMENT */
00249   void   (*free_stackentry)(DUNE_DAT * , void *); 
00250 };
00251 
00252 /* setup hmesh with given data */
00253 extern void *setupHmesh(const int noe, const int nov, 
00254                         const int maxlev, DUNE_DAT * dune);
00255 
00256 /* delete given hmesh pointer */
00257 extern void deleteHmesh( void * hmesh ); 
00258 extern void deleteFunctions( void * hmesh ); 
00259 
00260 extern void displayTimeScene(INFO * info);
00261 extern void handleMesh (void *hmesh, bool gridMode );
00262 
00263 extern DUNE_FDATA * extractData (void *hmesh , int num );
00264 
00265 /* setup TimeScene Tree  */
00266 extern void timeSceneInit(INFO *info, const int n_info, const int procs);
00267 extern void addDataToHmesh(void  *hmesh, DUNE_FDATA * data);
00268 
00269 extern void addHmeshToTimeScene(void * timescene, double time, void  *hmesh , int proc);
00270 
00271 extern void addHmeshToGlobalTimeScene(double time, void  *hmesh , int proc);
00272 extern void tsc_timebar(void *timescene, double t_start, double t_end);
00273 extern void colorBarMinMax(const double min, const double max);
00274 
00275 #endif

Generated on 9 Apr 2008 with Doxygen (ver 1.5.2) [logfile].