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