Skip to content

[WIP] Assumed shape beta pdf - #3000

Open
bigfooted wants to merge 55 commits into
developfrom
feature_flamelet_assumed_shape
Open

bigfooted wants to merge 55 commits into
developfrom
feature_flamelet_assumed_shape

Conversation

@bigfooted

@bigfooted bigfooted commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Proposed Changes

Give a brief overview of your contribution here in a few sentences.

Assumed shape beta pdf approach for turbulent combustion

Related Work

Resolve any issues (bug fix or feature request), note any related PRs, or mention interactions with the work of others, if any.

PR Checklist

Put an X by all that apply. You can fill this out after submitting the PR. If you have any questions, don't hesitate to ask! We want to help. These are a guide for you to know what the reviewers will be looking for in your contribution.

  • I am submitting my contribution to the develop branch.
  • My contribution generates no new compiler warnings (try with --warnlevel=3 when using meson).
  • My contribution is commented and consistent with SU2 style (https://su2code.github.io/docs_v7/Style-Guide/).
  • I used the pre-commit hook to prevent dirty commits and used pre-commit run --all to format old commits.
  • I have added a test case that demonstrates my contribution, if necessary.
  • I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp), if necessary.

bigfooted and others added 4 commits October 31, 2026 23:23
The names in CONTROLLING_VARIABLE_NAMES (ProgressVariable, EnthalpyTot,
MixtureFraction) now set the role of each transported scalar, replacing
the fixed positions I_PROGVAR, I_ENTH and I_MIXFRAC. EnthalpyTot is
required together with ProgressVariable, MixtureFraction or both, so pure
non-premixed (MixtureFraction, EnthalpyTot) manifolds are supported.

- Table axes follow the order of the names; the third name is the level.
- Without a progress variable the thickened flame correction is off and
  FLAME_FRONT initializes the mixture fraction, as before.
- Preferential diffusion looks up only the beta terms of present variables.
- The inlet profile template writes one column per controlling variable.

Results are identical to develop for flamelet cases 01, 03, 05, 06, 07,
09 and the laminar diffusion flame tutorial.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ProgressVariableVariance and MixtureFractionVariance in
CONTROLLING_VARIABLE_NAMES are transported scalars that the manifold uses
as a controlling variable, typically the table level of an assumed PDF
table. Their source is the table entry in CONTROLLING_VARIABLE_SOURCE_NAMES
plus the turbulent production 2 mu_t/Sc_t |grad(mean)|^2 and the
dissipation C_d rho beta* omega var of the SST model, the latter implicit.

- A variance requires its mean and KIND_TURB_MODEL= SST, is clipped at
  zero, and switches off the thickened flame correction; preferential
  diffusion is not available with it.
- FLAMELET_VARIANCE_DISSIPATION_COEFF sets C_d (default 2.0).
- The look-up table rejects more than three controlling variables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Jacobian

A transported variance is limited to (mean - min)(max - mean), the variance of
a two-point distribution on the range of its mean. The range is [0, 1] for the
mixture fraction and the range of the table axis (or of the network input
scaling) for the progress variable.

The species solver solves for the increment of rho*Y, so the implicit Jacobian
of the auxiliary-species source is source_cons / rho, not source_cons. The
reference value of cfd_flamelet_ch4_cht changes in one residual by 4e-5.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ce, restart by name

The look-up table and the networks take each variance normalized by its upper
limit (mean - min)(max - mean). The mixture fraction is bounded by 0 and 1, the
progress variable by the manifold variables ProgressVariableMin and
ProgressVariableMax. The conversion is done in CFluidFlamelet before every
look-up, and the variance clip uses the same limit. This replaces the global
table and network input ranges.

The source of a variance is formed from the manifold variable mean(phi*S_phi)
as 2 (mean(phi*S_phi) - mean(phi) mean(S_phi)); a NULL name gives no source.

