Skip to content

Addition of multiple features required for SA-DDES turbulence model#428

Merged
HendriceH merged 3 commits into
developfrom
feat/turbModel
Apr 29, 2026
Merged

Addition of multiple features required for SA-DDES turbulence model#428
HendriceH merged 3 commits into
developfrom
feat/turbModel

Conversation

@HendriceH
Copy link
Copy Markdown
Collaborator

@HendriceH HendriceH commented Jan 8, 2026

Implementation of turbulence model

This PR implements features required to run the SpalartAllmarasDDES turbulence model which is implemented in NeoFOAM PR 233 It consists of the following components:

Generally required for turbulence models

  1. Tensor and symmTensor primitives
  2. New Su type overload of source operator source (the available implementation before was only a Sp type source term that multiplies by the transport variable) to be able to add source terms that do not linearly depend on the turbulence transport variable
  3. Functionality to pass generic fields to correctBoundaryConditions

@HendriceH HendriceH self-assigned this Jan 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 8, 2026

Thank you for your PR, here are some useful tips:

@HendriceH HendriceH force-pushed the feat/turbModel branch 2 times, most recently from 1c56610 to 7f60dfd Compare January 20, 2026 21:00
@HendriceH HendriceH added the ready-for-review Set this label to indicate that the PR is ready for review label Feb 9, 2026
@HenningScheufler HenningScheufler marked this pull request as ready for review February 14, 2026 17:30
Comment thread include/NeoN/finiteVolume/cellCentred/boundary/volume/nutWallFunction.hpp Outdated
Comment thread include/NeoN/finiteVolume/cellCentred/operators/viscousStressOperator.hpp Outdated
Comment thread include/NeoN/dsl/explicit.hpp Outdated
Comment thread include/NeoN/finiteVolume/cellCentred/fields/tensorVecField.hpp Outdated
Comment thread include/NeoN/turbulenceModels/SpalartAllmarasDDES.hpp Outdated
Comment thread src/dsl/explicit.cpp Outdated
{

template<typename ValueType>
class SourceUTerm : public dsl::OperatorMixin<VolumeField<ValueType>>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

SourceUTerm seems from the name to be specialized on the velocity field

Is there no implemenation of SourceTerm?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

U here does not stand for velocity U, but for the different source types:
Sp - proportional part: term is multiplied with transport variable
Su - unconditional part: term is independant of tranport variable
in NeoN we currently only have Sp type sources.

Comment thread src/finiteVolume/cellCentred/operators/viscousStressOperator.cpp Outdated
Comment thread src/turbulenceModels/SpalartAllmarasDDES.cpp Outdated
@HendriceH HendriceH force-pushed the feat/turbModel branch 2 times, most recently from 9c8850a to 76194dd Compare April 20, 2026 16:33
@HendriceH HendriceH changed the title Prototype of SA-DDES turbulence model Addition of multiple features required for SA-DDES turbulence model Apr 22, 2026
Copy link
Copy Markdown
Contributor

@greole greole left a comment

Choose a reason for hiding this comment

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

LGTM! But make sure the CI passes before merging and please add curly braces for the for loops.

Comment thread CHANGELOG.md Outdated
@@ -1,7 +1,8 @@
# Version 0.3.0 (unreleased)
# Version 0.3.0 (unreleased) 428
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.

Suggested change
# Version 0.3.0 (unreleased) 428
# Version 0.3.0 (unreleased)

Comment on lines +90 to +95
auto hostSource = source.copyToHost();
auto hostSourceView = hostSource.view();
for (auto ii = 0; ii < hostSource.size(); ++ii)
{
REQUIRE(hostSourceView[ii] - 5 * one<TestType>() == TestType(0.0));
}
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.

This can be handled with the new REQUIRE_THAT(exp, IsEqualTo(source));

Comment on lines +34 to +35
for (int k = 0; k < 6; ++k)
data_[k] = 0.0;
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.

I dont know why claude is too lazy here to add curly braces. Without curly braces, it is very easy to break.

Suggested change
for (int k = 0; k < 6; ++k)
data_[k] = 0.0;
for (int k = 0; k < 6; ++k) {
data_[k] = 0.0;
}

Comment on lines +86 to +87
for (int k = 0; k < 6; ++k)
if (data_[k] != rhs.data_[k]) return false;
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.

same here and all other for loops, please add curly braces for loop bodies even for a single line case.

);
}

/** @brief T + T^T - (2/3)*tr(T)*I — matches OpenFOAM devTwoSymm, used for viscous stress */
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.

Suggested change
/** @brief T + T^T - (2/3)*tr(T)*I — matches OpenFOAM devTwoSymm, used for viscous stress */
/** @brief T + T^T - (2/3)*tr(T)*I — used for viscous stress */

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.

I am unsure about this, i dont think it is the greatest design, but i can live with it for now. Maybe we can use std::variant<VolumeField<scalar>, VolumeField<Vec3>> to make it a bit more DRY and have just one std::unordered_map. (But maybe it is also too painfull to use)? @HenningScheufler what do you think?

…arbitrary fields into correctBoundaryConditions()
@HendriceH HendriceH merged commit 8f9e50b into develop Apr 29, 2026
20 of 21 checks passed
greole pushed a commit that referenced this pull request May 13, 2026
Addition of multiple features required for SA-DDES turbulence model
@HendriceH HendriceH deleted the feat/turbModel branch May 27, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Set this label to indicate that the PR is ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants