Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extending CFL adapt to include species transport #2298

Merged
merged 13 commits into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions SU2_CFD/src/solvers/CSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry,

CSolver *solverFlow = solver_container[iMesh][FLOW_SOL];
CSolver *solverTurb = solver_container[iMesh][TURB_SOL];
CSolver *solverSpecies = solver_container[iMesh][SPECIES_SOL];

/* Compute the reduction factor for CFLs on the coarse levels. */

Expand All @@ -1744,10 +1745,12 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry,
solver residual within the specified number of linear iterations. */

su2double linResTurb = 0.0;
su2double linResSpecies = 0.0;
if ((iMesh == MESH_0) && solverTurb) linResTurb = solverTurb->GetResLinSolver();
if ((iMesh == MESH_0) && solverSpecies) linResSpecies = solverSpecies->GetResLinSolver();

/* Max linear residual between flow and turbulence. */
const su2double linRes = max(solverFlow->GetResLinSolver(), linResTurb);
/* Max linear residual between flow and turbulence/species transport. */
const su2double linRes = max(solverFlow->GetResLinSolver(), max(linResTurb, linResSpecies));

/* Tolerance limited to an acceptable value. */
const su2double linTol = max(acceptableLinTol, config->GetLinear_Solver_Error());
Expand Down Expand Up @@ -1779,6 +1782,11 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry,
New_Func += log10(solverTurb->GetRes_RMS(iVar));
}
}
if ((iMesh == MESH_0) && solverSpecies) {
for (unsigned short iVar = 0; iVar < solverSpecies->GetnVar(); iVar++) {
New_Func += log10(solverSpecies->GetRes_RMS(iVar));
}
}

/* Compute the difference in the nonlinear residuals between the
current and previous iterations, taking care with very low initial
Expand Down Expand Up @@ -1822,6 +1830,7 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry,

su2double myCFLMin = 1e30, myCFLMax = 0.0, myCFLSum = 0.0;
const su2double CFLTurbReduction = config->GetCFLRedCoeff_Turb();
const su2double CFLSpeciesReduction = config->GetCFLRedCoeff_Species();

SU2_OMP_MASTER
if ((iMesh == MESH_0) && fullComms) {
Expand Down Expand Up @@ -1888,6 +1897,9 @@ void CSolver::AdaptCFLNumber(CGeometry **geometry,
if ((iMesh == MESH_0) && solverTurb) {
solverTurb->GetNodes()->SetLocalCFL(iPoint, CFL * CFLTurbReduction);
}
if ((iMesh == MESH_0) && solverSpecies) {
solverSpecies->GetNodes()->SetLocalCFL(iPoint, CFL * CFLSpeciesReduction);
}

/* Store min and max CFL for reporting on the fine grid. */

Expand Down