aboutsummaryrefslogtreecommitdiff
path: root/CarpetAttic
diff options
context:
space:
mode:
authorcvs_anon <>2003-09-23 10:35:00 +0000
committercvs_anon <>2003-09-23 10:35:00 +0000
commitd670632ee12507b1d4ac2e6348edc7b6e6b5278c (patch)
tree6b35019cc522bc45365b3def27760ab055185849 /CarpetAttic
parent00509e12e14450bb26de6fc29b3309a75677891f (diff)
New file containing util routines.
darcs-hash:20030923103550-62b91-5ab4d33553469e5e3298597d0148cf4ed1ecdc8a.gz
Diffstat (limited to 'CarpetAttic')
-rw-r--r--CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc164
1 files changed, 70 insertions, 94 deletions
diff --git a/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc b/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc
index 1342cbfa5..8d9af6b5b 100644
--- a/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc
+++ b/CarpetAttic/CarpetIOFlexIOCheckpoint/src/ioflexioUtil.cc
@@ -30,6 +30,10 @@
#undef BYTE
#undef CHAR
+//#include "CactusBase/IOUtil/src/ioGH.h"
+//#include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h"
+//#include "CactusBase/IOUtil/src/ioutil_Utils.h"
+
#include "bbox.hh"
#include "data.hh"
#include "gdata.hh"
@@ -46,9 +50,9 @@ namespace CarpetIOFlexIOUtil {
using namespace Carpet;
using namespace CarpetIOFlexIO;
- IObase::DataType FlexIODataType (int cctk_type){
- //we need this to have the FlexIO data types on hand
- //for WriteGFAs
+IObase::DataType FlexIODataType (int cctk_type){
+ //we need this to have the FlexIO data types on hand
+ //for WriteGFAs
int retval;
@@ -86,102 +90,74 @@ namespace CarpetIOFlexIOUtil {
}
- void DumpCommonAttributes (const cGH *cgh, IObase* writer, ioRequest* request)
- {
- int tl;
- CCTK_INT attr_int,dimscalar;
- DECLARE_CCTK_PARAMETERS;
-
- /* attributes describing the variable */
-
- char *name = CCTK_FullName (request->vindex);
- WriteAttribute(writer,"name",name);
- free(name);
-
- char* groupname = CCTK_GroupNameFromVarI (request->vindex);
- WriteAttribute(writer,"groupname",groupname);
- free (groupname);
-
- WriteAttribute(writer,"grouptype",CCTK_GroupTypeFromVarI (request->vindex));
- WriteAttribute(writer,"reflevel",reflevel);
- WriteAttribute(writer,"component",component);
- WriteAttribute(writer,"mglevel",mglevel);
-
-
- WriteAttribute (writer,"ntimelevels",CCTK_MaxTimeLevelsVI (request->vindex));
-
- // lets get the correct Carpet time level (which is the (-1) * timelevel):
- if (request->timelevel==0)
- tl = 0;
- else
- tl = - request->timelevel;
- WriteAttribute (writer, "timelevel", tl);
-
- WriteAttribute (writer, "carpet_flexio_version", 1);
- WriteAttribute (writer, "cctk_dim", cgh->cctk_dim);
- WriteAttribute (writer, "cctk_iteration", cgh->cctk_iteration);
- WriteAttribute (writer, "cctk_gsh", cgh->cctk_gsh, dim);
- WriteAttribute (writer, "cctk_lsh", cgh->cctk_lsh, dim);
- WriteAttribute (writer, "cctk_lbnd", cgh->cctk_lbnd, dim);
- WriteAttribute (writer, "cctk_delta_time", cgh->cctk_delta_time);
- WriteAttribute (writer, "cctk_delta_space", cgh->cctk_delta_space, dim);
- WriteAttribute (writer, "cctk_origin_space", cgh->cctk_origin_space, dim);
- WriteAttribute (writer, "cctk_bbox", cgh->cctk_bbox, 2*dim);
- WriteAttribute (writer, "cctk_levfac", cgh->cctk_levfac, dim);
- WriteAttribute (writer, "cctk_levoff", cgh->cctk_levoff, dim);
- WriteAttribute (writer, "cctk_levoffdenom", cgh->cctk_levoffdenom, dim);
- WriteAttribute (writer, "cctk_timefac", cgh->cctk_timefac);
- WriteAttribute (writer, "cctk_convlevel", cgh->cctk_convlevel);
- WriteAttribute (writer, "cctk_nghostzones", cgh->cctk_nghostzones, dim);
- WriteAttribute (writer, "cctk_time", cgh->cctk_time);
- }
+void DumpCommonAttributes (const cGH *cgh, IObase* writer, ioRequest* request)
+{
+ int dim, vdim;
+ CCTK_INT attr_int;
+ CCTK_REAL *attr_real;
+ char coord_system_name[20];
+ DECLARE_CCTK_PARAMETERS
-
- void WriteAttribute (IObase* writer, const char* name, int value)
- {
- WriteAttribute (writer, name, &value, 1);
- }
-
- void WriteAttribute (IObase* writer, const char* name,
- const int* values, int nvalues)
- {
- assert (writer);
- assert (name);
- assert (values);
- vector<CCTK_INT4> values1(nvalues);
- for (int i=0; i<nvalues; ++i) {
- values1[i] = values[i];
- }
- writer->writeAttribute (name, IObase::Int32, nvalues, &values1[0]);
- }
-
- void WriteAttribute (IObase* writer, const char* name, CCTK_REAL value)
- {
- WriteAttribute (writer, name, &value, 1);
- }
-
- void WriteAttribute (IObase* writer, const char* name,
- const CCTK_REAL* values, int nvalues)
+ int varindex = request->vindex;
+
+ /* attributes describing the variable */
+ char* groupname = CCTK_GroupNameFromVarI (varindex);
+
+ //DEBUG
+ //CCTK_VInfo (CCTK_THORNSTRING, "DUMPATTRIB reflevel,component,mglevel %d,%d,%d",reflevel,component,mglevel);
+
+ writer->writeAttribute("groupname",IObase::Char,strlen(groupname)+1,groupname);
+ free (groupname);
+
+ CCTK_INT attr_int = CCTK_GroupTypeFromVarI (varindex);
+ writer->writeAttribute("grouptype",FlexIODataType(CCTK_VARIABLE_INT),1,&attr_int);
+
+ writer->writeAttribute("reflevel",FlexIODataType(CCTK_VARIABLE_INT),1,&reflevel);
+ writer->writeAttribute("component",FlexIODataType(CCTK_VARIABLE_INT),1,&component);
+ writer->writeAttribute("mglevel",FlexIODataType(CCTK_VARIABLE_INT),1,&mglevel);
+
+ attr_int = CCTK_MaxTimeLevelsVI (varindex);
+ writer->writeAttribute("ntimelevels",FlexIODataType(CCTK_VARIABLE_INT),1,&attr_int);
+
+ writer->writeAttribute("timelevel",FlexIODataType(CCTK_VARIABLE_INT),1,&request->timelevel);
+
+ writer->writeAttribute("global_size",FlexIODataType(CCTK_VARIABLE_INT),request->hdim,request->hsize);
+ writer->writeAttribute("time",FlexIODataType(CCTK_VARIABLE_REAL),1,&cgh->cctk_time);
+
+ /* attributes describing the underlying grid
+ These are only stored for CCTK_GF variables if they are associated
+ with coordinates. */
+ /* FIXME: This is hardcoded for cartesian coordinate systems.
+ A better solution would be to be able to query the coordinate
+ system which is associated with the variable. */
+ vdim = CCTK_GroupDimFromVarI (request->vindex);
+ sprintf (coord_system_name, "cart%dd", vdim);
+ if (CCTK_GroupTypeFromVarI (request->vindex) == CCTK_GF &&
+ CCTK_CoordSystemHandle (coord_system_name) >= 0)
{
- assert (writer);
- assert (name);
- assert (values);
- vector<CCTK_REAL8> values1(nvalues);
- for (int i=0; i<nvalues; ++i) {
- values1[i] = values[i];
+ attr_real = (CCTK_REAL*) malloc (3 * vdim * sizeof (CCTK_REAL));
+ for (dim = 0; dim < vdim; dim++)
+ {
+ CCTK_CoordRange (cgh, &attr_real[dim], &attr_real[dim + vdim], dim + 1,
+ NULL, coord_system_name);
+
+ attr_real[dim + 0*vdim] +=
+ request->origin[dim] * cgh->cctk_delta_space[dim];
+ attr_real[dim + 2*vdim] =
+ cgh->cctk_delta_space[dim] * request->downsample[dim];
+ attr_real[dim + 1*vdim] = attr_real[dim + 0*vdim] +
+ ((request->extent[dim] + request->downsample[dim]-1) /
+ request->downsample[dim] - 1) * attr_real[dim + 2*vdim];
}
- writer->writeAttribute (name, IObase::Float64, nvalues, &values1[0]);
- }
- void WriteAttribute (IObase* writer, const char* name,
- const char* valuestring)
- {
- assert (writer);
- assert (name);
- assert (valuestring);
- writer->writeAttribute (name, IObase::String, strlen(valuestring)+1, valuestring);
+ writer->writeAttribute ("origin", FlexIODataType(CCTK_VARIABLE_REAL), vdim, attr_real);
+ writer->writeAttribute ("min_ext", FlexIODataType(CCTK_VARIABLE_REAL), vdim, attr_real);
+ writer->writeAttribute ("max_ext", FlexIODataType(CCTK_VARIABLE_REAL), vdim, attr_real+vdim);
+ writer->writeAttribute ("delta", FlexIODataType(CCTK_VARIABLE_REAL), vdim, attr_real+2*vdim);
+ free (attr_real);
}
-
+}
+
} // namespace CarpetIOFlexIOUtil