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