The flamelet restart is read by field name, and a variance missing from the
restart file starts from its initial value. The MLP look-up query is paired
also for a single look-up variable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bigfooted bigfooted changed the title Feature assumed shape pdf [WIP] Assumed shape beta pdf Nov 2, 2026
bigfooted and others added 2 commits November 2, 2026 21:25
With implicit periodicity, the PERIODIC_RESIDUAL comms delete the rows of
the passive points (first marker of each pair) and add only their diagonal
block to the master. The off-diagonal blocks of the passive rows, and the
columns of other rows that refer to passive points, are lost. On a wedge one
cell thick every point is periodic, so most of the Jacobian coupling
disappears and the Newton step is useless above CFL ~25.

CSolver::CouplePeriodicJacobian moves those blocks to the master rows and
columns, rotated, before the comms. Only masters on the same rank and blocks
that exist in the sparsity pattern are coupled. Blocks go through
GetBlockView/SetBlock, so the quantized Q_LU_SGS storage works too.

The edge between a point and its own periodic image is left out of the local
time step. It only rotates the state, but it added the sound speed and the
viscous term and made the time step ~60x too small on the axis of a wedge.

New case TestCases/incomp_rans/morse_swirl_jet (Morse 1980 swirling jet,
5 deg one-cell wedge, SA) and regression test inc_turb_morse_swirl_jet
(restart, 10 iterations); mesh and solution are in the TestCases branch
fix_periodic_jacobian, which regression.yml points to until it is merged.

Regression values of the periodic cases in parallel_regression.py and
serial_regression.py are updated; hybrid and AD values are not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bigfooted

Copy link
Copy Markdown
Contributor Author

@EvertBunschoten still a WIP but maybe you can already have a look at it to steer it in the right direction.

bigfooted and others added 19 commits November 15, 2026 16:53
Without viscous walls, CGeometry::ComputeWallDistance set the distance to
zero at every point. The SA and SST source terms (and the LM transition
sources) are skipped where the distance is zero, so a wall-free RANS
domain such as a free jet had no turbulence production or destruction:
the turbulence variables were only convected and diffused from the
inflow.

The distance is now 1e15. SA then takes its free-shear limit
(S_hat -> Omega, destruction -> 0), SST gets F1 = F2 = 0 (k-epsilon
branch), and DES length scales become the grid scale. 1e15 keeps d^2
far from overflow.

The only affected regression test is rans/actuatordisk_bem: rms[nu_tilde]
at iteration 15 changes from -10.32 to -8.60, because the restart was
computed without SA sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The progress variable source was treated fully explicitly, which stalls
the PV equation at high CFL. Add the decreasing part of dS/dPV, obtained
from a forward-difference table lookup, to the Jacobian diagonal.

With CFL 1e5, an ILU preconditioner and a consistent table, the unsteady
1D premixed flame converges in 8-10 inner iterations per time step and
matches a 300-inner-iteration reference.

Flamelet regression residuals shift slightly; reference values are not
yet updated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The extra Jacobian term changes the iteration history of the flamelet
tests. The discrete adjoint tests change because the adjoint linear
solves reuse the primal Jacobian; the converged adjoint is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Accumulating SetBlock is a no-op on quantized (Q_LU_SGS) off-diagonal
  blocks, so the moved blocks were dropped. Quantized blocks are now
  decoded, added and re-encoded; full-precision blocks keep the in-place
  addition, so results are unchanged bit for bit.
- A passive point is coupled only if every moved block exists in the
  sparsity pattern of its master. On thicker periodic meshes only the
  along-face blocks fit; moving those alone slowed the discrete adjoint
  (transonic_stator AD from -7.31 to -6.76 at iteration 79). Now these
  meshes behave as on develop, and one-cell wedges and slices keep the
  full coupling.
- Loops run over a list of the coupled passive points instead of all
  points.
