Skip to content
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

Fix bug in SA-neg diffusion term (and generalize indices of flow variables for use by scalar solvers and numerics) #1392

Merged
merged 14 commits into from
Nov 8, 2021

Conversation

WallyMaier
Copy link
Contributor

@WallyMaier WallyMaier commented Oct 6, 2021

Proposed Changes

This draft PR aims to generalize and template the turbulence solver/ scalar solvers to reduce code duplication and allow NEMO access to the turbulence solvers. The ideas were discussed with @pcarruscag, @TobiKattmann and @suargi,
I am opening up the draft PR very early, so this is very much a work in process.

The main idea is use templates to introduce differing variable index values into the Scalar/Turb solvers.

Related Work

This idea follows PR #1375 and PR #1330

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 the '-Wall -Wextra -Wno-unused-parameter -Wno-empty-body' compiler flags, or simply --warnlevel=2 when using meson).
  • My contribution is commented and consistent with SU2 style.
  • 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.

@pr-triage pr-triage bot added the PR: draft label Oct 6, 2021
@WallyMaier WallyMaier changed the base branch from master to develop October 6, 2021 05:54
@su2code su2code deleted a comment from lgtm-com bot Oct 6, 2021
@pcarruscag pcarruscag changed the title [WIP] Generalized Turbulent solver indices -> NEMO turbulence [WIP] NEMO Turbulence (generalize indices of flow variables for use by scalar solvers and numerics) Oct 9, 2021
@lgtm-com
Copy link

lgtm-com bot commented Nov 7, 2021

This pull request fixes 1 alert when merging ac3f474 into 147dfac - view on LGTM.com

fixed alerts:

  • 1 for Comparison of narrow type with wide type in loop condition

@lgtm-com
Copy link

lgtm-com bot commented Nov 7, 2021

This pull request fixes 1 alert when merging 9790d11 into 147dfac - view on LGTM.com

fixed alerts:

  • 1 for Comparison of narrow type with wide type in loop condition

@lgtm-com
Copy link

lgtm-com bot commented Nov 7, 2021

This pull request fixes 1 alert when merging 60eed7c into 147dfac - view on LGTM.com

fixed alerts:

  • 1 for Comparison of narrow type with wide type in loop condition

@lgtm-com
Copy link

lgtm-com bot commented Nov 7, 2021

This pull request fixes 1 alert when merging 40c5586 into 147dfac - view on LGTM.com

fixed alerts:

  • 1 for Comparison of narrow type with wide type in loop condition

@pcarruscag pcarruscag changed the title [WIP] NEMO Turbulence (generalize indices of flow variables for use by scalar solvers and numerics) Fix bug in SA-neg diffusion term (and generalize indices of flow variables for use by scalar solvers and numerics) Nov 8, 2021
@pcarruscag pcarruscag marked this pull request as ready for review November 8, 2021 08:54
nu_e = nu_ij + fn*nu_tilde_ij;
}

Flux[0] = nu_e*Proj_Mean_GradScalarVar[0]/sigma;
Copy link
Member

Choose a reason for hiding this comment

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

There was a bug here for SA-neg as it was using the "uncorrected flux" which is prone to odd-even decoupling.
To keep track of this I've changed the scope of the PR.

The intrusive part of the changes (for @TobiKattmann and @suargi ) is done, so if it is ok with you I propose merging this now, to use it also in the species solver and refactored SA sources.

@WallyMaier please continue the NEMO turbulence in another PR, it should work out of the box now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll give this PR a read later today 👍

Density_i = V_i[nDim+2];
Laminar_Viscosity_i = V_i[nDim+5];
}
Density_i = V_i[idx.Density()];
Copy link
Member

Choose a reason for hiding this comment

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

I kept the sources cpp instead of moving to the hpp only to highlight the changes for @suargi , eventually it should be in an hpp to avoid the explicit instantiations (bottom of the file).

@lgtm-com
Copy link

lgtm-com bot commented Nov 8, 2021

This pull request fixes 1 alert when merging f7d054e into 147dfac - view on LGTM.com

fixed alerts:

  • 1 for Comparison of narrow type with wide type in loop condition

Copy link
Contributor Author

@WallyMaier WallyMaier left a comment

Choose a reason for hiding this comment

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

