diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index e2fdd39f0f1..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 */ @@ -5737,6 +5738,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. @@ -9372,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..7ff5696002f 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); @@ -3722,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) { 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/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. ---*/ 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); 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(); } 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 %