- CompletePeriodicComms comments named the wrong marker as master.
- Regression values: periodic tests without coupled points are back to
  their develop values; Morse (after #3014) and the two pipeSlice tests
  use the values computed by CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No periodic point is coupled in this case. The values change at the
1e-5 level on CI only; local builds of develop and of this branch give
bit-identical results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The chemical source of a transported scalar variance was formed in SU2 as
2 (mean(phi S) - mean(phi) mean(S)) from two interpolated manifold columns.
Linear interpolation of mean(phi S) and mean(S) leaves a spurious term
sum_i w_i (phi_i - phi) mean(S)_i, of order (dS/dphi) dphi^2, which does
not vanish at zero variance. Behind the flame it is a sink that drives the
variance below zero, and the clipping at zero then gives a two-iteration
limit cycle.

With FLAMELET_TABULATED_VARIANCE_SOURCE= YES the variance source column is
taken as the chemical variance source itself, computed per manifold node
where the mean and both integrals are exact; it is then zero at zero
variance. The default NO keeps the previous behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A negative chemical variance source is added to the Jacobian as
-S / (rho var), its linearization as proportional to rho var. The update
then cannot drive the variance below zero, so the clipping at zero no
longer enters the iteration. Positive sources stay explicit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- One helper, RotateMomentumBlock, computes Ql*B*Qr^T on the momentum rows
  and columns. It replaces the hand-unrolled 2D/3D rotation in the periodic
  comms and the Rotation/RotateRows/RotateColumns lambdas.
- Rotation matrices are built once per marker instead of once per block.
- CBlockView::apply<false> decodes, adds and re-encodes quantized blocks
  instead of silently doing nothing, so AddBlock works with Q_LU_SGS and the
  local workaround is removed.
- The time step skips an edge when j is the periodic donor of i on this
  rank, read from the geometry, independent of whether the point is coupled.
  This removes skipImages, ArePeriodicImages and the per-iteration call to
  SetPeriodicMaster.
- SetPeriodicMaster is called once from CouplePeriodicJacobian; the
  redundant implicit_periodic test and the PeriodicPassive member are gone.

Regression values are unchanged: for the periodic and Q_LU_SGS cases the
results are identical to the previous commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The moved Jacobian blocks and the rotation matrices of the coupling are
  passive types; RotateMomentumBlock is templated on the block scalar so the
  comms keep their active block.
- Descriptive loop variables (iVar, jVar, iDim, jDim) in RotateMomentumBlock
  and ReadBlock.
- SetPeriodicMaster and CouplePeriodicJacobian use the member nPoint instead
  of a local nPointAll.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Beyond the first and last table level the lookup used the outer level alone,
so looked-up quantities stopped depending on the level variable. With
preferential diffusion the mixture fraction is then no longer restored by
its own diffusion and can run away, e.g. to negative values at a lean H2
flame tip. Queries outside the level range are now extrapolated linearly
from the two outermost levels, up to one level spacing, and still reported
as outside the manifold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The preferential diffusion flux D grad(beta - phi) used the Jacobian of the
ordinary diffusion, i.e. d(beta - phi)/dphi = 1, without the coupling
between the controlling variables and without the thermal term of the
enthalpy equation. For the mixture fraction of lean H2 flames dbeta/dZ is
about 3-4, so the term was under-implicit and the mixture fraction and
enthalpy oscillated with a period of two iterations near cooled walls.

The solver now evaluates d(beta_i - phi_i)/dphi_j, with beta_T dT/dphi_j in
the enthalpy row, by finite differences of the manifold lookup when the
preferential diffusion scalars are updated: central differences inside the
manifold, one-sided towards it at its edges, and the previous Jacobian where
neither fits. The steps are 1e-3 of the global range of each controlling
variable. The edge kernel assembles the full block. The residual is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…de the manifold

GetBurntProgressVariable marched the progress variable up in steps of 1e-3
and returned the first value that was outside the manifold, because the step
taken after leaving it was subtracted only once. The whole burnt region of a
flame front initialization then started just outside the table, where the
lookup returns frozen values of the nearest nodes; in a lean H2 slit burner
these points persisted as a band of progress variable above equilibrium.

The march now keeps the last value inside the manifold. When it leaves the
manifold, the edge is bisected and the burnt value is set 0.1% of the
progress variable range inside it. When the ignition temperature is reached
first, that value is returned as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ps, inlet profiles

Flamelet manifold:
- CLookUpTable computes the progress variable range of each table level as a
  function of the second controlling variable from the boundary edges
  (GetRangeCV1). With axes (c, h) and levels in the progress variable
  variance, the upper bound of c is capped by the table edge and lookups are
  moved just inside it.
- Sources named *_Reduced are tabulated divided by c*(1-c*) and multiplied
  back in SU2, so they vanish at the progress variable bounds.
- FLAMELET_IMPLICIT_PV_SOURCE adds the derivative of the progress variable
  source to the Jacobian where the source decreases with the progress
  variable.
- The variance normalisation stays continuous at the bounds of the mean.

Convergence:
- BETA_LOCAL_FLOOR: local preconditioning parameter of the incompressible
  solver, beta from the local velocity bounded below by a fraction of the
  domain maximum (1 keeps the uniform value).
- SCALAR_TIME_STEP_RATIO: scalars use their own local convective and
  diffusive time step, capped at this ratio times the flow time step
  (1 keeps the flow time step).

Inlet profiles:
- CMarkerProfileReaderFVM keeps the header skip per marker, so files with
  several markers are read correctly.
- Flamelet inlets with a profile file take the enthalpy from the profile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The implicit treatment of the progress variable source only adds the part
where the source decreases with the progress variable to the Jacobian, so
it strengthens the diagonal and leaves the residual unchanged. It is now
used whenever the scalars are integrated implicitly, and the option
FLAMELET_IMPLICIT_PV_SOURCE is removed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bigfooted and others added 29 commits November 27, 2026 22:48
The fluid model now provides dS_PV/dPV through GetProgVarSourceJacobian:
analytically from the MLP Jacobian query, and by a forward difference on
the PV source column only for the lookup table. The solver no longer
perturbs the full source lookup and sets the derivative to zero where the
PV source is clipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SetPeriodicMaster runs on the first call of CouplePeriodicJacobian, when the
sparsity pattern of the Jacobian is fixed, and also stores the list of
coupled points and the rotation matrix of each periodic marker. Cases with
no coupled points return before the OpenMP safe-access region.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The periodic part of each dual volume was communicated once, in
CommunicateInitialState, so in the discrete adjoint it did not depend on the
mesh coordinates and the geometric sensitivities missed its derivative.
CSolver::CommunicatePeriodicVolume resets and accumulates the periodic
volume; the adjoint fluid iteration calls it after UpdateGeometry.

On the Morse swirling jet (one-cell wedge, every point periodic) the
adjoint derivative of the inlet static pressure with respect to a smooth
mesh deformation changes from +22.6 to -2.02; central finite differences
give -2.137. The primal is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
discadj_incomp_turb_morse_swirl_jet runs 10 adjoint iterations of the
one-cell periodic wedge from the converged primal solution, with the inlet
static pressure as objective. Every point of the wedge is periodic, so the
test covers the coupled Jacobian in the adjoint linear solve.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
GetProgVarSourceJacobian gives dS_PV/dPV at constant normalized variance.
The MLP method uses the network Jacobian, with the product rule for a
reduced source; the lookup table keeps the central difference inside the
progress variable range. The solver only stores the result.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
SetManifoldInputs clamps the progress variable to the table edge, so the
lookup never reports extrapolation above the table maximum. When the
unburnt state can not reach the ignition temperature (e.g. cooled burnt gas
as free stream), GetBurntProgressVariable then marched forever and the
flame front initialization hung. The march now also treats a progress
variable above the table maximum as outside the manifold.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The passive face of an implicit periodic pair had its residual zeroed,
so the volume output showed residuals on only one of the two planes.
PERIODIC_IMPLICIT now also sends the master's (rotated) residual to the
passive point. The solution and convergence history are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The accumulate lambda returned a CoDi expression in forward mode, which
PassiveValue does not unwrap, so static_cast<float> failed. Return T.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Jacobian is active in forward AD, so the moved blocks use its scalar
type there and stay passive otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
periodic3d_axis (new in develop) couples its one-cell wedge points; the Morse
primal and adjoint values follow the develop changes; transonic_stator returns
to the develop values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Beyond the first and last table level the lookup used the outer level alone,
so looked-up quantities stopped depending on the level variable. With
preferential diffusion the mixture fraction is then no longer restored by
its own diffusion and can run away, e.g. to negative values at a lean H2
flame tip. Queries outside the level range are now extrapolated linearly
from the two outermost levels, up to one level spacing, and still reported
as outside the manifold.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 24c8fbc)
The preferential diffusion flux D grad(beta - phi) used the Jacobian of the
ordinary diffusion, i.e. d(beta - phi)/dphi = 1, without the coupling
between the controlling variables and without the thermal term of the
enthalpy equation. For the mixture fraction of lean H2 flames dbeta/dZ is
about 3-4, so the term was under-implicit and the mixture fraction and
enthalpy oscillated with a period of two iterations near cooled walls.

