Skip to content

Commit

Permalink
Feature CFL adaptation initial iteration (#2362)
Browse files Browse the repository at this point in the history
* Feature to define initial iteration to apply CFL adaption.

A spark initialization was not possible with CFL adaptation, as the CFL number would increase too far before the spark initiates the combustion. This led to immediate flashback or blow-off. An additional parameter in the CFL adaptation defines the iteration, at which the CFL adaption should start. This allows the combustion to stabilize before the CFL number increases.

Co-authored-by: Nijso <[email protected]>
Co-authored-by: TobiKattmann <[email protected]>
Co-authored-by: Nijso <[email protected]>
Co-authored-by: Pedro Gomes <[email protected]>
  • Loading branch information
5 people authored Oct 25, 2024
1 parent a3a90e0 commit 492ada9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ class CConfig {
bool Radiation; /*!< \brief Determines if a radiation model is incorporated. */
su2double CFL_Rad; /*!< \brief CFL Number for the radiation solver. */

array<su2double,5> default_cfl_adapt; /*!< \brief Default CFL adapt param array for the COption class. */
array<su2double,6> default_cfl_adapt; /*!< \brief Default CFL adapt param array for the COption class. */
su2double vel_init[3], /*!< \brief initial velocity array for the COption class. */
vel_inf[3], /*!< \brief freestream velocity array for the COption class. */
eng_cyl[7], /*!< \brief engine box array for the COption class. */
Expand Down
12 changes: 9 additions & 3 deletions Common/src/CConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,11 +1777,16 @@ void CConfig::SetConfig_Options() {
/* DESCRIPTION: Activate The adaptive CFL number. */
addBoolOption("CFL_ADAPT", CFL_Adapt, false);
/* !\brief CFL_ADAPT_PARAM
* DESCRIPTION: Parameters of the adaptive CFL number (factor down, factor up, CFL limit (min and max), acceptable linear residual )
* DESCRIPTION: Parameters of the adaptive CFL number (factor down, factor up, CFL limit (min and max)[, acceptable linear residual][, starting iteration]).
* Parameters in square brackets are optional, parameter "starting iteration" only valid with parameter "acceptable linear residual".
* Factor down generally <1.0, factor up generally > 1.0 to cause the CFL to increase when the under-relaxation parameter is 1.0
* and to decrease when the under-relaxation parameter is less than 0.1. Factor is multiplicative. \ingroup Config*/
default_cfl_adapt[0] = 1.0; default_cfl_adapt[1] = 1.0; default_cfl_adapt[2] = 10.0; default_cfl_adapt[3] = 100.0;
default_cfl_adapt[0] = 0.1;
default_cfl_adapt[1] = 1.2;
default_cfl_adapt[2] = 10.0;
default_cfl_adapt[3] = 100.0;
default_cfl_adapt[4] = 0.001;
default_cfl_adapt[5] = 0.0;
addDoubleListOption("CFL_ADAPT_PARAM", nCFL_AdaptParam, CFL_AdaptParam);
/* DESCRIPTION: Reduction factor of the CFL coefficient in the adjoint problem */
addDoubleOption("CFL_REDUCTION_ADJFLOW", CFLRedCoeff_AdjFlow, 0.8);
Expand Down Expand Up @@ -7230,7 +7235,8 @@ void CConfig::SetOutput(SU2_COMPONENT val_software, unsigned short val_izone) {
if (!CFL_Adapt) cout << "No CFL adaptation." << endl;
else cout << "CFL adaptation. Factor down: "<< CFL_AdaptParam[0] <<", factor up: "<< CFL_AdaptParam[1]
<<",\n lower limit: "<< CFL_AdaptParam[2] <<", upper limit: " << CFL_AdaptParam[3]
<<",\n acceptable linear residual: "<< CFL_AdaptParam[4] << "." << endl;
<<",\n acceptable linear residual: "<< CFL_AdaptParam[4]
<<"'\n starting iteration: "<< CFL_AdaptParam[5] << "." << endl;

if (nMGLevels !=0) {
PrintingToolbox::CTablePrinter MGTable(&std::cout);
Expand Down
9 changes: 7 additions & 2 deletions SU2_CFD/src/solvers/CSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1717,6 +1717,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry,
const su2double CFLMin = config->GetCFL_AdaptParam(2);
const su2double CFLMax = config->GetCFL_AdaptParam(3);
const su2double acceptableLinTol = config->GetCFL_AdaptParam(4);
const su2double startingIter = config->GetCFL_AdaptParam(5);
const bool fullComms = (config->GetComm_Level() == COMM_FULL);

/* Number of iterations considered to check for stagnation. */
Expand Down Expand Up @@ -1764,8 +1765,12 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry,

/* Check if we should decrease or if we can increase, the 20% is to avoid flip-flopping. */
resetCFL = linRes > 0.99;
reduceCFL = linRes > 1.2*linTol;
canIncrease = linRes < linTol;
unsigned long iter = config->GetMultizone_Problem() ? config->GetOuterIter() : config->GetInnerIter();

/* only change CFL number when larger than starting iteration */
reduceCFL = (linRes > 1.2*linTol) && (iter >= startingIter);

canIncrease = (linRes < linTol) && (iter >= startingIter);

if ((iMesh == MESH_0) && (Res_Count > 0)) {
Old_Func = New_Func;
Expand Down
8 changes: 4 additions & 4 deletions config_template.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -1389,12 +1389,12 @@ CFL_NUMBER= 15.0
CFL_ADAPT= NO
%
% Parameters of the adaptive CFL number (factor-down, factor-up, CFL min value,
% CFL max value, acceptable linear solver convergence)
% Local CFL increases by factor-up until max if the solution rate of change is not limited,
% and acceptable linear convergence is achieved. It is reduced if rate is limited, or if there
% CFL max value, acceptable linear solver convergence, starting iteration)
% After the starting iteration has passed, local CFL increases by factor-up until max if the solution rate of
% change is not limited, and acceptable linear convergence is achieved. It is reduced if rate is limited, or if there
% is not enough linear convergence, or if the nonlinear residuals are stagnant and oscillatory.
% It is reset back to min when linear solvers diverge, or if nonlinear residuals increase too much.
CFL_ADAPT_PARAM= ( 0.1, 2.0, 10.0, 1e10, 0.001 )
CFL_ADAPT_PARAM= ( 0.1, 2.0, 10.0, 1e10, 0.001, 0)
%
% Maximum Delta Time in local time stepping simulations
MAX_DELTA_TIME= 1E6
Expand Down

0 comments on commit 492ada9

Please sign in to comment.