00001
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
00048 friend class GridHierarchy;
00049
00050 protected:
00051
00052 short gfid;
00053 short gftype;
00054 short gfrank;
00055 char *gfname;
00056
00057 short overlap[DAGHMaxRank];
00058
00059
00060 int loffset;
00061
00062
00063 int cfactor;
00064
00065
00066 short alignment;
00067
00068
00069 short bwidth;
00070
00071
00072 short extghostwidth;
00073
00074
00075 short comm_flag;
00076 short bndry_flag;
00077 short adaptbndry_flag;
00078 short extghost_flag;
00079 short compose_flag;
00080 short template_flag;
00081
00082
00083 short init_flag;
00084 short update_flag;
00085 short prolong_flag;
00086 short restrict_flag;
00087 short bndry_update_flag;
00088 short adaptbndry_update_flag;
00089 short io_flag;
00090 short chkpt_flag;
00091
00092
00093 int lmax_recompose;
00094
00095
00096 short time_sten_rad;
00097 short* space_sten_rad;
00098
00099
00100 short *time_alias;
00101
00102
00103 double* phys_time;
00104
00105
00106 GhostInteraction interactions;
00107
00108
00109 GF_Interaction*** ghost_send_info;
00110 short* ghost_recv_cnt;
00111 GF_Interaction*** ghost_recv_info;
00112 GridTableGhostRcv*** ghost_recv_server;
00113
00114
00115 GridTableDataRcv*** data_recv_server;
00116
00117
00118 BBoxList** bndrybboxlist;
00119 BBoxList** prolongbboxlist;
00120
00121
00122 GridBoxList *cggbl, *plgbl, *clgbl;
00123
00124 int updatedstep;
00125
00126
00127 GridTable *gt;
00128
00129
00130 GridHierarchy &dagh;
00131
00132
00133 DAGHGFVFlagType userflags[DAGHGFVFlagNum];
00134
00135
00136
00137 unsigned *rcvsize;
00138
00139 unsigned* sndsize;
00140 BBox* sndbbox;
00141 short* sndindex;
00142 short* rcvindex;
00143 short* sndlevel;
00144 short* sndcnt;
00145
00146 public:
00147
00148
00149
00150 GridFunctionVoid(const int type,
00151 const int rank,
00152 const char name[],
00153 GridHierarchy &gh,
00154 const int loff,
00155 const int cfac,
00156 const int align,
00157 const int bndrywidth,
00158 const int extghwidth,
00159 const int cflag,
00160 const int bflag,
00161 const int adptbflag,
00162 const int extghflag);
00163
00164 GridFunctionVoid(const int type,
00165 const int rank,
00166 const char name[],
00167 const int tsten,
00168 const int ssten,
00169 GridHierarchy &gh,
00170 const int loff,
00171 const int cfac,
00172 const int align,
00173 const int bndrywidth,
00174 const int extghwidth,
00175 const int cflag,
00176 const int bflag,
00177 const int adptbflag,
00178 const int extghflag);
00179
00180 GridFunctionVoid(const int type,
00181 const int rank,
00182 const char name[],
00183 const int tsten,
00184 const int *ssten,
00185 GridHierarchy &gh,
00186 const int loff,
00187 const int cfac,
00188 const int align,
00189 const int bndrywidth,
00190 const int extghwidth,
00191 const int cflag,
00192 const int bflag,
00193 const int adptbflag,
00194 const int extghflag);
00195
00196 GridFunctionVoid(const char name[],
00197 const int rank,
00198 const GridFunctionVoid& gfv,
00199 const int cflag,
00200 const int bflag,
00201 const int adptbflag,
00202 const int extghflag);
00203
00204
00205
00206 virtual ~GridFunctionVoid();
00207
00208 public:
00209
00210
00211
00212 void GF_SetGridFunctionType(const int gft);
00213
00214
00215
00216
00217 inline void GF_SetCommType(const int cflag)
00218 { comm_flag = cflag; }
00219 inline void GF_SetBoundaryType(const int bflag)
00220 { bndry_flag = bflag; }
00221 inline void GF_SetAdaptBoundaryType(const int adptbflag)
00222 { adaptbndry_flag = adptbflag; }
00223 inline void GF_SetExternalGhostFlag(const int egflag)
00224 { extghost_flag = egflag; }
00225
00226
00227
00228
00229 inline void GF_SetInitializeFlag(const int flag)
00230 { init_flag = flag; }
00231 inline void GF_SetUpdateFlag(const int flag)
00232 { update_flag = flag; }
00233 inline void GF_SetProlongFlag(const int flag)
00234 { prolong_flag = flag; }
00235 inline void GF_SetRestrictFlag(const int flag)
00236 { restrict_flag = flag; }
00237 inline void GF_SetBndryUpdateFlag(const int flag)
00238 { bndry_update_flag = flag; }
00239 inline void GF_SetAdaptBndryUpdateFlag(const int flag)
00240 { adaptbndry_update_flag = flag; }
00241 inline void GF_SetIOFlag(const int flag)
00242 { io_flag = flag; }
00243 inline void GF_SetCheckpointFlag(const int flag)
00244 { chkpt_flag = flag; }
00245
00246 inline int initialize()
00247 { return init_flag == DAGHTrue; }
00248 inline int update()
00249 { return update_flag == DAGHTrue; }
00250 inline int prolong()
00251 { return prolong_flag == DAGHTrue; }
00252 inline int Restrict()
00253 { return restrict_flag == DAGHTrue; }
00254 inline int bndry_update()
00255 { return bndry_update_flag == DAGHTrue; }
00256 inline int adaptbndry_update()
00257 { return adaptbndry_update_flag == DAGHTrue; }
00258 inline int io()
00259 { return io_flag == DAGHTrue; }
00260 inline int checkpoint()
00261 { return chkpt_flag == DAGHTrue; }
00262
00263
00264
00265
00266 inline void GF_BoundaryWidth(const int width) { bwidth = width; }
00267
00268
00269
00270
00271 inline void GF_ExternalGhostWidth(const int width)
00272 { extghostwidth = width; }
00273
00274
00275
00276
00277 void GF_SetSpaceStencil(const int s_sten);
00278 void GF_SetSpaceStencil(const int* s_sten);
00279
00280
00281
00282
00283
00284 void GF_SetTimeStencil(const int t_sten);
00285
00286
00287
00288
00289 inline void GF_SetAlignment(const int align) { alignment = align; }
00290
00291
00292
00293
00294 inline void GF_SetTimeAlias(const int t, const int alias_to)
00295 { GF_DeleteGDBStorage(t + time_sten_rad);
00296 time_alias[t+time_sten_rad] = (alias_to+time_sten_rad); }
00297
00298
00299
00300
00301 inline void GF_SetMaxRecomposeLevel(const int l) { lmax_recompose = l; }
00302
00303
00304
00305
00306 inline int GF_Id() const { return (gfid); }
00307 inline int GF_Type() const { return (gftype); }
00308 inline char const *GF_Name() const { return gfname; }
00309
00310 inline char *GF_Name() { return gfname; }
00311 inline int GF_Rank() const { return gfrank; }
00312 inline void GF_SetName(char* newname) { gfname = newname; }
00313
00314 inline int factor() const { return (cfactor); }
00315 inline int GF_Alignment() const { return alignment; }
00316
00317 inline int comm() const
00318 { return (comm_flag != DAGHNoComm); }
00319 inline int externalboundary() const
00320 { return (bndry_flag != DAGHNoBoundary); }
00321 inline int adaptiveboundary() const
00322 { return (adaptbndry_flag != DAGHNoAdaptBoundary); }
00323
00324 inline int externalghost() const
00325 { return (extghost_flag != DAGHTrue); }
00326
00327 inline int composed() const
00328 { return (compose_flag == DAGHTrue); }
00329
00330 inline int comm_type() const
00331 { return (comm_flag); }
00332 inline int boundary_type() const
00333 { return (bndry_flag); }
00334 inline int adaptiveboundary_type() const
00335 { return (adaptbndry_flag); }
00336
00337 inline int boundary_width() const
00338 { return (bwidth); }
00339 inline int externalghost_width() const
00340 { return (extghostwidth); }
00341
00342 inline GridBoxList* current_ggbl() const { return (cggbl); }
00343 inline void set_current_ggbl(GridBoxList* gbl) { cggbl=gbl; }
00344 inline GridBoxList* parent_lgbl() const { return (plgbl); }
00345 inline void set_parent_lgbl(GridBoxList* gbl) { plgbl=gbl; }
00346 inline GridBoxList* children_lgbl() const { return (clgbl); }
00347 inline void set_children_lgbl(GridBoxList* gbl) { clgbl=gbl; }
00348
00349
00350 BBox usedbbox(const BBox& gb, const int& level, const int& align);
00352 BBox usedbbox(const GridBox& gb, const int& level, const int& align)
00353 { return (usedbbox(gb.gbBBox(), level, align)); }
00354
00355
00356
00357
00358
00359 inline int updatedvaluestep() const { return updatedstep; }
00360 inline void setupdatedvaluestep(const int ustep) { updatedstep = ustep; }
00361
00362
00363
00364
00365 inline void GF_SetUserFlag(const int id, const DAGHGFVFlagType& f)
00366 { assert (id < DAGHGFVFlagNum); userflags[id] = f; }
00367
00368 inline DAGHGFVFlagType GF_GetUserFlag(const int id)
00369 { assert (id < DAGHGFVFlagNum); return (userflags[id]); }
00370
00371
00372
00373
00374 void GF_FreeTmpStorage();
00375
00376
00377
00378
00379 virtual void GF_DeleteGDBStorage(const int t);
00380
00381
00382
00383
00384 virtual void GF_Sync(const int time, const int level)
00385 { std::cerr << "Dummy GF_Sync(time, level) function\n"; }
00386
00387 virtual void GF_Sync(const int time, const int level,
00388 const int axis, const int dir)
00389 { std::cerr << "Dummy GF_Sync(time, level, axis, dir) function\n"; }
00390
00391 virtual void GF_WriteGhosts(const int time, const int level)
00392 { std::cerr << "Dummy GF_WriteGhosts(time, level) function\n"; }
00393
00394 virtual void GF_WriteGhosts(const int time, const int level,
00395 const int axis, const int dir)
00396 { std::cerr << "Dummy GF_WriteGhosts(time, level, axis, dir) function\n"; }
00397
00398 virtual void GF_ReadGhosts(const int time, const int level)
00399 { std::cerr << "Dummy GF_ReadGhosts(time, level) function\n"; }
00400
00401 virtual void GF_ReadGhosts(const int time, const int level,
00402 const int axis, const int dir)
00403 { std::cerr << "Dummy GF_ReadGhosts(time, level, axis, dir) function\n"; }
00404
00405 virtual void GF_Compose();
00406 virtual void GF_Recompose(int* reuse_possible, GridBoxList** ollist,
00407 GridBoxList** rlist, GridBoxList** slist,
00408 GridBoxList** olist);
00409
00410 virtual void GF_CheckpointRecompose();
00411 virtual void GF_CheckpointRecompose(std::stringstream& ifs);
00412 virtual void GF_Checkpoint(std::ofstream& ofs);
00413 virtual void GF_Checkpoint(std::stringstream& ofs);
00414 virtual int GF_Checkpoint_StrStream_Memory();
00415 virtual void GF_CheckpointRestart(int proc=-1);
00416 virtual void GF_CheckpointRestart(std::stringstream& ifs);
00417
00418 private:
00419
00420 GridFunctionVoid(GridFunctionVoid const &other);
00421 GridFunctionVoid const &operator= (GridFunctionVoid const &other);
00422 };
00423
00424 std::ostream& operator<<(std::ostream& os, const GridFunctionVoid& gfv);
00425 std::ofstream& operator<<(std::ofstream& ofs, const GridFunctionVoid& gfv);
00426 std::ifstream& operator>>(std::ifstream& ifs, GridFunctionVoid& gfv);
00427 std::stringstream& operator<<(std::stringstream& ofs,
00428 const GridFunctionVoid& gfv);
00429 std::stringstream& operator>>(std::stringstream& ifs,
00430 GridFunctionVoid& gfv);
00431
00432 #endif