aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2010-02-17 16:26:25 -0800
committerBarry Wardell <barry.wardell@gmail.com>2011-12-14 16:45:31 +0000
commit2bfffa309ba1dfad58d0ff36ca168b1c62d5a6d2 (patch)
tree859508ab280030584899f2992bf7ede26574d79a /Carpet/CarpetLib/src
parentcfae0901455ec6058613fe0a6a92ede157e2e6c3 (diff)
CarpetLib: Add field "active" to dh::dboxes
Add field "active" to dh::dboxes, the replicated part of the data hierarchy. Since bboxsets cannot be transmitted via MPI, this can contain only up to 4 bboxes. There are helper routines to transform bboxsets to these bboxes and back.
Diffstat (limited to 'Carpet/CarpetLib/src')
-rw-r--r--Carpet/CarpetLib/src/dh.cc31
-rw-r--r--Carpet/CarpetLib/src/dh.hh9
2 files changed, 39 insertions, 1 deletions
diff --git a/Carpet/CarpetLib/src/dh.cc b/Carpet/CarpetLib/src/dh.cc
index b18e1737f..d16fde8eb 100644
--- a/Carpet/CarpetLib/src/dh.cc
+++ b/Carpet/CarpetLib/src/dh.cc
@@ -1151,6 +1151,8 @@ regrid (bool const do_init)
level.AT(c).exterior = full_level.AT(c).exterior;
level.AT(c).owned = full_level.AT(c).owned;
level.AT(c).interior = full_level.AT(c).interior;
+ dh::dboxes::ibset2ibboxs (full_level.AT(c).active,
+ level.AT(c).active, level.AT(c).numactive);
level.AT(c).exterior_size = full_level.AT(c).exterior.size();
level.AT(c).owned_size = full_level.AT(c).owned.size();
@@ -1528,6 +1530,8 @@ mpi_datatype (dh::dboxes const &)
ENTRY(int, exterior),
ENTRY(int, owned),
ENTRY(int, interior),
+ ENTRY(int, numactive),
+ ENTRY(int, active),
ENTRY(dh::dboxes::size_type, exterior_size),
ENTRY(dh::dboxes::size_type, owned_size),
ENTRY(dh::dboxes::size_type, active_size),
@@ -1620,6 +1624,30 @@ allmemory ()
return mem;
}
+int const dh::dboxes::maxactive;
+
+void
+dh::dboxes::
+ibset2ibboxs (ibset const& s, ibbox* const bs, int& nbs)
+{
+ assert (s.setsize() <= maxactive);
+ nbs = 0;
+ for (ibset::const_iterator si = s.begin(); si != s.end(); ++si) {
+ bs[nbs++] = *si;
+ }
+}
+
+void
+dh::dboxes::
+ibboxs2ibset (ibbox const* const bs, int const& nbs, ibset& s)
+{
+ s = ibset();
+ assert (nbs>=0 and nbs<=maxactive);
+ for (int n=0; n<nbs; ++n) {
+ s += bs[n];
+ }
+}
+
size_t
dh::dboxes::
memory ()
@@ -1628,7 +1656,8 @@ memory ()
return
memoryof (exterior) +
memoryof (owned) +
- memoryof (interior);
+ memoryof (interior) +
+ memoryof (active);
}
size_t
diff --git a/Carpet/CarpetLib/src/dh.hh b/Carpet/CarpetLib/src/dh.hh
index 6d0b63007..d509f1bda 100644
--- a/Carpet/CarpetLib/src/dh.hh
+++ b/Carpet/CarpetLib/src/dh.hh
@@ -49,10 +49,19 @@ public:
ibbox owned; // evolved in time
ibbox interior; // interior (without ghost zones)
+ // TODO: Create a new datatype bboxarr for this? Or get rid of
+ // it?
+ int numactive;
+ static int const maxactive = 4;
+ ibbox active[maxactive]; // owned minus buffers
+
// Region statistics:
typedef ibbox::size_type size_type;
size_type exterior_size, owned_size, active_size;
+ static void ibset2ibboxs (ibset const& s, ibbox* bs, int& nbs);
+ static void ibboxs2ibset (ibbox const* bs, int const& nbs, ibset& s);
+
size_t memory () const CCTK_ATTRIBUTE_PURE;
istream & input (istream & is);
ostream & output (ostream & os) const;