aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Carpet/CarpetLib/src/defs.cc16
-rw-r--r--Carpet/CarpetLib/src/dh.cc44
-rw-r--r--Carpet/CarpetLib/src/dh.hh13
-rw-r--r--Carpet/CarpetLib/src/gdata.cc8
-rw-r--r--Carpet/CarpetLib/src/gdata.hh5
-rw-r--r--Carpet/CarpetLib/src/ggf.cc13
-rw-r--r--Carpet/CarpetLib/src/ggf.hh7
-rw-r--r--Carpet/CarpetLib/src/gh.cc46
-rw-r--r--Carpet/CarpetLib/src/gh.hh19
-rw-r--r--Carpet/CarpetLib/src/th.cc16
-rw-r--r--Carpet/CarpetLib/src/th.hh4
11 files changed, 90 insertions, 101 deletions
diff --git a/Carpet/CarpetLib/src/defs.cc b/Carpet/CarpetLib/src/defs.cc
index 0bc1e5d48..7776a3ab8 100644
--- a/Carpet/CarpetLib/src/defs.cc
+++ b/Carpet/CarpetLib/src/defs.cc
@@ -340,26 +340,31 @@ template CCTK_REAL ipow (CCTK_REAL x, int y);
//template vect<int,dim> ipow (vect<int,dim> x, int y);
template vect<CCTK_REAL,dim> ipow (vect<CCTK_REAL,dim> x, int y);
+template size_t memoryof (rvect const & v);
//template size_t memoryof (list<ibbox> const & l);
//template size_t memoryof (list<ivect> const & l);
-template size_t memoryof (list<dh*> const & l);
-template size_t memoryof (list<gh*> const & l);
-template size_t memoryof (list<gdata*> const & l);
-template size_t memoryof (list<ggf*> const & l);
-template size_t memoryof (list<th*> const & l);
+template size_t memoryof (set<dh*> const & l);
+template size_t memoryof (set<gh*> const & l);
+template size_t memoryof (set<gdata*> const & l);
+template size_t memoryof (set<ggf*> const & l);
+template size_t memoryof (set<th*> const & l);
template size_t memoryof (stack<void*> const & s);
template size_t memoryof (vector<bool> const & v);
template size_t memoryof (vector<int> const & v);
//template size_t memoryof (vector<CCTK_REAL> const & v);
+template size_t memoryof (vector<dh*> const & v);
+template size_t memoryof (vector<gh*> const & v);
template size_t memoryof (vector<bbox<int,1> > const & v);
template size_t memoryof (vector<bbox<int,2> > const & v);
template size_t memoryof (vector<bbox<int,3> > const & v);
+template size_t memoryof (vector<rbbox> const & v);
template size_t memoryof (vector<bboxset1::bboxset<int,dim> > const & v);
#ifdef CARPET_ENABLE_BBOXSET2
template size_t memoryof (vector<bboxset2::bboxset<int,dim> > const & v);
#endif
template size_t memoryof (vector<ivect> const & v);
template size_t memoryof (vector<i2vect> const & v);
+template size_t memoryof (vector<rvect> const & v);
template size_t memoryof (vector<fulltree<int,dim,pseudoregion_t>*> const & f);
//template size_t memoryof (vector<pseudoregion_t> const & v);
//template size_t memoryof (vector<region_t> const & v);
@@ -367,6 +372,7 @@ template size_t memoryof (vector<sendrecv_pseudoregion_t> const & v);
template size_t memoryof (vector<vector<int> > const & v);
template size_t memoryof (vector<vector<CCTK_REAL> > const & v);
template size_t memoryof (vector<vector<ibbox> > const & v);
+template size_t memoryof (vector<vector<rvect> > const & v);
template size_t memoryof (vector<vector<dh::fast_dboxes> > const & v);
//template size_t memoryof (vector<vector<dh::full_dboxes> > const & v);
template size_t memoryof (vector<vector<dh::level_dboxes> > const & v);
diff --git a/Carpet/CarpetLib/src/dh.cc b/Carpet/CarpetLib/src/dh.cc
index 5eaa49cf9..44a87c0fd 100644
--- a/Carpet/CarpetLib/src/dh.cc
+++ b/Carpet/CarpetLib/src/dh.cc
@@ -23,7 +23,7 @@ using namespace CarpetLib;
-list<dh*> dh::alldh;
+set<dh*> dh::alldh;
@@ -120,8 +120,8 @@ dh (gh & h_,
assert (prolongation_orders_space.AT(rl) >= 0);
}
- alldhi = alldh.insert(alldh.end(), this);
- gh_handle = h.add (this);
+ alldh.insert(this);
+ h.insert (this);
CHECKPOINT;
regrid (false);
for (int rl = 0; rl < h.reflevels(); ++ rl) {
@@ -137,8 +137,9 @@ dh::
~dh ()
{
CHECKPOINT;
- h.erase (gh_handle);
- alldh.erase(alldhi);
+ assert (gfs.empty());
+ h.erase (this);
+ alldh.erase (this);
}
@@ -2114,8 +2115,7 @@ regrid (bool const do_init)
cout << "memoryof(dh.fast_boxes)=" << memoryof(fast_boxes) << eol;
int gfcount = 0;
size_t gfmemory = 0;
- for (list<ggf*>::const_iterator
- gfi = gfs.begin(); gfi != gfs.end(); ++ gfi)
+ for (set<ggf*>::const_iterator gfi = gfs.begin(); gfi != gfs.end(); ++ gfi)
{
++ gfcount;
gfmemory += memoryof(**gfi);
@@ -2200,39 +2200,39 @@ recompose (int const rl, bool const do_prolongate)
static Carpet::Timer timer ("CarpetLib::dh::recompose");
timer.start ();
- for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
+ for (set<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
(*f)->recompose_crop ();
}
if (combine_recompose) {
// Recompose all grid functions of this refinement levels at once.
// This may be faster, but requires more memory.
- for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
+ for (set<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
(*f)->recompose_allocate (rl);
}
// TODO: If this works, rename do_prolongate to do_init here, and
// remove the do_prolongate parameter from ggf::recompose_fill
#if 0
for (comm_state state; not state.done(); state.step()) {
- for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
+ for (set<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
(*f)->recompose_fill (state, rl, do_prolongate);
}
}
#endif
if (do_prolongate) {
for (comm_state state; not state.done(); state.step()) {
- for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
+ for (set<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
(*f)->recompose_fill (state, rl, true);
}
}
}
- for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
+ for (set<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
(*f)->recompose_free_old (rl);
}
} else {
// Recompose the grid functions sequentially. This may be slower,
// but requires less memory. This is the default.
- for (list<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
+ for (set<ggf*>::iterator f=gfs.begin(); f!=gfs.end(); ++f) {
(*f)->recompose_allocate (rl);
#if 0
for (comm_state state; not state.done(); state.step()) {
@@ -2254,20 +2254,20 @@ recompose (int const rl, bool const do_prolongate)
// Grid function management
-dh::ggf_handle
+void
dh::
-add (ggf * const f)
+insert (ggf * const f)
{
CHECKPOINT;
- return gfs.insert (gfs.end(), f);
+ gfs.insert (f);
}
void
dh::
-erase (ggf_handle const fi)
+erase (ggf * const f)
{
CHECKPOINT;
- gfs.erase (fi);
+ gfs.erase (f);
}
@@ -2397,9 +2397,6 @@ memory ()
const
{
return
- sizeof alldhi + // memoryof (alldhi) +
- sizeof & h + // memoryof (& h) +
- sizeof gh_handle + // memoryof (gh_handle) +
memoryof (ghost_widths) +
memoryof (buffer_widths) +
memoryof (overlap_widths) +
@@ -2416,8 +2413,7 @@ dh::
allmemory ()
{
size_t mem = memoryof(alldh);
- for (list<dh*>::const_iterator
- dhi = alldh.begin(); dhi != alldh.end(); ++ dhi)
+ for (set<dh*>::const_iterator dhi = alldh.begin(); dhi != alldh.end(); ++ dhi)
{
mem += memoryof(**dhi);
}
@@ -2754,7 +2750,7 @@ output (ostream & os)
<< "gfs={";
{
bool isfirst = true;
- for (list<ggf*>::const_iterator
+ for (set<ggf*>::const_iterator
f = gfs.begin(); f != gfs.end(); ++ f, isfirst = false)
{
if (not isfirst) os << ",";
diff --git a/Carpet/CarpetLib/src/dh.hh b/Carpet/CarpetLib/src/dh.hh
index 2a03ceccc..b558b013f 100644
--- a/Carpet/CarpetLib/src/dh.hh
+++ b/Carpet/CarpetLib/src/dh.hh
@@ -4,7 +4,7 @@
#include <cassert>
#include <cstdlib>
#include <iostream>
-#include <list>
+#include <set>
#include <string>
#include <vector>
@@ -29,8 +29,7 @@ class dh;
// A data hierarchy (grid hierarchy plus ghost zones)
class dh {
- static list<dh*> alldh;
- list<dh*>::iterator alldhi;
+ static set<dh*> alldh;
// Types
public:
@@ -232,7 +231,6 @@ public: // should be readonly
// Fields
gh & h; // hierarchy
- gh::dh_handle gh_handle;
#if 0
i2vect ghost_width; // number of ghost zones
@@ -250,8 +248,7 @@ public: // should be readonly
level_mboxes level_boxes; // grid hierarchy [ml][rl]
fast_mboxes fast_boxes; // grid hierarchy [ml][rl][p]
- typedef list<ggf*>::iterator ggf_handle;
- list<ggf*> gfs; // list of all grid functions
+ set<ggf*> gfs; // all grid functions
public:
@@ -288,8 +285,8 @@ private:
public:
// Grid function management
- ggf_handle add (ggf * f);
- void erase (ggf_handle fi);
+ void insert (ggf * f);
+ void erase (ggf * f);
// Output
size_t memory () const CCTK_MEMBER_ATTRIBUTE_PURE;
diff --git a/Carpet/CarpetLib/src/gdata.cc b/Carpet/CarpetLib/src/gdata.cc
index ecc8c4ba8..2226a5b07 100644
--- a/Carpet/CarpetLib/src/gdata.cc
+++ b/Carpet/CarpetLib/src/gdata.cc
@@ -79,7 +79,7 @@ template MPI_Datatype mpi_datatype (slab<int,dim> const&);
-list<gdata*> gdata::allgdata;
+set<gdata*> gdata::allgdata;
@@ -96,7 +96,7 @@ gdata::gdata (const int varindex_,
{
DECLARE_CCTK_PARAMETERS;
- allgdatai = allgdata.insert(allgdata.end(), this);
+ allgdata.insert(this);
if (barriers) {
dist::barrier (dist::comm(), 783988953, "CarpetLib::gdata::gdata");
@@ -108,7 +108,7 @@ gdata::~gdata ()
{
DECLARE_CCTK_PARAMETERS;
- allgdata.erase(allgdatai);
+ allgdata.erase(this);
if (barriers) {
dist::barrier (dist::comm(), 109687805, "CarpetLib::gdata::~gdata");
@@ -463,7 +463,7 @@ gdata::
allmemory ()
{
size_t mem = memoryof(allgdata);
- for (list<gdata*>::const_iterator
+ for (set<gdata*>::const_iterator
gdatai = allgdata.begin(); gdatai != allgdata.end(); ++ gdatai)
{
mem += memoryof(**gdatai);
diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh
index 230a6583c..086d84b28 100644
--- a/Carpet/CarpetLib/src/gdata.hh
+++ b/Carpet/CarpetLib/src/gdata.hh
@@ -51,9 +51,8 @@ namespace dist {
// A generic data storage without type information
class gdata {
- static list<gdata*> allgdata;
- list<gdata*>::iterator allgdatai;
-
+ static set<gdata*> allgdata;
+
protected: // should be readonly
// Fields
diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc
index 0f5015897..ebc81cb6d 100644
--- a/Carpet/CarpetLib/src/ggf.cc
+++ b/Carpet/CarpetLib/src/ggf.cc
@@ -21,7 +21,7 @@ using namespace CarpetLib;
-list<ggf*> ggf::allggf;
+set<ggf*> ggf::allggf;
@@ -50,15 +50,14 @@ ggf::ggf (const int varindex_, const operator_type transport_operator_,
timelevels_.AT(ml).resize(d.h.reflevels(), 0);
}
- allggfi = allggf.insert(allggf.end(), this);
-
- dh_handle = d.add(this);
+ allggf.insert (this);
+ d.insert (this);
}
// Destructors
ggf::~ggf () {
- d.erase(dh_handle);
- allggf.erase(allggfi);
+ d.erase (this);
+ allggf.erase (this);
}
// Comparison
@@ -663,7 +662,7 @@ ggf::
allmemory ()
{
size_t mem = memoryof(allggf);
- for (list<ggf*>::const_iterator
+ for (set<ggf*>::const_iterator
ggfi = allggf.begin(); ggfi != allggf.end(); ++ ggfi)
{
mem += memoryof(**ggfi);
diff --git a/Carpet/CarpetLib/src/ggf.hh b/Carpet/CarpetLib/src/ggf.hh
index 2e8b9f4ad..d55deb270 100644
--- a/Carpet/CarpetLib/src/ggf.hh
+++ b/Carpet/CarpetLib/src/ggf.hh
@@ -5,6 +5,7 @@
#include <cassert>
#include <iostream>
+#include <set>
#include <string>
#include <vector>
@@ -29,9 +30,8 @@ ostream& operator<< (ostream& os, const ggf& f);
// A generic grid function without type information
class ggf {
- static list<ggf*> allggf;
- list<ggf*>::iterator allggfi;
-
+ static set<ggf*> allggf;
+
// Types
typedef vector <pseudoregion_t> pvect;
typedef vector <sendrecv_pseudoregion_t> srpvect;
@@ -53,7 +53,6 @@ public: // should be readonly
const gh &h; // grid hierarchy
dh &d; // data hierarchy
- dh::ggf_handle dh_handle;
protected:
vector<vector<int> > timelevels_; // time levels [ml][rl]
diff --git a/Carpet/CarpetLib/src/gh.cc b/Carpet/CarpetLib/src/gh.cc
index 3659f977c..5c13d0b6a 100644
--- a/Carpet/CarpetLib/src/gh.cc
+++ b/Carpet/CarpetLib/src/gh.cc
@@ -19,7 +19,7 @@ using namespace std;
-list<gh*> gh::allgh;
+set<gh*> gh::allgh;
@@ -70,14 +70,14 @@ gh (vector<ivect> const & reffacts_, centering const refcent_,
}
}
- allghi = allgh.insert(allgh.end(), this);
+ allgh.insert (this);
}
// Destructors
gh::
~gh ()
{
- allgh.erase(allghi);
+ allgh.erase (this);
}
@@ -233,11 +233,11 @@ regrid (rregs const & superregs, mregs const & regs, bool const do_init)
// Regrid the other hierarchies
- for (list<th*>::iterator t=ths.begin(); t!=ths.end(); ++t) {
+ for (set<th*>::iterator t=ths.begin(); t!=ths.end(); ++t) {
(*t)->regrid();
}
- for (list<dh*>::iterator d=dhs.begin(); d!=dhs.end(); ++d) {
+ for (set<dh*>::iterator d=dhs.begin(); d!=dhs.end(); ++d) {
(*d)->regrid(do_init);
}
@@ -254,11 +254,11 @@ regrid_free (bool const do_init)
old_global_components_.clear();
old_local_components_.clear();
- for (list<th*>::iterator t=ths.begin(); t!=ths.end(); ++t) {
+ for (set<th*>::iterator t=ths.begin(); t!=ths.end(); ++t) {
(*t)->regrid_free();
}
- for (list<dh*>::iterator d=dhs.begin(); d!=dhs.end(); ++d) {
+ for (set<dh*>::iterator d=dhs.begin(); d!=dhs.end(); ++d) {
(*d)->regrid_free(do_init);
}
}
@@ -275,7 +275,7 @@ recompose (int const rl,
if (do_recompose) {
// Recompose the other hierarchies
- for (list<dh*>::iterator d=dhs.begin(); d!=dhs.end(); ++d) {
+ for (set<dh*>::iterator d=dhs.begin(); d!=dhs.end(); ++d) {
(*d)->recompose (rl, do_prolongate);
}
@@ -454,7 +454,7 @@ locate_position (rvect const & rpos,
// Find associated dh
assert (dhs.size() == 1);
- dh const& dd = *dhs.front();
+ dh const& dd = **dhs.begin();
// Try finer levels first
for (rl = maxrl-1; rl >= minrl; --rl) {
@@ -515,7 +515,7 @@ locate_position (ivect const & ipos,
// Find associated dh
assert (dhs.size() == 1);
- dh const& dd = *dhs.front();
+ dh const& dd = **dhs.begin();
// Try finer levels first
for (rl = maxrl-1; rl >= minrl; --rl) {
@@ -566,36 +566,36 @@ locate_position (ivect const & ipos,
// Time hierarchy management
-gh::th_handle
+void
gh::
-add (th * const t)
+insert (th * const t)
{
- return ths.insert(ths.end(), t);
+ ths.insert(t);
}
void
gh::
-erase (th_handle const ti)
+erase (th * const t)
{
- ths.erase(ti);
+ ths.erase(t);
}
// Data hierarchy management
-gh::dh_handle
+void
gh::
-add (dh * const d)
+insert (dh * const d)
{
- return dhs.insert(dhs.end(), d);
+ dhs.insert(d);
}
void
gh::
-erase (dh_handle di)
+erase (dh * const d)
{
- dhs.erase (di);
+ dhs.erase(d);
}
@@ -608,7 +608,6 @@ memory ()
const
{
return
- sizeof allghi + // memoryof (allghi) +
memoryof (reffacts) +
memoryof (refcent) +
memoryof (mgfact) +
@@ -630,8 +629,7 @@ gh::
allmemory ()
{
size_t mem = memoryof(allgh);
- for (list<gh*>::const_iterator
- ghi = allgh.begin(); ghi != allgh.end(); ++ ghi)
+ for (set<gh*>::const_iterator ghi = allgh.begin(); ghi != allgh.end(); ++ ghi)
{
mem += memoryof(**ghi);
}
@@ -692,7 +690,7 @@ output (ostream & os)
<< "dhs={";
{
bool isfirst = true;
- for (list<dh*>::const_iterator
+ for (set<dh*>::const_iterator
d = dhs.begin(); d != dhs.end(); ++ d, isfirst = false)
{
if (not isfirst) os << ",";
diff --git a/Carpet/CarpetLib/src/gh.hh b/Carpet/CarpetLib/src/gh.hh
index ef6198e0f..8c59c7073 100644
--- a/Carpet/CarpetLib/src/gh.hh
+++ b/Carpet/CarpetLib/src/gh.hh
@@ -3,7 +3,7 @@
#include <cassert>
#include <iostream>
-#include <list>
+#include <set>
#include <vector>
#include "bbox.hh"
@@ -28,8 +28,7 @@ class gh;
// level. The extents do not include ghost zones.
class gh {
- static list<gh*> allgh;
- list<gh*>::iterator allghi;
+ static set<gh*> allgh;
public:
@@ -64,10 +63,8 @@ public:
mregs regions; // extents and properties of all grids
mregs oldregions; // extents and properties of all grids
- typedef list<th*>::iterator th_handle;
- list<th*> ths; // list of all time hierarchies
- typedef list<dh*>::iterator dh_handle;
- list<dh*> dhs; // list of all data hierarchies
+ set<th*> ths; // all time hierarchies
+ set<dh*> dhs; // all data hierarchies
public:
@@ -179,12 +176,12 @@ public:
CCTK_MEMBER_ATTRIBUTE_PURE;
// Time hierarchy management
- th_handle add (th * t);
- void erase (th_handle ti);
+ void insert (th * t);
+ void erase (th * t);
// Data hierarchy management
- dh_handle add (dh * d);
- void erase (dh_handle di);
+ void insert (dh * d);
+ void erase (dh * d);
// Output
size_t memory () const CCTK_MEMBER_ATTRIBUTE_PURE;
diff --git a/Carpet/CarpetLib/src/th.cc b/Carpet/CarpetLib/src/th.cc
index 9817e77bb..33c748e51 100644
--- a/Carpet/CarpetLib/src/th.cc
+++ b/Carpet/CarpetLib/src/th.cc
@@ -14,7 +14,7 @@ using namespace std;
-list<th*> th::allth;
+set<th*> th::allth;
@@ -27,8 +27,8 @@ th::th (gh& h_,
timelevels(0)
{
reffacts.resize(1, 1);
- allthi = allth.insert(allth.end(), this);
- gh_handle = h.add(this);
+ allth.insert(this);
+ h.insert(this);
}
th::th (gh& h_, int const timelevels_, vector<int> const& reffacts_,
@@ -44,15 +44,15 @@ th::th (gh& h_, int const timelevels_, vector<int> const& reffacts_,
assert (reffacts.AT(n) >= reffacts.AT(n-1));
assert (reffacts.AT(n) % reffacts.AT(n-1) == 0);
}
- allthi = allth.insert(allth.end(), this);
- gh_handle = h.add(this);
+ allth.insert(this);
+ h.insert(this);
}
// Destructors
th::~th ()
{
- h.erase(gh_handle);
- allth.erase(allthi);
+ h.erase(this);
+ allth.erase(this);
}
// Modifiers
@@ -187,7 +187,7 @@ th::
allmemory ()
{
size_t mem = memoryof(allth);
- for (list<th*>::const_iterator
+ for (set<th*>::const_iterator
thi = allth.begin(); thi != allth.end(); ++ thi)
{
mem += memoryof(**thi);
diff --git a/Carpet/CarpetLib/src/th.hh b/Carpet/CarpetLib/src/th.hh
index d925aeab4..12c7733b9 100644
--- a/Carpet/CarpetLib/src/th.hh
+++ b/Carpet/CarpetLib/src/th.hh
@@ -28,14 +28,12 @@ ostream& operator<< (ostream& os, const th& t);
// The time hierarchy (information about the current time)
class th {
- static list<th*> allth;
- list<th*>::iterator allthi;
+ static set<th*> allth;
public: // should be readonly
// Fields
gh& h; // hierarchy
- gh::th_handle gh_handle;
bool const time_interpolation_during_regridding;