The solver now evaluates d(beta_i - phi_i)/dphi_j, with beta_T dT/dphi_j in
the enthalpy row, by finite differences of the manifold lookup when the
preferential diffusion scalars are updated: central differences inside the
manifold, one-sided towards it at its edges, and the previous Jacobian where
neither fits. The steps are 1e-3 of the global range of each controlling
variable. The edge kernel assembles the full block. The residual is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 9cace00)
…de the manifold

GetBurntProgressVariable marched the progress variable up in steps of 1e-3
and returned the first value that was outside the manifold, because the step
taken after leaving it was subtracted only once. The whole burnt region of a
flame front initialization then started just outside the table, where the
lookup returns frozen values of the nearest nodes; in a lean H2 slit burner
these points persisted as a band of progress variable above equilibrium.

The march now keeps the last value inside the manifold. When it leaves the
manifold, the edge is bisected and the burnt value is set 0.1% of the
progress variable range inside it. When the ignition temperature is reached
first, that value is returned as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bian

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…riance source offset

- The progress variable source Jacobian of the table uses a difference step of
  1e-3 of the progress variable range of the table (GetRangeCV).
- The table edge bounds the progress variable whenever it is the first table
  axis, and a progress variable beyond the edge is reported outside the manifold.
- The progress variable range lookup is reused while the controlling variables
  other than the variance are unchanged (not in reverse mode AD).
