Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 #ifndef _included_PackedGridDataBucket_h 00002 #define _included_PackedGridDataBucket_h 00003 00009 #include "DAGHParams.h" 00010 #include "DAGHDefaults.h" 00011 00012 #include "DAGHSfc.h" 00013 #include "BBox.h" 00014 00015 #include "PackedDataBucketVoid.h" 00016 #include "ObjectCounter.h" 00017 00018 /* Bucket/Message Types */ 00019 #define DAGHSingle (1) 00020 #define DAGHPacked (2) 00021 00022 #ifndef DAGHBktGFNameWidth 00023 #define DAGHBktGFNameWidth (32) 00024 #endif 00025 00030 struct gdhdr 00031 { 00032 friend ostream& operator << (ostream& os, const struct gdhdr& hdr); 00033 00035 short int type; 00037 short int owner; 00039 short unsigned gfid; 00041 short gfdatatype; 00043 short gfstaggertype; 00045 char gfname[DAGHBktGFNameWidth]; 00047 BBox bbox; 00049 short int time; 00051 int time_value; 00053 char physical_time[sizeof(double)]; 00055 short int level; 00057 short int index; 00058 00059 inline gdhdr() {}; 00060 gdhdr(struct gdhdr& other); 00061 00062 gdhdr(const BBox& bb, 00063 const unsigned gf, const int gft, const int gfs, const char* gfn, 00064 const int t, const int tv, const int l, const int index, 00065 const int who, const int type); 00066 00067 static unsigned gdbsize(const unsigned dsize); 00068 }; 00069 00070 #define GridDataBucketVoidNULL ((GridDataBucketVoid *)NULL) 00071 00082 class GridDataBucketVoid : public DataBucketVoid, public ObjectCounter 00083 { 00084 int bkttype; 00085 00086 private: 00087 GridDataBucketVoid(const GridDataBucketVoid&); 00088 void operator = (const GridDataBucketVoid&); 00089 00090 public: 00091 inline GridDataBucketVoid* alias() 00092 { return((GridDataBucketVoid *) ObjectCounter::alias()); } 00093 00094 GridDataBucketVoid(const BBox& bb, const unsigned gf, 00095 const int time, const int time_value, const int level, const int index, 00096 const int who, const unsigned datasize, const int type); 00097 00098 GridDataBucketVoid(const BBox& bb, const unsigned gf, const int gfdtype, 00099 const int gfstype, const char* gfname, const int time, 00100 const int time_value, const int level, const int index, 00101 const int who, const unsigned datasize, const int type); 00102 00103 inline GridDataBucketVoid(const int n, unsigned* dsizes, const int type) 00104 : DataBucketVoid(sizeof(struct gdhdr), dsizes, n), bkttype(type) {} 00105 00106 void add(const BBox& bb, const unsigned gf, const int time, const int time_value, 00107 const int level, const int index, const int who, const int n); 00108 00109 void add(const BBox& bb, const unsigned gf, const int gfdtype, const int gfstype, 00110 const char* gfname, const int time, const int time_value, const int level, 00111 const int index, const int who, const int n); 00112 00113 inline GridDataBucketVoid(const void* package) 00114 :DataBucketVoid((const union drecord *) package) 00115 { bkttype = ((struct gdhdr *) DataBucketVoid::head())->type; } 00116 00117 inline GridDataBucketVoid(void* package) 00118 :DataBucketVoid((union drecord *) package) 00119 { bkttype = ((struct gdhdr *) DataBucketVoid::head())->type; } 00120 00121 inline GridDataBucketVoid(const void* package, const int n) 00122 :DataBucketVoid((const union drecord *) package, n) 00123 { bkttype = ((struct gdhdr *) DataBucketVoid::head())->type = DAGHSingle; } 00124 00125 GridDataBucketVoid(const struct gdhdr& other, const unsigned datasize); 00126 00127 inline int type() const { return (bkttype); } 00128 00129 inline struct gdhdr *head() 00130 { return ( (struct gdhdr *) DataBucketVoid::head() ); } 00131 inline struct gdhdr *head(const int i) 00132 { return ( (struct gdhdr *) DataBucketVoid::head(i) ); } 00133 00134 inline BBox const &bbox() const 00135 { return (((struct gdhdr *) DataBucketVoid::head())->bbox); } 00136 inline BBox const &bbox(const int i) const 00137 { return (((struct gdhdr *) DataBucketVoid::head(i))->bbox); } 00138 00139 inline short int owner() const 00140 { return (((struct gdhdr *) DataBucketVoid::head())->owner); } 00141 inline short int owner(const int i) const 00142 { return (((struct gdhdr *) DataBucketVoid::head(i))->owner); } 00143 00144 inline short int time() const 00145 { return ( ((struct gdhdr *) DataBucketVoid::head())->time); } 00146 inline short int time(const int i) const 00147 { return ( ((struct gdhdr *) DataBucketVoid::head(i))->time); } 00148 00149 inline short int time_value() const 00150 { return ( ((struct gdhdr *) DataBucketVoid::head())->time_value); } 00151 inline short int time_value(const int i) const 00152 { return ( ((struct gdhdr *) DataBucketVoid::head(i))->time_value); } 00153 00154 inline short int level() const 00155 { return ( ((struct gdhdr *) DataBucketVoid::head())->level); } 00156 inline short int level(const int i) const 00157 { return ( ((struct gdhdr *) DataBucketVoid::head(i))->level); } 00158 00159 inline short int index() const 00160 { return ( ((struct gdhdr *) DataBucketVoid::head())->index); } 00161 inline short int index(const int i) const 00162 { return ( ((struct gdhdr *) DataBucketVoid::head(i))->index); } 00163 00164 inline short unsigned gfid() const 00165 { return ( ((struct gdhdr *) DataBucketVoid::head())->gfid); } 00166 inline short unsigned gfid(const int i) const 00167 { return ( ((struct gdhdr *) DataBucketVoid::head(i))->gfid); } 00168 00169 inline short gfdatatype() const 00170 { return ( ((struct gdhdr *) DataBucketVoid::head())->gfdatatype); } 00171 inline short gfdatatype(const int i) const 00172 { return ( ((struct gdhdr *) DataBucketVoid::head(i))->gfdatatype); } 00173 00174 inline short gfstaggertype() const 00175 { return ( ((struct gdhdr *) DataBucketVoid::head())->gfstaggertype); } 00176 inline short gfstaggertype(const int i) const 00177 { return ( ((struct gdhdr *) DataBucketVoid::head(i))->gfstaggertype); } 00178 00179 inline char *gfname() const 00180 { return ( ((struct gdhdr *) DataBucketVoid::head())->gfname); } 00181 inline char *gfname(const int i) const 00182 { return ( ((struct gdhdr *) DataBucketVoid::head(i))->gfname); } 00183 00184 inline void setgfname(const char *name) const 00185 { strncpy(((struct gdhdr *)DataBucketVoid::head())->gfname, 00186 name,DAGHBktGFNameWidth-1); } 00187 inline void setgfname(const char *name, const int i) const 00188 { strncpy(((struct gdhdr *)DataBucketVoid::head(i))->gfname, 00189 name,DAGHBktGFNameWidth-1); } 00190 }; 00191 00200 template <class Type> 00201 class GridDataBucket: public GridDataBucketVoid 00202 { 00203 private: 00204 GridDataBucket(const GridDataBucket<Type>&); 00205 void operator = (const GridDataBucket<Type>&); 00206 00207 public: 00208 inline GridDataBucket(const BBox& bb, const unsigned gf, 00209 const int time, const int time_value, const int level, const int index, const int who, 00210 const int type=DAGHSingle) 00211 : GridDataBucketVoid(bb, gf, time, time_value, level, index, who, 00212 sizeof(Type), type) {} 00213 00214 inline GridDataBucket(const BBox& bb, const unsigned gf, 00215 const int gfdtype, const int gfstype, const char* gfname, 00216 const int time, const int time_value, const int level, const int index, const int who, 00217 const int type=DAGHSingle) 00218 : GridDataBucketVoid(bb, gf, gfdtype, gfstype, gfname, time, time_value, 00219 level, index, who, sizeof(Type), type) {} 00220 00221 inline GridDataBucket(const void* package) 00222 : GridDataBucketVoid(package) {} 00223 00224 inline GridDataBucket(void* package) 00225 : GridDataBucketVoid(package) {} 00226 00227 inline GridDataBucket(const void* package, const int n) 00228 : GridDataBucketVoid(package, n) {} 00229 00230 inline GridDataBucket(const int n, unsigned* dsizes, 00231 const int type) //=DAGHSingle) 00232 : GridDataBucketVoid(n, dsizes, type) {} 00233 00234 inline Type const *data() const 00235 { return ( (Type *) DataBucketVoid::data() ); } 00236 inline Type *data(void) 00237 { return ( (Type *) DataBucketVoid::data() ); } 00238 00239 inline Type const *data(const int i) const 00240 { return ( (Type *) DataBucketVoid::data(i) ); } 00241 inline Type *data(const int i) 00242 { return ( (Type *) DataBucketVoid::data(i) ); } 00243 }; 00244 00245 #endif
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04