vtf-logo

GridFunctionVoid.h

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

Generated on Fri Aug 24 13:00:29 2007 for AMROC's Hierachical Data Structures - by  doxygen 1.4.7