- The chemical variance source subtracts its value at zero variance, which is
  zero but for the interpolation error of the manifold.
- THICKENED_FLAME_CORRECTION= YES is an error where it does not apply.
- Scalar local time steps use the relative velocity on moving grids and
  include the periodic volume.
- Passive periodic points show the residual of their master.
- Unit test for the progress variable range of a table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	Common/src/containers/CLookUpTable.cpp
#	SU2_CFD/include/fluid/CFluidFlamelet.hpp
#	SU2_CFD/include/fluid/CFluidModel.hpp
#	SU2_CFD/include/numerics/species/flamelet_edge_flux.hpp
#	SU2_CFD/include/solvers/CSpeciesFlameletSolver.hpp
#	SU2_CFD/src/fluid/CFluidFlamelet.cpp
#	SU2_CFD/src/solvers/CSpeciesFlameletSolver.cpp
#	TestCases/parallel_regression.py
…e source

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ial diffusion changes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AuxVar.resize(nPoint, FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS) = su2double(0.0);
Grad_AuxVar.resize(nPoint, FLAMELET_PREF_DIFF_SCALARS::N_BETA_TERMS, nDim, 0.0);
const auto n_cv = flamelet_config_options.n_control_vars;
PrefDiffJacobian.resize(nPoint, n_cv * n_cv) = su2double(0.0);
bool same = bounds_cached;
for (auto iCV = 0u; iCV < n_control_vars; iCV++) {
if (static_cast<int>(iCV) == flamelet_options.idx_progvar_var) continue;
same = same && (bounds_key[iCV] == scalars[iCV]);

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants