diff options
Diffstat (limited to 'Carpet/CarpetLib/src')
-rw-r--r-- | Carpet/CarpetLib/src/bbox.cc | 24 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/bbox.hh | 18 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/defs.cc | 40 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/defs.hh | 19 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gh.cc | 10 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/gh.hh | 30 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/vect.cc | 28 | ||||
-rw-r--r-- | Carpet/CarpetLib/src/vect.hh | 18 |
8 files changed, 166 insertions, 21 deletions
diff --git a/Carpet/CarpetLib/src/bbox.cc b/Carpet/CarpetLib/src/bbox.cc index 337857826..27c1e784f 100644 --- a/Carpet/CarpetLib/src/bbox.cc +++ b/Carpet/CarpetLib/src/bbox.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/bbox.cc,v 1.7 2001/07/02 13:22:11 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.8 2002/03/11 13:17:12 schnetter Exp $ ***************************************************************************/ @@ -225,6 +225,28 @@ bbox<T,D>::iterator bbox<T,D>::end () const { +// Input +template<class T,int D> +void bbox<T,D>::input (istream& is) { + skipws (is); + assert (is.peek() == '('); + is.get(); + is >> _lower; + skipws (is); + assert (is.peek() == ':'); + is.get(); + is >> _upper; + skipws (is); + assert (is.peek() == ':'); + is.get(); + is >> _stride; + skipws (is); + assert (is.peek() == ')'); + is.get(); +} + + + // Output template<class T,int D> void bbox<T,D>::output (ostream& os) const { diff --git a/Carpet/CarpetLib/src/bbox.hh b/Carpet/CarpetLib/src/bbox.hh index 160748f27..04db295db 100644 --- a/Carpet/CarpetLib/src/bbox.hh +++ b/Carpet/CarpetLib/src/bbox.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/bbox.hh,v 1.8 2001/03/27 22:26:31 eschnett Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.hh,v 1.9 2002/03/11 13:17:12 schnetter Exp $ ***************************************************************************/ @@ -33,7 +33,9 @@ using namespace std; // Forward declaration template<class T, int D> class bbox; -// Output +// Input/Output +template<class T, int D> +istream& operator>> (istream& is, bbox<T,D>& b); template<class T, int D> ostream& operator<< (ostream& os, const bbox<T,D>& b); @@ -116,12 +118,22 @@ public: iterator begin () const; iterator end () const; - // Output + // Input/Output + void input (istream& is); void output (ostream& os) const; }; +// Input +template<class T,int D> +inline istream& operator>> (istream& is, bbox<T,D>& b) { + b.input(is); + return is; +} + + + // Output template<class T,int D> inline ostream& operator<< (ostream& os, const bbox<T,D>& b) { diff --git a/Carpet/CarpetLib/src/defs.cc b/Carpet/CarpetLib/src/defs.cc index f862195d3..5a913beb0 100644 --- a/Carpet/CarpetLib/src/defs.cc +++ b/Carpet/CarpetLib/src/defs.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/defs.cc,v 1.8 2001/08/26 13:59:31 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.cc,v 1.9 2002/03/11 13:17:12 schnetter Exp $ ***************************************************************************/ @@ -19,6 +19,7 @@ ***************************************************************************/ #include <assert.h> +#include <ctype.h> #include <iostream> #include <list> @@ -33,6 +34,38 @@ using namespace std; +void skipws (istream& is) { + while (is.good() && isspace(is.peek())) { + is.get(); + } +} + + + +// Vector input +template<class T> +istream& input (istream& is, vector<T>& v) { + v.clear(); + skipws (is); + assert (is.peek() == '['); + is.get(); + skipws (is); + while (is.good() && is.peek() != ']') { + v.push_back (); + is >> v[v.size()-1]; + skipws (is); + if (is.peek() != ',') break; + is.get(); + skipws (is); + } + skipws (is); + assert (is.peek() == ']'); + is.get(); + return is; +} + + + // List output template<class T> ostream& output (ostream& os, const list<T>& l) { @@ -76,6 +109,10 @@ ostream& output (ostream& os, const vector<T>& v) { #include "bbox.hh" #include "bboxset.hh" +template istream& input (istream& os, vector<bbox<int,3> >& v); +template istream& input (istream& os, vector<vector<bbox<int,3> > >& v); +template istream& input (istream& os, vector<vector<vect<vect<bool,2>,3> > >& v); + template ostream& output (ostream& os, const list<bbox<int,3> >& l); template ostream& output (ostream& os, const set<bbox<int,3> >& s); template ostream& output (ostream& os, const set<bboxset<int,3> >& s); @@ -84,5 +121,6 @@ template ostream& output (ostream& os, const vector<bbox<int,3> >& v); template ostream& output (ostream& os, const vector<list<bbox<int,3> > >& v); template ostream& output (ostream& os, const vector<vector<int> >& v); template ostream& output (ostream& os, const vector<vector<bbox<int,3> > >& v); +template ostream& output (ostream& os, const vector<vector<vect<vect<bool,2>,3> > >& v); template ostream& output (ostream& os, const vector<vector<vector<bbox<int,3> > > >& v); #endif diff --git a/Carpet/CarpetLib/src/defs.hh b/Carpet/CarpetLib/src/defs.hh index a85b164c1..8f1810bcb 100644 --- a/Carpet/CarpetLib/src/defs.hh +++ b/Carpet/CarpetLib/src/defs.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/defs.hh,v 1.6 2002/01/09 13:56:26 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.hh,v 1.7 2002/03/11 13:17:13 schnetter Exp $ ***************************************************************************/ @@ -62,6 +62,23 @@ inline T ipow (const T& x, const int y) { } } + + +// Skip whitespace +void skipws (istream& is); + + + +// Container input +template<class T> istream& input (istream& is, vector<T>& v); + +template<class T> +inline istream& operator>> (istream& is, vector<T>& v) { + return input(is,v); +} + + + // Container output template<class T> ostream& output (ostream& os, const list<T>& l); template<class T> ostream& output (ostream& os, const set<T>& s); diff --git a/Carpet/CarpetLib/src/gh.cc b/Carpet/CarpetLib/src/gh.cc index 95bf16350..c0cd6df08 100644 --- a/Carpet/CarpetLib/src/gh.cc +++ b/Carpet/CarpetLib/src/gh.cc @@ -7,7 +7,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.cc,v 1.11 2002/01/09 13:56:27 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.cc,v 1.12 2002/03/11 13:17:13 schnetter Exp $ ***************************************************************************/ @@ -52,8 +52,10 @@ gh<D>::~gh () { } // Modifiers template<int D> -void gh<D>::recompose (const rexts& exts, const rprocs& procs) { +void gh<D>::recompose (const rexts& exts, const rbnds& outer_bounds, + const rprocs& procs) { extents = exts; + outer_boundaries = outer_bounds; processors = procs; // Consistency checks @@ -63,8 +65,10 @@ void gh<D>::recompose (const rexts& exts, const rprocs& procs) { // Check processor number consistency for (int rl=0; rl<reflevels(); ++rl) { assert (processors.size() == extents.size()); + assert (outer_boundaries.size() == extents.size()); for (int c=0; c<components(rl); ++c) { - assert (procs[rl].size() == extents[rl].size()); + assert (processors[rl].size() == extents[rl].size()); + assert (outer_boundaries[rl].size() == extents[rl].size()); } } diff --git a/Carpet/CarpetLib/src/gh.hh b/Carpet/CarpetLib/src/gh.hh index 4748fb1de..a1f917f95 100644 --- a/Carpet/CarpetLib/src/gh.hh +++ b/Carpet/CarpetLib/src/gh.hh @@ -7,7 +7,7 @@ copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu - $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.hh,v 1.8 2001/12/14 16:39:43 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gh.hh,v 1.9 2002/03/11 13:17:13 schnetter Exp $ ***************************************************************************/ @@ -56,19 +56,26 @@ public: typedef vect<int,D> ivect; typedef bbox<int,D> ibbox; - typedef vector<ibbox> mexts; // ... for each multigrid level - typedef vector<mexts> cexts; // ... for each component - typedef vector<cexts> rexts; // ... for each refinement level + typedef vect<vect<bool,2>,D> bvect; - typedef vector<int> cprocs; // ... for each component - typedef vector<cprocs> rprocs; // ... for each refinement level + typedef vector<ibbox> mexts; // ... for each multigrid level + typedef vector<mexts> cexts; // ... for each component + typedef vector<cexts> rexts; // ... for each refinement level + + typedef vector<bvect> cbnds; // ... for each component + typedef vector<cbnds> rbnds; // ... for each refinement level + + typedef vector<int> cprocs; // ... for each component + typedef vector<cprocs> rprocs; // ... for each refinement level public: // should be readonly ibbox baseextent; // bounds (inclusive) of base level vector<vector<ibbox> > bases; // [rl][ml] - rexts extents; // bounds of all grids + // TODO: invent structure for this + rexts extents; // extents of all grids + rbnds outer_boundaries; // boundary descriptions of all grids rprocs processors; // processor numbers of all grids list<dh<D>*> dhs; // list of all data hierarchies @@ -84,7 +91,8 @@ public: virtual ~gh (); // Modifiers - void recompose (const rexts& exts, const rprocs& procs); + void recompose (const rexts& exts, const rbnds& outer_bounds, + const rprocs& procs); // Helpers cexts make_reflevel_multigrid_boxes (const vector<ibbox>& exts, @@ -110,6 +118,12 @@ public: return (int)extents[rl][c].size(); } + bvect outer_boundary (const int rl, const int c) const { + assert (rl>=0 && rl<reflevels()); + assert (c>=0 && c<components(rl)); + return outer_boundaries[rl][c]; + } + int proc (const int rl, const int c) const { assert (rl>=0 && rl<reflevels()); assert (c>=0 && c<components(rl)); diff --git a/Carpet/CarpetLib/src/vect.cc b/Carpet/CarpetLib/src/vect.cc index 132e37afa..85a608ee9 100644 --- a/Carpet/CarpetLib/src/vect.cc +++ b/Carpet/CarpetLib/src/vect.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/vect.cc,v 1.6 2002/01/08 12:03:55 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.cc,v 1.7 2002/03/11 13:17:13 schnetter Exp $ ***************************************************************************/ @@ -32,13 +32,34 @@ using namespace std; +// Input +template<class T,int D> +void vect<T,D>::input (istream& is) { + skipws (is); + assert (is.peek() == '['); + is.get(); + for (int d=0; d<D; ++d) { + is >> (*this)[d]; + if (d<D-1) { + skipws (is); + assert (is.peek() == ','); + is.get(); + } + } + skipws (is); + assert (is.peek() == ']'); + is.get(); +} + + + // Output template<class T,int D> void vect<T,D>::output (ostream& os) const { os << "["; for (int d=0; d<D; ++d) { - if (d>0) os << ","; os << (*this)[d]; + if (d<D-1) os << ","; } os << "]"; } @@ -52,6 +73,9 @@ template class vect<int,1>; template class vect<int,2>; template class vect<int,3>; +template void vect<double,3>::input (istream& is); +template void vect<vect<bool,2>,3>::input (istream& is); template void vect<double,3>::output (ostream& os) const; +template void vect<vect<bool,2>,3>::output (ostream& os) const; #endif diff --git a/Carpet/CarpetLib/src/vect.hh b/Carpet/CarpetLib/src/vect.hh index f53038741..beee9608d 100644 --- a/Carpet/CarpetLib/src/vect.hh +++ b/Carpet/CarpetLib/src/vect.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/vect.hh,v 1.8 2002/01/09 17:45:42 schnetter Exp $ + $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.9 2002/03/11 13:17:13 schnetter Exp $ ***************************************************************************/ @@ -33,7 +33,9 @@ using namespace std; // Forward definition template<class T, int D> class vect; -// Output +// Input/Output +template<class T,int D> +istream& operator>> (istream& is, vect<T,D>& a); template<class T,int D> ostream& operator<< (ostream& os, const vect<T,D>& a); @@ -444,6 +446,8 @@ public: return r; } + // Input/Output + void input (istream& is); void output (ostream& os) const; }; @@ -598,6 +602,16 @@ inline vect<TT,D> scan1 (TT (* const func)(TT val, T x), TT val, +// Input +template<class T,int D> +inline istream& operator>> (istream& is, vect<T,D>& a) { + a.input(is); + return is; +} + + + +// Output template<class T,int D> inline ostream& operator<< (ostream& os, const vect<T,D>& a) { a.output(os); |