aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Requirements/src/Requirements.cc
diff options
context:
space:
mode:
Diffstat (limited to 'Carpet/Requirements/src/Requirements.cc')
-rw-r--r--Carpet/Requirements/src/Requirements.cc248
1 files changed, 1 insertions, 247 deletions
diff --git a/Carpet/Requirements/src/Requirements.cc b/Carpet/Requirements/src/Requirements.cc
index 538c96188..0584a5972 100644
--- a/Carpet/Requirements/src/Requirements.cc
+++ b/Carpet/Requirements/src/Requirements.cc
@@ -23,6 +23,7 @@
#include <clauses.hh>
#include <location.hh>
#include <util.hh>
+#include <gridpoint.hh>
using namespace std;
@@ -51,253 +52,6 @@ namespace Requirements {
// while time level cycling; routines should specify how many time
// levels they require/provide
- bool there_was_an_error = false;
- bool there_was_a_warning = false;
-
-
- // Represents which have valid information and which do not.
- // 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:
- gridpoint_t():
- 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):
- 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, 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,
- int vi, int rl, int m, int tl) const;
- void report_error(cFunctionData const* function_data,
- int vi, int rl, int m, int tl,
- char const* what, char const* where) const;
- 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, 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
- 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, location_t &l)
- {
- if (i_interior == b)
- return;
- i_interior = b;
- output_location(l, BIT_INTERIOR);
- }
- void gridpoint_t::set_boundary(bool b, location_t &l)
- {
- if (i_boundary == b)
- return;
- i_boundary = b;
- output_location(l, BIT_BOUNDARY);
- }
- void gridpoint_t::set_ghostzones(bool b, location_t &l)
- {
- if (i_ghostzones == b)
- return;
- i_ghostzones = b;
- output_location(l, BIT_GHOSTZONES);
- }
- void gridpoint_t::set_boundary_ghostzones(bool b, location_t &l)
- {
- if (i_boundary_ghostzones == b)
- return;
- i_boundary_ghostzones = b;
- output_location(l, BIT_BOUNDARY_GHOSTZONES);
- }
-
- inline ostream& operator<< (ostream& os, const gridpoint_t& a) {
- a.output(os);
- return os;
- }
-
-
-
- // Check that all the parts of the grid variables read by a function
- // are valid. This will be called before the function is executed.
- void gridpoint_t::check_state(clause_t const& clause,
- cFunctionData const* const function_data,
- int const vi,
- int const rl, int const m, int const tl)
- const
- {
- if (not i_interior) {
- if (clause.everywhere or clause.interior) {
- report_error(function_data, vi, rl, m, tl,
- "calling function", "interior");
- }
- }
- if (not i_boundary) {
- if (clause.everywhere or clause.boundary) {
- report_error(function_data, vi, rl, m, tl,
- "calling function", "boundary");
- }
- }
- if (not i_ghostzones) {
- if (clause.everywhere) {
- report_error(function_data, vi, rl, m, tl,
- "calling function", "ghostzones");
- }
- }
- if (not i_boundary_ghostzones) {
- if (clause.everywhere or clause.boundary_ghostzones) {
- report_error(function_data, vi, rl, m, tl,
- "calling", "boundary-ghostzones");
- }
- }
- }
-
- void gridpoint_t::report_error(cFunctionData const* const function_data,
- int const vi,
- int const rl, int const m, int const tl,
- char const* const what,
- char const* const where) const
- {
- char* const fullname = CCTK_FullName(vi);
- ostringstream state;
- state << "current state: " << *this << std::endl;
- if (function_data) {
- // The error is related to a scheduled function
- CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Schedule READS clause not satisfied: "
- "Function %s::%s in %s: "
- "Variable %s reflevel=%d map=%d timelevel=%d: "
- "%s not valid for %s. %s",
- function_data->thorn, function_data->routine,
- function_data->where,
- fullname, rl, m, tl,
- where, what, state.str().c_str());
- } else {
- // The error is not related to a scheduled function
- CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Schedule READS clause not satisfied: "
- "Variable %s reflevel=%d map=%d timelevel=%d: "
- "%s not valid for %s. %s",
- fullname, rl, m, tl,
- where, what, state.str().c_str());
- }
- free(fullname);
- there_was_an_error = true;
- }
-
- void gridpoint_t::report_warning(cFunctionData const* const function_data,
- int const vi,
- int const rl, int const m, int const tl,
- char const* const what,
- char const* const where) const
- {
- char* const fullname = CCTK_FullName(vi);
- ostringstream state;
- state << "current state: " << *this << std::endl;
- if (function_data) {
- // The error is related to a scheduled function
- CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Schedule WRITES clause is superfluous: "
- "Function %s::%s in %s: "
- "Variable %s reflevel=%d map=%d timelevel=%d: "
- "%s already valid for %s. %s",
- function_data->thorn, function_data->routine,
- function_data->where,
- fullname, rl, m, tl,
- where, what, state.str().c_str());
- } else {
- // The error is not related to a scheduled function
- CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Schedule WRITES clause already satisfied: "
- "Variable %s reflevel=%d map=%d timelevel=%d: "
- "%s already valid for %s. %s",
- fullname, rl, m, tl,
- where, what, state.str().c_str());
- }
- free(fullname);
- there_was_a_warning = true;
- }
-
- // 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, location_t &loc)
- {
- int where = 0;
- if (clause.everywhere or clause.interior) {
- if (!i_interior)
- where |= BIT_INTERIOR;
- i_interior = true;
- }
- if (clause.everywhere or clause.boundary) {
- if (!i_boundary)
- where |= BIT_BOUNDARY;
- i_boundary = true;
- }
- if (clause.everywhere) {
- if (!i_ghostzones)
- where |= BIT_GHOSTZONES;
- i_ghostzones = true;
- }
- if (clause.everywhere or clause.boundary_ghostzones) {
- if (!i_boundary_ghostzones)
- where |= BIT_BOUNDARY_GHOSTZONES;
- i_boundary_ghostzones = true;
- }
- if (where)
- output_location(loc, where);
- }
-
- void gridpoint_t::output(ostream& os) const
- {
- os << "(";
- if (i_interior) os << "interior;";
- if (i_boundary) os << "boundary;";
- if (i_ghostzones) os << "ghostzones;";
- if (i_boundary_ghostzones) os << "boundary_ghostzones;";
- os << ")";
- }
-
- // Some readable and parsable debug output
- void gridpoint_t::output_location(location_t& l, int changed) const
- {
- DECLARE_CCTK_PARAMETERS;
- if (!print_changes)
- return;
-
- cout << "LOC: " << l << " "
- << ( (changed&BIT_INTERIOR) ?"(IN:":"(in:" ) << i_interior
- << ( (changed&BIT_BOUNDARY) ?",BO:":",bo:" ) << i_boundary
- << ( (changed&BIT_GHOSTZONES) ?",GH:":",gh:" ) << i_ghostzones
- << ( (changed&BIT_BOUNDARY_GHOSTZONES)?",BG:":",bg:" ) << i_boundary_ghostzones
- << ") " << l.info << "\n";
- }
-
-
// The state (valid/invalid) of parts of the grid for all
// timelevels, maps, refinement levels and variables
class all_state_t {