Skip to content

Commit

Permalink
Remove more root() (#1184)
Browse files Browse the repository at this point in the history
* Remove more root()

* Delete some more debug indirections

* Style
  • Loading branch information
psakievich committed May 5, 2023
1 parent b5a0342 commit bf95a95
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 53 deletions.
1 change: 0 additions & 1 deletion include/LinearSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class LinearSolver
*/
virtual void destroyLinearSolver() = 0;

Simulation* root();
LinearSolvers* parent();
LinearSolvers* linearSolvers_;

Expand Down
3 changes: 2 additions & 1 deletion include/NaluEnv.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class NaluEnv
~NaluEnv();

static NaluEnv& self();

MPI_Comm parallelCommunicator_;
int pSize_;
int pRank_;
Expand All @@ -42,13 +41,15 @@ class NaluEnv
NaluEmptyStreamBuffer naluEmptyStreamBuffer_;
std::filebuf naluStreamBuffer_;
std::filebuf naluParallelStreamBuffer_;
bool debug_;

std::ostream& naluOutputP0();
std::ostream& naluOutput();

MPI_Comm parallel_comm();
int parallel_size();
int parallel_rank();
bool debug() { return debug_; }

/** Redirect output to a log file
*
Expand Down
1 change: 0 additions & 1 deletion include/Realm.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ class Realm
Realms* parent() const;
Realms* parent();

bool debug() const;
bool get_activate_memory_diagnostic();
void provide_memory_summary();
std::string convert_bytes(double bytes);
Expand Down
3 changes: 0 additions & 3 deletions include/Simulation.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class Simulation
void high_level_banner();
Simulation* root() { return this; }
Simulation* parent() { return 0; }
bool debug() { return debug_; }
bool debug() const { return debug_; }
void setSerializedIOGroupSize(int siogs);
static stk::diag::TimerSet& rootTimerSet();
static stk::diag::Timer& rootTimer();
Expand All @@ -56,7 +54,6 @@ class Simulation
Transfers* transfers_;
LinearSolvers* linearSolvers_;

static bool debug_;
int serializedIOGroupSize_;

private:
Expand Down
2 changes: 1 addition & 1 deletion nalu.C
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ main(int argc, char** argv)
<< std::endl;
sim.setSerializedIOGroupSize(serializedIOGroupSize);
}
sim.debug_ = debug;
naluEnv.debug_ = debug;
sim.load(doc);
sim.breadboard();
sim.initialize();
Expand Down
16 changes: 8 additions & 8 deletions src/EquationSystems.C
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ EquationSystems::load(const YAML::Node& y_node)

if (expect_map(y_system, "LowMachEOM", true)) {
y_eqsys = expect_map(y_system, "LowMachEOM", true);
if (root()->debug())
if (NaluEnv::self().debug())
NaluEnv::self().naluOutputP0()
<< "eqSys = LowMachEOM " << std::endl;
bool elemCont = (realm_.realmUsesEdges_) ? false : true;
Expand All @@ -132,34 +132,34 @@ EquationSystems::load(const YAML::Node& y_node)
} else if (expect_map(y_system, "VolumeOfFluid", true)) {

y_eqsys = expect_map(y_system, "VolumeOfFluid", true);
if (root()->debug())
if (NaluEnv::self().debug())
NaluEnv::self().naluOutputP0()
<< "eqSys = VolumeOfFluid" << std::endl;
eqSys = new VolumeOfFluidEquationSystem(*this);

} else if (expect_map(y_system, "ShearStressTransport", true)) {
y_eqsys = expect_map(y_system, "ShearStressTransport", true);
if (root()->debug())
if (NaluEnv::self().debug())
NaluEnv::self().naluOutputP0() << "eqSys = tke/sdr " << std::endl;
eqSys = new ShearStressTransportEquationSystem(*this);
} else if (expect_map(y_system, "ChienKEpsilon", true)) {
y_eqsys = expect_map(y_system, "ChienKEpsilon", true);
if (root()->debug())
if (NaluEnv::self().debug())
NaluEnv::self().naluOutputP0() << "eqSys = tke/tdr " << std::endl;
eqSys = new ChienKEpsilonEquationSystem(*this);
} else if (expect_map(y_system, "WilcoxKOmega", true)) {
y_eqsys = expect_map(y_system, "WilcoxKOmega", true);
if (root()->debug())
if (NaluEnv::self().debug())
NaluEnv::self().naluOutputP0() << "eqSys = tke/sdr " << std::endl;
eqSys = new WilcoxKOmegaEquationSystem(*this);
} else if (expect_map(y_system, "TurbKineticEnergy", true)) {
y_eqsys = expect_map(y_system, "TurbKineticEnergy", true);
if (root()->debug())
if (NaluEnv::self().debug())
NaluEnv::self().naluOutputP0() << "eqSys = tke " << std::endl;
eqSys = new TurbKineticEnergyEquationSystem(*this);
} else if (expect_map(y_system, "Enthalpy", true)) {
y_eqsys = expect_map(y_system, "Enthalpy", true);
if (root()->debug())
if (NaluEnv::self().debug())
NaluEnv::self().naluOutputP0() << "eqSys = enthalpy " << std::endl;
double minT = 250.0;
double maxT = 3000.0;
Expand All @@ -171,7 +171,7 @@ EquationSystems::load(const YAML::Node& y_node)
eqSys = new EnthalpyEquationSystem(*this, minT, maxT, ouputClipDiag);
} else if (expect_map(y_system, "HeatConduction", true)) {
y_eqsys = expect_map(y_system, "HeatConduction", true);
if (root()->debug())
if (NaluEnv::self().debug())
NaluEnv::self().naluOutputP0()
<< "eqSys = HeatConduction " << std::endl;
#ifdef NALU_HAS_MATRIXFREE
Expand Down
11 changes: 0 additions & 11 deletions src/LinearSolver.C
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@
namespace sierra {
namespace nalu {

Simulation*
LinearSolver::root()
{
return linearSolvers_->root();
}
LinearSolvers*
LinearSolver::parent()
{
return linearSolvers_;
}

#ifdef NALU_USES_TRILINOS_SOLVERS

TpetraLinearSolver::TpetraLinearSolver(
Expand Down
11 changes: 0 additions & 11 deletions src/LinearSolvers.C
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ LinearSolvers::~LinearSolvers()
#endif
}

Simulation*
LinearSolvers::root()
{
return &sim_;
}
Simulation*
LinearSolvers::parent()
{
return root();
}

void
LinearSolvers::load(const YAML::Node& node)
{
Expand Down
2 changes: 1 addition & 1 deletion src/LinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ LinearSystem::get_timer_precond()
bool
LinearSystem::debug()
{
if (linearSolver_ && linearSolver_->root() && linearSolver_->root()->debug())
if (NaluEnv::self().debug())
return true;
return false;
}
Expand Down
3 changes: 2 additions & 1 deletion src/NaluEnv.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ NaluEnv::NaluEnv()
stdoutStream_(std::cout.rdbuf()),
naluLogStream_(new std::ostream(std::cout.rdbuf())),
naluParallelStream_(new std::ostream(&naluParallelStreamBuffer_)),
parallelLog_(false)
parallelLog_(false),
debug_(false)
{
// initialize
MPI_Comm_size(parallelCommunicator_, &pSize_);
Expand Down
14 changes: 4 additions & 10 deletions src/Realm.C
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,6 @@ Realm::breadboard()
equationSystems_.breadboard();
}

bool
Realm::debug() const
{
return root()->debug_;
}

//--------------------------------------------------------------------------
//-------- get_activate_memory_diagnostic ----------------------------------
//--------------------------------------------------------------------------
Expand Down Expand Up @@ -847,7 +841,7 @@ Realm::load(const YAML::Node& node)
NaluEnv::self().naluOutputP0()
<< "===========================" << std::endl;
initialConditions_ =
InitialConditionCreator(debug()).create_ic_vector(node);
InitialConditionCreator(NaluEnv::self().debug()).create_ic_vector(node);
NaluEnv::self().naluOutputP0() << std::endl;
NaluEnv::self().naluOutputP0()
<< "Material Prop Review: " << std::endl;
Expand Down Expand Up @@ -2345,7 +2339,7 @@ Realm::provide_entity_count()
void
Realm::delete_edges()
{
if (debug()) {
if (NaluEnv::self().debug()) {
std::vector<size_t> counts;
stk::mesh::comm_mesh_counts(*bulkData_, counts);

Expand All @@ -2360,7 +2354,7 @@ Realm::delete_edges()
std::vector<stk::mesh::Entity> edges;
stk::mesh::get_selected_entities(*edgesPart_, edge_buckets, edges);

if (debug()) {
if (NaluEnv::self().debug()) {
size_t sz = edges.size(), g_sz = 0;
stk::all_reduce_sum(NaluEnv::self().parallel_comm(), &sz, &g_sz, 1);
NaluEnv::self().naluOutputP0()
Expand Down Expand Up @@ -2448,7 +2442,7 @@ Realm::delete_edges()
}
bulkData_->modification_end();

if (debug()) {
if (NaluEnv::self().debug()) {
std::vector<size_t> counts;
stk::mesh::comm_mesh_counts(*bulkData_, counts);

Expand Down
1 change: 0 additions & 1 deletion src/Simulation.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace nalu {
//--------------------------------------------------------------------------
//-------- destructor ------------------------------------------------------
//--------------------------------------------------------------------------
bool Simulation::debug_ = false;

Simulation::Simulation(const YAML::Node& root_node)
: m_root_node(root_node),
Expand Down
2 changes: 1 addition & 1 deletion src/TpetraLinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ TpetraLinearSystem::solve(stk::mesh::FieldBase* linearSolutionField)
TpetraLinearSolver* linearSolver =
reinterpret_cast<TpetraLinearSolver*>(linearSolver_);

if (realm_.debug()) {
if (NaluEnv::self().debug()) {
checkForNaN(true);
if (checkForZeroRow(true, false, true)) {
throw std::runtime_error("ERROR checkForZeroRow in solve()");
Expand Down
2 changes: 1 addition & 1 deletion src/TpetraSegregatedLinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@ TpetraSegregatedLinearSystem::solve(stk::mesh::FieldBase* linearSolutionField)
TpetraLinearSolver* linearSolver =
reinterpret_cast<TpetraLinearSolver*>(linearSolver_);

if (realm_.debug()) {
if (NaluEnv::self().debug()) {
checkForNaN(true);
if (checkForZeroRow(true, false, true)) {
throw std::runtime_error("ERROR checkForZeroRow in solve()");
Expand Down
2 changes: 1 addition & 1 deletion src/TurbKineticEnergyEquationSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ TurbKineticEnergyEquationSystem::update_and_clip()
ngpTke.modify_on_device();

// parallel assemble clipped value
if (realm_.debug()) {
if (NaluEnv::self().debug()) {
size_t g_numClip = 0;
stk::ParallelMachine comm = NaluEnv::self().parallel_comm();
stk::all_reduce_sum(comm, &numClip, &g_numClip, 1);
Expand Down

0 comments on commit bf95a95

Please sign in to comment.