From 2bfffa309ba1dfad58d0ff36ca168b1c62d5a6d2 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Wed, 17 Feb 2010 16:26:25 -0800 Subject: 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. --- Carpet/CarpetLib/src/dh.cc | 31 ++++++++++++++++++++++++++++++- Carpet/CarpetLib/src/dh.hh | 9 +++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'Carpet/CarpetLib/src') 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