aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
authorschnetter <>2002-01-09 22:42:00 +0000
committerschnetter <>2002-01-09 22:42:00 +0000
commit21ec705634caf28a5c6c1826b0823482915d142f (patch)
treecc720de8d0358cfd2e110499586bf8077de63308 /Carpet
parent313504329f18e0bba86b7cf05c7a95a167e085f5 (diff)
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
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/CarpetIOASCII/param.ccl12
-rw-r--r--Carpet/CarpetIOASCII/src/ioascii.cc218
-rw-r--r--Carpet/CarpetLib/src/data.cc12
-rw-r--r--Carpet/CarpetLib/src/data.hh12
-rw-r--r--Carpet/CarpetLib/src/gdata.cc121
-rw-r--r--Carpet/CarpetLib/src/gdata.hh28
6 files changed, 225 insertions, 178 deletions
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<int D,int DD>
+static void WriteASCII (ostream& os,
+ const generic_data<D>* const gfdata,
+ const bbox<int,D>& gfext,
+ const int vi,
+ const int time,
+ const vect<int,D>& org,
+ const vect<int,DD>& dirs,
+ const int tl,
+ const int rl,
+ const int c,
+ const int ml,
+ const CCTK_REAL coord_time,
+ const vect<CCTK_REAL,D>& coord_lower,
+ const vect<CCTK_REAL,D>& coord_upper);
+
int CarpetIOASCIIStartup()
@@ -332,8 +354,27 @@ int CarpetIOASCII<outdim>
const generic_data<dim>* const data
= (*ff) (tl, reflevel, component, mglevel);
- const bbox<int,dim> ext = data->extent();
- const vect<int,dim> offset1 = offset * ext.stride();
+ bbox<int,dim> ext = data->extent();
+
+ vect<int,dim> lo = ext.lower();
+ vect<int,dim> hi = ext.upper();
+ vect<int,dim> str = ext.stride();
+
+ // Ignore ghost zones if desired
+ for (int d=0; d<dim; ++d) {
+ bool output_lower_ghosts
+ = cgh->cctk_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<int,dim>(lo,hi,str);
// coordinates
const double coord_time = cgh->cctk_time;
@@ -357,12 +398,14 @@ int CarpetIOASCII<outdim>
}
// Note: don't permute the "coord_delta" and "data->extent().lower()"
// (you'll pick up the integer operator* then)
- const vect<double,dim> coord_lower = global_lower + coord_delta * vect<double,dim>(data->extent().lower());
- const vect<double,dim> coord_upper = global_lower + coord_delta * vect<double,dim>(data->extent().upper());
+ const vect<double,dim> coord_lower = global_lower + coord_delta * vect<double,dim>(lo);
+ const vect<double,dim> coord_upper = global_lower + coord_delta * vect<double,dim>(hi);
+
+ const vect<int,dim> 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<int D,int DD>
+void WriteASCII (ostream& os,
+ const generic_data<D>* const gfdata,
+ const bbox<int,D>& gfext,
+ const int vi,
+ const int time,
+ const vect<int,D>& org,
+ const vect<int,DD>& dirs,
+ const int tl,
+ const int rl,
+ const int c,
+ const int ml,
+ const CCTK_REAL coord_time,
+ const vect<CCTK_REAL,D>& coord_lower,
+ const vect<CCTK_REAL,D>& 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<D; ++d) os << " i" << coords[d];
+ os << " time ";
+ for (int d=0; d<D; ++d) os << " " << coords[d];
+ os << " data" << endl;
+
+ const vect<int,DD> lo = gfext.lower()[dirs];
+ const vect<int,DD> up = gfext.upper()[dirs];
+ const vect<int,DD> str = gfext.stride()[dirs];
+ const bbox<int,DD> ext(lo,up,str);
+
+ // Check whether the output origin is contained in the extent of
+ // the data that should be output
+ vect<int,dim> org1(org);
+ for (int d=0; d<DD; ++d) org1[dirs[d]] = ext.lower()[d];
+ if (gfext.contains(org1)) {
+
+ for (bbox<int,DD>::iterator it=ext.begin(); it!=ext.end(); ++it) {
+ vect<int,dim> index(org);
+ for (int d=0; d<DD; ++d) index[dirs[d]] = (*it)[d];
+ os << time << " " << tl << " " << rl << " " << c << " " << ml
+ << " ";
+ for (int d=0; d<D; ++d) os << index[d] << " ";
+ os << " " << coord_time << " ";
+ for (int d=0; d<D; ++d) {
+ if (gfext.upper()[d] - gfext.lower()[d] != 0) {
+ os << (coord_lower[d] + (index[d] - gfext.lower()[d])
+ * (coord_upper[d] - coord_lower[d])
+ / (gfext.upper()[d] - gfext.lower()[d])) << " ";
+ } else {
+ os << coord_lower[d] << " ";
+ }
+ }
+ os << " ";
+ switch (CCTK_VarTypeI(vi)) {
+#define TYPECASE(N,T) \
+ case N: \
+ os << (*(data<T,D>*)gfdata)[index]; \
+ break;
+#include "Carpet/Carpet/src/typecase"
+#undef TYPECASE
+ default:
+ UnsupportedVarType(vi);
+ }
+ os << endl;
+ for (int d=0; d<DD; ++d) {
+ if (index[dirs[d]]!=gfext.upper()[dirs[d]]) break;
+ os << endl;
+ }
+ }
+
+ } else {
+
+ os << "#" << endl;
+
+ } // if ! ext contains org
+
+ assert (os.good());
+
+ }
+
+ } else {
+ // copy to processor 0 and output there
+
+ generic_data<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<int,3>& gfext,
+ const int vi,
+ const int time,
+ const vect<int,3>& org,
+ const vect<int,1>& dirs,
+ const int tl,
+ const int rl,
+ const int c,
+ const int ml,
+ const CCTK_REAL coord_time,
+ const vect<CCTK_REAL,3>& coord_lower,
+ const vect<CCTK_REAL,3>& coord_upper);
+
+template
+void WriteASCII (ostream& os,
+ const generic_data<3>* const gfdata,
+ const bbox<int,3>& gfext,
+ const int vi,
+ const int time,
+ const vect<int,3>& org,
+ const vect<int,2>& dirs,
+ const int tl,
+ const int rl,
+ const int c,
+ const int ml,
+ const CCTK_REAL coord_time,
+ const vect<CCTK_REAL,3>& coord_lower,
+ const vect<CCTK_REAL,3>& coord_upper);
+
+template
+void WriteASCII (ostream& os,
+ const generic_data<3>* const gfdata,
+ const bbox<int,3>& gfext,
+ const int vi,
+ const int time,
+ const vect<int,3>& org,
+ const vect<int,3>& dirs,
+ const int tl,
+ const int rl,
+ const int c,
+ const int ml,
+ const CCTK_REAL coord_time,
+ const vect<CCTK_REAL,3>& coord_lower,
+ const vect<CCTK_REAL,3>& 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 $
***************************************************************************/
@@ -571,16 +571,6 @@ void data<CCTK_REAL8,3>
// Output
-template<class T, int D>
-void data<T,D>::write_ascii_output_element (ostream& os, const ivect& index)
- const
-{
- os << (*this)[index];
-}
-
-
-
-// Output
template<class T,int D>
ostream& data<T,D>::output (ostream& os) const {
os << "data<T," << D << ">:"
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<D>
-// Output
-template<int D>
-template<int DD>
-void generic_data<D>::write_ascii (ostream& os, const int time,
- const vect<int,D>& org,
- const vect<int,DD>& dirs,
- const int tl, const int rl,
- const int c, const int ml,
- const double coord_time,
- const vect<double,D>& coord_lower,
- const vect<double,D>& 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<D; ++d) os << " i" << coords[d];
- os << " time ";
- for (int d=0; d<D; ++d) os << " " << coords[d];
- os << " data" << endl;
-
- const vect<int,DD> lo = extent().lower()[dirs];
- const vect<int,DD> up = extent().upper()[dirs];
- const vect<int,DD> str = extent().stride()[dirs];
- const bbox<int,DD> 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<DD; ++d) org1[dirs[d]] = ext.lower()[d];
- if (extent().contains(org1)) {
-
- for (bbox<int,DD>::iterator it=ext.begin(); it!=ext.end(); ++it) {
- ivect index(org);
- for (int d=0; d<DD; ++d) index[dirs[d]] = (*it)[d];
- os << time << " " << tl << " " << rl << " " << c << " " << ml
- << " ";
- for (int d=0; d<D; ++d) os << index[d] << " ";
- os << " " << coord_time << " ";
- for (int d=0; d<D; ++d) {
- if (extent().upper()[d] - extent().lower()[d] != 0) {
- os << coord_lower[d] + (index[d] - extent().lower()[d]) * (coord_upper[d] - coord_lower[d]) / (extent().upper()[d] - extent().lower()[d]) << " ";
- } else {
- os << coord_lower[d] << " ";
- }
- }
- os << " ";
- write_ascii_output_element (os, index);
- os << endl;
- for (int d=0; d<DD; ++d) {
- if (index[dirs[d]]!=extent().upper()[dirs[d]]) break;
- os << endl;
- }
- }
-
- } else {
-
- os << "#" << endl;
-
- } // if ! ext contains org
-
- assert (os.good());
-
- }
-
- } else {
- // copy to processor 0 and output there
-
- generic_data* const tmp = make_typed();
- tmp->allocate(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<int,3>& org, const vect<int,1>& dirs,
- const int tl, const int rl, const int c, const int ml,
- const double coord_time,
- const vect<double,3>& coord_lower,
- const vect<double,3>& coord_upper) const;
-template void generic_data<3>
-::write_ascii (ostream& os, const int time,
- const vect<int,3>& org, const vect<int,2>& dirs,
- const int tl, const int rl, const int c, const int ml,
- const double coord_time,
- const vect<double,3>& coord_lower,
- const vect<double,3>& coord_upper) const;
-template void generic_data<3>
-::write_ascii (ostream& os, const int time,
- const vect<int,3>& org, const vect<int,3>& dirs,
- const int tl, const int rl, const int c, const int ml,
- const double coord_time,
- const vect<double,3>& coord_lower,
- const vect<double,3>& 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<int DD>
- void write_ascii (ostream& os, const int time,
- const vect<int,D>& org, const vect<int,DD>& dirs,
- const int tl, const int rl,
- const int c, const int ml,
- const double ctime,
- const vect<double,D>& coord_lower,
- const vect<double,D>& 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:
};