From 0dec47fc1cae30794ac565b0d0b42dba3d9d2e8a Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Thu, 13 Apr 2006 19:26:00 +0000 Subject: CarpetLib: Store number of time levels per refinement level Store the number of active time levels per refinement level, not globally, because each refinement level can have a different number of active time levels. darcs-hash:20060413192655-dae7b-be12d1baef21b3f0a24bbb022297a4856c7d6f14.gz --- Carpet/CarpetLib/src/gf.cc | 6 ++-- Carpet/CarpetLib/src/ggf.cc | 87 ++++++++++++++++++++++++--------------------- Carpet/CarpetLib/src/ggf.hh | 9 +++-- 3 files changed, 54 insertions(+), 48 deletions(-) (limited to 'Carpet/CarpetLib') diff --git a/Carpet/CarpetLib/src/gf.cc b/Carpet/CarpetLib/src/gf.cc index cc51697fd..26fa00f38 100644 --- a/Carpet/CarpetLib/src/gf.cc +++ b/Carpet/CarpetLib/src/gf.cc @@ -54,20 +54,20 @@ gf::~gf () template const data* gf::operator() (int tl, int rl, int c, int ml) const { - assert (tl>=0 and tl=0 and rl=0 and c=0 and ml=0 and tl*)storage.at(ml).at(rl).at(c).at(tl); } template data* gf::operator() (int tl, int rl, int c, int ml) { - assert (tl>=0 and tl=0 and rl=0 and c=0 and ml=0 and tl*)storage.at(ml).at(rl).at(c).at(tl); } @@ -80,7 +80,7 @@ ostream& gf::output (ostream& os) const T Tdummy; os << "gf<" << typestring(Tdummy) << ">:" << varindex << "[" << CCTK_VarName(varindex) << "]," - << "tls=" << timelevels(); + << "tls=" << timelevels_; return os; } diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc index d360ddf23..428346de9 100644 --- a/Carpet/CarpetLib/src/ggf.cc +++ b/Carpet/CarpetLib/src/ggf.cc @@ -25,7 +25,6 @@ ggf::ggf (const int varindex_, const operator_type transport_operator_, : varindex(varindex_), transport_operator(transport_operator_), t(t_), prolongation_order_time(prolongation_order_time_), h(d_.h), d(d_), - timelevels_(0), storage(h.mglevels()), vectorlength(vectorlength_), vectorindex(vectorindex_), vectorleader(vectorleader_) @@ -37,6 +36,11 @@ ggf::ggf (const int varindex_, const operator_type transport_operator_, assert ((vectorindex==0 and !vectorleader) or (vectorindex!=0 and vectorleader)); + timelevels_.resize(d.h.mglevels()); + for (int ml=0; ml= 0); - if (new_timelevels < timelevels()) { + if (new_timelevels < timelevels(ml,rl)) { for (int c=0; c<(int)storage.at(ml).at(rl).size(); ++c) { - for (int tl=new_timelevels; tl timelevels()) { + } else if (new_timelevels > timelevels(ml,rl)) { for (int c=0; c<(int)storage.at(ml).at(rl).size(); ++c) { storage.at(ml).at(rl).at(c).resize (new_timelevels); - for (int tl=timelevels(); tlallocate (d.boxes.at(ml).at(rl).at(c).exterior, h.proc(rl,c)); @@ -82,7 +86,7 @@ void ggf::set_timelevels (const int ml, const int rl, const int new_timelevels) } - timelevels_ = new_timelevels; + timelevels_.at(ml).at(rl) = new_timelevels; } @@ -110,8 +114,8 @@ bool ggf::recompose_did_change (const int rl) const if (storage.at(ml).size() <= rl) return true; if (storage.at(ml).at(rl).size() != h.components(rl)) return true; for (int c=0; cextent(); if (haveextent != wantextent) return true; @@ -134,14 +138,18 @@ void ggf::recompose_allocate (const int rl) storage.at(ml).at(rl).resize(0); } + for (int ml=0; mlallocate (d.boxes.at(ml).at(rl).at(c).exterior, h.proc(rl,c)); @@ -156,7 +164,7 @@ void ggf::recompose_fill (comm_state& state, const int rl, // Initialise the new storage for (int ml=0; ml= numtl); + assert (timelevels(ml,rl) >= numtl); vector tls(numtl); vector times(numtl); for (int i=0; i0) { for (int ml=0; ml=0 and rl=0 and c=0 and ml0; --tl) { + gdata* tmpdata = storage.at(ml).at(rl).at(c).at(timelevels(ml,rl)-1); + for (int tl=timelevels(ml,rl)-1; tl>0; --tl) { storage.at(ml).at(rl).at(c).at(tl) = storage.at(ml).at(rl).at(c).at(tl-1); } storage.at(ml).at(rl).at(c).at(0) = tmpdata; @@ -305,9 +313,9 @@ void ggf::flip (int rl, int c, int ml) { assert (rl>=0 and rl=0 and c=0 and ml=0 and tl1=0 and rl1=0 and c1=0 and ml1=0 and tl2=0 and tl1=0 and rl2=0 and tl2=0 and tl1=0 and rl1=0 and c1=0 and ml1=0 and tl1=0 and tl2=0 and rl2=0 and tl2=0 and tl1=0 and rl1=0 and c1=0 and ml1=0 and tl1=0 and tl2=0 and rl2=0 and tl2 tl2s, int rl2, int ml2, CCTK_REAL time) { - assert (tl1>=0 and tl1=0 and rl1=0 and c1=0 and ml1=0 and tl2s.at(i)=0 and tl1=0 and rl2=0 and ml2=0 and tl2s.at(i) gsrcs(tl2s.size()); vector times(tl2s.size()); @@ -431,16 +439,16 @@ void ggf::intercat (comm_state& state, const vector tl2s, int rl2, int ml2, const CCTK_REAL time) { - assert (tl1>=0 and tl1=0 and rl1=0 and c1=0 and ml1=0 and tl2s.at(i)=0 and tl1=0 and rl2=0 and ml2=0 and tl2s.at(i) gsrcs(tl2s.size()); vector times(tl2s.size()); @@ -468,14 +476,14 @@ void ggf::intercat (comm_state& state, const vector tl2s, int rl2, int ml2, const CCTK_REAL time) { - assert (tl1>=0 and tl1=0 and rl1=0 and c1=0 and ml1=0 and tl1=0 and rl2=0 and tl2s.at(i)=0 and tl2s.at(i)=0 and rl2=0 and ml2 tl2s; if (transport_operator != op_copy) { // Interpolation in time -if (timelevels() < prolongation_order_time+1) fprintf (stderr, "got '%s' with %d timelevels order %d\n", CCTK_FullName (varindex), timelevels(), prolongation_order_time); - assert (timelevels() >= prolongation_order_time+1); + assert (timelevels(ml,rl) >= prolongation_order_time+1); tl2s.resize(prolongation_order_time+1); for (int i=0; i<=prolongation_order_time; ++i) tl2s.at(i) = i; } else { - assert (timelevels() >= 1); + assert (timelevels(ml,rl) >= 1); tl2s.resize(1); tl2s.at(0) = 0; } @@ -599,7 +606,7 @@ void ggf::ref_prolongate (comm_state& state, if (transport_operator == op_none) return; vector tl2s; // Interpolation in time - assert (timelevels() >= prolongation_order_time+1); + assert (timelevels(ml,rl) >= prolongation_order_time+1); tl2s.resize(prolongation_order_time+1); for (int i=0; i<=prolongation_order_time; ++i) tl2s.at(i) = i; intercat (state, diff --git a/Carpet/CarpetLib/src/ggf.hh b/Carpet/CarpetLib/src/ggf.hh index 88fbadf07..5a2bab361 100644 --- a/Carpet/CarpetLib/src/ggf.hh +++ b/Carpet/CarpetLib/src/ggf.hh @@ -51,10 +51,9 @@ public: // should be readonly const gh &h; // grid hierarchy dh &d; // data hierarchy -private: - int timelevels_; // time levels - protected: + vector > timelevels_; // time levels + mdata storage; // storage public: @@ -81,9 +80,9 @@ public: bool operator== (const ggf& f) const; // Querying - int timelevels () const + int timelevels (int const ml, int const rl) const { - return timelevels_; + return timelevels_.at(ml).at(rl); } -- cgit v1.2.3