Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
writehdf.cpp File Reference
#include <stdio.h>
#include "gridutil.h"
#include "mfhdf.h"
Include dependency graph for writehdf.cpp:

Go to the source code of this file.

Macros

#define chk(x)   checkHDFerr(x,__FILE__,__LINE__)
 

Typedefs

typedef double REAL
 

Functions

static int checkHDFerr (int errCode, const char *fName, int lineNo)
 
const char * write_hdf (const blockDim &dim, const vector3d *locs, const char *filename)
 

Macro Definition Documentation

#define chk (   x)    checkHDFerr(x,__FILE__,__LINE__)

Definition at line 67 of file writehdf.cpp.

Referenced by write_hdf().

Typedef Documentation

typedef double REAL

Definition at line 65 of file writehdf.cpp.

Function Documentation

static int checkHDFerr ( int  errCode,
const char *  fName,
int  lineNo 
)
static

Definition at line 68 of file writehdf.cpp.

68  {
69  if (errCode==-1) {
70  fprintf(stderr,"HDF I/O Error in (%s:%d)\n",
71  fName,lineNo);
72  exit(23);
73  }
74  return errCode;
75 }
void int int int REAL REAL REAL const char * fName
Definition: write.cpp:76
const char* write_hdf ( const blockDim dim,
const vector3d locs,
const char *  filename 
)

Definition at line 77 of file writehdf.cpp.

References chk, blockDim::getSize(), i, cimg_library::cimg::time(), x, vector3d::x, y, vector3d::y, z, and vector3d::z.

Referenced by writeBlocks().

79 {
80  const int dataType=6;//double precision float
81  REAL time=0.0;
82  int32 timeLen=1;
83  chk(DFSDsetdims(1,&timeLen));
84  chk(DFSDsetNT(dataType));
85  chk(DFSDputdata(filename, 1, &timeLen, &time));
86 
87  //Copy the data from C++ array to C arrays
88  int len=dim.getSize();
89  REAL *x=new REAL[len];
90  REAL *y=new REAL[len];
91  REAL *z=new REAL[len];
92  blockLoc i;
93  for (i[2]=0; i[2]<dim[2]; i[2]++)
94  for (i[1]=0; i[1]<dim[1]; i[1]++)
95  for (i[0]=0; i[0]<dim[0]; i[0]++)
96  { //Copy data into separate, coordinate-wise arrays
97  int c_i=dim[i], f_i=dim[i];
98  x[f_i]=locs[c_i].x;
99  y[f_i]=locs[c_i].y;
100  z[f_i]=locs[c_i].z;
101  }
102 
103  //Send the data off to HDF
104  int32 dSize[3]; //Swap dimensions
105  dSize[0]=dim[2]; dSize[1]=dim[1]; dSize[2]=dim[0];
106  chk(DFSDsetdims(3,dSize));
107  chk(DFSDsetNT(dataType));
108  chk(DFSDadddata(filename, 3, dSize, x));
109  chk(DFSDadddata(filename, 3, dSize, y));
110  chk(DFSDadddata(filename, 3, dSize, z));
111 
112  //Clean up output arrays
113  delete[] x; delete[] y; delete[] z;
114 
115  return NULL;
116 }
void int int REAL REAL * y
Definition: read.cpp:74
double REAL
Definition: read.cpp:70
real x
Definition: vector3d.h:88
real y
Definition: vector3d.h:88
void int int int REAL REAL REAL * z
Definition: write.cpp:76
#define chk(x)
Definition: writehdf.cpp:67
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
unsigned long time()
Get the value of a system timer with a millisecond precision.
Definition: CImg.h:4605
int getSize(void) const
Definition: gridutil.h:126
real z
Definition: vector3d.h:88

Here is the call graph for this function:

Here is the caller graph for this function: