Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8bd6c74
Implicit progress variable source Jacobian for flamelet solver
bigfooted Nov 19, 2026
b1387fa
Update flamelet regression values for the implicit PV source Jacobian
bigfooted Nov 19, 2026
899ab14
update monitor for unsteady plotting
bigfooted Nov 21, 2026
5cbf7a2
Merge branch 'develop' into fix_unsteady_flamelet
EvertBunschoten Nov 26, 2026
b2cd7c9
Move the progress variable source Jacobian into CFluidFlamelet
bigfooted Nov 27, 2026
99fff93
Merge remote-tracking branch 'origin/fix_unsteady_flamelet' into fix_…
bigfooted Nov 28, 2026
6dabf0c
Merge branch 'develop' into fix_unsteady_flamelet
bigfooted Nov 29, 2026
0e34254
Apply black formatting to the monitor script and its tests
bigfooted Nov 29, 2026
2fdac90
Flamelet LUT: extrapolate linearly beyond the outer table levels
bigfooted Nov 26, 2026
9f36808
Flamelet: block Jacobian of the preferential diffusion terms
bigfooted Nov 26, 2026
c91ac9b
Flamelet: keep the burnt state of the flame front initialization insi…
bigfooted Nov 26, 2026
2215935
Update flamelet regression values for the preferential diffusion Jaco…
bigfooted Nov 29, 2026
971ee6f
Merge branch 'develop' into fix_unsteady_flamelet
bigfooted Nov 29, 2026
a34cb00
Merge branch 'fix_unsteady_flamelet' of https://github.com/su2code/su…
bigfooted Nov 29, 2026
1652a6d
Potential fix for pull request finding 'CodeQL / Multiplication resul…
bigfooted Nov 29, 2026
ceb8532
Move the SU2_MON changes to their own pull request
bigfooted Nov 29, 2026
c3bc995
Flamelet: clamp outside the mixture fraction range, robust PV source …
bigfooted Nov 29, 2026
4dd35f6
Update the flame initialization and premixed hydrogen regression values
bigfooted Nov 30, 2026
76d548e
Fix the preferential diffusion Jacobian step in AD builds
bigfooted Nov 30, 2026
2ee8857
Flamelet: thermal PD Jacobian with its own diffusivity, guard off-man…
bigfooted Nov 30, 2026
645ae90
Merge branch 'develop' into fix_unsteady_flamelet
bigfooted Dec 1, 2026
16203e5
Merge branch 'develop' into fix_unsteady_flamelet
bigfooted Dec 2, 2026
7fa2ba5
Flamelet: divide the auxiliary species source Jacobian by density
bigfooted Dec 2, 2026
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
8 changes: 8 additions & 0 deletions Common/include/containers/CLookUpTable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,14 @@ class CLookUpTable {
return limits_table_x[i_level];
}

/*!
* \brief Determine the minimum and maximum value of the third controlling variable.
* \returns Pair of the values of the first and last table level.
*/
inline std::pair<su2double, su2double> GetTableLimitsZ() const {
return std::make_pair(z_values_levels.front(), z_values_levels.back());
}

