Blockstructured Adaptive Mesh Refinement in object-oriented C++
00001 00006 #include "PackedGridDataBucket.h" 00007 00008 /*************************************************************************/ 00009 gdhdr::gdhdr(struct gdhdr& other) 00010 : type(other.type), owner(other.owner), 00011 gfid(other.gfid), gfdatatype(other.gfdatatype), 00012 gfstaggertype(other.gfstaggertype), 00013 bbox(other.bbox), time(other.time), 00014 time_value(other.time_value), level(other.level), index(other.index) 00015 { 00016 strncpy(gfname,other.gfname,DAGHBktGFNameWidth-1); 00017 gfname[DAGHBktGFNameWidth-1] = '\0'; 00018 double zero = 0.0; 00019 memcpy(physical_time,(char *)&zero,sizeof(double)); 00020 } 00021 00022 gdhdr::gdhdr(const BBox& bb, 00023 const unsigned gf, const int gft, const int gfs, 00024 const char* gfn, 00025 const int t, const int tv, const int l, const int idx, 00026 const int who, const int bkttype) 00027 : type(bkttype), owner(who), 00028 gfid(gf), gfdatatype(gft), gfstaggertype(gfs), 00029 bbox(bb), time(t), 00030 time_value(tv), level(l), index(idx) 00031 { 00032 strncpy(gfname,gfn,DAGHBktGFNameWidth-1); 00033 gfname[DAGHBktGFNameWidth-1] = '\0'; 00034 double zero = 0.0; 00035 memcpy(physical_time,(char *)&zero,sizeof(double)); 00036 } 00037 00038 unsigned gdhdr::gdbsize(const unsigned dsize) 00039 { 00040 unsigned hsize = sizeof(struct gdhdr) + sizeof(struct dbkthdr); 00041 unsigned int align = ((hsize > 8) ? 16 : ((hsize > 4) ? 8 : 4)); 00042 unsigned headsize = (hsize+align-1) & (~(align-1)); 00043 00044 align = ((dsize > 8) ? 16 : ((dsize > 4) ? 8 : 4)); 00045 unsigned datasize = (dsize+align-1) & (~(align-1)); 00046 00047 return (headsize+datasize); 00048 } 00049 /*************************************************************************/ 00050 00051 GridDataBucketVoid::GridDataBucketVoid(const BBox& bb, 00052 const unsigned gf, 00053 const int time, 00054 const int time_value, 00055 const int level, 00056 const int index, 00057 const int who, 00058 const unsigned datasize, 00059 const int type) 00060 : DataBucketVoid(sizeof(struct gdhdr),datasize*bb.size()), bkttype(type) 00061 { 00062 struct gdhdr *gdh == (struct gdhdr *) DataBucketVoid::head(); 00063 gdh->type = bkttype; 00064 gdh->owner = (short) who; 00065 gdh->gfid = (short) gf; 00066 gdh->gfdatatype = DAGHNull; 00067 gdh->gfstaggertype = DAGHNull; 00068 gdh->gfname[0] = '\0'; 00069 gdh->bbox = bb; 00070 gdh->time = time; 00071 gdh->time_value = time_value; 00072 double zero = 0.0; 00073 memcpy(gdh->physical_time,(char *)&zero,sizeof(double)); 00074 gdh->level = level; 00075 gdh->index = index; 00076 } 00077 00078 GridDataBucketVoid::GridDataBucketVoid(const BBox& bb, 00079 const unsigned gf, 00080 const int gfdtype, 00081 const int gfstype, 00082 const char* gfname, 00083 const int time, 00084 const int time_value, 00085 const int level, 00086 const int index, 00087 const int who, 00088 const unsigned datasize, 00089 const int type) 00090 : DataBucketVoid(sizeof(struct gdhdr),datasize*bb.size()), bkttype(type) 00091 { 00092 struct gdhdr *gdh == (struct gdhdr *) DataBucketVoid::head(); 00093 gdh->type = bkttype; 00094 gdh->owner = (short) who; 00095 gdh->gfid = (short) gf; 00096 gdh->gfdatatype = gfdtype; 00097 gdh->gfstaggertype = gfstype; 00098 strncpy(gdh->gfname,gfname,DAGHBktGFNameWidth-1); 00099 gdh->gfname[DAGHBktGFNameWidth-1] = '\0'; 00100 gdh->bbox = bb; 00101 gdh->time = time; 00102 gdh->time_value = time_value; 00103 double zero = 0.0; 00104 memcpy(gdh->physical_time,(char *)&zero,sizeof(double)); 00105 gdh->level = level; 00106 gdh->index = index; 00107 } 00108 00109 GridDataBucketVoid::GridDataBucketVoid(const struct gdhdr& other, 00110 const unsigned datasize) 00111 :DataBucketVoid(sizeof(struct gdhdr),datasize*other.bbox.size()), 00112 bkttype(other.type) 00113 00114 { 00115 struct gdhdr *gdh == (struct gdhdr *) DataBucketVoid::head(); 00116 gdh->type = other.type; 00117 gdh->owner = other.owner; 00118 gdh->gfid = other.gfid; 00119 gdh->gfdatatype = other.gfdatatype; 00120 gdh->gfstaggertype = other.gfstaggertype; 00121 strncpy(gdh->gfname,other.gfname,DAGHBktGFNameWidth-1); 00122 gdh->gfname[DAGHBktGFNameWidth-1] = '\0'; 00123 gdh->bbox = other.bbox; 00124 gdh->time = other.time; 00125 gdh->time_value = other.time_value; 00126 memcpy(gdh->physical_time,other.physical_time,sizeof(double)); 00127 gdh->level = other.level; 00128 gdh->index = other.index; 00129 } 00130 00131 void GridDataBucketVoid::add(const BBox& bb, const unsigned gf, 00132 const int time, const int time_value, 00133 const int level, const int index, 00134 const int who, const int n) 00135 { 00136 struct gdhdr *gdh == (struct gdhdr *) DataBucketVoid::head(n); 00137 gdh->type = bkttype; 00138 gdh->owner = (short) who; 00139 gdh->gfid = (short) gf; 00140 gdh->gfdatatype = DAGHNull; 00141 gdh->gfstaggertype = DAGHNull; 00142 gdh->gfname[0] = '\0'; 00143 gdh->bbox = bb; 00144 gdh->time = time; 00145 gdh->time_value = time_value; 00146 double zero = 0.0; 00147 memcpy(gdh->physical_time,(char *)&zero,sizeof(double)); 00148 gdh->level = level; 00149 gdh->index = index; 00150 } 00151 00152 void GridDataBucketVoid::add(const BBox& bb, const unsigned gf, 00153 const int gfdtype, const int gfstype, 00154 const char* gfname, const int time, 00155 const int time_value, const int level, 00156 const int index, const int who, const int n) 00157 { 00158 struct gdhdr *gdh == (struct gdhdr *) DataBucketVoid::head(n); 00159 gdh->type = bkttype; 00160 gdh->owner = (short) who; 00161 gdh->gfid = (short) gf; 00162 gdh->gfdatatype = gfdtype; 00163 gdh->gfstaggertype = gfstype; 00164 strncpy(gdh->gfname,gfname,DAGHBktGFNameWidth-1); 00165 gdh->gfname[DAGHBktGFNameWidth-1] = '\0'; 00166 gdh->bbox = bb; 00167 gdh->time = time; 00168 gdh->time_value = time_value; 00169 double zero = 0.0; 00170 memcpy(gdh->physical_time,(char *)&zero,sizeof(double)); 00171 gdh->level = level; 00172 gdh->index = index; 00173 } 00174 00175 ostream& operator << (ostream& os, const struct gdhdr& hdr) 00176 { 00177 00178 if (&hdr == (struct gdhdr *)NULL) return os; 00179 00180 os << "[Type:" << hdr.type << "]"; 00181 os << "[Owner:" << hdr.owner << "]"; 00182 os << "[GFid:" << hdr.gfid << "]"; 00183 os << "[" << hdr.gfdatatype << "]"; 00184 os << "[" << hdr.gfstaggertype << "]"; 00185 os << "[" << hdr.gfname << "]"; 00186 os << "[Time Index:" << hdr.time << "]"; 00187 os << "[Time Value:" << hdr.time_value << "]"; 00188 double print_out; 00189 memcpy((char *)&print_out,hdr.physical_time,sizeof(double)); 00190 os << "[Physical Time:" << print_out << "]"; 00191 os << "[Lev:" << hdr.level << "]"; 00192 os << "[Index:" << hdr.index << "]"; 00193 00194 os << "[BBox:" << hdr.bbox << "]"; 00195 00196 return os; 00197 }
Quickstart Users Guide Programmers Reference Installation Examples Download
AMROC Main Home Contactlast update: 06/01/04