From 21ec705634caf28a5c6c1826b0823482915d142f Mon Sep 17 00:00:00 2001 From: schnetter <> Date: Wed, 9 Jan 2002 22:42:00 +0000 Subject: Moved ASCII output from CarpetLib (where it never belonged) to Moved ASCII output from CarpetLib (where it never belonged) to CarpetIOASCII. Added parameter to not output the ghost zones for ASCII output. darcs-hash:20020109224240-07bb3-457f3768c8aee0b68db6a7a85741ccd9191ee39e.gz --- Carpet/CarpetIOASCII/param.ccl | 12 +- Carpet/CarpetIOASCII/src/ioascii.cc | 218 ++++++++++++++++++++++++++++++++++-- Carpet/CarpetLib/src/data.cc | 12 +- Carpet/CarpetLib/src/data.hh | 12 +- Carpet/CarpetLib/src/gdata.cc | 121 +------------------- Carpet/CarpetLib/src/gdata.hh | 28 +---- 6 files changed, 225 insertions(+), 178 deletions(-) (limited to 'Carpet') diff --git a/Carpet/CarpetIOASCII/param.ccl b/Carpet/CarpetIOASCII/param.ccl index f30df8d85..b004844c9 100644 --- a/Carpet/CarpetIOASCII/param.ccl +++ b/Carpet/CarpetIOASCII/param.ccl @@ -1,5 +1,5 @@ # Parameter definitions for thorn CarpetIOASCII -# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/param.ccl,v 1.4 2001/12/17 13:34:02 schnetter Exp $ +# $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/param.ccl,v 1.5 2002/01/09 23:42:40 schnetter Exp $ @@ -41,6 +41,16 @@ restricted: +BOOLEAN out3D_ghosts "Output ghost zones as well" +{ +} "yes" + +BOOLEAN out3D_outer_ghosts "Output outer boundary ghost zones as well" +{ +} "yes" + + + BOOLEAN separate_grids "Separate grid levels in the output file by additional empty lines" { } "yes" diff --git a/Carpet/CarpetIOASCII/src/ioascii.cc b/Carpet/CarpetIOASCII/src/ioascii.cc index 14ee7962b..7b64b12b8 100644 --- a/Carpet/CarpetIOASCII/src/ioascii.cc +++ b/Carpet/CarpetIOASCII/src/ioascii.cc @@ -17,6 +17,7 @@ #include "CactusBase/IOUtil/src/ioutil_CheckpointRecovery.h" #include "Carpet/CarpetLib/src/data.hh" +#include "Carpet/CarpetLib/src/dist.hh" #include "Carpet/CarpetLib/src/gdata.hh" #include "Carpet/CarpetLib/src/gf.hh" #include "Carpet/CarpetLib/src/ggf.hh" @@ -26,10 +27,15 @@ #include "ioascii.hh" -static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.27 2002/01/08 13:49:22 schnetter Exp $"; +static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetIOASCII/src/ioascii.cc,v 1.28 2002/01/09 23:42:40 schnetter Exp $"; +// That's a hack +namespace Carpet { + void UnsupportedVarType (const int vindex); +} + using namespace std; using namespace Carpet; @@ -39,6 +45,22 @@ static bool CheckForVariable (const cGH* const cgh, const char* const varlist, const int vindex); static void SetFlag (int index, const char* optstring, void* arg); +template +static void WriteASCII (ostream& os, + const generic_data* const gfdata, + const bbox& gfext, + const int vi, + const int time, + const vect& org, + const vect& dirs, + const int tl, + const int rl, + const int c, + const int ml, + const CCTK_REAL coord_time, + const vect& coord_lower, + const vect& coord_upper); + int CarpetIOASCIIStartup() @@ -332,8 +354,27 @@ int CarpetIOASCII const generic_data* const data = (*ff) (tl, reflevel, component, mglevel); - const bbox ext = data->extent(); - const vect offset1 = offset * ext.stride(); + bbox ext = data->extent(); + + vect lo = ext.lower(); + vect hi = ext.upper(); + vect str = ext.stride(); + + // Ignore ghost zones if desired + for (int d=0; dcctk_bbox[2*d] ? out3D_outer_ghosts : out3D_ghosts; + bool output_upper_ghosts + = cgh->cctk_bbox[2*d+1] ? out3D_outer_ghosts : out3D_ghosts; + + if (! output_lower_ghosts) { + lo[d] += cgh->cctk_nghostzones[d] * str[d]; + } + if (! output_upper_ghosts) { + hi[d] -= cgh->cctk_nghostzones[d] * str[d]; + } + } + ext = bbox(lo,hi,str); // coordinates const double coord_time = cgh->cctk_time; @@ -357,12 +398,14 @@ int CarpetIOASCII } // Note: don't permute the "coord_delta" and "data->extent().lower()" // (you'll pick up the integer operator* then) - const vect coord_lower = global_lower + coord_delta * vect(data->extent().lower()); - const vect coord_upper = global_lower + coord_delta * vect(data->extent().upper()); + const vect coord_lower = global_lower + coord_delta * vect(lo); + const vect coord_upper = global_lower + coord_delta * vect(hi); + + const vect offset1 = offset * ext.stride(); - data->write_ascii (file, cgh->cctk_iteration, offset1, dirs, - tl, reflevel, component, mglevel, - coord_time, coord_lower, coord_upper); + WriteASCII (file, data, ext, n, cgh->cctk_iteration, offset1, dirs, + tl, reflevel, component, mglevel, + coord_time, coord_lower, coord_upper); // Append EOL after every component if (CCTK_MyProc(cgh)==0) { @@ -634,7 +677,166 @@ void SetFlag (int index, const char* optstring, void* arg) +// Output +template +void WriteASCII (ostream& os, + const generic_data* const gfdata, + const bbox& gfext, + const int vi, + const int time, + const vect& org, + const vect& dirs, + const int tl, + const int rl, + const int c, + const int ml, + const CCTK_REAL coord_time, + const vect& coord_lower, + const vect& coord_upper) +{ + assert (DD<=D); + + if (gfdata->proc()==0) { + // output on processor 0 + + int rank; + MPI_Comm_rank (dist::comm, &rank); + if (rank == 0) { + + assert (os.good()); + + os << "# iteration " << time << endl + << "# time level " << tl << " refinement level " << rl + << " component " << c << " multigrid level " << ml << endl + << "# column format: it tl rl c ml "; + assert (D>=1 && D<=3); + const char* const coords = "xyz"; + for (int d=0; d lo = gfext.lower()[dirs]; + const vect up = gfext.upper()[dirs]; + const vect str = gfext.stride()[dirs]; + const bbox ext(lo,up,str); + + // Check whether the output origin is contained in the extent of + // the data that should be output + vect org1(org); + for (int d=0; d::iterator it=ext.begin(); it!=ext.end(); ++it) { + vect index(org); + for (int d=0; d*)gfdata)[index]; \ + break; +#include "Carpet/Carpet/src/typecase" +#undef TYPECASE + default: + UnsupportedVarType(vi); + } + os << endl; + for (int d=0; d* const tmp = gfdata->make_typed(); + tmp->allocate(gfdata->extent(), 0); + tmp->copy_from (gfdata, gfdata->extent()); + WriteASCII (os, tmp, gfext, vi, time, org, dirs, tl, rl, c, ml, + coord_time, coord_lower, coord_upper); + delete tmp; + + } +} + + + + + // Explicit instantiation for all output dimensions template class CarpetIOASCII<1>; template class CarpetIOASCII<2>; template class CarpetIOASCII<3>; + +template +void WriteASCII (ostream& os, + const generic_data<3>* const gfdata, + const bbox& gfext, + const int vi, + const int time, + const vect& org, + const vect& dirs, + const int tl, + const int rl, + const int c, + const int ml, + const CCTK_REAL coord_time, + const vect& coord_lower, + const vect& coord_upper); + +template +void WriteASCII (ostream& os, + const generic_data<3>* const gfdata, + const bbox& gfext, + const int vi, + const int time, + const vect& org, + const vect& dirs, + const int tl, + const int rl, + const int c, + const int ml, + const CCTK_REAL coord_time, + const vect& coord_lower, + const vect& coord_upper); + +template +void WriteASCII (ostream& os, + const generic_data<3>* const gfdata, + const bbox& gfext, + const int vi, + const int time, + const vect& org, + const vect& dirs, + const int tl, + const int rl, + const int c, + const int ml, + const CCTK_REAL coord_time, + const vect& coord_lower, + const vect& coord_upper); diff --git a/Carpet/CarpetLib/src/data.cc b/Carpet/CarpetLib/src/data.cc index e2a7a8dae..fe7fa53f8 100644 --- a/Carpet/CarpetLib/src/data.cc +++ b/Carpet/CarpetLib/src/data.cc @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.cc,v 1.15 2001/12/14 16:39:41 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.cc,v 1.16 2002/01/09 23:42:41 schnetter Exp $ ***************************************************************************/ @@ -570,16 +570,6 @@ void data -// Output -template -void data::write_ascii_output_element (ostream& os, const ivect& index) - const -{ - os << (*this)[index]; -} - - - // Output template ostream& data::output (ostream& os) const { diff --git a/Carpet/CarpetLib/src/data.hh b/Carpet/CarpetLib/src/data.hh index 00e239e22..3d2e1c792 100644 --- a/Carpet/CarpetLib/src/data.hh +++ b/Carpet/CarpetLib/src/data.hh @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.hh,v 1.8 2001/12/09 16:43:09 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/data.hh,v 1.9 2002/01/09 23:42:41 schnetter Exp $ ***************************************************************************/ @@ -99,16 +99,6 @@ public: const int order_space, const int order_time); - void write_ascii_output_element (ostream& os, const ivect& index) const; -// void write_ieee (const string name, const int time, -// const int tl, const int rl, const int c, const int ml) -// const; -// void write_hdf (const string name, const int time, -// const int tl, const int rl, const int c, const int ml) -// const; -// void write_h5 (const string name, const int time, -// const int tl, const int rl, const int c, const int ml) -// const; public: // Output diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc index a0e90346d..4f59b201e 100644 --- a/Carpet/CarpetLib/src/gdata.cc +++ b/Carpet/CarpetLib/src/gdata.cc @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.17 2002/01/08 12:03:55 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.cc,v 1.18 2002/01/09 23:42:42 schnetter Exp $ ***************************************************************************/ @@ -128,127 +128,8 @@ void generic_data -// Output -template -template -void generic_data::write_ascii (ostream& os, const int time, - const vect& org, - const vect& dirs, - const int tl, const int rl, - const int c, const int ml, - const double coord_time, - const vect& coord_lower, - const vect& coord_upper) - const -{ - assert (_has_storage); - CHECKPOINT; - - assert (DD<=D); - - if (proc()==0) { - // output on processor 0 - - int rank; - MPI_Comm_rank (dist::comm, &rank); - if (rank == 0) { - - assert (os.good()); - - os << "# iteration " << time << endl - << "# time level " << tl << " refinement level " << rl - << " component " << c << " multigrid level " << ml << endl - << "# column format: it tl rl c ml "; - assert (D>=1 && D<=3); - const char* const coords = "xyz"; - for (int d=0; d lo = extent().lower()[dirs]; - const vect up = extent().upper()[dirs]; - const vect str = extent().stride()[dirs]; - const bbox ext(lo,up,str); - - // Check whether the output origin is contained in the extent of - // the data - ivect org1(org); - for (int d=0; d::iterator it=ext.begin(); it!=ext.end(); ++it) { - ivect index(org); - for (int d=0; dallocate(extent(), 0); - tmp->copy_from (this, extent()); - tmp->write_ascii (os, time, org, dirs, tl, rl, c, ml, - coord_time, coord_lower, coord_upper); - delete tmp; - - } -} - - - #if defined(TMPL_EXPLICIT) template class generic_data<3>; -template void generic_data<3> -::write_ascii (ostream& os, const int time, - const vect& org, const vect& dirs, - const int tl, const int rl, const int c, const int ml, - const double coord_time, - const vect& coord_lower, - const vect& coord_upper) const; -template void generic_data<3> -::write_ascii (ostream& os, const int time, - const vect& org, const vect& dirs, - const int tl, const int rl, const int c, const int ml, - const double coord_time, - const vect& coord_lower, - const vect& coord_upper) const; -template void generic_data<3> -::write_ascii (ostream& os, const int time, - const vect& org, const vect& dirs, - const int tl, const int rl, const int c, const int ml, - const double coord_time, - const vect& coord_lower, - const vect& coord_upper) const; - #endif diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh index d9f6fb842..9b1e85555 100644 --- a/Carpet/CarpetLib/src/gdata.hh +++ b/Carpet/CarpetLib/src/gdata.hh @@ -5,7 +5,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.hh,v 1.12 2002/01/08 12:03:55 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.hh,v 1.13 2002/01/09 23:42:42 schnetter Exp $ ***************************************************************************/ @@ -113,32 +113,6 @@ protected: const int order_space, const int order_time) = 0; -public: - - // Output - template - void write_ascii (ostream& os, const int time, - const vect& org, const vect& dirs, - const int tl, const int rl, - const int c, const int ml, - const double ctime, - const vect& coord_lower, - const vect& coord_upper) - const; -protected: - virtual void write_ascii_output_element (ostream& os, const ivect& index) - const = 0; -public: -// void write_ieee (const string name, const int time, -// const int tl, const int rl, const int c, const int ml) -// const; -// void write_hdf (const string name, const int time, -// const int tl, const int rl, const int c, const int ml) -// const; -// void write_h5 (const string name, const int time, -// const int tl, const int rl, const int c, const int ml) -// const; -public: }; -- cgit v1.2.3