From b0c9d8da284072920221feec4483e5bdcfb37ceb Mon Sep 17 00:00:00 2001 From: Joseph Signorelli Date: Wed, 27 Dec 2023 14:00:49 -0600 Subject: [PATCH 1/6] Added setter for dimensional Delta_UnstTime --- Common/include/CConfig.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index e2fdd39f0f1..1144851ac0a 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5737,6 +5737,13 @@ class CConfig { */ su2double GetDelta_UnstTime(void) const { return Delta_UnstTime; } + /*! + * \brief Set Delta_UnstTime (dimensional timestep) + * \param[in] val_delta_unsttime - Value of the unsteady dimensional timestep + */ + void SetDelta_UnstTime(su2double val_delta_unsttime) { Delta_UnstTime = val_delta_unsttime; } + + /*! * \brief Set the value of the unsteadty time step using the CFL number. * \param[in] val_delta_unsttimend - Value of the unsteady time step using CFL number. From b1b04c3c362c853b37aed0a4e1245d2f362f47a3 Mon Sep 17 00:00:00 2001 From: Joseph Signorelli Date: Wed, 27 Dec 2023 14:01:35 -0600 Subject: [PATCH 2/6] Python wrapper setter for dim + ND unsteady dt, getter now gets actual dt --- SU2_CFD/include/drivers/CDriver.hpp | 7 +++++++ SU2_CFD/src/python_wrapper_structure.cpp | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 72de6af4c89..13851484b9b 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -486,6 +486,13 @@ class CDriver : public CDriverBase { */ passivedouble GetUnsteadyTimeStep() const; + /*! + * \brief Set the unsteady time step. + * \param[in] unst_dt - Dimensional unsteady time step. + */ + void SetUnsteadyTimeStep(passivedouble unst_dt); + + /*! * \brief Get the name of the output file for the surface. * \return File name for the surface output. diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index cac6186e04c..ffabde0dc76 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -67,7 +67,15 @@ unsigned long CDriver::GetNumberTimeIter() const { return config_container[selec unsigned long CDriver::GetTimeIter() const { return TimeIter; } passivedouble CDriver::GetUnsteadyTimeStep() const { - return SU2_TYPE::GetValue(config_container[selected_zone]->GetTime_Step()); + return SU2_TYPE::GetValue(config_container[selected_zone]->GetDelta_UnstTime()); +} + +void CDriver::SetUnsteadyTimeStep(passivedouble unst_dt) { + // Set across all zones + for (iZone = 0; iZone < nZone; iZone++) { + config_container[iZone]->SetDelta_UnstTime(unst_dt); + config_container[iZone]->SetDelta_UnstTimeND(unst_dt/config_container[iZone]->GetTime_Ref()); + } } string CDriver::GetSurfaceFileName() const { return config_container[selected_zone]->GetSurfCoeff_FileName(); } From e185b4bb849bfb6dbf54ab65a4919e19244ebdc4 Mon Sep 17 00:00:00 2001 From: Joseph Signorelli Date: Wed, 27 Dec 2023 14:02:55 -0600 Subject: [PATCH 3/6] Update CUR_TIME w/ previous TIME_STEP --- SU2_CFD/src/output/COutput.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 4dad97f8e34..6335307e03f 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -2191,13 +2191,12 @@ void COutput::ComputeSimpleCustomOutputs(const CConfig *config) { void COutput::LoadCommonHistoryData(const CConfig *config) { - SetHistoryOutputValue("TIME_STEP", config->GetDelta_UnstTimeND()*config->GetTime_Ref()); - /*--- Update the current time only if the time iteration has changed ---*/ - if (SU2_TYPE::Int(GetHistoryFieldValue("TIME_ITER")) != static_cast(curTimeIter)) { SetHistoryOutputValue("CUR_TIME", GetHistoryFieldValue("CUR_TIME") + GetHistoryFieldValue("TIME_STEP")); } + + SetHistoryOutputValue("TIME_STEP", config->GetDelta_UnstTimeND()*config->GetTime_Ref()); SetHistoryOutputValue("TIME_ITER", curTimeIter); SetHistoryOutputValue("INNER_ITER", curInnerIter); From 5188c0783f9b1df26fdab87cb1622894e37f5ace Mon Sep 17 00:00:00 2001 From: Joseph Signorelli Date: Thu, 28 Dec 2023 09:03:16 -0600 Subject: [PATCH 4/6] Addition of START_TIME option + variable Includes a getter method in CConfig --- Common/include/CConfig.hpp | 10 +++++++++- Common/src/CConfig.cpp | 2 ++ config_template.cfg | 4 ++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 1144851ac0a..15abd8c237e 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -1140,7 +1140,8 @@ class CConfig { Restart_Iter; /*!< \brief Determines the restart iteration in the multizone problem */ su2double Time_Step; /*!< \brief Determines the time step for the multizone problem */ su2double Max_Time; /*!< \brief Determines the maximum time for the time-domain problems */ - + su2double Start_Time; /*!< \brief Determines the starting time for the time-domain problems */ + unsigned long HistoryWrtFreq[3], /*!< \brief Array containing history writing frequencies for timer iter, outer iter, inner iter */ ScreenWrtFreq[3]; /*!< \brief Array containing screen writing frequencies for timer iter, outer iter, inner iter */ OUTPUT_TYPE* VolumeOutputFiles; /*!< \brief File formats to output */ @@ -9379,6 +9380,13 @@ class CConfig { */ su2double GetMax_Time(void) const { return Max_Time; } + /*! + * \brief Get the start simulation time for time-domain problems + * \return Simulation start time for multizone problems, it is set on all the zones + */ + su2double GetStart_Time(void) const { return Start_Time; } + + /*! * \brief Get the level of MPI communications to be performed. * \return Level of MPI communications. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 59584271ac5..3a021c27d2b 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -2548,6 +2548,8 @@ void CConfig::SetConfig_Options() { addDoubleOption("TIME_STEP", Time_Step, 0.0); /* DESCRIPTION: Total Physical Time for time-domain problems (s) */ addDoubleOption("MAX_TIME", Max_Time, 1.0); + /* DESCRIPTION: Start Physical Time for time-domain problems (s) */ + addDoubleOption("START_TIME", Start_Time, -1.0); /* DESCRIPTION: Determines if the special output is written out */ addBoolOption("SPECIAL_OUTPUT", SpecialOutput, false); diff --git a/config_template.cfg b/config_template.cfg index ea621b85e7e..5d8ef808028 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -143,6 +143,10 @@ TIME_STEP= 0.0 % Total Physical Time for dual time stepping simulations (s) MAX_TIME= 50.0 % +% Start time for dual time stepping simulations +% = -1 for default calculation (START_TIME=RESTART_ITER*TIME_STEP) +START_TIME=-1 +% % Unsteady Courant-Friedrichs-Lewy number of the finest grid UNST_CFL_NUMBER= 0.0 % From 196dc201f523bf5eeb499814947ce8b7d0d86014 Mon Sep 17 00:00:00 2001 From: Joseph Signorelli Date: Thu, 28 Dec 2023 13:23:58 -0600 Subject: [PATCH 5/6] Added default start time calculation --- Common/src/CConfig.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 3a021c27d2b..7ff5696002f 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -3724,6 +3724,10 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i if(nTimeIter <= Restart_Iter) SU2_MPI::Error("TIME_ITER must be larger than RESTART_ITER.", CURRENT_FUNCTION); } + /*--- Set default start time for simulations if given time < 0 ---*/ + if (Start_Time < 0) + Start_Time = Restart_Iter*Time_Step; + /*--- WINDOW_START_ITER must be larger than or equal to: RESTART_ITER. Otherwise, the running average is wrong. ---*/ if (OptionIsSet("WINDOW_START_ITER")) { if (StartWindowIteration < Restart_Iter) { From 4b6a357d1c9408900b2f8360be586c872b35f7fc Mon Sep 17 00:00:00 2001 From: Joseph Signorelli Date: Thu, 28 Dec 2023 13:24:15 -0600 Subject: [PATCH 6/6] CDrivers::Preprocess updated to appropriately set PhysicalTime --- SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp | 9 +++++++-- SU2_CFD/src/drivers/CDriver.cpp | 10 +++++++--- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 6 +++++- SU2_CFD/src/drivers/CSinglezoneDriver.cpp | 10 +++++++--- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index e1ffb15fdaa..faee0b320a8 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -133,8 +133,13 @@ void CDiscAdjMultizoneDriver::Preprocess(unsigned long TimeIter) { config_container[iZone]->SetTimeIter(TimeIter); if (time_domain) - config_container[iZone]->SetPhysicalTime(static_cast(TimeIter)*config_container[iZone]->GetDelta_UnstTimeND()); - else + { + /*--- If first iteration, use start time. Otherwise, add dt ---*/ + if (TimeIter == config_container[iZone]->GetRestart_Iter()) + config_container[iZone]->SetPhysicalTime(config_container[iZone]->GetStart_Time()/config_container[iZone]->GetTime_Ref()); + else + config_container[iZone]->SetPhysicalTime(config_container[iZone]->GetPhysicalTime() + config_container[iZone]->GetDelta_UnstTimeND()); + } else config_container[iZone]->SetPhysicalTime(0.0); /*--- Preprocess the iteration of each zone. ---*/ diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index d8ba985fafa..c4e0eb7bd4f 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -3022,9 +3022,13 @@ void CFluidDriver::Preprocess(unsigned long Iter) { for (iZone = 0; iZone < nZone; iZone++) { config_container[iZone]->SetInnerIter(Iter); - if (config_container[iZone]->GetTime_Marching() != TIME_MARCHING::STEADY) - config_container[iZone]->SetPhysicalTime(static_cast(Iter)*config_container[iZone]->GetDelta_UnstTimeND()); - else + if (config_container[iZone]->GetTime_Marching() != TIME_MARCHING::STEADY) { + /*--- If first iteration, use start time. Otherwise, add dt ---*/ + if (Iter == config_container[iZone]->GetRestart_Iter()) + config_container[iZone]->SetPhysicalTime(config_container[iZone]->GetStart_Time()/config_container[iZone]->GetTime_Ref()); + else + config_container[iZone]->SetPhysicalTime(config_container[iZone]->GetPhysicalTime() + config_container[iZone]->GetDelta_UnstTimeND()); + } else config_container[iZone]->SetPhysicalTime(0.0); } diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 49a9c58e724..3607e42c87d 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -223,7 +223,11 @@ void CMultizoneDriver::Preprocess(unsigned long TimeIter) { general once the drivers are more stable. ---*/ if (driver_config->GetTime_Domain()) { - config_container[iZone]->SetPhysicalTime(static_cast(TimeIter)*config_container[iZone]->GetDelta_UnstTimeND()); + /*--- If first iteration, use start time. Otherwise, add dt ---*/ + if (TimeIter == config_container[iZone]->GetRestart_Iter()) + config_container[iZone]->SetPhysicalTime(config_container[iZone]->GetStart_Time()/config_container[iZone]->GetTime_Ref()); + else + config_container[iZone]->SetPhysicalTime(config_container[iZone]->GetPhysicalTime() + config_container[iZone]->GetDelta_UnstTimeND()); } else { config_container[iZone]->SetPhysicalTime(0.0); diff --git a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp index c35d6b8eac5..b407638f94b 100644 --- a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp @@ -114,9 +114,13 @@ void CSinglezoneDriver::Preprocess(unsigned long TimeIter) { this can be used for verification / MMS. This should also be more general once the drivers are more stable. ---*/ - if (config_container[ZONE_0]->GetTime_Marching() != TIME_MARCHING::STEADY) - config_container[ZONE_0]->SetPhysicalTime(static_cast(TimeIter)*config_container[ZONE_0]->GetDelta_UnstTimeND()); - else + if (config_container[ZONE_0]->GetTime_Marching() != TIME_MARCHING::STEADY) { + /*--- If first iteration, use start time. Otherwise, add dt ---*/ + if (TimeIter == config_container[ZONE_0]->GetRestart_Iter()) + config_container[ZONE_0]->SetPhysicalTime(config_container[ZONE_0]->GetStart_Time()/config_container[ZONE_0]->GetTime_Ref()); + else + config_container[ZONE_0]->SetPhysicalTime(config_container[ZONE_0]->GetPhysicalTime() + config_container[ZONE_0]->GetDelta_UnstTimeND()); + } else config_container[ZONE_0]->SetPhysicalTime(0.0); /*--- Ramp turbo BCs for this time step. ---*/