-
Notifications
You must be signed in to change notification settings - Fork 975
Stochastic Backscatter Model for Grey Area Mitigation in Hybrid RANS-LES Simulations #2572
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
Open
AngPass
wants to merge
108
commits into
su2code:develop
Choose a base branch
from
AngPass:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
36b6f7a
Preliminary implementation: uncorrelated stochastic variables
AngPass d6d6e39
Merge branch 'su2code:develop' into develop
AngPass cfa0cd8
Add solution of Langevin equations
AngPass fd800d3
Merge branch 'develop' into develop
AngPass 34f676f
Fix sanitizer warnings and regression failures
AngPass 66293fd
Minor fixes
AngPass 4a11c8b
Merge branch 'develop' into develop
AngPass 3481df3
Ensure consistency with DES
AngPass 26bcfda
Merge branch 'develop' into develop
AngPass 85b8aac
Boundary conditions for Langevin equations
AngPass 6293042
Use symmetry-preserving scheme for Langevin equations
AngPass b03f630
Merge branch 'develop' into develop
AngPass 1e8e4e1
Add option for simulating DIHT
AngPass 67c133c
Fix options for DIHT
AngPass 25a32f7
Merge branch 'develop' into develop
AngPass 9657bfb
Consistent estimation of turb. kinetic energy (for SA)
AngPass e1181d3
Merge branch 'develop' into develop
AngPass 968d8f9
Add Laplacian smoothing (Langevin equations)
AngPass 2f8245e
Fix redundancy in CTurbSAVariable.hpp
AngPass bdbfa05
Add stochastic source to turbulence model equation
AngPass 7457d95
Merge branch 'develop' into develop
AngPass 3272a1b
SOR algorithm for Laplacian smoothing
AngPass ddb99bf
Merge branch 'su2code:develop' into develop
AngPass 15dbff3
Correct scaling of stochastic source terms in Langevin eqs.
AngPass 4dd0f90
Merge branch 'su2code:develop' into develop
AngPass d93ed49
Merge branch 'su2code:develop' into develop
AngPass 420e44a
Add LD2 scheme for the incompressible solver
AngPass 02dbb54
Merge branch 'develop' of https://github.com/AngPass/SU2 into develop
AngPass 2f654c6
Merge branch 'develop' into develop
AngPass 65e531e
Merge branch 'develop' into develop
AngPass 5c3e35c
Fix LD2 for periodic boundaries
AngPass 71dca9c
Merge branch 'develop' into develop
AngPass 6389023
Include stochastic source term in turb. equation
AngPass d382a2d
Minor fixes
d1a1ae8
Add time-averaged skin friction coefficient
babfb58
Minor fix
AngPass 562f311
Minor fix
AngPass 14323bb
Merge branch 'develop' into develop
AngPass 92a016b
Merge branch 'develop' into develop
AngPass 90ede00
Add fields to VOLUME_OUTPUT
a5b3aa0
Fix LD2 option in config file
ebb6806
Merge branch 'develop' into develop
AngPass 3e44cd6
Merge branch 'develop' into develop
AngPass 3530ea8
Merge branch 'develop' into develop
AngPass 0df34ac
Enhance numerical robustness
343ed9b
Merge branch 'develop' into develop
AngPass f539511
Merge branch 'develop' into develop
AngPass 443838f
Enhance numerical efficiency
86ba8d8
Merge branch 'develop' into develop
AngPass fb3f8ec
Fix bug in viscous flux computation
241fbcb
Merge branch 'develop' into develop
AngPass c20511e
Merge branch 'develop' into develop
AngPass 77de85b
First major revision
1b77a2b
Merge branch 'develop' into develop
AngPass 84c42d2
Minor fixes
e9cb3d8
Merge branch 'develop' into develop
AngPass dc5189d
Add new features
6598226
Merge branch 'develop' into develop
AngPass 6515a53
Merge branch 'develop' into develop
AngPass 0a0f348
Merge branch 'develop' into develop
AngPass cb91b8e
Redefine scaling of stochastic source term
190a1cc
Update config template
e6b9937
Delete TestCases/backscatter/DIHT directory
AngPass daac35f
Include stochastic variables in restart file
af37287
Merge branch 'develop' into develop
AngPass 692e87a
Merge branch 'develop' into develop
AngPass 3e49b9b
Change proposed test case
3d4bcb4
Merge branch 'develop' into develop
AngPass fcbca34
Update Common/include/toolboxes/random_toolbox.hpp
AngPass d3e8e31
Update Common/include/toolboxes/random_toolbox.hpp
AngPass 6500ddd
Update SU2_CFD/src/solvers/CTurbSASolver.cpp
AngPass 5459137
Update SU2_CFD/src/solvers/CTurbSASolver.cpp
AngPass f633f7b
Update SU2_CFD/include/numerics/turbulent/turb_sources.hpp
AngPass 5203d3f
Update SU2_CFD/src/numerics/flow/convection/centered.cpp
AngPass f4b2fa1
Update SU2_CFD/src/solvers/CTurbSASolver.cpp
AngPass 77b4e57
Merge branch 'develop' into develop
AngPass 617453d
Second major revision
ca6cfb6
Minor fixes
efeb505
Merge branch 'develop' into develop
AngPass 5bc9b35
Minor fixes
bbf40fb
Merge branch 'develop' into develop
AngPass c702cc9
Third major revision
6dc1738
Update SU2_CFD/include/variables/CTurbSAVariable.hpp
AngPass 592bdf4
Update SU2_CFD/include/numerics/CNumerics.hpp
AngPass fdbec42
Update SU2_CFD/src/solvers/CTurbSASolver.cpp
AngPass 3c2e445
Update SU2_CFD/src/solvers/CTurbSASolver.cpp
AngPass 17bfb65
Update SU2_CFD/src/solvers/CTurbSASolver.cpp
AngPass a27c3ff
Add residuals of stoch. variables to vol. outputs
f7bd1c7
Update Common/include/toolboxes/random_toolbox.hpp
AngPass 88726b0
Merge branch 'develop' into develop
AngPass ebcc1b8
Fix compilation errors
4d6ee96
Fix compilation errors - bis
f6c1f08
Fix compilation errors - tris
86a1d42
Fix compilation errors - tetra
9a3a043
Apply suggestions from code review
pcarruscag 44fd568
Update SU2_CFD/include/variables/CTurbSAVariable.hpp
AngPass 52f3ec1
Update SU2_CFD/include/variables/CTurbSAVariable.hpp
AngPass 052d613
Update SU2_CFD/include/variables/CTurbSAVariable.hpp
AngPass 29004cb
Update SU2_CFD/include/variables/CTurbVariable.hpp
AngPass 92f9056
Update SU2_CFD/src/variables/CTurbSAVariable.cpp
AngPass 36f154b
Update SU2_CFD/src/solvers/CTurbSASolver.cpp
AngPass ffdeca1
Fix code formatting
ca99d8d
Fix compilation errors - V
6a2f950
Fix errors in regression tests (hopefully)
2541151
Restore nPrimVarGrad in InitiatePeriodicComms
9c4b84a
Restore DDES test case (committed by mistake)
f2a7402
Merge branch 'develop' into develop
AngPass 8b78410
Simplify backscatter test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,172 @@ | ||
| /*! | ||
| * \file random_toolbox.hpp | ||
| * \brief Collection of utility functions for random number generation. | ||
| * \version 8.4.0 "Harrier" | ||
| * | ||
| * SU2 Project Website: https://su2code.github.io | ||
| * | ||
| * The SU2 Project is maintained by the SU2 Foundation | ||
| * (http://su2foundation.org) | ||
| * | ||
| * Copyright 2012-2025, SU2 Contributors (cf. AUTHORS.md) | ||
| * | ||
| * SU2 is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Lesser General Public | ||
| * License as published by the Free Software Foundation; either | ||
| * version 2.1 of the License, or (at your option) any later version. | ||
| * | ||
| * SU2 is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| * Lesser General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Lesser General Public | ||
| * License along with SU2. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| #pragma once | ||
| #include <cstdint> | ||
| #include "../option_structure.hpp" | ||
|
|
||
| namespace RandomToolbox { | ||
| /// \addtogroup RandomToolbox | ||
| /// @{ | ||
|
|
||
| /*! | ||
| * \brief SplitMix64 hash function for 64-bit integers. | ||
| * \param[in] x Input value to hash. | ||
| * \return Hashed 64-bit output. | ||
| */ | ||
| static inline uint64_t splitmix64(uint64_t x) { | ||
| x += 0x9e3779b97f4a7c15ULL; // golden ratio offset | ||
| x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9ULL; // first mixing step | ||
| x = (x ^ (x >> 27)) * 0x94d049bb133111ebULL; // second mixing step | ||
| return x ^ (x >> 31); // final avalanche | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Generate a deterministic 64-bit hash from three integers. | ||
| * \param[in] nodeIndex Global node index. | ||
| * \param[in] iDim Dimension index. | ||
| * \param[in] timeIter Current time iteration of the simulation. | ||
| * \return 64-bit hash value. | ||
| */ | ||
| inline uint64_t GetHash(unsigned long nodeIndex, unsigned short iDim, unsigned long timeIter) { | ||
| uint64_t x = nodeIndex; | ||
| x ^= splitmix64(iDim); | ||
| x ^= splitmix64(timeIter); | ||
| return splitmix64(x); | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Convert a 64-bit hash into a uniform double in (0,1]. | ||
| * Uses the top 53 bits of the hash to fill the mantissa of a double. | ||
| * Ensures the result is never zero, suitable for Box-Muller transform. | ||
| * \param[in] x 64-bit hash. | ||
| * \return Uniform double in the interval (0,1]. | ||
| */ | ||
| inline double HashToUniform(uint64_t x) { | ||
| constexpr double inv53 = 1.0 / 9007199254740992.0; // 1/2^53 | ||
| uint64_t uInt = x >> 11; // top 53 bits | ||
| return (uInt + 1) * inv53; // map to (0,1] | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Generate a standard normal random number from a 64-bit hash. | ||
| * Uses two deterministic uniforms derived from the hash and its bitwise NOT | ||
| * as inputs to the Box-Muller transform. | ||
| * \param[in] x 64-bit hash. | ||
| * \return Standard normal random number (mean=0, stddev=1). | ||
| */ | ||
| inline double HashToNormal(uint64_t x) { | ||
| double u = HashToUniform(x); // first uniform | ||
| double v = HashToUniform(~x); // second uniform (bitwise NOT) | ||
| double r = sqrt(-2.0 * log(u)); | ||
| double theta = 2.0 * PI_NUMBER * v; | ||
| return r * cos(theta); // one normal sample | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Generate a deterministic standard normal number for a cell, dimension, and timestep. | ||
| * | ||
| * Combines hashing and Box-Muller in one function. | ||
| * | ||
| * \param[in] nodeIndex Global node index. | ||
| * \param[in] dim Dimension index. | ||
| * \param[in] timeIter Simulation timestep (1-based). | ||
| * \return Standard normal random number. | ||
| */ | ||
| inline double GetNormal(unsigned long nodeIndex, unsigned long dim, unsigned long timeIter) { | ||
| uint64_t hash = GetHash(nodeIndex, dim, timeIter); | ||
| return HashToNormal(hash); | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Compute modified bessel function of first kind (order 0). | ||
| * \param[in] x Argument of Bessel funtion. | ||
| * \return Value of Bessel function. | ||
| */ | ||
| template <class T> | ||
| inline T GetBesselZero(const T& x) { | ||
| T abx = fabs(x); | ||
|
|
||
| if (abx < 3.75) { | ||
| T t = abx / 3.75; | ||
| T p = | ||
| 1.0 + | ||
| t * t * | ||
| (3.5156229 + | ||
| t * t * (3.0899424 + t * t * (1.2067492 + t * t * (0.2659732 + t * t * (0.0360768 + t * t * 0.0045813))))); | ||
| return log(p); | ||
| } else { | ||
| T t = 3.75 / abx; | ||
|
|
||
| T poly = | ||
| 0.39894228 + | ||
| t * (0.01328592 + | ||
| t * (0.00225319 + | ||
| t * (-0.00157565 + | ||
| t * (0.00916281 + t * (-0.02057706 + t * (0.02635537 + t * (-0.01647633 + t * 0.00392377))))))); | ||
|
|
||
| T arg = sqrt(abx) * poly; | ||
| return abx - log(arg); | ||
| } | ||
| } | ||
|
|
||
| /*! | ||
| * \brief Compute integral involving the product of three modified Bessel functions. | ||
| * Useful for scaling the smoothed stochastic source terms in Langevin equations. | ||
| * \param[in] beta_x Argument in x-direction. | ||
| * \param[in] beta_y Argument in y-direction. | ||
| * \param[in] beta_z Argument in z-direction. | ||
| * \return Value of the integral. | ||
| */ | ||
| template <class T> | ||
| inline T GetBesselIntegral(const T& beta_x, const T& beta_y, const T& beta_z) { | ||
| const T A = 1 + 2 * (beta_x + beta_y + beta_z); | ||
| const T Bx = 2 * beta_x; | ||
| const T By = 2 * beta_y; | ||
| const T Bz = 2 * beta_z; | ||
|
|
||
| const int N = 4000; | ||
| const T t_max = 20.0; | ||
| const T dt = t_max / N; | ||
|
|
||
| T sum = T(0.0); | ||
|
|
||
| for (int i = 1; i <= N; i++) { | ||
| T t = i * dt; | ||
|
|
||
| T lin = log(t) - A * t + GetBesselZero(T(Bx * t)) + GetBesselZero(T(By * t)) + GetBesselZero(T(Bz * t)); | ||
|
|
||
| T integrand = exp(lin); | ||
|
|
||
| T weight = (i == N) ? 0.5 : 1.0; | ||
| sum += integrand * weight; | ||
| } | ||
|
|
||
| return sum * dt; | ||
| } | ||
|
|
||
| /// @} | ||
| } // namespace RandomToolbox | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.