@pcarruscag thanks for taking this over. It was much needed and I was dragging my feet. Ill work to make the necessary NEMO changes in another PR. I can't approved but LGTM.

}
} else {
for (unsigned short iDim = 0; iDim < nDim; iDim++) {
q_ij += 0.5 * (V_i[iDim + idx.Velocity()] + V_j[iDim + idx.Velocity()]) * Normal[iDim];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -41,6 +41,7 @@ CNEMOEulerVariable::CNEMOEulerVariable(su2double val_pressure,
const CConfig *config,
CNEMOGas *fluidmodel)
: CFlowVariable(npoint, ndim, nvar, nvarprim, nvarprimgrad, config),
indices(ndim, config->GetnSpecies()),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -355,7 +355,7 @@ def main():
turb_naca0012_sa.cfg_dir = "rans/naca0012"
turb_naca0012_sa.cfg_file = "turb_NACA0012_sa.cfg"
turb_naca0012_sa.test_iter = 10
turb_naca0012_sa.test_vals = [-11.133933, -14.498178, 1.064330, 0.019756, 20, -1.898609, 20, -2.719825]
turb_naca0012_sa.test_vals = [-8.629583, -10.377793, 1.064488, 0.019711, 20.000000, -2.173971, 20.000000, -5.213344]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any idea why plain old SA would see such a change?

Copy link
Member

Choose a reason for hiding this comment

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

it's SA-neg for which the bug was fixed

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that the regression tests introduced in #1418 have passed, in particular in parallel_regression.py therer is a regression test for the negative SA. This means that this regression test is not properly defined and should be improved. Wonder about the others.

Copy link
Contributor

@TobiKattmann TobiKattmann left a comment

Choose a reason for hiding this comment

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

Thanks @WallyMaier and @pcarruscag for this. No more guessing what e.g V_i[nDim+2] now actually is 👍

I think the changes I have to make to #1388 are somewhat clear (after all, I can follow the Turbulence example :) )

So LGTM

Comment on lines +55 to +58
su2double Flux[MAXNVAR]; /*!< \brief Final result, diffusive flux/residual. */
su2double* Jacobian_i[MAXNVAR]; /*!< \brief Flux Jacobian w.r.t. node i. */
su2double* Jacobian_j[MAXNVAR]; /*!< \brief Flux Jacobian w.r.t. node j. */
su2double JacobianBuffer[2*MAXNVAR*MAXNVAR]; /*!< \brief Static storage for the two Jacobians. */
Copy link
Contributor

Choose a reason for hiding this comment

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

The great static-ification of SU2 👍

SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp Outdated Show resolved Hide resolved
SU2_CFD/include/numerics/turbulent/turb_diffusion.hpp Outdated Show resolved Hide resolved
SU2_CFD/include/variables/CEulerVariable.hpp Show resolved Hide resolved
SU2_CFD/src/drivers/CDriver.cpp Show resolved Hide resolved
Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com>
@lgtm-com
Copy link

lgtm-com bot commented Nov 8, 2021

This pull request fixes 1 alert when merging 57a736a into 147dfac - view on LGTM.com

fixed alerts:

  • 1 for Comparison of narrow type with wide type in loop condition

@pcarruscag
Copy link
Member

Thank you for the reviews folks, no feet were dragged, I was just looking for a relaxed Sunday activity.

@pcarruscag pcarruscag merged commit 641d254 into develop Nov 8, 2021
@pcarruscag pcarruscag deleted the feature_NEMO_turbulent branch November 8, 2021 23:23
TobiKattmann added a commit that referenced this pull request Nov 9, 2021
Introduced in #1392. The porting approach for now was to simply to way
it was done for turbulence. For the species_sources one could and should
prob adopt the approach for convection/diffusion. But for ease of
merging that was not done yet.
@@ -641,7 +641,7 @@ def main():
turbmod_sa_neg_rae2822.cfg_dir = "turbulence_models/sa/rae2822"
turbmod_sa_neg_rae2822.cfg_file = "turb_SA_NEG_RAE2822.cfg"
turbmod_sa_neg_rae2822.test_iter = 20
turbmod_sa_neg_rae2822.test_vals = [-2.004688, 0.742320, 0.497307, -5.265640, 0.809478, 0.061986]
turbmod_sa_neg_rae2822.test_vals = [-2.004689, 0.742306, 0.497308, -5.265793, 0.809463, 0.062016]
turbmod_sa_neg_rae2822.su2_exec = "mpirun -n 2 SU2_CFD"
Copy link
Member

Choose a reason for hiding this comment

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

It did not pass @suargi

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad. Thanks!

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.

4 participants