AMROC Main     Blockstructured Adaptive Mesh Refinement in object-oriented C++


Main Page   Class Hierarchy   Compound List   File List  

GridFunctionVoid.h

Go to the documentation of this file.
00001 #ifndef _included_GridFunctionVoid_h
00002 #define _included_GridFunctionVoid_h
00003 
00009 #include "DAGHParams.h"
00010 #include "DAGHDefaults.h"
00011 
00012 #include "DAGHInteraction.h"
00013 
00014 #include "GridTable.h"
00015 #include "CommRcvServer.h"
00016 
00017 #include "GFInteraction.h"
00018 
00019 #ifndef DAGHGFVFlagType
00020 #define DAGHGFVFlagType    short
00021 #endif
00022 
00023 #ifndef DAGHGFVFlagNum
00024 #define DAGHGFVFlagNum     10
00025 #endif
00026 
00027 class GridHierarchy;
00028 
00033 class GridFunctionVoid
00034   {
00035    friend ostream& operator<<(ostream&, const GridFunctionVoid&);
00036    friend ofstream& operator<<(ofstream&, const GridFunctionVoid&);
00037    friend ifstream& operator>>(ifstream&, GridFunctionVoid&);
00038    friend strstream& operator<<(strstream&, const GridFunctionVoid&);
00039    friend strstream& operator>>(strstream&, GridFunctionVoid&);
00040 
00041    /* All that has to be accesed by the GridHierarchy will go here */
00042    friend class GridHierarchy; 
00043 
00044 protected:
00045    /* General information */
00046    short gfid;          /* my unique id */
00047    short gftype;        /* type ? DAGHCellCentered/DAGHNonCellCentered/.. */
00048    short gfrank;        /* rank */
00049    char *gfname;  /* print name */
00050 
00051    short overlap[DAGHMaxRank]; /* Overlap info... */
00052 
00053    /* level offset - used to store coarser grids in fine levels */ 
00054    int loffset;
00055 
00056    /* coarsening factor - used to create coarser grids for error estimation or multigrid */
00057    int cfactor;
00058 
00059    /* alignment (if rank < dagh.rank) */
00060    short alignment;
00061 
00062    /* boundary width */
00063    short bwidth;
00064 
00065    /* External ghost width */
00066    short extghostwidth;
00067 
00068    /* Attributes */
00069    short comm_flag;     /* communication type */
00070    short bndry_flag;    /* boundary type */
00071    short adaptbndry_flag; /* adaptive boundary type */
00072    short extghost_flag; /* ext. ghost or no ext. ghost */
00073    short compose_flag;  /* have I already been composed */
00074    short template_flag; /* am I using a precomputed template */
00075 
00076    /* Other Attributes */
00077    short init_flag;       /* to init or not to init */
00078    short update_flag;     /* to update or not to update */
00079    short prolong_flag;    /* to prolong or not to prolong */
00080    short restrict_flag;   /* to restrict or not to restrict */
00081    short bndry_update_flag; /* to update boundary or not */
00082    short adaptbndry_update_flag; /* to update adaptive boundary or not */
00083    short io_flag;         /* to io or not to io */
00084    short chkpt_flag;      /* to checkpoint or not to checkpoint */
00085 
00086    /* Maximal level that is initialized during recomposition */
00087    int lmax_recompose;
00088 
00089    /* Stencil information */
00090    short time_sten_rad;
00091    short* space_sten_rad;
00092 
00093    /* Time aliasing information */
00094    short *time_alias;
00095 
00096    /* Physical time information */
00097    double* phys_time;
00098 
00099    /* Interactions */
00100    GhostInteraction interactions;
00101 
00102    /* Ghost Communication Stuff [np][levels * axis * dir] */
00103    GF_Interaction*** ghost_send_info;
00104    short* ghost_recv_cnt;
00105    GF_Interaction*** ghost_recv_info;
00106    GridTableGhostRcv*** ghost_recv_server;
00107 
00108    /* Data Communication Stuff [np][time * level * length * 2] */
00109    GridTableDataRcv*** data_recv_server;
00110 
00111    /* Lists for external and adaptive ghost cell regions */
00112    BBoxList** bndrybboxlist;
00113    BBoxList** prolongbboxlist;
00114 
00115    int updatedstep;     /* Where does the updated timestep reside ? */
00116 
00117    /* My Grid Table */
00118    GridTable *gt;
00119 
00120    /* and a ref to the GridHierarchy */
00121    GridHierarchy &dagh;
00122 
00123    /* some flags for the user */
00124    DAGHGFVFlagType userflags[DAGHGFVFlagNum];
00125 
00126    /* For Efficient Recompose */
00127    /* Recv */
00128    unsigned *rcvsize;
00129    /* Send */
00130    unsigned* sndsize;
00131    BBox* sndbbox;
00132    short* sndindex;
00133    short* rcvindex;
00134    short* sndlevel;
00135    short* sndcnt;
00136 
00137 public:
00138    /*****************************************************************************/
00139    /* constructor */
00140    /*****************************************************************************/
00141    GridFunctionVoid(const int type, 
00142                     const int rank,
00143                     const char name[], 
00144                     GridHierarchy &gh,
00145                     const int loff,
00146                     const int cfac,
00147                     const int align,
00148                     const int bndrywidth,
00149                     const int extghwidth,
00150                     const int cflag, 
00151                     const int bflag,
00152                     const int adptbflag,
00153                     const int extghflag);
00154 
00155    GridFunctionVoid(const int type, 
00156                     const int rank,
00157                     const char name[], 
00158                     const int tsten, 
00159                     const int ssten, 
00160                     GridHierarchy &gh,
00161                     const int loff,
00162                     const int cfac,
00163                     const int align,
00164                     const int bndrywidth,
00165                     const int extghwidth,
00166                     const int cflag, 
00167                     const int bflag,
00168                     const int adptbflag,
00169                     const int extghflag);
00170 
00171    GridFunctionVoid(const int type, 
00172                     const int rank,
00173                     const char name[], 
00174                     const int tsten, 
00175                     const int *ssten, 
00176                     GridHierarchy &gh,
00177                     const int loff,
00178                     const int cfac,
00179                     const int align,
00180                     const int bndrywidth,
00181                     const int extghwidth,
00182                     const int cflag, 
00183                     const int bflag,
00184                     const int adptbflag,
00185                     const int extghflag);
00186  
00187    GridFunctionVoid(const char name[], 
00188                     const int rank,
00189                     const GridFunctionVoid& gfv,
00190                     const int cflag, 
00191                     const int bflag,
00192                     const int adptbflag,
00193                     const int extghflag);
00194    /*****************************************************************************/
00195    /* destructor */
00196    /*****************************************************************************/
00197    virtual ~GridFunctionVoid();
00198 
00199 public:
00200    /*****************************************************************************/
00201    /* Set GF Type */
00202    /*****************************************************************************/
00203    void GF_SetGridFunctionType(const int gft); 
00204 
00205    /*****************************************************************************/
00206    /* set flags */
00207    /*****************************************************************************/
00208    inline void GF_SetCommType(const int cflag) 
00209      { comm_flag = cflag; }
00210    inline void GF_SetBoundaryType(const int bflag) 
00211      { bndry_flag = bflag; }
00212    inline void GF_SetAdaptBoundaryType(const int adptbflag) 
00213      { adaptbndry_flag = adptbflag; }
00214    inline void GF_SetExternalGhostFlag(const int egflag) 
00215      { extghost_flag = egflag; }
00216 
00217    /*****************************************************************************/
00218    /* set/test attributes */
00219    /*****************************************************************************/
00220    inline void GF_SetInitializeFlag(const int flag) 
00221      { init_flag = flag; }
00222    inline void GF_SetUpdateFlag(const int flag) 
00223      { update_flag = flag; }
00224    inline void GF_SetProlongFlag(const int flag) 
00225      { prolong_flag = flag; }
00226    inline void GF_SetRestrictFlag(const int flag) 
00227      { restrict_flag = flag; }
00228    inline void GF_SetBndryUpdateFlag(const int flag) 
00229      { bndry_update_flag = flag; }
00230    inline void GF_SetAdaptBndryUpdateFlag(const int flag) 
00231      { adaptbndry_update_flag = flag; }
00232    inline void GF_SetIOFlag(const int flag) 
00233      { io_flag = flag; }
00234    inline void GF_SetCheckpointFlag(const int flag) 
00235      { chkpt_flag = flag; }
00236 
00237    inline int initialize() 
00238      { return init_flag == DAGHTrue; }
00239    inline int update() 
00240      { return update_flag == DAGHTrue; }
00241    inline int prolong() 
00242      { return prolong_flag == DAGHTrue; }
00243    inline int Restrict()  
00244      { return restrict_flag == DAGHTrue; }
00245    inline int bndry_update() 
00246      { return bndry_update_flag == DAGHTrue; }
00247    inline int adaptbndry_update() 
00248      { return adaptbndry_update_flag == DAGHTrue; }
00249    inline int io() 
00250      { return io_flag == DAGHTrue; }
00251    inline int checkpoint() 
00252      { return chkpt_flag == DAGHTrue; }
00253 
00254    /*****************************************************************************/
00255    /* set boundary width */
00256    /*****************************************************************************/
00257    inline void GF_BoundaryWidth(const int width) { bwidth = width; }
00258 
00259    /*****************************************************************************/
00260    /* set external ghost width */
00261    /*****************************************************************************/
00262    inline void GF_ExternalGhostWidth(const int width) 
00263         { extghostwidth = width; }
00264 
00265    /*****************************************************************************/
00266    /* define Stencils */
00267    /*****************************************************************************/
00268    void GF_SetSpaceStencil(const int s_sten);
00269    void GF_SetSpaceStencil(const int* s_sten);
00270 
00271    /*****************************************************************************/
00272    /* set time stencil */
00273    /* time goes from -time_sten_rad to time_sten_rad i.e. 2*time_sten_rad+1 */
00274    /*****************************************************************************/
00275    void GF_SetTimeStencil(const int t_sten);
00276 
00277    /*****************************************************************************/
00278    /* set alignment - used when rank < dagh.rank */
00279    /*****************************************************************************/
00280    inline void GF_SetAlignment(const int align) { alignment = align; }
00281         
00282    /*****************************************************************************/
00283    /* set time aliases */
00284    /*****************************************************************************/
00285    inline void GF_SetTimeAlias(const int t, const int alias_to)
00286         { GF_DeleteGDBStorage(t + time_sten_rad);
00287           time_alias[t+time_sten_rad] = (alias_to+time_sten_rad); }
00288 
00289    /*****************************************************************************/
00290    /* set maximal recomposition level */
00291    /*****************************************************************************/
00292    inline void GF_SetMaxRecomposeLevel(const int l) { lmax_recompose = l; }
00293 
00294    /*****************************************************************************/
00295    /* general queries */
00296    /*****************************************************************************/
00297    inline int GF_Id() const { return (gfid); }
00298    inline int GF_Type() const { return (gftype); }
00299    inline char const *GF_Name() const { return gfname; }
00300    
00301    inline char *GF_Name() { return gfname; }
00302    inline int GF_Rank() const { return gfrank; }
00303    inline void GF_SetName(char* newname) { gfname = newname; }
00304 
00305    inline int factor() const { return (cfactor); }
00306    inline int GF_Alignment() const { return alignment; }
00307 
00308    inline int comm() const 
00309      { return (comm_flag != DAGHNoComm); }
00310    inline int externalboundary() const 
00311      { return (bndry_flag != DAGHNoBoundary); }
00312    inline int adaptiveboundary() const 
00313      { return (adaptbndry_flag != DAGHNoAdaptBoundary); }
00314 
00315    inline int externalghost() const 
00316      { return (extghost_flag != DAGHTrue); }
00317 
00318    inline int composed() const 
00319      { return (compose_flag == DAGHTrue); }
00320 
00321    inline int comm_type() const 
00322      { return (comm_flag); }
00323    inline int boundary_type() const 
00324      { return (bndry_flag); }
00325    inline int adaptiveboundary_type() const 
00326      { return (adaptbndry_flag); }
00327 
00328    inline int boundary_width() const
00329      { return (bwidth); }
00330    inline int externalghost_width() const
00331      { return (extghostwidth); }
00332 
00333    /*************************************************************************/
00334    BBox usedbbox(const BBox& gb, const int& level, const int& align);
00336    BBox usedbbox(const GridBox& gb, const int& level, const int& align)
00337      { return (usedbbox(gb.gbBBox(), level, align)); }
00338    /*****************************************************************************/
00339 
00340    /*************************************************************************/
00341    /* Set/Query Updated Timestep Info */
00342    /*************************************************************************/
00343    inline int updatedvaluestep() const { return updatedstep; }
00344    inline void setupdatedvaluestep(const int ustep) { updatedstep = ustep; }
00345 
00346    /*****************************************************************************/
00347    /* set and query user flags */
00348    /*****************************************************************************/
00349    inline void GF_SetUserFlag(const int id, const DAGHGFVFlagType& f)
00350      { assert (id < DAGHGFVFlagNum); userflags[id] = f; }
00351 
00352    inline DAGHGFVFlagType GF_GetUserFlag(const int id)
00353      { assert (id < DAGHGFVFlagNum); return (userflags[id]); }
00354 
00355    /*****************************************************************************/
00356    /* Free temporary storage */
00357    /*****************************************************************************/
00358    void GF_FreeTmpStorage();
00359 
00360    /*****************************************************************************/
00361    /* virtual methods for time aliasing */
00362    /*****************************************************************************/
00363    virtual void GF_DeleteGDBStorage(const int t);
00364 
00365    /*****************************************************************************/
00366    /* virtual methods that will be called by GridHierarchy */
00367    /*****************************************************************************/
00368    inline virtual void GF_Sync(const int time, const int level)
00369      { cerr << "Dummy GF_Sync(time, level) function\n"; }
00370 
00371    inline virtual void GF_Sync(const int time, const int level,
00372                                const int axis, const int dir)
00373      { cerr << "Dummy GF_Sync(time, level, axis, dir) function\n"; }
00374 
00375    inline virtual void GF_WriteGhosts(const int time, const int level)
00376      { cerr << "Dummy GF_WriteGhosts(time, level) function\n"; }
00377 
00378    inline virtual void GF_WriteGhosts(const int time, const int level,
00379                                       const int axis, const int dir)
00380      { cerr << "Dummy GF_WriteGhosts(time, level, axis, dir) function\n"; }
00381 
00382    inline virtual void GF_ReadGhosts(const int time, const int level)
00383      { cerr << "Dummy GF_ReadGhosts(time, level) function\n"; }
00384 
00385    inline virtual void GF_ReadGhosts(const int time, const int level,
00386                                      const int axis, const int dir)
00387      { cerr << "Dummy GF_ReadGhosts(time, level, axis, dir) function\n"; }
00388 
00389    virtual void GF_Compose();
00390    virtual void GF_Recompose(int* reuse_possible, GridBoxList** ollist,
00391                              GridBoxList** rlist, GridBoxList** slist, 
00392                              GridBoxList** olist);
00393 
00394    virtual void GF_CheckpointRecompose();
00395    virtual void GF_CheckpointRecompose(strstream& ifs);
00396    virtual void GF_Checkpoint(ofstream& ofs);   
00397    virtual void GF_Checkpoint(strstream& ofs);   
00398    virtual int  GF_Checkpoint_StrStream_Memory();
00399    virtual void GF_CheckpointRestart(int proc=-1);
00400    virtual void GF_CheckpointRestart(strstream& ifs);
00401 
00402 private:
00403    /* disable this */
00404    GridFunctionVoid const &operator= (GridFunctionVoid const &other);
00405   };
00406 
00407 ostream& operator<<(ostream& os, const GridFunctionVoid& gfv);
00408 ofstream& operator<<(ofstream& ofs, const GridFunctionVoid& gfv);
00409 ifstream& operator>>(ifstream& ifs, GridFunctionVoid& gfv);
00410 strstream& operator<<(strstream& ofs, const GridFunctionVoid& gfv);
00411 strstream& operator>>(strstream& ifs, GridFunctionVoid& gfv);
00412 
00413 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



AMROC Main      Home      Contact
last update: 06/01/04