Skip to content

Implementing variable density for unsteady incompressible flow#2641

Open
tkiymaz wants to merge 83 commits into
developfrom
fix_inc_unsteady_density
Open

Implementing variable density for unsteady incompressible flow#2641
tkiymaz wants to merge 83 commits into
developfrom
fix_inc_unsteady_density

Conversation

@tkiymaz

@tkiymaz tkiymaz commented Dec 10, 2025

Copy link
Copy Markdown

Proposed Changes

Implements variable density treatment for unsteady incompressible flow simulations. Currently, SU2 uses constant density in transient simulations, which is inaccurate for combustion cases where density varies significantly due to heat release and species composition changes. This contribution enables proper density updates during time-stepping for flamelet-based combustion modeling. For now, only 1st order time marching is implemented

Related Work

Related to incompressible flow solver and flamelet combustion modeling. No specific issue linked yet.

PR Checklist

  • 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.

Tahsin Berk Kiymaz and others added 3 commits June 17, 2025 10:28
@pcarruscag

Copy link
Copy Markdown
Member

@Cristopher-Morales can you review this pr please?

Removed commented-out code for setting density at local point.
Updated the comment for density retrieval to reflect changes for transient density handling.
Removed unnecessary blank lines in CIncEulerVariable.hpp
Removed unnecessary blank lines in CVariable.hpp
Removed unnecessary blank lines to improve code readability.
@Cristopher-Morales

Copy link
Copy Markdown
Contributor

@Cristopher-Morales can you review this pr please?

Hi @pcarruscag !

Yes, I can help reviewing this PR.

Please let me know if you need something else from my side

Removed commented-out code and updated density calculation.
@bigfooted

Copy link
Copy Markdown
Contributor

@Cristopher-Morales I guess the changes to the preconditioner can be removed from this PR since we now have your implementation

Comment thread SU2_CFD/include/variables/CVariable.hpp Outdated
Removed debug print statement from SetPrimVar function.
Comment thread SU2_CFD/include/output/COutput.hpp Outdated
Comment on lines +102 to +105

inline void Set_Density_time_n(unsigned long iPoint, su2double val) {
Density_time_n[iPoint] = val;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation must be added, similar to the function above SetDensity, Same for the two functions below Set_Density_unsteady and GetDensity_time_n

@bigfooted

Copy link
Copy Markdown
Contributor

@tkiymaz I updated the code with the changes that we discussed in the past weeks. There's also the bug fix for the combustion restart. Can you add the testcase with a restart file? The su2 mesh and restart file go in the testcases repository, the cfg file can go in this PR.

@bigfooted bigfooted changed the title [WIP] Implementing variable density for unsteady incompressible flow Implementing variable density for unsteady incompressible flow Apr 30, 2026
@bigfooted

Copy link
Copy Markdown
Contributor

@pcarruscag can you have a quick look at this PR? The primal works as expected, the adjoint unsteady will be finalized in another PR.

Comment thread SU2_CFD/include/solvers/CScalarSolver.inl Outdated
Comment thread SU2_CFD/include/solvers/CScalarSolver.inl Outdated
Comment thread SU2_CFD/include/solvers/CScalarSolver.inl Outdated
Comment thread SU2_CFD/include/solvers/CSpeciesSolver.hpp Outdated
Comment thread SU2_CFD/include/solvers/CTurbSolver.hpp Outdated
Comment on lines +74 to +75
VectorType Density_time_n, /*!< \brief Density at time n for dual-time stepping. */
Density_time_n1; /*!< \brief Density at time n-1 for dual-time stepping. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to recompute the old densities on the fly from the old solution variables instead of storing?
This would avoid the issues with restart files, adjoints, etc.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dear Pedro, thanks for the advice, but I'd keep storing it here due to runtime. In the flamelet path ρ isn't a closed-form EoS; it's a multi-dimensional LUT interpolation (one of the most expensive per-node ops in the solver). ρⁿ/ρⁿ⁻¹ are frozen over the whole physical time step, but the dual-time residual is assembled every inner iteration (and it gets even more computationally costly with high inner iteration number), so storing evaluates each old density once per step while recomputing from the old state would redo the identical LUT lookup. It also mirrors the existing scheme: we already store Solution_time_n/_n1 rather than reconstructing old states on the fly. There is no problem with the restart right now. Regarding adjoints, I can do a future work on it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pcarruscag : do you mean only recompute the density when doing a restart or always recompute from the EoS? Because at restart that would be beneficial in the sense that it saves (or actually it does not save) 2 restart fields.
@tkiymaz we have the possibility to use the ideal gas law instead of lookup for the steady state flamelet solver. Do we re-evaluate the EoS every inner iteration with this approach?

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.

5 participants