From f010a361179a4a1e3e882a34b36cc4d39bf5c161 Mon Sep 17 00:00:00 2001 From: schnetter <> Date: Tue, 18 Mar 2003 16:30:00 +0000 Subject: Add normalize routine to normalise bboxsets. This isn't perfect yet, Add normalize routine to normalise bboxsets. This isn't perfect yet, i.e. it still misses some cases. Fix bug in calculating the regions that should be restricted to: exclude all regions used as source for boundary prolongations, even if these prolongations go to a different processor. darcs-hash:20030318163025-07bb3-1cfed59a57c2db71d3dae5528e93a570ccb13101.gz --- Carpet/CarpetLib/src/bboxset.cc | 64 +++++++++++++++++++++++++++++++++++++++-- Carpet/CarpetLib/src/defs.cc | 16 ++++++++++- Carpet/CarpetLib/src/defs.hh | 9 +++++- Carpet/CarpetLib/src/dh.cc | 16 ++++++----- Carpet/CarpetLib/src/vect.hh | 9 +++++- 5 files changed, 102 insertions(+), 12 deletions(-) (limited to 'Carpet/CarpetLib') diff --git a/Carpet/CarpetLib/src/bboxset.cc b/Carpet/CarpetLib/src/bboxset.cc index b440bb59d..4b7b7c831 100644 --- a/Carpet/CarpetLib/src/bboxset.cc +++ b/Carpet/CarpetLib/src/bboxset.cc @@ -1,9 +1,10 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bboxset.cc,v 1.12 2003/02/25 22:57:00 schnetter Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bboxset.cc,v 1.13 2003/03/18 17:30:25 schnetter Exp $ #include #include #include +#include #include "defs.hh" @@ -58,8 +59,67 @@ bool bboxset::invariant () const { // Normalisation template void bboxset::normalize () { - // TODO assert (invariant()); + const int num_initial_boxes = bs.size(); + int num_combined_boxes = 0; + stack todo, done; + for (typename set::const_iterator elt = bs.begin(); elt != bs.end(); ++elt) { + done.push (*elt); + } + // TODO: This will not catch all cases where bboxes can be combined. + for (int d=0; d(); + while (! todo.empty()) { + restart:; + box item = todo.top(); + todo.pop(); + stack work = done; + done = stack(); + while (! work.empty()) { + box comp = work.top(); + work.pop(); + { + assert (all(comp.stride() == item.stride())); + if (comp.upper()[d] + item.stride()[d] == item.lower()[d]) { + if (all((comp.lower() == item.lower() + && comp.upper() == item.upper()).replace (d, true))) { + box newbox = box(comp.lower(), item.upper(), item.stride()); + todo.push (newbox); + while (! work.empty()) { + done.push (work.top()); + work.pop(); + } + ++num_combined_boxes; + goto restart; + } + } + if (item.upper()[d] + item.stride()[d] == comp.lower()[d]) { + if (all((comp.lower() == item.lower() + && comp.upper() == item.upper()).replace (d, true))) { + box newbox = box(item.lower(), comp.upper(), item.stride()); + todo.push (newbox); + while (! work.empty()) { + done.push (work.top()); + work.pop(); + } + ++num_combined_boxes; + goto restart; + } + } + } + done.push (comp); + } // while work + done.push (item); + } // while todo + } // for d + bs.clear(); + while (! done.empty()) { + bs.insert (done.top()); + done.pop(); + } + const int num_final_boxes = bs.size(); + assert (num_initial_boxes - num_combined_boxes == num_final_boxes); } diff --git a/Carpet/CarpetLib/src/defs.cc b/Carpet/CarpetLib/src/defs.cc index 3309fb31c..19c79ae7d 100644 --- a/Carpet/CarpetLib/src/defs.cc +++ b/Carpet/CarpetLib/src/defs.cc @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.cc,v 1.14 2003/02/27 22:23:19 shawley Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.cc,v 1.15 2003/03/18 17:30:25 schnetter Exp $ #include #include @@ -6,6 +6,7 @@ #include #include #include +#include #include #include "defs.hh" @@ -71,6 +72,18 @@ ostream& output (ostream& os, const set& s) { return os; } +// Stack output +template +ostream& output (ostream& os, const stack& s) { + stack s2 (s); + list l; + while (! s2.empty()) { + l.insert (l.begin(), s2.top()); + s2.pop(); + } + return output (os, l); +} + // Vector output template ostream& output (ostream& os, const vector& v) { @@ -96,6 +109,7 @@ template istream& input (istream& os, vector,3> > >& v) template ostream& output (ostream& os, const list >& l); template ostream& output (ostream& os, const set >& s); template ostream& output (ostream& os, const set >& s); +template ostream& output (ostream& os, const stack >& s); template ostream& output (ostream& os, const vector& v); template ostream& output (ostream& os, const vector >& v); template ostream& output (ostream& os, const vector > >& v); diff --git a/Carpet/CarpetLib/src/defs.hh b/Carpet/CarpetLib/src/defs.hh index 4e3cab8d8..b948d7a9a 100644 --- a/Carpet/CarpetLib/src/defs.hh +++ b/Carpet/CarpetLib/src/defs.hh @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.hh,v 1.10 2003/01/03 15:49:36 schnetter Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.hh,v 1.11 2003/03/18 17:30:25 schnetter Exp $ #ifndef DEFS_HH #define DEFS_HH @@ -14,6 +14,7 @@ #include #include #include +#include #include using namespace std; @@ -121,6 +122,7 @@ inline istream& operator>> (istream& is, vector& v) { // Container output template ostream& output (ostream& os, const list& l); template ostream& output (ostream& os, const set& s); +template ostream& output (ostream& os, const stack& s); template ostream& output (ostream& os, const vector& v); template @@ -133,6 +135,11 @@ inline ostream& operator<< (ostream& os, const set& s) { return output(os,s); } +template +inline ostream& operator<< (ostream& os, const stack& s) { + return output(os,s); +} + template inline ostream& operator<< (ostream& os, const vector& v) { return output(os,v); diff --git a/Carpet/CarpetLib/src/dh.cc b/Carpet/CarpetLib/src/dh.cc index 7b856565a..02bfd4b03 100644 --- a/Carpet/CarpetLib/src/dh.cc +++ b/Carpet/CarpetLib/src/dh.cc @@ -1,4 +1,4 @@ -// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/dh.cc,v 1.26 2003/02/25 22:57:00 schnetter Exp $ +// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/dh.cc,v 1.27 2003/03/18 17:30:25 schnetter Exp $ #include @@ -260,13 +260,15 @@ void dh::recompose () { // (the restriction must not fill points that are used // to prolongate the boundaries) ibset recvs = intrf.contracted_for(intr) & intr; - const iblist& sendlist - = boxes[rl][c][ml].send_ref_bnd_fine[cc]; - for (typename iblist::const_iterator sli = sendlist.begin(); - sli != sendlist.end(); - ++sli) { - recvs -= *sli; + for (int ccc=0; ccc=0 && d