From fa459d512e8e454f5fb69062f53cb6b0963b5959 Mon Sep 17 00:00:00 2001 From: Frank Löffler Date: Wed, 3 Apr 2013 15:35:19 -0500 Subject: make bool members of gridpoint_t class private, provide accessors and use them --- Carpet/Requirements/src/Requirements.cc | 106 +++++++++++++++++++++----------- 1 file changed, 69 insertions(+), 37 deletions(-) (limited to 'Carpet/Requirements') diff --git a/Carpet/Requirements/src/Requirements.cc b/Carpet/Requirements/src/Requirements.cc index f5a44b43d..a8f8269ca 100644 --- a/Carpet/Requirements/src/Requirements.cc +++ b/Carpet/Requirements/src/Requirements.cc @@ -58,22 +58,32 @@ namespace Requirements { // This will later be indexed by rl, map etc. // Currently only works with unigrid. class gridpoint_t { + bool i_interior, i_boundary, i_ghostzones, i_boundary_ghostzones; public: - bool interior, boundary, ghostzones, boundary_ghostzones; gridpoint_t(): - interior(false), boundary(false), ghostzones(false), - boundary_ghostzones(false) + i_interior(false), i_boundary(false), i_ghostzones(false), + i_boundary_ghostzones(false) {} // Construct an object with information about which points are // valid, assuming that a function with the given clause has just // been run gridpoint_t(clause_t const& clause): - interior(clause.everywhere or clause.interior), - boundary(clause.everywhere or clause.boundary), - ghostzones(clause.everywhere), - boundary_ghostzones(clause.everywhere or clause.boundary_ghostzones) + i_interior(clause.everywhere or clause.interior), + i_boundary(clause.everywhere or clause.boundary), + i_ghostzones(clause.everywhere), + i_boundary_ghostzones(clause.everywhere or clause.boundary_ghostzones) {} + // Accessors + bool interior() const; + bool boundary() const; + bool ghostzones() const; + bool boundary_ghostzones() const; + void set_interior(bool b); + void set_boundary(bool b); + void set_ghostzones(bool b); + void set_boundary_ghostzones(bool b); + void check_state(clause_t const& clause, cFunctionData const* function_data, int vi, int rl, int m, int tl) const; @@ -90,6 +100,28 @@ namespace Requirements { void output (ostream& os) const; }; + // Accessors + bool gridpoint_t::interior() const { return i_interior; } + bool gridpoint_t::boundary() const { return i_boundary; } + bool gridpoint_t::ghostzones() const { return i_ghostzones; } + bool gridpoint_t::boundary_ghostzones() const { return i_boundary_ghostzones; } + void gridpoint_t::set_interior(bool b) + { + i_interior = b; + } + void gridpoint_t::set_boundary(bool b) + { + i_boundary = b; + } + void gridpoint_t::set_ghostzones(bool b) + { + i_ghostzones = b; + } + void gridpoint_t::set_boundary_ghostzones(bool b) + { + i_boundary_ghostzones = b; + } + inline ostream& operator<< (ostream& os, const gridpoint_t& a) { a.output(os); return os; @@ -104,25 +136,25 @@ namespace Requirements { int const rl, int const m, int const tl) const { - if (not interior) { + if (not i_interior) { if (clause.everywhere or clause.interior) { report_error(function_data, vi, rl, m, tl, "calling function", "interior"); } } - if (not boundary) { + if (not i_boundary) { if (clause.everywhere or clause.boundary) { report_error(function_data, vi, rl, m, tl, "calling function", "boundary"); } } - if (not ghostzones) { + if (not i_ghostzones) { if (clause.everywhere) { report_error(function_data, vi, rl, m, tl, "calling function", "ghostzones"); } } - if (not boundary_ghostzones) { + if (not i_boundary_ghostzones) { if (clause.everywhere or clause.boundary_ghostzones) { report_error(function_data, vi, rl, m, tl, "calling", "boundary-ghostzones"); @@ -201,26 +233,26 @@ namespace Requirements { void gridpoint_t::update_state(clause_t const& clause) { if (clause.everywhere or clause.interior) { - interior = true; + set_interior(true); } if (clause.everywhere or clause.boundary) { - boundary = true; + set_boundary(true); } if (clause.everywhere) { - ghostzones = true; + set_ghostzones(true); } if (clause.everywhere or clause.boundary_ghostzones) { - boundary_ghostzones = true; + set_boundary_ghostzones(true); } } void gridpoint_t::output(ostream& os) const { os << "("; - if (interior) os << "interior;"; - if (boundary) os << "boundary;"; - if (ghostzones) os << "ghostzones;"; - if (boundary_ghostzones) os << "boundary_ghostzones;"; + if (i_interior) os << "interior;"; + if (i_boundary) os << "boundary;"; + if (i_ghostzones) os << "ghostzones;"; + if (i_boundary_ghostzones) os << "boundary_ghostzones;"; os << ")"; } @@ -572,13 +604,13 @@ namespace Requirements { gridpoint_t& gp = *itl; switch (where) { case valid::nowhere: - gp.interior = false; + gp.set_interior(false); // fall through case valid::interior: // Recomposing sets only the interior - gp.boundary = false; - gp.ghostzones = false; - gp.boundary_ghostzones = false; + gp.set_boundary(false); + gp.set_ghostzones(false); + gp.set_boundary_ghostzones(false); // fall through case valid::everywhere: // do nothing @@ -927,7 +959,7 @@ namespace Requirements { gridpoint_t& gp = tls.AT(tl); // Synchronising requires a valid interior - if (not gp.interior) { + if (not gp.interior()) { gp.report_error (function_data, vi, rl, m, tl, "synchronising", "interior"); } @@ -943,8 +975,8 @@ namespace Requirements { int const ctimelevels = int(ctls.size()); for (int ctl=0; ctl