00001
00002
00003 #ifndef _included_GridDataBlock_h
00004 #define _included_GridDataBlock_h
00005
00011 #include "DAGHParams.h"
00012
00013 #include "Coords.h"
00014 #include "BBox.h"
00015
00016 #include "GridBox.h"
00017 #include "GridBoxList.h"
00018 #include "PackedGridDataBucket.h"
00019 #include "GridTable.h"
00020 #include "GridHierarchy.h"
00021
00022 #include "CommServer.h"
00023
00024 #include "GDBInteraction.h"
00025
00026
00027 void gdbSetRanks(const int rank, const int align, short* ranks);
00028 void gdbAlignBBox(const int, class BBox&, const int);
00029
00030 #include "GridFunctionVoid.h"
00031
00032 #include "GridData1.h"
00033 #include "GridData2.h"
00034 #include "GridData3.h"
00035
00036 #include <iosfwd>
00037
00038 template <class Type, int dim> class GridFunction;
00039 template <class Type, int dim> class GridDataBlock;
00040 template <class Type, int dim> std::ostream& operator<<(std::ostream&, const GridDataBlock<Type,dim>&);
00041 template <class Type, int dim> std::ofstream& operator<<(std::ofstream&, const GridDataBlock<Type,dim>&);
00042 template <class Type, int dim> std::ifstream& operator>>(std::ifstream&, GridDataBlock<Type,dim>&);
00043 template <class Type, int dim> std::stringstream& operator<<(std::stringstream&,
00044 const GridDataBlock<Type,dim>&);
00045 template <class Type, int dim> std::stringstream& operator>>(std::stringstream&,
00046 GridDataBlock<Type,dim>&);
00047
00055 template <class Type, int dim>
00056 class GridDataBlock {
00057 friend class GridFunction<Type,dim>;
00058
00059 const int gfid;
00060
00061
00062
00063
00064 public:
00066 short timenum;
00067 short levelnum;
00068
00069
00070 private:
00071 short myindex;
00073 short* sten_rad;
00074
00075
00076
00077
00078 short ranks[dim];
00079 BBox merged_bbox;
00080 BBox interior_bbox;
00081
00082
00089 BBox prolongbbox[2*dim];
00090 short prolongflag[2*dim];
00091
00095 BBoxList* bndrybboxlist[2*dim];
00096 int bndryindex[2*dim];
00097
00099 int reuse;
00100
00102 GridData<Type,dim> data;
00103
00104
00105
00106
00107
00108
00109 GDB_Interaction* gdb_parent_info;
00110 int gdb_parent_index;
00111 GDB_Interaction* gdb_child_info;
00112 int gdb_child_index;
00113
00114
00115
00116
00117 short comm_flag;
00118 int maxindex;
00119 GDB_Interaction*** gdb_write_info;
00120 int** gdb_write_index;
00121 GDB_Interaction*** gdb_read_info;
00122 int** gdb_read_index;
00123 GridTableGhostRcv *gdb_data_rcv;
00124
00125
00126
00128 GridTable >able;
00129
00130
00131
00133 GridHierarchy &dagh;
00134
00135
00136 private:
00137
00138
00139
00140 GridDataBlock(const GridDataBlock<Type,dim>& other);
00141 GridDataBlock<Type,dim> const &operator=(const GridDataBlock<Type,dim>& other);
00142
00143 private:
00144
00145
00146
00147 GridDataBlock(GridFunctionVoid& gf,
00148 GridHierarchy& gh,
00149 GridTable& gt,
00150 const GhostInteraction& gi,
00151 const int midx,
00152 const GridBox& gb,
00153 const int time,
00154 const int level,
00155 const int bwidth,
00156 BBoxList* bndrybbl,
00157 BBoxList* prolongbbl,
00158 const int extghwidth,
00159 const short* olap,
00160 const short *sten,
00161 const int align,
00162 const int mindex,
00163 const int cflag,
00164 const GridDataBlock<Type,dim>* gdbtmpl);
00165
00166
00167
00168
00169 ~GridDataBlock();
00170
00171
00172
00173
00174 void intersectgbl(GridFunctionVoid& gf,
00175 GridBoxList& gbl,
00176 const BBox& bbtest,
00177 const int& level,
00178 GridBoxList& resgbl,
00179 const short* olap,
00180 const short* sten,
00181 const int& align,
00182 GridBoxList** workgbl,
00183 const BBox* bballow = 0);
00184
00185 void gdbSetUpLevelInteractionInfo(GridFunctionVoid& gf,
00186 GridHierarchy& gh,
00187 const short* olap,
00188 const int& align);
00189
00190 void gdbSetUpBoundaries(const int& bwidth,
00191 BBoxList* bndrybbl,
00192 BBoxList* prolongbbl,
00193 const short* olap);
00194
00195 void gdbSetUpGhostInteractionInfo(GridFunctionVoid& gf,
00196 const BBox& di_bbox,
00197 const BBox& dm_bbox,
00198 const GhostInteraction& gi,
00199 const short* olap,
00200 const short* dsten_rad,
00201 const int align);
00202
00203 void gdbAddLevelInteractionInfo(GridFunctionVoid& gf,
00204 GridBoxList& lgbl,
00205 const int& level,
00206 GDB_Interaction*& gdb_il_info,
00207 int& mindex,
00208 const short* olap,
00209 const int& align);
00210 void gdbAddGhostInteractionInfo(const int axis, const int dir,
00211 const BBox& rb, const BBox& wb,
00212 const BBox& hisbb,
00213 const int owner, const int idx,
00214 BBox*** setup_write_info,
00215 BBox*** setup_read_info);
00216
00217
00218
00219
00220 void gdbSetUpMain(const int extghwidth);
00221
00222
00223
00224
00225 public:
00226 inline int has_parents() const { return (gdb_parent_index>0); }
00227 inline const int& parents() const { return (gdb_parent_index); }
00228 inline const GDB_Interaction* parentlist() const { return (gdb_parent_info); }
00229 inline GDB_Interaction* parentlist() { return (gdb_parent_info); }
00230 inline const BBox& parentbox(const int& j) { return (gdb_parent_info[j].bbox); }
00231 inline const int& parentidx(const int& j) { return (gdb_parent_info[j].idx); }
00232
00233 inline int has_children() const { return (gdb_child_index>0); }
00234 inline const int& children() const { return (gdb_child_index); }
00235 inline const GDB_Interaction* childlist() const { return (gdb_child_info); }
00236 inline GDB_Interaction* childlist() { return (gdb_child_info); }
00237 inline const BBox& childbox(const int& j) { return (gdb_child_info[j].bbox); }
00238 inline const int& childidx(const int& j) { return (gdb_child_info[j].idx); }
00239
00240
00241
00242
00243 private:
00244 int gdbWriteGhosts(const int proc,
00245 const int time_value,
00246 const int axis,
00247 const int dir,
00248 GridDataBucket<Type>& gdb,
00249 const int at);
00250
00251 public:
00252 inline GDB_Interaction** gdbReadInfo(const int proc)
00253 { return ( (gdb_read_info[proc]) ? gdb_read_info[proc] : 0 ); }
00254 inline GDB_Interaction** gdbWriteInfo(const int proc)
00255 { return ( (gdb_write_info[proc]) ? gdb_write_info[proc] : 0 ); }
00256
00257
00258
00259
00260
00261 private:
00262 void gdbWriteData(const int time_value, GridDataBucket<Type>& gdb, const int at);
00263 void gdbWriteData(const int time_value, const BBox& where,
00264 GridDataBucket<Type>& gdb, const int at);
00265
00266
00267
00268
00269
00270 public:
00271 inline const BBox& boundingbox() const { return (merged_bbox); }
00272 inline const BBox& interiorbox() const { return (interior_bbox); }
00273 inline const BBox& databox() const { return (griddata().bbox()); }
00274
00275 inline int has_externalboundaries() const {
00276 for (register int r=0; r<2*dim; r++)
00277 if (bndryindex[r]>0) return 1;
00278 return 0;
00279 }
00280 inline int has_externalboundary(const int dir) const { return (bndryindex[dir]>0); }
00281 inline const int& externalboundaries(const int dir) const { return (bndryindex[dir]); }
00282 inline int externalboundaries(const int dir) { return (bndryindex[dir]); }
00283 inline const BBoxList* externalbndrylist(const int dir) const { return (bndrybboxlist[dir]); }
00284 inline BBoxList* externalbndrylist(const int dir) { return (bndrybboxlist[dir]); }
00285
00286 inline int has_adaptiveboundaries() const {
00287 for (register int r=0; r<2*dim; r++)
00288 if (prolongflag[r]==DAGHTrue) return 1;
00289 return 0;
00290 }
00291 inline int has_adaptiveboundary(const int dir) const { return (prolongflag[dir]==DAGHTrue); }
00292 inline const BBox& adaptivebndrybox(const int dir) const { return (prolongbbox[dir]); }
00293
00294 void gdbPrintData(std::ostream& os) const;
00295 int MemoryUsage();
00296
00297
00298
00299
00300
00301 public:
00302 GridData<Type,dim> &griddata() { return (data); }
00303 const GridData<Type,dim> &griddata() const { return (data); }
00304
00305
00306 friend std::ostream& operator<< <>(std::ostream&,
00307 const GridDataBlock<Type,dim>&);
00308 friend std::ofstream& operator<< <>(std::ofstream&,
00309 const GridDataBlock<Type,dim>&);
00310 friend std::ifstream& operator>> <>(std::ifstream&,
00311 GridDataBlock<Type,dim>&);
00312 friend std::stringstream& operator<< <>(std::stringstream&,
00313 const GridDataBlock<Type,dim>&);
00314 friend std::stringstream& operator>> <>(std::stringstream&,
00315 GridDataBlock<Type,dim>&);
00316
00317 };
00318
00319 #include "GridDataBlock.ipp"
00320
00321 #endif
00322