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
00183 void gdbSetUpLevelInteractionInfo(GridFunctionVoid& gf,
00184 GridHierarchy& gh,
00185 const short* olap,
00186 const int& align);
00187
00188 void gdbSetUpBoundaries(const int& bwidth,
00189 BBoxList* bndrybbl,
00190 BBoxList* prolongbbl,
00191 const short* olap);
00192
00193 void gdbSetUpGhostInteractionInfo(GridFunctionVoid& gf,
00194 const BBox& di_bbox,
00195 const BBox& dm_bbox,
00196 const GhostInteraction& gi,
00197 const short* olap,
00198 const short* dsten_rad,
00199 const int align);
00200
00201 void gdbAddLevelInteractionInfo(GridFunctionVoid& gf,
00202 GridBoxList& lgbl,
00203 const int& level,
00204 GDB_Interaction*& gdb_il_info,
00205 int& mindex,
00206 const short* olap,
00207 const int& align);
00208 void gdbAddGhostInteractionInfo(const int axis, const int dir,
00209 const BBox& rb, const BBox& wb,
00210 const BBox& hisbb,
00211 const int owner, const int idx,
00212 BBox*** setup_write_info,
00213 BBox*** setup_read_info);
00214
00215
00216
00217
00218 void gdbSetUpMain(const int extghwidth);
00219
00220
00221
00222
00223 public:
00224 inline int has_parents() const { return (gdb_parent_index>0); }
00225 inline const int& parents() const { return (gdb_parent_index); }
00226 inline const GDB_Interaction* parentlist() const { return (gdb_parent_info); }
00227 inline GDB_Interaction* parentlist() { return (gdb_parent_info); }
00228 inline const BBox& parentbox(const int& j) { return (gdb_parent_info[j].bbox); }
00229 inline const int& parentidx(const int& j) { return (gdb_parent_info[j].idx); }
00230
00231 inline int has_children() const { return (gdb_child_index>0); }
00232 inline const int& children() const { return (gdb_child_index); }
00233 inline const GDB_Interaction* childlist() const { return (gdb_child_info); }
00234 inline GDB_Interaction* childlist() { return (gdb_child_info); }
00235 inline const BBox& childbox(const int& j) { return (gdb_child_info[j].bbox); }
00236 inline const int& childidx(const int& j) { return (gdb_child_info[j].idx); }
00237
00238
00239
00240
00241 private:
00242 int gdbWriteGhosts(const int proc,
00243 const int time_value,
00244 const int axis,
00245 const int dir,
00246 GridDataBucket<Type>& gdb,
00247 const int at);
00248
00249 public:
00250 inline GDB_Interaction** gdbReadInfo(const int proc)
00251 { return ( (gdb_read_info[proc]) ? gdb_read_info[proc] : 0 ); }
00252 inline GDB_Interaction** gdbWriteInfo(const int proc)
00253 { return ( (gdb_write_info[proc]) ? gdb_write_info[proc] : 0 ); }
00254
00255
00256
00257
00258
00259 private:
00260 void gdbWriteData(const int time_value, GridDataBucket<Type>& gdb, const int at);
00261 void gdbWriteData(const int time_value, const BBox& where,
00262 GridDataBucket<Type>& gdb, const int at);
00263
00264
00265
00266
00267
00268 public:
00269 inline const BBox& boundingbox() const { return (merged_bbox); }
00270 inline const BBox& interiorbox() const { return (interior_bbox); }
00271 inline const BBox& databox() const { return (griddata().bbox()); }
00272
00273 inline int has_externalboundaries() const {
00274 for (register int r=0; r<2*dim; r++)
00275 if (bndryindex[r]>0) return 1;
00276 return 0;
00277 }
00278 inline int has_externalboundary(const int dir) const { return (bndryindex[dir]>0); }
00279 inline const int& externalboundaries(const int dir) const { return (bndryindex[dir]); }
00280 inline int externalboundaries(const int dir) { return (bndryindex[dir]); }
00281 inline const BBoxList* externalbndrylist(const int dir) const { return (bndrybboxlist[dir]); }
00282 inline BBoxList* externalbndrylist(const int dir) { return (bndrybboxlist[dir]); }
00283
00284 inline int has_adaptiveboundaries() const {
00285 for (register int r=0; r<2*dim; r++)
00286 if (prolongflag[r]==DAGHTrue) return 1;
00287 return 0;
00288 }
00289 inline int has_adaptiveboundary(const int dir) const { return (prolongflag[dir]==DAGHTrue); }
00290 inline const BBox& adaptivebndrybox(const int dir) const { return (prolongbbox[dir]); }
00291
00292 void gdbPrintData(std::ostream& os) const;
00293 int MemoryUsage();
00294
00295
00296
00297
00298
00299 public:
00300 GridData<Type,dim> &griddata() { return (data); }
00301 const GridData<Type,dim> &griddata() const { return (data); }
00302
00303
00304 friend std::ostream& operator<< <>(std::ostream&,
00305 const GridDataBlock<Type,dim>&);
00306 friend std::ofstream& operator<< <>(std::ofstream&,
00307 const GridDataBlock<Type,dim>&);
00308 friend std::ifstream& operator>> <>(std::ifstream&,
00309 GridDataBlock<Type,dim>&);
00310 friend std::stringstream& operator<< <>(std::stringstream&,
00311 const GridDataBlock<Type,dim>&);
00312 friend std::stringstream& operator>> <>(std::stringstream&,
00313 GridDataBlock<Type,dim>&);
00314
00315 };
00316
00317 #include "GridDataBlock.ipp"
00318
00319 #endif
00320