/*!
* \brief Check whether requested set of variables are included in the table.
*/
Expand Down
10 changes: 10 additions & 0 deletions SU2_CFD/include/fluid/CFluidFlamelet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class CFluidFlamelet final : public CFluidModel {
MLPToolbox::CIOMap* iomap_PD; /*!< \brief Input-output map for the preferential diffusion scalars. */
MLPToolbox::CIOMap* iomap_Sources; /*!< \brief Input-output map for species source terms. */
MLPToolbox::CIOMap* iomap_LookUp; /*!< \brief Input-output map for passive look-up terms. */
MLPToolbox::CIOMap* iomap_SourceJacobian; /*!< \brief Input-output map for the progress variable source Jacobian. */
MLPToolbox::CIOMap* iomap_Current;
#endif

Expand All @@ -93,6 +94,8 @@ class CFluidFlamelet final : public CFluidModel {
val_vars_LookUp, /*!< \brief References passive look-up terms. */
val_vars_PD; /*!< \brief References to preferential diffusion scalars. */

su2double source_pv_jac; /*!< \brief Derivative of the progress variable source with respect to the progress variable. */

void PreprocessLookUp(CConfig* config);

/*! \brief
Expand Down Expand Up @@ -135,6 +138,13 @@ class CFluidFlamelet final : public CFluidModel {
unsigned long EvaluateDataSet(const vector<su2double>& input_scalar, unsigned short lookup_type,
vector<su2double>& output_refs);

/*!
* \brief Derivative of the progress variable source term with respect to the progress variable.
* \note Analytic for the MLP method, one-sided difference for the lookup table.
* \param[in] input_scalar - controlling variables used to interpolate manifold.
*/
su2double GetProgVarSourceJacobian(const vector<su2double>& input_scalar) override;

/*!
* \brief Check for out-of-bounds condition for data set interpolation.
* \return - within bounds (0) or out of bounds (1).
Expand Down
6 changes: 6 additions & 0 deletions SU2_CFD/include/fluid/CFluidModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ class CFluidModel {
return 0;
}

/*!
* \brief Derivative of the progress variable source term with respect to the progress variable.
* \param[in] input_scalar - data manifold query data.
*/
virtual su2double GetProgVarSourceJacobian(const vector<su2double>& input_scalar) { return 0.0; }

/*!
* \brief Get fluid dynamic viscosity.
*/
Expand Down
33 changes: 25 additions & 8 deletions SU2_CFD/include/numerics/species/flamelet_edge_flux.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ class CScalarFlux_Flamelet final
* \brief Preferential diffusion, two terms with the shape of the ordinary diffusion but of
* states the model synthesises: div(D grad(beta - phi)) for each controlling variable,
* and a thermal term div(beta_T D grad(T)) on the enthalpy equation.
* \note The thermal term has no implicit part, matching the treatment of the heat flux it
* models; the first term has the same thin shear layer Jacobian as the ordinary diffusion,
* because it is the same operator applied to a shifted state.
* \note The Jacobian uses d(beta - phi)/dphi and dT/dphi from the solver, each with the diffusivity of its flux.
*/
template <class VariableType>
FORCEINLINE void extraDiffusionTerms(const FlowIndices& idx, const ScalarFluxOptions& opt, Int iPoint,
Expand Down Expand Up @@ -104,11 +102,16 @@ class CScalarFlux_Flamelet final
if (!opt.oneSided) res.flux_j(iScalar) += D * projGrad;

if (opt.implicit) {
res.jac_ii(iScalar, iScalar) += D * proj_on_rho_i;
if (!opt.oneSided) {
res.jac_ij(iScalar, iScalar) -= D * proj_on_rho_j;
res.jac_ji(iScalar, iScalar) -= D * proj_on_rho_i;
res.jac_jj(iScalar, iScalar) += D * proj_on_rho_j;
for (auto jScalar = 0u; jScalar < nControlVars; ++jScalar) {
const auto iEntry = iScalar * nControlVars + jScalar;
const Double dState_i = gatherVariables(iPoint, side_i.scalarNodes.GetPrefDiffJacobian(), iEntry);
const Double dState_j = gatherVariables(jPoint, side_j.scalarNodes.GetPrefDiffJacobian(), iEntry);
res.jac_ii(iScalar, jScalar) += D * proj_on_rho_i * dState_i;
if (!opt.oneSided) {
res.jac_ij(iScalar, jScalar) -= D * proj_on_rho_j * dState_j;
res.jac_ji(iScalar, jScalar) -= D * proj_on_rho_i * dState_i;
res.jac_jj(iScalar, jScalar) += D * proj_on_rho_j * dState_j;
}
}
}
}
Expand All @@ -132,6 +135,20 @@ class CScalarFlux_Flamelet final

res.flux_i(I_ENTH) -= Dth * projGradT;
if (!opt.oneSided) res.flux_j(I_ENTH) += Dth * projGradT;

if (opt.implicit) {
const auto iFirst = nControlVars * nControlVars;
for (auto jScalar = 0u; jScalar < nControlVars; ++jScalar) {
const Double dT_i = gatherVariables(iPoint, side_i.scalarNodes.GetPrefDiffJacobian(), iFirst + jScalar);
const Double dT_j = gatherVariables(jPoint, side_j.scalarNodes.GetPrefDiffJacobian(), iFirst + jScalar);
res.jac_ii(I_ENTH, jScalar) += Dth * proj_on_rho_i * dT_i;
if (!opt.oneSided) {
res.jac_ij(I_ENTH, jScalar) -= Dth * proj_on_rho_j * dT_j;
res.jac_ji(I_ENTH, jScalar) -= Dth * proj_on_rho_i * dT_i;
res.jac_jj(I_ENTH, jScalar) += Dth * proj_on_rho_j * dT_j;
}
}
}
}

private:
Expand Down
11 changes: 10 additions & 1 deletion SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver {
/*!< \brief Number of points outside the manifold domain, shared across OpenMP threads so it can be
* accumulated atomically and reduced by the master thread alone in Preprocessing. */
unsigned long n_not_in_domain_local = 0;
bool pd_jacobian = false; /*!< \brief Whether the preferential diffusion Jacobian is evaluated this iteration. */
passivedouble pd_jacobian_step[MAXNVAR] = {0}; /*!< \brief Finite difference step per controlling variable. */

/*!
* \brief Set the finite difference steps of the preferential diffusion Jacobian, a fraction of the global
* range of each controlling variable.
*/
void SetPrefDiffJacobianSteps();
/*!
* \brief Compute the preconditioner for low-Mach flows.
* \param[in] geometry - Geometrical definition of the problem.
Expand Down Expand Up @@ -105,7 +113,8 @@ class CSpeciesFlameletSolver final : public CSpeciesSolver {
const vector<su2double>& scalars);

/*!
* \brief Retrieve the preferential diffusion scalar values from manifold.
* \brief Retrieve the preferential diffusion scalar values from manifold, and their derivatives to the
* controlling variables when the scheme is implicit.
* \param[in] fluid_model_local - pointer to flamelet fluid model.
* \param[in] iPoint - node ID.
* \param[in] scalars - local scalar solution.
Expand Down
11 changes: 11 additions & 0 deletions SU2_CFD/include/variables/CSpeciesFlameletVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class CSpeciesFlameletVariable final : public CSpeciesVariable {
MatrixType lookup_scalar; /*!< \brief Vector of the source terms from the lookup table for each scalar equation */
su2vector<unsigned short> table_misses; /*!< \brief Vector of lookup table misses. */
MatrixType source_cons_jac; /*!< \brief Consumption-rate Jacobian dS_aux_i/dY_aux_i = source_cons_i, one column per user scalar. */
VectorType source_pv_jac; /*!< \brief Derivative of the progress variable source with respect to the progress variable. */

public:
/*!
Expand Down Expand Up @@ -102,4 +103,14 @@ class CSpeciesFlameletVariable final : public CSpeciesVariable {
inline su2double GetAuxSourceCons(unsigned long iPoint, unsigned long i_aux) const {
return source_cons_jac(iPoint, i_aux);
}

/*!
* \brief Store the derivative of the progress variable source with respect to the progress variable.
*/
inline void SetSourceJacobianPV(unsigned long iPoint, su2double val) { source_pv_jac(iPoint) = val; }

/*!
* \brief Get the derivative of the progress variable source with respect to the progress variable.
*/
inline su2double GetSourceJacobianPV(unsigned long iPoint) const { return source_pv_jac(iPoint); }
};
13 changes: 13 additions & 0 deletions SU2_CFD/include/variables/CSpeciesVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,23 @@ class CSpeciesVariable : public CScalarVariable {
MatrixType SpeciesSourceTerm; /*!< \brief Matrix (nPoint, nVar) of chemical source terms for species transport*/
MatrixType SpeciesSourceJacobian; /*!< \brief Matrix (nPoint, nVar) of the diagonal chemical source Jacobian. */
VectorType HeatRelease; /*!< \brief Vector of heat release due to combustion for species transport*/
MatrixType PrefDiffJacobian; /*!< \brief Matrix (nPoint, nCV*nCV + nCV): row-major d(beta_i - phi_i)/d(phi_j), then dT/d(phi_j). */

public:
static constexpr size_t MAXNVAR = MAX_TRANSPORTED_SPECIES; /*!< \brief Max number of variables for static arrays. */

/*!
* \brief Derivatives of the preferential diffusion states to the controlling variables, row-major per point.
*/
inline const MatrixType& GetPrefDiffJacobian() const { return PrefDiffJacobian; }

/*!
* \brief Set one derivative: entry iCV*nCV + jCV of the beta block, or nCV*nCV + jCV for temperature.
*/
inline void SetPrefDiffJacobian(unsigned long iPoint, unsigned long iEntry, su2double val) {
PrefDiffJacobian(iPoint, iEntry) = val;
}

/*!
* \brief Constructor of the class.
* \param[in] species_inf - species variable values (initialization value).
Expand Down
51 changes: 51 additions & 0 deletions SU2_CFD/src/fluid/CFluidFlamelet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ CFluidFlamelet::~CFluidFlamelet() {
delete iomap_TD;
delete iomap_Sources;
delete iomap_LookUp;
delete iomap_SourceJacobian;
delete lookup_mlp;
if (preferential_diffusion) delete iomap_PD;
}
Expand Down Expand Up @@ -244,6 +245,11 @@ void CFluidFlamelet::PreprocessLookUp(CConfig* config) {
iomap_PD = new MLPToolbox::CIOMap(controlling_variable_names, varnames_PD);
lookup_mlp->PairVariableswithMLPs(*iomap_PD);
}
iomap_SourceJacobian =
new MLPToolbox::CIOMap(controlling_variable_names, {varnames_Sources[I_PROGVAR]});
iomap_SourceJacobian->AddQueryJacobian(varnames_Sources[I_PROGVAR], controlling_variable_names[I_PROGVAR],
&source_pv_jac);
lookup_mlp->PairVariableswithMLPs(*iomap_SourceJacobian);
#endif
} else {
for (auto iVar = 0u; iVar < varnames_TD.size(); iVar++) {
Expand Down Expand Up @@ -322,6 +328,12 @@ unsigned long CFluidFlamelet::EvaluateDataSet(const vector<su2double>& input_sca
SU2_MPI::Error(string("Output vector size incompatible with manifold lookup operation."), CURRENT_FUNCTION);
if (include_mixture_fraction) {
inside = look_up_table->LookUp_XYZ(LUT_idx, output_refs, val_prog, val_enth, val_mixfrac);
/*--- Beyond the outer levels, beta_Z - Z keeps its boundary value. ---*/
if (lookup_type == FLAMELET_LOOKUP_OPS::PREFDIF) {
const auto limits_z = look_up_table->GetTableLimitsZ();
const su2double mixfrac_bound = min(max(val_mixfrac, limits_z.first), limits_z.second);
output_refs[FLAMELET_PREF_DIFF_SCALARS::I_BETA_MIXFRAC] += val_mixfrac - mixfrac_bound;
}
} else {
inside = look_up_table->LookUp_XY(LUT_idx, output_refs, val_prog, val_enth);
}
Expand All @@ -342,3 +354,42 @@ unsigned long CFluidFlamelet::EvaluateDataSet(const vector<su2double>& input_sca
AD::EndPreacc();
return extrapolation;
}

su2double CFluidFlamelet::GetProgVarSourceJacobian(const vector<su2double>& input_scalar) {
const su2double val_prog = input_scalar[I_PROGVAR], val_enth = input_scalar[I_ENTH];
const su2double val_mixfrac = include_mixture_fraction ? input_scalar[I_MIXFRAC] : 0.0;
switch (Kind_DataDriven_Method) {
case ENUM_DATADRIVEN_METHOD::LUT: {
const su2double delta = 1e-6;
const unsigned long idx = LUT_idx_Sources[I_PROGVAR];
auto lookup = [&](const su2double pv, su2double& source) {
if (include_mixture_fraction) return look_up_table->LookUp_XYZ(idx, &source, pv, val_enth, val_mixfrac);
return look_up_table->LookUp_XY(idx, &source, pv, val_enth);
};
/*--- Forward difference, backward at the manifold edge, zero for a point outside. ---*/
su2double source, source_pert;
if (!lookup(val_prog, source)) {
source_pv_jac = 0.0;
} else if (lookup(val_prog + delta, source_pert)) {
source_pv_jac = (source_pert - source) / delta;
} else if (lookup(val_prog - delta, source_pert)) {
source_pv_jac = (source - source_pert) / delta;
} else {
source_pv_jac = 0.0;
}
break;
}
case ENUM_DATADRIVEN_METHOD::MLP: {
#ifdef USE_MLPCPP
su2double source;
vector<su2double*> refs_vars{&source};
if (!lookup_mlp->Predict(*iomap_SourceJacobian, input_scalar, refs_vars)) source_pv_jac = 0.0;
#endif
break;
}
default:
source_pv_jac = 0.0;
break;
}
return source_pv_jac;
}
Loading
Loading