From d41c0c9cc79dbddf6442e344615e2c36b127d99b Mon Sep 17 00:00:00 2001 From: Frank Löffler Date: Wed, 3 Apr 2013 20:51:29 -0500 Subject: use parameter to enable output if state of variable changes --- Carpet/Requirements/param.ccl | 4 ++ Carpet/Requirements/src/Requirements.cc | 110 +++++++++++++++++++++++++------- 2 files changed, 90 insertions(+), 24 deletions(-) (limited to 'Carpet/Requirements') diff --git a/Carpet/Requirements/param.ccl b/Carpet/Requirements/param.ccl index 48759832b..e4b19dd72 100644 --- a/Carpet/Requirements/param.ccl +++ b/Carpet/Requirements/param.ccl @@ -16,3 +16,7 @@ STRING ignore_these_variables "Assume that these variables are always valid ever { "([A-Za-z0-9_]+[:][:][A-Za-z0-9_]+([[:space:]]+|$))*" :: "space separated list of variables or groups" } "" + +BOOLEAN print_changes "Enable debug output about when regions get set/unset" STEERABLE=always +{ +} "no" diff --git a/Carpet/Requirements/src/Requirements.cc b/Carpet/Requirements/src/Requirements.cc index bfe06fbd0..7be2ff549 100644 --- a/Carpet/Requirements/src/Requirements.cc +++ b/Carpet/Requirements/src/Requirements.cc @@ -62,8 +62,24 @@ namespace Requirements { location_t(int _vi, int _tl, int _rl, int _m): vi(_vi), tl(_tl), rl(_rl), m(_m) {} + // Output helper + void output (ostream& os) const; }; + inline ostream& operator<< (ostream& os, const location_t& a) { + a.output(os); + return os; + } + + void location_t::output(ostream& os) const + { + os << "LOC: "; + os << "vi:" << vi << ","; + os << "[rl:" << rl << ","; + os << "tl:" << tl << ","; + os << "m:" << m << "]"; + } + // Represents which have valid information and which do not. // This will later be indexed by rl, map etc. // Currently only works with unigrid. @@ -89,10 +105,10 @@ namespace Requirements { 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 set_interior(bool b, location_t &l); + void set_boundary(bool b, location_t &l); + void set_ghostzones(bool b, location_t &l); + void set_boundary_ghostzones(bool b, location_t &l); void check_state(clause_t const& clause, cFunctionData const* function_data, @@ -103,11 +119,12 @@ namespace Requirements { void report_warning(cFunctionData const* function_data, int vi, int rl, int m, int tl, char const* what, char const* where) const; - void update_state(clause_t const& clause); + void update_state(clause_t const& clause, location_t &loc); // Input/Output helpers void input (istream& is); void output (ostream& os) const; + void output_location (location_t &l, int changed) const; }; // Accessors @@ -115,20 +132,32 @@ namespace Requirements { 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) + void gridpoint_t::set_interior(bool b, location_t &l) { + if (i_interior == b) + return; + output_location(l, 1); i_interior = b; } - void gridpoint_t::set_boundary(bool b) + void gridpoint_t::set_boundary(bool b, location_t &l) { + if (i_boundary == b) + return; + output_location(l, 2); i_boundary = b; } - void gridpoint_t::set_ghostzones(bool b) + void gridpoint_t::set_ghostzones(bool b, location_t &l) { + if (i_ghostzones == b) + return; + output_location(l, 4); i_ghostzones = b; } - void gridpoint_t::set_boundary_ghostzones(bool b) + void gridpoint_t::set_boundary_ghostzones(bool b, location_t &l) { + if (i_boundary_ghostzones == b) + return; + output_location(l, 8); i_boundary_ghostzones = b; } @@ -241,19 +270,19 @@ namespace Requirements { // Update this object to reflect the fact that some parts of some // variables are now valid after a function has been called - void gridpoint_t::update_state(clause_t const& clause) + void gridpoint_t::update_state(clause_t const& clause, location_t &loc) { if (clause.everywhere or clause.interior) { - set_interior(true); + set_interior(true, loc); } if (clause.everywhere or clause.boundary) { - set_boundary(true); + set_boundary(true, loc); } if (clause.everywhere) { - set_ghostzones(true); + set_ghostzones(true, loc); } if (clause.everywhere or clause.boundary_ghostzones) { - set_boundary_ghostzones(true); + set_boundary_ghostzones(true, loc); } } @@ -267,6 +296,19 @@ namespace Requirements { os << ")"; } + void gridpoint_t::output_location(location_t& l, int changed) const + { + DECLARE_CCTK_PARAMETERS; + if (!print_changes) + return; + cout << l + << ( (changed&1)?"(in:":"(IN:" ) << i_interior + << ( (changed&2)?",bo:":",BO:" ) << i_boundary + << ( (changed&4)?",gh:":",GH:" ) << i_ghostzones + << ( (changed&8)?",bg:":",BG:" ) << i_boundary_ghostzones + << ")\n"; + } + // The state (valid/invalid) of parts of the grid for all // timelevels, maps, refinement levels and variables @@ -577,6 +619,8 @@ namespace Requirements { { DECLARE_CCTK_PARAMETERS; int const ng = CCTK_NumGroups(); + location_t loc; + loc.rl = reflevel; for (int gi=0; gi::const_iterator iclause = clauses.writes.begin(); @@ -870,6 +918,7 @@ namespace Requirements { ++ivar) { int const vi = *ivar; + loc.vi = vi; // Loop over all (refinement levels, maps, time levels) reflevels_t& rls = vars.AT(vi); @@ -882,6 +931,7 @@ namespace Requirements { } for (int rl=min_rl; rl const& groups, int const reflevel, int const timelevel) { + location_t loc; + loc.rl = reflevel; + loc.tl = timelevel; // Loop over all variables for (vector::const_iterator igi = groups.begin(); igi != groups.end(); ++igi) @@ -973,6 +1028,7 @@ namespace Requirements { for (int vi=v0; vi const& groups, int const reflevel) { + location_t loc; + loc.rl = reflevel; // Loop over all variables for (vector::const_iterator igi = groups.begin(); igi != groups.end(); ++igi) @@ -1082,14 +1141,17 @@ namespace Requirements { for (int vi=v0; vi