From 740a903b1a7f29b246077735f0b2f1af3c029f0c Mon Sep 17 00:00:00 2001 From: Steffen Date: Thu, 9 Oct 2025 15:42:53 -0400 Subject: [PATCH] added sim_time_output --- include/common/globalconstants.hpp | 4 +++- include/solvers/snsolver_hpc.hpp | 1 + src/common/config.cpp | 20 ++++++++++++-------- src/solvers/snsolver_hpc.cpp | 7 ++++++- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/include/common/globalconstants.hpp b/include/common/globalconstants.hpp index b0ca20e3..4dca338f 100644 --- a/include/common/globalconstants.hpp +++ b/include/common/globalconstants.hpp @@ -178,6 +178,7 @@ inline std::map VolOutput_Map{ enum SCALAR_OUTPUT { WALL_TIME, ITER, + SIM_TIME, MASS, RMS_FLUX, VTK_OUTPUT, @@ -202,7 +203,8 @@ enum SCALAR_OUTPUT { }; inline std::map ScalarOutput_Map{ { "ITER", ITER }, - { "WALL_TIME", WALL_TIME }, + { "WALL_TIME", WALL_TIME }, + { "SIM_TIME", SIM_TIME }, { "MASS", MASS }, { "RMS_FLUX", RMS_FLUX }, { "VTK_OUTPUT", VTK_OUTPUT }, diff --git a/include/solvers/snsolver_hpc.hpp b/include/solvers/snsolver_hpc.hpp index 4bdb32ed..410c5086 100644 --- a/include/solvers/snsolver_hpc.hpp +++ b/include/solvers/snsolver_hpc.hpp @@ -24,6 +24,7 @@ class SNSolverHPC unsigned long _startSysIdx; unsigned long _endSysIdx; + double _curSimTime;/*!< @brief current in-simulation time after current iteration */ double _currTime; /*!< @brief wall-time after current iteration */ Config* _settings; /*!< @brief config class for global information */ Mesh* _mesh; diff --git a/src/common/config.cpp b/src/common/config.cpp index 4e189192..01f87ea6 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -760,6 +760,7 @@ void Config::SetPostprocessing() { case PROBLEM_Lattice: legalOutputs = { ITER, WALL_TIME, + SIM_TIME, MASS, RMS_FLUX, VTK_OUTPUT, @@ -780,7 +781,7 @@ void Config::SetPostprocessing() { ErrorMessages::Error( "Illegal output field <" + foundKey + "> for option SCREEN_OUTPUT for this test case.\n" - "Supported fields are: ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, FINAL_TIME_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW, " + "Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, FINAL_TIME_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW, " "FINAL_TIME_PARTICLE_ABSORPTION, TOTAL_PARTICLE_ABSORPTION, MAX_PARTICLE_ABSORPTION\n" "Please check your .cfg file.", CURRENT_FUNCTION ); @@ -790,6 +791,7 @@ void Config::SetPostprocessing() { case PROBLEM_SymmetricHohlraum: legalOutputs = { ITER, + SIM_TIME, WALL_TIME, MASS, RMS_FLUX, @@ -813,7 +815,7 @@ void Config::SetPostprocessing() { ErrorMessages::Error( "Illegal output field <" + foundKey + "> for option SCREEN_OUTPUT for this test case.\n" - "Supported fields are: ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, TOTAL_PARTICLE_ABSORPTION_CENTER, \n" + "Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, TOTAL_PARTICLE_ABSORPTION_CENTER, \n" "TOTAL_PARTICLE_ABSORPTION_VERTICAL, TOTAL_PARTICLE_ABSORPTION_HORIZONTAL, PROBE_MOMENT_TIME_TRACE, CUR_OUTFLOW, \n " "TOTAL_OUTFLOW, MAX_OUTFLOW, VAR_ABSORPTION_GREEN \n" "Please check your .cfg file.", @@ -822,7 +824,7 @@ void Config::SetPostprocessing() { break; default: - legalOutputs = { ITER, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW }; + legalOutputs = { ITER, SIM_TIME, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW }; it = std::find( legalOutputs.begin(), legalOutputs.end(), _screenOutput[idx_screenOutput] ); if( it == legalOutputs.end() ) { @@ -830,7 +832,7 @@ void Config::SetPostprocessing() { ErrorMessages::Error( "Illegal output field <" + foundKey + "> for option SCREEN_OUTPUT for this test case.\n" - "Supported fields are: ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW \n" + "Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW \n" "Please check your .cfg file.", CURRENT_FUNCTION ); } @@ -909,6 +911,7 @@ void Config::SetPostprocessing() { case PROBLEM_Lattice: legalOutputs = { ITER, WALL_TIME, + SIM_TIME, MASS, RMS_FLUX, VTK_OUTPUT, @@ -929,7 +932,7 @@ void Config::SetPostprocessing() { ErrorMessages::Error( "Illegal output field <" + foundKey + "> for option HISTORY_OUTPUT for this test case.\n" - "Supported fields are: ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, FINAL_TIME_OUTFLOW,\n" + "Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, FINAL_TIME_OUTFLOW,\n" "TOTAL_OUTFLOW, MAX_OUTFLOW, FINAL_TIME_PARTICLE_ABSORPTION, TOTAL_PARTICLE_ABSORPTION, MAX_PARTICLE_ABSORPTION\n" "Please check your .cfg file.", CURRENT_FUNCTION ); @@ -939,6 +942,7 @@ void Config::SetPostprocessing() { case PROBLEM_SymmetricHohlraum: legalOutputs = { ITER, WALL_TIME, + SIM_TIME, MASS, RMS_FLUX, VTK_OUTPUT, @@ -962,7 +966,7 @@ void Config::SetPostprocessing() { ErrorMessages::Error( "Illegal output field <" + foundKey + "> for option HISTORY_OUTPUT for this test case.\n" - "Supported fields are: ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, TOTAL_PARTICLE_ABSORPTION_CENTER, \n " + "Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, TOTAL_PARTICLE_ABSORPTION_CENTER, \n " "TOTAL_PARTICLE_ABSORPTION_VERTICAL, TOTAL_PARTICLE_ABSORPTION_HORIZONTAL,PROBE_MOMENT_TIME_TRACE, CUR_OUTFLOW, \n" "TOTAL_OUTFLOW, MAX_OUTFLOW , VAR_ABSORPTION_GREEN, ABSORPTION_GREEN_BLOCK, ABSORPTION_GREEN_LINE \n" "Please check your .cfg file.", @@ -971,7 +975,7 @@ void Config::SetPostprocessing() { break; default: - legalOutputs = { ITER, WALL_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW }; + legalOutputs = { ITER, WALL_TIME, SIM_TIME, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW }; it = std::find( legalOutputs.begin(), legalOutputs.end(), _historyOutput[idx_historyOutput] ); if( it == legalOutputs.end() ) { @@ -979,7 +983,7 @@ void Config::SetPostprocessing() { ErrorMessages::Error( "Illegal output field <" + foundKey + "> for option SCREEN_OUTPUT for this test case.\n" - "Supported fields are: ITER, MASS, RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW \n" + "Supported fields are: ITER, SIM_TIME, WALL_TIME, MASS RMS_FLUX, VTK_OUTPUT, CSV_OUTPUT, CUR_OUTFLOW, TOTAL_OUTFLOW, MAX_OUTFLOW \n" "Please check your .cfg file.", CURRENT_FUNCTION ); } diff --git a/src/solvers/snsolver_hpc.cpp b/src/solvers/snsolver_hpc.cpp index 6bec5280..d56f7b90 100644 --- a/src/solvers/snsolver_hpc.cpp +++ b/src/solvers/snsolver_hpc.cpp @@ -286,7 +286,7 @@ void SNSolverHPC::Solve() { PrepareVolumeOutput(); DrawPreSolverOutput(); } - + _curSimTime = 0.0; auto start = std::chrono::high_resolution_clock::now(); // Start timing std::chrono::duration duration; @@ -317,6 +317,7 @@ void SNSolverHPC::Solve() { ( _spatialOrder == 2 ) ? FluxOrder2() : FluxOrder1(); FVMUpdate(); } + _curSimTime += _dT; IterPostprocessing(); // --- Wall time measurement duration = std::chrono::high_resolution_clock::now() - start; @@ -885,6 +886,7 @@ void SNSolverHPC::PrepareScreenOutput() { switch( _settings->GetScreenOutput()[idx_field] ) { case MASS: _screenOutputFieldNames[idx_field] = "Mass"; break; case ITER: _screenOutputFieldNames[idx_field] = "Iter"; break; + case SIM_TIME: _screenOutputFieldNames[idx_field] = "Sim time"; break; case WALL_TIME: _screenOutputFieldNames[idx_field] = "Wall time [s]"; break; case RMS_FLUX: _screenOutputFieldNames[idx_field] = "RMS flux"; break; case VTK_OUTPUT: _screenOutputFieldNames[idx_field] = "VTK out"; break; @@ -932,6 +934,7 @@ void SNSolverHPC::WriteScalarOutput( unsigned idx_iter ) { switch( _settings->GetScreenOutput()[idx_field] ) { case MASS: _screenOutputFields[idx_field] = _mass; break; case ITER: _screenOutputFields[idx_field] = idx_iter; break; + case SIM_TIME: _screenOutputFields[idx_field] = _curSimTime; break; case WALL_TIME: _screenOutputFields[idx_field] = _currTime; break; case RMS_FLUX: _screenOutputFields[idx_field] = _rmsFlux; break; case VTK_OUTPUT: @@ -986,6 +989,7 @@ void SNSolverHPC::WriteScalarOutput( unsigned idx_iter ) { switch( _settings->GetHistoryOutput()[idx_field] ) { case MASS: _historyOutputFields[idx_field] = _mass; break; case ITER: _historyOutputFields[idx_field] = idx_iter; break; + case SIM_TIME: _screenOutputFields[idx_field] = _curSimTime; break; case WALL_TIME: _historyOutputFields[idx_field] = _currTime; break; case RMS_FLUX: _historyOutputFields[idx_field] = _rmsFlux; break; case VTK_OUTPUT: @@ -1131,6 +1135,7 @@ void SNSolverHPC::PrepareHistoryOutput() { switch( _settings->GetHistoryOutput()[idx_field] ) { case MASS: _historyOutputFieldNames[idx_field] = "Mass"; break; case ITER: _historyOutputFieldNames[idx_field] = "Iter"; break; + case SIM_TIME: _historyOutputFieldNames[idx_field] = "Sim_time"; break; case WALL_TIME: _historyOutputFieldNames[idx_field] = "Wall_time_[s]"; break; case RMS_FLUX: _historyOutputFieldNames[idx_field] = "RMS_flux"; break; case VTK_OUTPUT: _historyOutputFieldNames[idx_field] = "VTK_out"; break;