00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __EBINTERFACE_H_
00033 #define __EBINTERFACE_H_
00034
00035 #include <hdf5.h>
00036 #include <math.h>
00037
00038 struct {
00039 int i;
00040 int j;
00041 }typedef intvect2d ;
00042
00043 struct {
00044 int i;
00045 int j;
00046 int k;
00047 }typedef intvect3d ;
00048
00049 struct {
00050 intvect2d lo;
00051 intvect2d hi;
00052 }typedef box2d ;
00053
00054 struct{
00055 intvect3d lo;
00056 intvect3d hi;
00057 } typedef box3d;
00058
00059 union
00060 {
00061 box2d b2;
00062 box3d b3;
00063 } typedef box;
00064
00065
00066 struct {
00067 intvect3d index;
00068 double volfrac;
00069 double areafrac[6];
00070
00071 } typedef regvof ;
00072
00073
00074 struct {
00075 double areafrac;
00076 intvect3d neighbour;
00077 int nindex;
00078 } typedef irregface;
00079
00080 struct {
00081 intvect3d index;
00082 double volfrac;
00083 int numfaces;
00084 irregface* faces;
00085 } typedef irregvof;
00086
00087
00088
00089
00090
00091 void initializeHDF5datatypes();
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123 int writeEBChomboFile(const char* filename,
00124 box3d domain,
00125 int length,
00126 box3d* boxes,
00127 long* regoffset,
00128 long* irregoffset,
00129 long numreg,
00130 long numirreg,
00131 regvof* regularVofs,
00132 irregvof* irregularVofs);
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144 int isEmpty(const box2d*);
00145 int numPnts2(const box2d*);
00146 int numPnts3(const box3d*);
00147
00148 void grow2(box2d*, intvect2d*);
00149 void grow3(box3d*, intvect3d*);
00150
00151 void refine2(box2d*, int refinement);
00152 void refine3(box3d*, int refinement);
00153 int cut(const box3d* box, int dir, int index);
00154 box2d* crossSection(const box3d* box, int dir, box2d* box2);
00155
00156 static hid_t intvect2d_id, intvect3d_id, box2d_id, box3d_id ;
00157
00158
00159
00160
00161
00162
00163
00164 enum{Float, Double} typedef ChPrecision;
00165
00166 struct
00167 {
00168 hid_t file_ID;
00169 hid_t group_ID;
00170 int dim;
00171 ChPrecision precision;
00172 }typedef HDF5Handle;
00173
00174
00175
00176
00177
00178
00179
00180 int Handleopen(HDF5Handle* handle, const char* filename, hid_t accessMode);
00181 int HandlesetGroup(HDF5Handle* handle, const char* group);
00182 int Handleclose(HDF5Handle handle);
00183 int HandleCreateGroup(HDF5Handle* handle, const char* group);
00184
00185
00186 #define ChTYPES 8
00187 enum{INTEGER, FLOAT, DOUBLE, CHAR, INTVECT2D, INTVECT3D, BOX2D, BOX3D}typedef ChattributeType;
00188 static const char* TYPE_NAMES[ChTYPES];
00189
00190 struct
00191 {
00192 void* data;
00193 char* name;
00194 int attributeType;
00195 void* next;
00196 } typedef Attribute;
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217 struct
00218 {
00219 int numByType[ChTYPES];
00220 Attribute* accessByType[ChTYPES];
00221 int dim;
00222 ChPrecision precision;
00223 } typedef HDF5attributes;
00224
00225 void freeHDF5attributes(HDF5attributes* attributes);
00226 void printAttributes(HDF5attributes* attributes);
00227
00228
00229
00230
00231 extern Attribute* ADD_tmp;
00232 extern Attribute* ADD_at;
00233 #define ADD_ATTRIBUTE(attrib, Ttype, ChType, Sname, value) \
00234 ADD_tmp = attrib.accessByType[ChType] ; \
00235 ADD_at = (Attribute*) malloc(sizeof(Attribute)); \
00236 attrib.accessByType[ChType] = ADD_at; \
00237 ADD_at->name = malloc(strlen(Sname)+1); \
00238 sprintf(ADD_at->name, Sname); \
00239 ADD_at->data = malloc(sizeof(Ttype)); \
00240 ADD_at->attributeType = ChType; \
00241 *((Ttype *)ADD_at->data) = value; \
00242 ADD_at->next = ADD_tmp; \
00243 attrib.numByType[ChType]++; \
00244
00245 #define ADD_CHAR_ATTRIBUTE(attrib, Sname, value) \
00246 ADD_tmp = attrib.accessByType[CHAR] ; \
00247 ADD_at = (Attribute*) malloc(sizeof(Attribute)); \
00248 attrib.accessByType[CHAR] = ADD_at; \
00249 ADD_at->name = malloc(strlen(Sname)); \
00250 sprintf(ADD_at->name, Sname); \
00251 ADD_at->data = malloc(strlen(value)); \
00252 ADD_at->attributeType = CHAR; \
00253 sprintf((char*)ADD_at->data, value); \
00254 ADD_at->next = ADD_tmp; \
00255 attrib.numByType[CHAR]++; \
00256
00257
00258
00259
00260
00261
00262
00263 int readHDF5attributes(HDF5attributes* attr, HDF5Handle handle);
00264
00265
00266
00267
00268 int readBoxes(box** boxes, int* length, HDF5Handle handle);
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280 int writeHDF5attributes(HDF5attributes* attr, HDF5Handle handle);
00281
00282 int writeBoxes(box* boxes, int length, HDF5Handle handle);
00283
00284
00285
00286
00289 #define CFINITE(X) !isnan(X) && (X) < HUGE_VAL && (X) > -HUGE_VAL
00290
00291 #endif