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


Main Page   Class Hierarchy   Compound List   File List  

GridHierarchy.h

Go to the documentation of this file.
00001 #ifndef _included_GridHierarchy_h
00002 #define _included_GridHierarchy_h
00003 
00009 #include "DAGHParams.h"
00010 #include "DAGHDefaults.h"
00011 
00012 #include "DAGHDistribution.h"
00013 
00014 #include "List.h"
00015 #include "GridUnitList.h"
00016 #include "GridBoxList.h"
00017 #include "BBoxList.h"
00018 
00019 #include "DCoords.h"
00020 
00021 #include "CommServer.h"
00022 #include "CommIOServer.h"
00023 
00024 #include "GridFunctionVoid.h"
00025 #include "AllocError.h"
00026 
00027 // John Shalf's TCP++ Library"
00028 #ifdef DAGH_IOV
00029 #include <RawTCP.H>
00030 #endif
00031 
00032 /*************************************************************************/
00033 /* Space-Time Dimension Specs */
00034 /*************************************************************************/
00035 struct dimspec {
00036   double low; 
00037   double high; 
00038   double h; 
00039   double hfine; 
00040   unsigned n; 
00041   unsigned nfine; 
00042   inline dimspec():low(0),high(0),h(0),hfine(0),n(0),nfine(0) {}
00043 };
00044 /*************************************************************************/
00045 
00046 /*************************************************************************/
00047 /* Merged bbox + grid unit list combo */
00048 /*************************************************************************/
00049 struct MergedGridUnit { 
00050   BBox bb;
00051   GridUnitList gul;
00052 };
00053 /*************************************************************************/
00054 
00055 /*************************************************************************/
00056 /* Utility routines */
00057 /*************************************************************************/
00058 inline double toWorld(struct dimspec const &ds, const int lc)
00059         { return (ds.low + (lc*ds.hfine)); }
00060 inline double toWorld(struct dimspec const &ds, const int lc, 
00061                       const int step)
00062         { return (ds.low + (lc*ds.hfine)); }
00063 
00064 inline double toWorldLower(struct dimspec const &ds, const int lc, 
00065                            const int step, const int olap)
00066         { return (ds.high*((1.0*lc)/(1.0*ds.nfine)) + 
00067                   ds.low*(1.0 - (1.0*lc)/(1.0*ds.nfine))); }
00068 inline double toWorldUpper(struct dimspec const &ds, const int lc, 
00069                            const int step, const int olap)
00070         { return (ds.high*((1.0*(lc+(1-olap)*step))/(1.0*ds.nfine)) + 
00071                   ds.low*(1.0 - (1.0*(lc+(1-olap)*step))/(1.0*ds.nfine))); }
00072 
00073 inline int toLocal(struct dimspec const &ds, double const wc)
00074         { return ((int) ((wc - ds.low)/ds.hfine)); }
00075 /*************************************************************************/
00076 
00077 /*************************************************************************/
00078 /* IO ping functions */
00079 /*************************************************************************/
00080 /* A PingFunction for Ending IO */
00081 void DAGHIO_EndIOPingFunction(GridHierarchy &GH);
00082 /*************************************************************************/
00083 
00084 #ifdef DAGH_IOV
00085 /*************************************************************************/
00086 /* For Wei's IOV Server */
00087 /*************************************************************************/
00088 void WriteStream(GridHierarchy& GH, RawTCPport* Server, const GridBoxList& cgbl);
00089 /*************************************************************************/
00090 #endif
00091 
00092 #ifndef DAGHDefaultDistribution
00093 #define DAGHDefaultDistribution (DAGHCompositeDistribution)
00094 #endif
00095 
00096 #ifndef DAGHDefaultPartMinGUWidth
00097 #define DAGHDefaultPartMinGUWidth       (1)
00098 #endif
00099 #ifndef DAGHDefaultRefineMinGUWidth
00100 #define DAGHDefaultRefineMinGUWidth     (1)
00101 #endif
00102 
00103 #ifndef DAGHDefaultBoundary
00104 #define DAGHDefaultBoundary     (DAGHBoundaryRegular)
00105 #endif
00106 
00107 #ifndef DAGHDefaultAdaptBoundary
00108 #define DAGHDefaultAdaptBoundary (DAGHAdaptBoundaryInterp)
00109 #endif
00110 
00111 #ifndef DAGHDefaultRefineFactor
00112 #define DAGHDefaultRefineFactor (2)
00113 #endif
00114 
00115 #ifndef DAGHDefaultRefineLevel
00116 #define DAGHDefaultRefineLevel  (1)
00117 #endif
00118 
00119 #ifndef DAGHMaxIOTypes
00120 #define DAGHMaxIOTypes          (5)
00121 #endif 
00122 
00123 #ifndef DAGHChkPtTagNameSize
00124 #define DAGHChkPtTagNameSize    (256)
00125 #endif
00126 
00146 class GridHierarchy 
00147   {
00148    friend ostream&  operator << (ostream& os, const GridHierarchy& );
00149    friend ofstream& operator << (ofstream& ofs, const GridHierarchy&);
00150    friend ifstream& operator >> (ifstream& ifs, GridHierarchy&);
00151    friend strstream& operator << (strstream& ofs, const GridHierarchy&);
00152    friend strstream& operator >> (strstream& ifs, GridHierarchy&);
00153 
00154 public:
00156    short const rank;
00157 
00158 private:
00160    struct dimspec dspecs[DAGHMaxRank];  
00162    struct dimspec tspecs;
00164    BBox basebbox;
00165 
00167    short daghtype;
00169    short overlap[DAGHMaxRank];
00170 
00172    short bndrytype;
00174    short adaptbndrytype;
00176    short bndrywidth;
00178    short bndryperiodic[DAGHMaxRank];  
00179    short periodicidx[DAGHMaxRank];  
00180 
00182    short extghostwidth;
00183 
00184    /* Refinement Information */
00186    short levels;        
00188    short maxlev;        
00190    short crslev;
00192    short *refby;        
00193 
00195    short finelev;
00196 
00198    BBox intbbox;                
00200    BBoxList* intbaselist;    
00202    double* bndrycoords;          
00203    int nbndrycoords;
00204 
00205    /* Boxes of cut-off regions */
00206    BBox* cutbbox;              
00207    int ncutbbox;
00208 
00210    int *curtime;        
00211 
00213    int updatedstep;     
00214 
00215    /* number of buffer cells for proper nesting of higher levels */
00216    int nestbuffer;     
00217 
00218    /* coarsening factor  when constructing GridUnits */
00219    int cfactor;         
00220    int guwidth;
00221 
00222 public:
00224    short distribution_type;
00225    DAGHDistribution* distribution;
00226    
00227 public:
00228    /* Global Information */
00230    GridUnitList *complist;
00232    GridBoxList **globalgbl, **oldglobalgbl;
00233 
00234    /* Local Information */
00236    GridUnitList *locallist;     
00238    GridBoxList **localgbl, **oldlocalgbl;
00240    BBoxList** localbboxarray;
00241 
00242 public:
00244    short gfnum;
00245    GridFunctionVoid **gflist;
00246 
00248    short io_type;
00249    DAGHIOServerRcv *io_write_server;
00250    DAGHIOServerSnd *io_read_server;
00251    DAGHIOServerPing *io_end_server;
00252 
00253 private:
00255    short chkptflag;
00256    int chkptpnum;
00257    char chkptname[DAGHChkPtTagNameSize];
00258 
00259 #ifdef DAGH_IOV
00260 private:
00261    RawTCPserver *ServerPort;
00262    RawTCPport *Server;
00263 #endif
00264 
00265 private:
00266    /*************************************************************************/
00267    /* Disable the following */
00268    /*************************************************************************/
00269    GridHierarchy(GridHierarchy const &other);
00270    GridHierarchy const &operator= (GridHierarchy const &other);
00271 
00272 public:
00273    /*************************************************************************/
00274    /* Constructors */
00275    /*************************************************************************/
00276    GridHierarchy(const int ndim, const int type, const int max_level);
00277 
00278    /*************************************************************************/
00279    /* Destructor */
00280    /*************************************************************************/
00281    ~GridHierarchy(void);
00282     
00283    /*************************************************************************/
00284    /* Setup DAGH */
00285    /*************************************************************************/
00286 public:
00287    void DAGH_SetBaseGrid(double const *bbox, const int *shape,
00288                          const int& ncuts, const int *cuts);
00289    void DAGH_SetTimeSpecs(double const starttime, 
00290                           double const stoptime, 
00291                           const int ntsteps);
00292    inline void DAGH_GetTimeSpecs(double& starttime, double& stoptime) {
00293      starttime = tspecs.low;
00294      stoptime  = tspecs.high;
00295    }
00296 
00297    inline void DAGH_SetBoundaryType(const int type) 
00298      { bndrytype = type; }
00299    inline void DAGH_SetAdaptBoundaryType(const int type) 
00300      { adaptbndrytype = type; }
00301    inline void DAGH_SetBoundaryWidth(const int width) 
00302      { bndrywidth = width; }
00303    inline void DAGH_SetPeriodicBoundaries(const int dir, const int value) 
00304      { if (dir>=0 && dir<rank) bndryperiodic[dir] = value; }
00305 
00306    inline void DAGH_SetExternalGhostWidth(const int width) 
00307      { extghostwidth = width; }
00308 
00309    void DAGH_SetRefineFactor(const int rfactor);
00310    void DAGH_SetRefineFactor(const int lev, const int rfactor);
00311 
00312    inline void DAGH_SetDistributionType(const int type)
00313         { distribution_type = type; if (distribution) distribution->set_dist(type); }
00314    inline void DAGH_SetDistributionType(const int type, BBoxList& bbl)
00315         { distribution_type = type; if (distribution) distribution->set_dist(type,bbl); }
00316 
00317    inline void DAGH_SetWorkFunction(void *wf)
00318         { if (distribution) distribution->set_workfunc(wf); }
00319 
00320    inline void DAGH_SetNestingBuffer(const int& nb)
00321         { nestbuffer = nb; }
00322 
00323    /*************************************************************************/
00324    /* Extend GridBoxLists in case of periodic boundaries */
00325    /*************************************************************************/
00326 private:
00327    void DAGH_PeriodicAppendTogbl(GridBoxList *gbl, GridBox* gb, const BBox& bbox, 
00328                                  const BBox& bbtest, const int dir, const int base,
00329                                  const int maxlength);
00330 public:
00331    void DAGH_PeriodicBoundaries(GridBoxList *gbl, GridBoxList *agbl);
00332 
00333    /*************************************************************************/
00334    /* Creation of GridUnitLists from BBoxLists */
00335    /*************************************************************************/
00336 private:
00337    BBox shrinktoroot(BBox& bb);
00338    BBox growtoroot(BBox& bb);
00339    BBoxList* shrinktoroot(BBoxList& bbl);
00340    BBoxList* growtoroot(BBoxList& bbl);
00341    //what to count: cells (what==0) or workload (what!=0)
00342    int countcells(BBox& bb, BBoxList** bbla, int count);
00343 public:
00344    void DAGH_CreateGridUnitList(GridUnitList*& gul, BBoxList** bbla, int count=DAGHFalse);
00345    void DAGH_CreateGridUnitList(GridUnitList*& gul, const BBox& _bb);
00346    void DAGH_CreateBBoxList(BBoxList*& bbl, GridUnitList& gul);
00347    
00348 public:
00350    void DAGH_ComposeHierarchy(void);
00351 
00352    /*************************************************************************/
00353    /* Setup GridFunctions */
00354    /*************************************************************************/
00355 public:
00356    int DAGH_AddGridFunction(GridFunctionVoid *gfv);
00357    inline void DAGH_DelGridFunction(const int gfid)
00358         { 
00359          gflist[gfid] = (GridFunctionVoid *) NULL; 
00360          if (comm_service::dce()) comm_service::delete_comm(gfid);
00361          gfnum--; 
00362         }
00363 
00364    inline void DAGH_ComposeGridFunctions(void)
00365         { 
00366          for (register int i=0; i<gfnum; i++) 
00367           { if (gflist[i]) gflist[i]->GF_Compose(); }
00368          if (chkpt_restart()) {
00369           for (register int i=0; i<gfnum; i++) 
00370            { if (gflist[i] && gflist[i]->checkpoint()) 
00371              gflist[i]->GF_CheckpointRestart(); }
00372          }
00373         }
00374 
00375    inline int DAGH_GridFunctionTemplate(GridFunctionVoid& gfv)
00376         { return (DAGHTemplateComm + gfv.gfid); }
00377 
00378    /*************************************************************************/
00379    /* Recomposition */
00380    /*************************************************************************/
00381 public:
00393    void DAGH_RecomposeHierarchy(int Partition); 
00394    inline void DAGH_RecomposeHierarchy() { DAGH_RecomposeHierarchy(DAGHTrue); }
00395 
00396 public:
00398    void DAGH_Refine(const int lev);
00403    void DAGH_Refine(BBoxList &bblist, const int lev);
00404 
00405    /*************************************************************************/
00406    /* Redistribution methods */
00407    /*************************************************************************/
00408 public:
00409    inline void DAGH_RedistributeHierarchy(const int type)
00410         { if (distribution) distribution->set_dist(type); DAGH_RecomposeHierarchy(); }
00411    inline void DAGH_RedistributeHierarchy(const int type, BBoxList& bbl)
00412         { if (distribution) distribution->set_dist(type,bbl); DAGH_RecomposeHierarchy(); }
00413 
00414    /*************************************************************************/
00415    /* For Checkpointing.... */
00416    /*************************************************************************/
00417 public:
00419    void DAGH_Checkpoint(const char* name);
00421    void DAGH_Checkpoint(strstream& ofs);
00422    int  DAGH_Checkpoint_StrStream_Memory();
00423    
00424    void DAGH_ComposeHierarchy(const char* name);
00426    void DAGH_RecomposeHierarchy(const char* name);
00428    void DAGH_RecomposeHierarchy(strstream& ifs);
00429 
00430    void DAGH_InitChkpt(const char* name) { 
00431      chkptflag = DAGHTrue; strncpy(chkptname,name,DAGHChkPtTagNameSize); 
00432      chkptname[DAGHChkPtTagNameSize-1] = '\0'; 
00433    }
00434    void DAGH_InitChkpt()
00435      { chkptflag = DAGHTrue; }
00436    void DAGH_StopChkpt()
00437      { chkptflag = DAGHFalse; chkptname[0] = '\0'; chkptpnum = 0; }
00438 
00439    int DAGH_OpenChkptIStream(const int p,
00440                              ifstream& ifs);
00441    void DAGH_CloseChkptIStream(ifstream& ifs)
00442      { ifs.close(); }
00443 
00444    int DAGH_OpenChkptIStream(const int p,
00445                              streampos*& chkptdir, 
00446                              char*& chkptnamedir,
00447                              ifstream& ifs);
00448    int DAGH_OpenChkptStrStream(streampos*& chkptdir, 
00449                                char*& chkptnamedir,
00450                                strstream& ifs);
00451 
00452    void DAGH_CloseChkptIStream(streampos*& chkptdir, 
00453                                char*& chkptnamedir,
00454                                ifstream& ifs)
00455      { if (chkptdir) delete [] chkptdir; 
00456        if (chkptnamedir) delete [] chkptnamedir; 
00457        ifs.close(); }
00458    void DAGH_CloseChkptStrStream(streampos*& chkptdir, 
00459                                  char*& chkptnamedir,
00460                                  strstream& ifs)
00461      { if (chkptdir) delete [] chkptdir; 
00462        if (chkptnamedir) delete [] chkptnamedir; }
00463 
00464    int DAGH_GetGFChkptIStream(const int p, const char* gfname, 
00465                               const int gfid,
00466                               ifstream& ifs);
00467    int DAGH_GetGFChkptStrStream(const char* gfname, 
00468                                 const int gfid,
00469                                 strstream& ifs);
00470 
00471    int DAGH_OpenChkptOStream(const int p,
00472                              ofstream& ofs);
00473    void DAGH_CloseChkptOStream(ofstream& ofs)
00474      { ofs.close(); }
00475 
00476    /*************************************************************************/
00477    /* Communications */
00478    /*************************************************************************/
00479 private:
00480    void DAGH_GlbConcat(void *snddata, int sndsize, void *&rcvdata, 
00481                        int &rcvsize, MPI_Comm Cin=0);
00482    //void DAGH_GlbConcat(void *snddata, const int size, 
00483    //                    void *&rcvdata, MPI_Comm Cin=0);
00484    //void DAGH_PingIONode(const int tag, int flg = DAGHTrue);
00485    void DAGH_PingIONode(const int tag, int flg);
00486 public:
00487    int DAGH_CommInit(MPI_Comm c = 0);
00488    void DAGH_CommKill(void);
00489 
00490     /*************************************************************************/
00491     /* Initialize the overlap flag array */
00492     /*************************************************************************/ 
00493 public:
00494    static void DAGH_InitOverlaps(const int Type, short* olap)
00495    { if (Type == DAGHCellCentered) 
00496        {olap[0] = 0; olap[1] = 0; olap[2] = 0; }
00497      else if (Type == DAGHVertexCentered) 
00498        {olap[0] = 1; olap[1] = 1; olap[2] = 1; } 
00499      else if (Type == DAGHFaceCentered_X) 
00500        {olap[0] = 1; olap[1] = 0; olap[2] = 0; }  
00501      else if (Type == DAGHFaceCentered_Y) 
00502        {olap[0] = 0; olap[1] = 1; olap[2] = 0; }  
00503      else if (Type == DAGHFaceCentered_Z) 
00504        {olap[0] = 0; olap[1] = 0; olap[2] = 1; } }
00505    /*************************************************************************/
00506 
00507    /*************************************************************************/
00508    /* Private query operators */
00509    /*************************************************************************/
00510 private:   
00511    inline int daghoverlapCC_or_NCC() const 
00512      { return ((daghtype==DAGHCellCentered) ? 0 : 1); }
00513 
00514    inline const short* daghoverlap() const 
00515      { return (overlap); }
00516 
00517    inline int daghoverlap(const int dir) const 
00518      { return (overlap[dir]); }
00519    /*************************************************************************/
00520    /* Static Generic public query operators */
00521    /*************************************************************************/
00522 public:
00523    static int daghoverlapCC_or_NCC(const int type) 
00524       { return((type==DAGHCellCentered) ? 0 : 1); }
00525    
00526    /*************************************************************************/
00527    /* Generic public query operators */
00528    /*************************************************************************/
00529 public:
00530    inline int default_alignment(const int r) const 
00531         { return ((r == rank) ? DAGH_All : 
00532                   (r == 3) ? DAGH_All : 
00533                   (r == 2) ? DAGH_XY : DAGH_X); }
00534    /*************************************************************************/
00535    /* GridHierarchy public query operators */
00536    /*************************************************************************/
00537 public:
00538    inline int dagh_type(void) const { return daghtype; }
00539 
00540    inline int boundarywidth(void) const { return bndrywidth; }
00541    inline int boundarytype(void) const { return bndrytype; }
00542    inline int adaptboundarytype(void) const { return adaptbndrytype; }
00543    inline int periodicboundary(const int d) const { return bndryperiodic[d]; }
00544    inline int periodicindex(const int d) const { return periodicidx[d]; }
00545 
00546    inline int externalghostwidth(void) const { return extghostwidth; }
00547 
00548    inline int totallevels(void) const { return levels; }
00549 
00550    inline int coarselevel(void) const { return crslev; }
00551    inline int maxlevel(void) const { return maxlev; }
00552    inline int finelevel(void) const { return finelev; }
00553 
00556    inline int stepsize(const int lev) const { 
00557      int ret=1; for (register int l=Max(0,lev); l<levels-1; l++) ret *= refby[l]; return (ret); 
00558    }
00559    inline int timestep(const int lev) const { 
00560      int ret=1; for (register int l=Max(0,lev); l<levels-1; l++) ret *= refby[l]; return (ret); 
00561    }
00563    inline int stepstaken(const int t, const int l) const
00564      { return (t/timestep(l)); }
00566    inline double delta_t(const int l) const
00567      { return (tspecs.h/refinedby(l)); }
00569    inline double delta_x(const int dim, const int l) const
00570      { return (dspecs[dim].h/refinedby(l)); }
00571 
00573    inline int refinefactor(const int lev) const 
00574      { return (lev>=0 && lev<levels ? refby[lev] : 1); }
00576    inline int refinedby(const int lev) const {
00577      int ret=1; for (register int l=0; l<Min(lev,levels); l++) ret *= refby[l]; return (ret);
00578    }
00580    int refinedby(const int l1, const int l2) const { 
00581      int ret=1;
00582      if (l1>=0 && l2>=0 && l1<levels && l2<levels)
00583        if (l2<l1) 
00584          for (register int l=l2; l<l1; l++) 
00585            ret *= refby[l]; 
00586        else if (l2>l1) {
00587          ret = -1;
00588          for (register int l=l1; l<l2; l++) 
00589            ret *= refby[l]; 
00590        }
00591      return (ret);
00592    }
00593 
00595    inline int buffer() const { return nestbuffer; }
00596 
00604    inline const int& gucfactor() const { return cfactor; }
00606    inline const int& guminwidth() const { return guwidth; }   
00608    inline void setgucfactor(const int& cfac) { 
00609      cfactor = cfac; 
00610      guwidth = (int)(log((double)cfactor)/log((double)2.0));
00611      if (guwidth<log((double)cfactor)/log((double)2.0)) guwidth++;
00612    }
00613 
00614    /*************************************************************************/
00615    /* Set/Query Updated Timestep Info */
00616    /*************************************************************************/
00617    inline int updatedvaluestep() const { return updatedstep; } 
00618    inline void setupdatedvaluestep(const int ustep) { updatedstep = ustep; } 
00619 
00620    /*************************************************************************/
00621    /* Checkpoint info... */
00622    /*************************************************************************/
00623    inline void chkpt_filename(ostrstream& obuf, const char* name, 
00624                               const int p)
00625      { obuf << name << "." << p << ".cp" << ((char)0); }
00626    inline int chkpt_restart(void) const 
00627      { return (chkptflag ==  DAGHTrue); }
00628    inline const char* chkpt_name(void) const 
00629      { return chkptname; }
00630    inline int chkpt_pnum(void) const
00631      { return chkptpnum; }
00632    inline void chkpt_reset(void)
00633      { chkptflag = DAGHFalse; chkptname[0] = '\0'; chkptpnum = 0; }
00634 
00635    /*************************************************************************/
00636    /* Set/Get current time */
00637    /*************************************************************************/
00638 public:
00643    inline int getCurrentTime(const int lev) const 
00644      { return curtime[lev] ; }
00645    inline void setCurrentTime(const int ctime, const int lev) 
00646      { curtime[lev] = ctime; }
00648    inline void incrCurrentTime(const int lev) 
00649      { curtime[lev] += timestep(lev); }
00650 
00652    inline int getPreviousTime(const int lev) const 
00653      { return curtime[lev] - timestep(lev); }
00655    inline int getNextTime(const int lev) const 
00656      { return curtime[lev] + timestep(lev); }
00657 
00658    /*************************************************************************/
00659    /* DAGH structure & coordinate information */
00660    /*************************************************************************/
00661 public:
00662    inline int GlobalLength(int lev) { return (globalgbl[lev] ? globalgbl[lev]->number() : 0); }
00663    inline int GlobalMaxIndex(int lev) { return (globalgbl[lev] ? globalgbl[lev]->maxindex() : 0); }
00664    inline int LocalLength(int lev)  { return (localgbl[lev] ? localgbl[lev]->number() : 0); }
00665 
00666    inline GridUnitList* clist() { return (complist); }
00667    inline GridUnitList* llist() { return (locallist); }
00668 
00670    inline GridBoxList** lgbl() { return (localgbl); }
00672    inline GridBoxList** ggbl() { return (globalgbl); }
00673    inline GridBoxList** oldlgbl() { return (oldlocalgbl); }
00674    inline GridBoxList** oldggbl() { return (oldglobalgbl); }
00675 
00677    inline GridBoxList* lgbl(int lev) { return (localgbl[lev]); }
00679    inline GridBoxList* ggbl(int lev) { return (globalgbl[lev]); }
00680    inline GridBoxList* oldlgbl(int lev) { return (oldlocalgbl[lev]); }
00681    inline GridBoxList* oldggbl(int lev) { return (oldglobalgbl[lev]); }
00682 
00683    /* Integer coords */
00684    void llb(int *lc) const;
00685    void lub(int *lc) const;
00686 
00688    inline Coords llb(void) const { return (basebbox.lower()); }
00689    inline Coords lub(void) const { return (basebbox.upper()); }
00690 
00691    /* World coords */
00692    void wlb(double *wc) const;
00693    void wub(double *wc) const;
00694   
00696    DCoords worldCoords(const int *lc, const int *ls) const;
00697    DCoords worldCoordsUpper(const int *lc, const int *ls) const;
00698    DCoords worldCoordsLower(const int *lc, const int *ls) const;
00699    DCoords worldStep(const int *ls) const;
00700 
00701    void worldCoords(const int *lc, const int *ls, double *wc) const;
00702    void worldStep(const int *ls, double *ws) const;
00703 
00704    /* To integer coords */
00705    Coords localCoords(double const *wc) const;
00706    Coords localStep(double const *ws) const;
00707 
00708    void localCoords(double const *wc, int *lc) const;
00709    void localStep(double const *ws, int *ls) const;
00710 
00711    /*************************************************************************/
00712    /* Bounding box information */
00713    /*************************************************************************/
00714 public:
00716    inline BBox bbbox(void) const { return basebbox; }
00717    inline BBox glbbbox(void) const { return intbbox; }
00719    inline BBox wholebbox(void) const 
00720      { return shrinkupperbydim(intbbox,daghoverlap()); }
00722    inline BBoxList* wholebaselist(void) const { return intbaselist; };
00724    inline const double* wholebndry(void) const { return bndrycoords; }
00725    inline const int& nbndry(void) const { return nbndrycoords; }
00726 
00727    /* Global BBox Lists */
00728    void glb_bboxlist(BBoxList& bbl,
00729                      const int l, 
00730                      const int type=DAGHCellCentered) const;
00731    /*************************************************************************/
00732    /* IO Support */
00733    /*************************************************************************/
00734 public:
00735    void DAGH_IOServe(void);
00736    inline void DAGH_IOType(const int type) { io_type = type; }
00737    void DAGH_IOEnd(void);
00738    friend void DAGHIO_EndIOPingFunction(GridHierarchy &GH);
00739 
00740    /*************************************************************************/
00741    /* Ghost Communications */
00742    /*************************************************************************/
00743 public:
00744    inline void DAGH_SyncGhostRegions(const int t, const int l)
00745      { 
00746       register int i;
00747       for (i=0; i<gfnum; i++)
00748         if (gflist[i] && gflist[i]->comm()) 
00749           gflist[i]->GF_WriteGhosts(t,l);
00750       for (i=0; i<gfnum; i++)
00751         if (gflist[i] && gflist[i]->comm()) 
00752           gflist[i]->GF_ReadGhosts(t,l);
00753      }
00754 
00755    inline void DAGH_SyncGhostRegions(const int t, const int l, 
00756                                      const int axis, const int dir)
00757      { 
00758       register int i;
00759       for (i=0; i<gfnum; i++) 
00760         if (gflist[i] && gflist[i]->comm()) 
00761           gflist[i]->GF_WriteGhosts(t,l,axis,dir);
00762       for (i=0; i<gfnum; i++) 
00763         if (gflist[i] && gflist[i]->comm()) 
00764           gflist[i]->GF_ReadGhosts(t,l,axis,dir);
00765      }
00766   };
00767 
00768 ostream&  operator << (ostream& , const GridHierarchy&);
00769 ostream&  operator << (ostream& , const struct dimspecs&);
00770 ostream&  operator << (ostream& , const struct MergedGridUnit&);
00771 
00772 ofstream& operator << (ofstream& , const GridHierarchy&);
00773 ifstream& operator >> (ifstream& , GridHierarchy&);
00774 strstream& operator << (strstream& , const GridHierarchy&);
00775 strstream& operator >> (strstream& , GridHierarchy&);
00776 
00777 
00778 #endif


Quickstart     Users Guide     Programmers Reference     Installation      Examples     Download



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