diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 2551bed0c0e5..c89dfa3e866a 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -979,7 +979,7 @@ class CConfig { unsigned short DirectDiff; /*!< \brief Direct Differentation mode. */ bool DiscreteAdjoint; /*!< \brief AD-based discrete adjoint mode. */ su2double Const_DES; /*!< \brief Detached Eddy Simulation Constant. */ - unsigned short Kind_WindowFct; /*!< \brief Type of window (weight) function for objective functional. */ + WINDOW_FUNCTION Kind_WindowFct; /*!< \brief Type of window (weight) function for objective functional. */ unsigned short Kind_HybridRANSLES; /*!< \brief Kind of Hybrid RANS/LES. */ unsigned short Kind_RoeLowDiss; /*!< \brief Kind of Roe scheme with low dissipation for unsteady flows. */ bool QCR; /*!< \brief Spalart-Allmaras with Quadratic Constitutive Relation, 2000 version (SA-QCR2000) . */ @@ -5211,7 +5211,7 @@ class CConfig { * \brief Get Index of the window function used as weight in the cost functional * \return */ - WINDOW_FUNCTION GetKindWindow(void) const { return static_cast(Kind_WindowFct); } + WINDOW_FUNCTION GetKindWindow(void) const { return Kind_WindowFct; } /*! * \brief Get the name of the file with the forces breakdown of the problem. diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 091521977f5a..24212dc66980 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -925,17 +925,17 @@ static const MapType SGS_Model_Map = { /*! * \brief Types of window (weight) functions for cost functional */ -enum WINDOW_FUNCTION { - SQUARE = 0, /*!< \brief No weight function (order 1)*/ - HANN = 1, /*!< \brief Hann-type weight function (order 3) */ - HANN_SQUARE = 2, /*!< \brief Hann-squared type weight function (order 5)*/ - BUMP = 3, /*!< \brief bump type weight function (exponential order of convergence) */ +enum class WINDOW_FUNCTION { + SQUARE, /*!< \brief No weight function (order 1)*/ + HANN, /*!< \brief Hann-type weight function (order 3) */ + HANN_SQUARE, /*!< \brief Hann-squared type weight function (order 5)*/ + BUMP, /*!< \brief bump type weight function (exponential order of convergence) */ }; static const MapType Window_Map = { - MakePair("SQUARE", SQUARE) - MakePair("HANN", HANN) - MakePair("HANN_SQUARE", HANN_SQUARE) - MakePair("BUMP", BUMP) + MakePair("SQUARE", WINDOW_FUNCTION::SQUARE) + MakePair("HANN", WINDOW_FUNCTION::HANN) + MakePair("HANN_SQUARE", WINDOW_FUNCTION::HANN_SQUARE) + MakePair("BUMP", WINDOW_FUNCTION::BUMP) }; /*! diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 897ab12de176..0948aab8310e 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -2677,7 +2677,7 @@ void CConfig::SetConfig_Options() { addUnsignedLongOption("WINDOW_START_ITER", StartWindowIteration, 0); /* DESCRIPTION: Window (weight) function for the cost-functional in the reverse sweep */ - addEnumOption("WINDOW_FUNCTION", Kind_WindowFct,Window_Map, SQUARE); + addEnumOption("WINDOW_FUNCTION", Kind_WindowFct, Window_Map, WINDOW_FUNCTION::SQUARE); /* DESCRIPTION: DES Constant */ addDoubleOption("DES_CONST", Const_DES, 0.65); diff --git a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp index 508efd6d326b..8be89ae85576 100644 --- a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp @@ -102,11 +102,4 @@ class CAdjFlowIncOutput final: public COutput { */ bool SetInit_Residuals(CConfig *config) override; - /*! - * \brief Check whether the averaged values should be updated - * \param[in] config - Definition of the particular problem. - * \return averages should be updated. - */ - bool SetUpdate_Averages(CConfig *config) override; - }; diff --git a/SU2_CFD/include/output/CAdjFlowOutput.hpp b/SU2_CFD/include/output/CAdjFlowOutput.hpp index de0f288056cb..d18e6aa462c4 100644 --- a/SU2_CFD/include/output/CAdjFlowOutput.hpp +++ b/SU2_CFD/include/output/CAdjFlowOutput.hpp @@ -99,11 +99,4 @@ class CAdjFlowCompOutput final: public COutput { */ bool SetInit_Residuals(CConfig *config) override; - /*! - * \brief Check whether the averaged values should be updated - * \param[in] config - Definition of the particular problem. - * \return averages should be updated. - */ - bool SetUpdate_Averages(CConfig *config) override; - }; diff --git a/SU2_CFD/include/output/CElasticityOutput.hpp b/SU2_CFD/include/output/CElasticityOutput.hpp index 7f6fe4662f06..b79ad3df54a4 100644 --- a/SU2_CFD/include/output/CElasticityOutput.hpp +++ b/SU2_CFD/include/output/CElasticityOutput.hpp @@ -88,4 +88,5 @@ class CElasticityOutput final: public COutput { * \return if the residuals should be initialized. */ bool SetInit_Residuals(CConfig *config) override; + }; diff --git a/SU2_CFD/include/output/CFlowCompFEMOutput.hpp b/SU2_CFD/include/output/CFlowCompFEMOutput.hpp index c806375eb00d..748be9c21a85 100644 --- a/SU2_CFD/include/output/CFlowCompFEMOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompFEMOutput.hpp @@ -103,11 +103,4 @@ class CFlowCompFEMOutput final: public CFlowOutput { */ bool SetInit_Residuals(CConfig *config) override; - /*! - * \brief Check whether the averaged values should be updated - * \param[in] config - Definition of the particular problem. - * \return averages should be updated. - */ - bool SetUpdate_Averages(CConfig *config) override; - }; diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index 3735a010372a..7af5d70a6a66 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -102,13 +102,6 @@ class CFlowCompOutput final: public CFlowOutput { */ bool SetInit_Residuals(CConfig *config) override; - /*! - * \brief Check whether the averaged values should be updated - * \param[in] config - Definition of the particular problem. - * \return averages should be updated. - */ - bool SetUpdate_Averages(CConfig *config) override; - /*! * \brief Write any additional output defined for the current solver. * \param[in] config - Definition of the particular problem per zone. diff --git a/SU2_CFD/include/output/CFlowIncOutput.hpp b/SU2_CFD/include/output/CFlowIncOutput.hpp index a534e9b113dc..af106a330932 100644 --- a/SU2_CFD/include/output/CFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CFlowIncOutput.hpp @@ -104,11 +104,4 @@ class CFlowIncOutput final: public CFlowOutput { */ bool SetInit_Residuals(CConfig *config) override; - /*! - * \brief Check whether the averaged values should be updated - * \param[in] config - Definition of the particular problem. - * \return averages should be updated. - */ - bool SetUpdate_Averages(CConfig *config) override; - }; diff --git a/SU2_CFD/include/output/CNEMOCompOutput.hpp b/SU2_CFD/include/output/CNEMOCompOutput.hpp index 64f54c71e58e..434536cd1c0f 100644 --- a/SU2_CFD/include/output/CNEMOCompOutput.hpp +++ b/SU2_CFD/include/output/CNEMOCompOutput.hpp @@ -103,13 +103,6 @@ class CNEMOCompOutput final: public CFlowOutput { */ bool SetInit_Residuals(CConfig *config) override; - /*! - * \brief Check whether the averaged values should be updated - * \param[in] config - Definition of the particular problem. - * \return averages should be updated. - */ - bool SetUpdate_Averages(CConfig *config) override; - /*! * \brief Write any additional output defined for the current solver. * \param[in] config - Definition of the particular problem per zone. diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 17701d4bc5d2..98ac3e416e35 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -652,6 +652,12 @@ class COutput { return (iIter % iFreq == 0); } + /*! + * \brief OutputScreenAndHistory + * \param[in] config - Definition of the particular problem. + */ + void OutputScreenAndHistory(CConfig *config); + /*! * \brief Set the history fields common for all solvers. * \param[in] config - Definition of the particular problem. @@ -735,13 +741,6 @@ class COutput { */ inline virtual bool SetInit_Residuals(CConfig *config) {return false;} - /*! - * \brief Check whether the averaged values should be updated - * \param[in] config - Definition of the particular problem. - * \return averages should be updated. - */ - inline virtual bool SetUpdate_Averages(CConfig *config){return false;} - /*! * \brief Set the values of the volume output fields for a surface point. * \param[in] config - Definition of the particular problem. diff --git a/SU2_CFD/include/output/tools/CWindowingTools.hpp b/SU2_CFD/include/output/tools/CWindowingTools.hpp index 89bb350771d6..eeef650ee453 100644 --- a/SU2_CFD/include/output/tools/CWindowingTools.hpp +++ b/SU2_CFD/include/output/tools/CWindowingTools.hpp @@ -28,6 +28,7 @@ #pragma once #include +#include #include "../../../../Common/include/option_structure.hpp" class CWindowingTools{ @@ -38,7 +39,7 @@ class CWindowingTools{ * \param endTimeIter - Number of time steps to average over * \return Value of the window-weight-function at time curTimeIter with time-frame endTimeIter */ - su2double GetWndWeight(WINDOW_FUNCTION windowId, unsigned long curTimeIter, unsigned long endTimeIter) const; + static su2double GetWndWeight(WINDOW_FUNCTION windowId, unsigned long curTimeIter, unsigned long endTimeIter); protected: // Long time windows @@ -47,74 +48,78 @@ class CWindowingTools{ * \param endTimeIter - Number of time steps to average over * \return Value of the window-weight-function at time curTimeIter with end-time endTimeIter */ - su2double HannWindow(unsigned long curTimeIter, unsigned long endTimeIter) const; + static su2double HannWindow(unsigned long curTimeIter, unsigned long endTimeIter); /*! \brief Returns the value of the Hann-Square-window function at time-step i with given end-time endTimeIter. * \param curTimeIter - Current time iteration of the solver * \param endTimeIter - Number of time steps to average over * \return Value of the window-weight-function at time curTimeIter with end-time endTimeIter */ - su2double HannSquaredWindow(unsigned long curTimeIter, unsigned long endTimeIter) const; + static su2double HannSquaredWindow(unsigned long curTimeIter, unsigned long endTimeIter); /*! \brief Returns the value of the Bump-window function at time-step i with given end-time endTimeIter. * \param curTimeIter - Current time iteration of the solver * \param endTimeIter - Number of time steps to average over * \return Value of the window-weight-function at time curTimeIter with end-time endTimeIter */ - su2double BumpWindow(unsigned long curTimeIter, unsigned long endTimeIter) const; + static su2double BumpWindow(unsigned long curTimeIter, unsigned long endTimeIter); }; class CWindowedAverage:CWindowingTools{ private: - su2double val; /*!< \brief Value of the windowed-time average (of the instantaneous output) from starting time to the current time iteration. */ - std::vector values; /*!< \brief Vector of instantatneous output values from starting time to the current time iteration.*/ + su2double val = 0.0; /*!< \brief Value of the windowed-time average (of the instantaneous output) from starting time to the current time iteration. */ + std::vector values; /*!< \brief Vector of instantatneous output values from starting time to the current time iteration.*/ + unsigned long lastTimeIter = std::numeric_limits::max(); public: - CWindowedAverage(); - - /*! \brief Returns the value of windowed-time average (of the instantaneous output) from starting time to the current time iteration - * \return val - */ - inline su2double GetVal() const{ - return val; - }; - - /*! \brief Resets the value of windowed-time average (of the instantaneous output) from starting time to the current time iteration to 0. - */ - void Reset(); + /*! + * \brief Returns the value of windowed-time average (of the instantaneous output) from starting time to the current time iteration + */ + inline su2double GetVal() const { return val; } - /*! \brief Adds the instantaneous output of the current iteration to the values-vector, if the current iteration is greater or equal to the starting iteration. - * \param valIn - value of the instantaneous output, that should be added - * \param currentIter - current time Iteration - * \param startIter - iteration to start the windowed-time average. - */ + /*! + *\brief Resets the value of windowed-time average (of the instantaneous output) from starting time to the current time iteration to 0. + */ + inline void Reset() { + val = 0.0; + values.clear(); + lastTimeIter = std::numeric_limits::max(); + } + + /*! + * \brief Adds the instantaneous output of the current iteration to the values-vector, if the current iteration is greater or equal to the starting iteration. + * \param valIn - value of the instantaneous output, that should be added + * \param currentIter - current time Iteration + * \param startIter - iteration to start the windowed-time average. + */ void addValue(su2double valIn, unsigned long curTimeIter,unsigned long startIter = 0); - /*! \brief Computes a windowed-time average of the values stored in the vector "values" using the windowing-function specified in enum windowId - * and stores it in "val". - * \param windowId - specified windowing-function - * \return windowed-time average of the values stored in the vector "values" - */ + /*! + * \brief Computes a windowed-time average of the values stored in the vector "values" using the windowing-function specified in enum windowId + * and stores it in "val". + * \param windowId - specified windowing-function + * \return windowed-time average of the values stored in the vector "values" + */ su2double WindowedUpdate(WINDOW_FUNCTION windowId); private: /*! \brief Computes a Square-windowed-time average of the values stored in the vector "values" with the Midpoint-integration rule (for consistency with the adjoint solver). * \return Squarewindowed-time average of the values stored in the vector "values" */ - su2double NoWindowing(); + su2double NoWindowing() const; /*! \brief Computes a Hann-windowed-time average of the values stored in the vector "values" with the Midpoint-integration rule (for consistency with the adjoint solver). * \return Squarewindowed-time average of the values stored in the vector "values" */ - su2double HannWindowing(); + su2double HannWindowing() const; /*! \brief Computes a Hann-Square-windowed-time average of the values stored in the vector "values" with the Midpoint-integration rule (for consistency with the adjoint solver). * \return Squarewindowed-time average of the values stored in the vector "values" */ - su2double HannSquaredWindowing(); + su2double HannSquaredWindowing() const; /*! \brief Computes a Bump-windowed-time average of the values stored in the vector "values" with the Midpoint-integration rule (for consistency with the adjoint solver). * \return Squarewindowed-time average of the values stored in the vector "values" */ - su2double BumpWindowing(); + su2double BumpWindowing() const; }; diff --git a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp index 9d501475b507..6d5db2133b20 100644 --- a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp @@ -466,11 +466,3 @@ bool CAdjFlowCompOutput::SetInit_Residuals(CConfig *config){ ((config->GetTime_Marching() == TIME_MARCHING::STEADY) && (curInnerIter < 2)); } - -bool CAdjFlowCompOutput::SetUpdate_Averages(CConfig *config){ - return false; - -// return (config->GetUnsteady_Simulation() != STEADY && !dualtime); - -} - diff --git a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp index fb2517917925..95cfe3623400 100644 --- a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp @@ -530,10 +530,3 @@ bool CAdjFlowIncOutput::SetInit_Residuals(CConfig *config){ (config->GetTime_Marching() == TIME_MARCHING::STEADY && (curTimeIter < 2)); } - -bool CAdjFlowIncOutput::SetUpdate_Averages(CConfig *config){ - return false; - -// return (config->GetUnsteady_Simulation() != STEADY && !dualtime); - -} diff --git a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp index 9490aad19e4b..91cade8a86c9 100644 --- a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp @@ -278,12 +278,3 @@ bool CFlowCompFEMOutput::SetInit_Residuals(CConfig *config){ (config->GetTime_Marching() == TIME_MARCHING::STEADY && (curTimeIter < 2)); } - -bool CFlowCompFEMOutput::SetUpdate_Averages(CConfig *config){ - return false; - -// return (config->GetUnsteady_Simulation() != STEADY && !dualtime); - -} - - diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 18c26c4f7230..ab005609c4f7 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -724,13 +724,6 @@ bool CFlowCompOutput::SetInit_Residuals(CConfig *config){ } -bool CFlowCompOutput::SetUpdate_Averages(CConfig *config){ - - return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == config->GetnInner_Iter() - 1 || convergence)); - -} - - void CFlowCompOutput::SetAdditionalScreenOutput(CConfig *config){ if (config->GetFixed_CL_Mode()){ diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index a5d7188f5d1f..7d63983d9ec5 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -701,9 +701,3 @@ bool CFlowIncOutput::SetInit_Residuals(CConfig *config){ (config->GetTime_Marching() == TIME_MARCHING::STEADY && (curInnerIter < 2)); } - -bool CFlowIncOutput::SetUpdate_Averages(CConfig *config){ - - return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == config->GetnInner_Iter() - 1 || convergence)); - -} diff --git a/SU2_CFD/src/output/CNEMOCompOutput.cpp b/SU2_CFD/src/output/CNEMOCompOutput.cpp index 754ce7e8f712..b4709a3de6a3 100644 --- a/SU2_CFD/src/output/CNEMOCompOutput.cpp +++ b/SU2_CFD/src/output/CNEMOCompOutput.cpp @@ -696,12 +696,6 @@ bool CNEMOCompOutput::SetInit_Residuals(CConfig *config){ } -bool CNEMOCompOutput::SetUpdate_Averages(CConfig *config){ - - return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == config->GetnInner_Iter() - 1 || convergence)); - -} - void CNEMOCompOutput::SetAdditionalScreenOutput(CConfig *config){ if (config->GetFixed_CL_Mode()){ diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index 4a81f7207d0d..40a4f50be75e 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -201,8 +201,6 @@ void COutput::SetHistory_Output(CGeometry *geometry, curOuterIter = OuterIter; curInnerIter = InnerIter; - bool write_header, write_history, write_screen; - /*--- Retrieve residual and extra data -----------------------------------------------------------------*/ LoadCommonHistoryData(config); @@ -215,23 +213,7 @@ void COutput::SetHistory_Output(CGeometry *geometry, MonitorTimeConvergence(config, curTimeIter); - /*--- Output using only the master node ---*/ - - if (rank == MASTER_NODE && !noWriting) { - - /*--- Write the history file ---------------------------------------------------------------------------*/ - write_history = WriteHistoryFile_Output(config); - if (write_history) SetHistoryFile_Output(config); - - /*--- Write the screen header---------------------------------------------------------------------------*/ - write_header = WriteScreen_Header(config); - if (write_header) SetScreen_Header(config); - - /*--- Write the screen output---------------------------------------------------------------------------*/ - write_screen = WriteScreen_Output(config); - if (write_screen) SetScreen_Output(config); - - } + OutputScreenAndHistory(config); } @@ -248,6 +230,7 @@ void COutput::SetHistory_Output(CGeometry *geometry, Convergence_Monitoring(config, curInnerIter); Postprocess_HistoryData(config); + } void COutput::SetMultizoneHistory_Output(COutput **output, CConfig **config, CConfig *driver_config, unsigned long TimeIter, unsigned long OuterIter){ @@ -256,8 +239,6 @@ void COutput::SetMultizoneHistory_Output(COutput **output, CConfig **config, CCo curAbsTimeIter = TimeIter - driver_config->GetRestart_Iter(); curOuterIter = OuterIter; - bool write_header, write_screen, write_history; - /*--- Retrieve residual and extra data -----------------------------------------------------------------*/ LoadCommonHistoryData(driver_config); @@ -270,24 +251,28 @@ void COutput::SetMultizoneHistory_Output(COutput **output, CConfig **config, CCo MonitorTimeConvergence(driver_config, curTimeIter); - /*--- Output using only the master node ---*/ + OutputScreenAndHistory(driver_config); + +} + +void COutput::OutputScreenAndHistory(CConfig *config) { + bool write_header, write_screen, write_history; if (rank == MASTER_NODE && !noWriting) { /*--- Write the history file ---------------------------------------------------------------------------*/ - write_history = WriteHistoryFile_Output(driver_config); - if (write_history) SetHistoryFile_Output(driver_config); + write_history = WriteHistoryFile_Output(config); + if (write_history) SetHistoryFile_Output(config); /*--- Write the screen header---------------------------------------------------------------------------*/ - write_header = WriteScreen_Header(driver_config); - if (write_header) SetScreen_Header(driver_config); + write_header = WriteScreen_Header(config); + if (write_header) SetScreen_Header(config); /*--- Write the screen output---------------------------------------------------------------------------*/ - write_screen = WriteScreen_Output(driver_config); - if (write_screen) SetScreen_Output(driver_config); + write_screen = WriteScreen_Output(config); + if (write_screen) SetScreen_Output(config); } - } void COutput::AllocateDataSorters(CConfig *config, CGeometry *geometry){ @@ -1716,10 +1701,6 @@ void COutput::SetAvgVolumeOutputValue(string name, unsigned long iPoint, su2doub } - - - - void COutput::Postprocess_HistoryData(CConfig *config){ map > Average; @@ -1741,13 +1722,11 @@ void COutput::Postprocess_HistoryData(CConfig *config){ } if (currentField.fieldType == HistoryFieldType::COEFFICIENT){ - if(SetUpdate_Averages(config)){ - if (config->GetTime_Domain()){ - windowedTimeAverages[historyOutput_List[iField]].addValue(currentField.value,config->GetTimeIter(), config->GetStartWindowIteration()); //Collecting Values for Windowing - SetHistoryOutputValue("TAVG_" + fieldIdentifier, windowedTimeAverages[fieldIdentifier].WindowedUpdate(config->GetKindWindow())); - if (config->GetDirectDiff() != NO_DERIVATIVE) { - SetHistoryOutputValue("D_TAVG_" + fieldIdentifier, SU2_TYPE::GetDerivative(windowedTimeAverages[fieldIdentifier].GetVal())); - } + if (config->GetTime_Domain()){ + windowedTimeAverages[historyOutput_List[iField]].addValue(currentField.value,config->GetTimeIter(), config->GetStartWindowIteration()); //Collecting Values for Windowing + SetHistoryOutputValue("TAVG_" + fieldIdentifier, windowedTimeAverages[fieldIdentifier].WindowedUpdate(config->GetKindWindow())); + if (config->GetDirectDiff() != NO_DERIVATIVE) { + SetHistoryOutputValue("D_TAVG_" + fieldIdentifier, SU2_TYPE::GetDerivative(windowedTimeAverages[fieldIdentifier].GetVal())); } } if (config->GetDirectDiff() != NO_DERIVATIVE){ diff --git a/SU2_CFD/src/output/tools/CWindowingTools.cpp b/SU2_CFD/src/output/tools/CWindowingTools.cpp index ae85afda06c7..409d792a258a 100644 --- a/SU2_CFD/src/output/tools/CWindowingTools.cpp +++ b/SU2_CFD/src/output/tools/CWindowingTools.cpp @@ -26,17 +26,20 @@ */ #include "../../../include/output/tools/CWindowingTools.hpp" +#include //WindowingTools -su2double CWindowingTools::GetWndWeight(WINDOW_FUNCTION windowId, unsigned long curTimeIter, unsigned long endTimeIter) const{ +su2double CWindowingTools::GetWndWeight(WINDOW_FUNCTION windowId, unsigned long curTimeIter, unsigned long endTimeIter) { switch (windowId) { - case HANN: return HannWindow(curTimeIter, endTimeIter); - case HANN_SQUARE: return HannSquaredWindow(curTimeIter, endTimeIter); - case BUMP: return BumpWindow(curTimeIter, endTimeIter); - default:return 1.0; + case WINDOW_FUNCTION::HANN: return HannWindow(curTimeIter, endTimeIter); + case WINDOW_FUNCTION::HANN_SQUARE: return HannSquaredWindow(curTimeIter, endTimeIter); + case WINDOW_FUNCTION::BUMP: return BumpWindow(curTimeIter, endTimeIter); + case WINDOW_FUNCTION::SQUARE: return 1.0; } + return 1.0; } -su2double CWindowingTools::HannWindow(unsigned long curTimeIter, unsigned long endTimeIter) const{ + +su2double CWindowingTools::HannWindow(unsigned long curTimeIter, unsigned long endTimeIter) { su2double currTimeDouble = static_cast(curTimeIter); if(endTimeIter==0) return 0; //Catch div by zero error, if window length is zero su2double endTimeDouble = static_cast(endTimeIter); @@ -44,7 +47,7 @@ su2double CWindowingTools::HannWindow(unsigned long curTimeIter, unsigned long e return 1.0-cos(2*PI_NUMBER*tau); } -su2double CWindowingTools::HannSquaredWindow(unsigned long curTimeIter, unsigned long endTimeIter) const{ +su2double CWindowingTools::HannSquaredWindow(unsigned long curTimeIter, unsigned long endTimeIter) { su2double currTimeDouble = static_cast(curTimeIter); if(endTimeIter==0) return 0; //Catch div by zero error, if window length is zero su2double endTimeDouble = static_cast(endTimeIter); @@ -52,7 +55,7 @@ su2double CWindowingTools::HannSquaredWindow(unsigned long curTimeIter, unsigned return 2.0/3.0*(1-cos(2*PI_NUMBER*tau))*(1-cos(2*PI_NUMBER*tau)); } -su2double CWindowingTools::BumpWindow(unsigned long curTimeIter, unsigned long endTimeIter) const{ +su2double CWindowingTools::BumpWindow(unsigned long curTimeIter, unsigned long endTimeIter) { if(curTimeIter==0) return 0; if(curTimeIter==endTimeIter) return 0; su2double currTimeDouble = static_cast(curTimeIter); @@ -63,27 +66,22 @@ su2double CWindowingTools::BumpWindow(unsigned long curTimeIter, unsigned long e * and it acts as a normalization constant */ } - -//WindowedAverage -CWindowedAverage::CWindowedAverage(){ - this->Reset(); -} - -void CWindowedAverage::Reset(){ - val = 0.; -} - void CWindowedAverage::addValue(su2double valIn, unsigned long curTimeIter,unsigned long startIter){ - if(curTimeIter >= startIter)values.push_back(valIn); + if (curTimeIter < startIter) return; + if (curTimeIter != lastTimeIter) { + lastTimeIter = curTimeIter; + values.push_back(valIn); + } + else values.back() = valIn; } su2double CWindowedAverage::WindowedUpdate(WINDOW_FUNCTION windowId){ if(values.size()>0){ switch (windowId){ - case HANN: val= HannWindowing(); return val; - case HANN_SQUARE: val= HannSquaredWindowing(); return val; - case BUMP: val= BumpWindowing(); return val; - default: val= NoWindowing(); return val; + case WINDOW_FUNCTION::HANN: val= HannWindowing(); return val; + case WINDOW_FUNCTION::HANN_SQUARE: val= HannSquaredWindowing(); return val; + case WINDOW_FUNCTION::BUMP: val= BumpWindowing(); return val; + case WINDOW_FUNCTION::SQUARE: val= NoWindowing(); return val; } } return 0.0; @@ -93,7 +91,7 @@ su2double CWindowedAverage::WindowedUpdate(WINDOW_FUNCTION windowId){ * Krakos et al. : "Sensitivity analysis of limit cycle oscillations" * by Krakos, J. A. and Wang, Q. and Hall, S. R. and Darmfoal, D. L.. */ -su2double CWindowedAverage::NoWindowing(){ +su2double CWindowedAverage::NoWindowing() const { su2double wnd_timeAvg = 0.0; for(unsigned long curTimeIter=0; curTimeIter(values.size()); } -su2double CWindowedAverage::HannWindowing(){ +su2double CWindowedAverage::HannWindowing() const { su2double wnd_timeAvg = 0.0; for(unsigned long curTimeIter=0; curTimeIter(values.size()); } -su2double CWindowedAverage::HannSquaredWindowing(){ +su2double CWindowedAverage::HannSquaredWindowing() const { su2double wnd_timeAvg = 0.0; for(unsigned long curTimeIter=0; curTimeIter(values.size()); } -su2double CWindowedAverage::BumpWindowing(){ +su2double CWindowedAverage::BumpWindowing() const { su2double wnd_timeAvg = 0.0; for(unsigned long curTimeIter=0; curTimeIter(values.size()); } - diff --git a/TestCases/fea_fsi/dyn_fsi/config.cfg b/TestCases/fea_fsi/dyn_fsi/config.cfg index 00f2925f0157..fd33d17790ee 100644 --- a/TestCases/fea_fsi/dyn_fsi/config.cfg +++ b/TestCases/fea_fsi/dyn_fsi/config.cfg @@ -22,3 +22,5 @@ RESTART_SOL= YES RESTART_ITER = 2 OUTER_ITER = 10 + +WRT_ZONE_HIST= YES \ No newline at end of file diff --git a/TestCases/fea_fsi/dyn_fsi/configFEA.cfg b/TestCases/fea_fsi/dyn_fsi/configFEA.cfg index 0423a1d488d1..a0487e2f5ac6 100644 --- a/TestCases/fea_fsi/dyn_fsi/configFEA.cfg +++ b/TestCases/fea_fsi/dyn_fsi/configFEA.cfg @@ -53,3 +53,8 @@ VOLUME_FILENAME= results_wall RESTART_FILENAME= restart_wall.dat SOLUTION_FILENAME= solution_wall.dat +HISTORY_OUTPUT= ITER, RMS_RES, STRUCT_COEFF, TAVG_STRUCT_COEFF +OBJECTIVE_FUNCTION= REFERENCE_NODE +REFERENCE_NODE = 3 +REFERENCE_NODE_DISPLACEMENT = (0.0, 0.0) +REFERENCE_NODE_PENALTY = 1.0 diff --git a/TestCases/fea_fsi/dyn_fsi/configFlow.cfg b/TestCases/fea_fsi/dyn_fsi/configFlow.cfg index 17104d089edd..8f81173a29ac 100644 --- a/TestCases/fea_fsi/dyn_fsi/configFlow.cfg +++ b/TestCases/fea_fsi/dyn_fsi/configFlow.cfg @@ -76,3 +76,4 @@ VOLUME_FILENAME= results_flow RESTART_FILENAME= restart_flow.dat SOLUTION_FILENAME= solution_flow.dat +HISTORY_OUTPUT= ITER, RMS_RES, AERO_COEFF, TAVG_AERO_COEFF diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index c7330365d7d2..481838842eb8 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -198,7 +198,7 @@ def main(): discadj_cylinder.cfg_dir = "disc_adj_rans/cylinder" discadj_cylinder.cfg_file = "cylinder_Windowing.cfg" discadj_cylinder.test_iter = 6 - discadj_cylinder.test_vals = [0.202349, -0.000119, 2.688757, -0.000032, 1.067900] + discadj_cylinder.test_vals = [0.202349, -0.000119, 1.899933, -0.000050, 1.067900] discadj_cylinder.su2_exec = "parallel_computation.py -f" discadj_cylinder.timeout = 1600 discadj_cylinder.tol = 0.0001