From a519edd102ed569684c34a1c0aa631c0601e0682 Mon Sep 17 00:00:00 2001 From: Marco De Lucia Date: Thu, 12 Dec 2024 16:20:09 +0100 Subject: [PATCH] Less and more informative stdout messages --- R_lib/kin_r_library.R | 4 ++-- src/Transport/DiffusionModule.cpp | 2 +- src/poet.cpp | 30 +++++++++++++++++------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/R_lib/kin_r_library.R b/R_lib/kin_r_library.R index 50497b958..97fd49e16 100644 --- a/R_lib/kin_r_library.R +++ b/R_lib/kin_r_library.R @@ -94,7 +94,7 @@ master_iteration_end <- function(setup, state_T, state_C) { ## Add last time step to simulation time setup$simulation_time <- setup$simulation_time + setup$timesteps[iter] - msgm("done iteration", iter, "/", length(setup$timesteps)) + ## msgm("done iteration", iter, "/", length(setup$timesteps)) setup$iter <- setup$iter + 1 return(setup) } @@ -132,7 +132,7 @@ ReadRObj <- function(path) { ## Handler to store R objs to binary files using either builtin ## saveRDS() or qs::qsave() based on file extension SaveRObj <- function(x, path) { - msgm("Storing to", path) + ## msgm("Storing to", path) ## code borrowed from tools::file_ext() pos <- regexpr("\\.([[:alnum:]]+)$", path) extension <- ifelse(pos > -1L, substring(path, pos + 1L), "") diff --git a/src/Transport/DiffusionModule.cpp b/src/Transport/DiffusionModule.cpp index 2ea80564a..754d135c9 100644 --- a/src/Transport/DiffusionModule.cpp +++ b/src/Transport/DiffusionModule.cpp @@ -70,7 +70,7 @@ VecToMatrix(const std::vector &vec, std::uint32_t n_rows, // static constexpr double ZERO_MULTIPLICATOR = 10E-14; void DiffusionModule::simulate(double requested_dt) { - MSG("Starting diffusion ..."); + // MSG("Starting diffusion ..."); const auto start_diffusion_t = std::chrono::high_resolution_clock::now(); const auto &n_rows = this->param_list.n_rows; diff --git a/src/poet.cpp b/src/poet.cpp index d4f27525f..93a168496 100644 --- a/src/poet.cpp +++ b/src/poet.cpp @@ -39,13 +39,14 @@ #include #include #include +#include #include #include #include -using namespace std; +// using namespace std; using namespace poet; using namespace Rcpp; @@ -292,18 +293,19 @@ static Rcpp::List RunMasterLoop(RInsidePOET &R, const RuntimeParameters ¶ms, const double &dt = params.timesteps[iter - 1]; - // cout << "CPP: Next time step is " << dt << "[s]" << endl; - MSG("Next time step is " + std::to_string(dt) + " [s]"); - + std::cout << std::endl; /* displaying iteration number, with C++ and R iterator */ - MSG("Going through iteration " + std::to_string(iter)); + MSG("Going through iteration " + std::to_string(iter) + "/" + + std::to_string(maxiter)); + + MSG("Current time step is " + std::format("{:.2f}", dt)); /* run transport */ diffusion.simulate(dt); chem.getField().update(diffusion.getField()); - MSG("Chemistry step"); + // MSG("Chemistry start"); if (params.use_ai_surrogate) { double ai_start_t = MPI_Wtime(); // Save current values from the tug field as predictor for the ai step @@ -319,16 +321,16 @@ static Rcpp::List RunMasterLoop(RInsidePOET &R, const RuntimeParameters ¶ms, R.parseEval("predictors_scaled <- preprocess(predictors)"); // Predict - MSG("AI Predict"); + MSG("AI Prediction"); R.parseEval( "aipreds_scaled <- prediction_step(model, predictors_scaled)"); // Apply postprocessing - MSG("AI Postprocesing"); + MSG("AI Postprocessing"); R.parseEval("aipreds <- postprocess(aipreds_scaled)"); // Validate prediction and write valid predictions to chem field - MSG("AI Validate"); + MSG("AI Validation"); R.parseEval( "validity_vector <- validate_predictions(predictors, aipreds)"); @@ -338,8 +340,8 @@ static Rcpp::List RunMasterLoop(RInsidePOET &R, const RuntimeParameters ¶ms, MSG("AI TempField"); std::vector> RTempField = R.parseEval("set_valid_predictions(predictors,\ - aipreds,\ - validity_vector)"); + aipreds,\ + validity_vector)"); MSG("AI Set Field"); Field predictions_field = @@ -390,9 +392,11 @@ static Rcpp::List RunMasterLoop(RInsidePOET &R, const RuntimeParameters ¶ms, MSG("End of *coupling* iteration " + std::to_string(iter) + "/" + std::to_string(maxiter)); - MSG(); + // MSG(); } // END SIMULATION LOOP + std::cout << std::endl; + Rcpp::List chem_profiling; chem_profiling["simtime"] = chem.GetChemistryTime(); chem_profiling["loop"] = chem.GetMasterLoopTime(); @@ -588,7 +592,7 @@ int main(int argc, char *argv[]) { R["setup"] = *global_rt_setup; R["setup$out_ext"] = run_params.out_ext; - string r_vis_code; + std::string r_vis_code; r_vis_code = "SaveRObj(x = profiling, path = paste0(out_dir, " "'/timings.', setup$out_ext));"; R.parseEval(r_vis_code);