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

NEMO - Improvements on the Preprocessing phase and inclusion of Chapmann-Enskog for Mutation++ #1343

Merged
merged 12 commits into from
Aug 9, 2021

Conversation

fmpmorgado
Copy link
Contributor

@fmpmorgado fmpmorgado commented Aug 2, 2021

Proposed Changes

Optimization of the Preprocessing phase;
Inclusion of the Chapmann-Enskog option for Mutation++

Related Work

None

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.

  • [ X ] I am submitting my contribution to the develop branch.
  • [ X ] 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).
  • [ X ] My contribution is commented and consistent with SU2 style.
  • [ X ] I have added a test case that demonstrates my contribution, if necessary.
  • [ X ] I have updated appropriate documentation (Tutorials, Docs Page, config_template.cpp) , if necessary.

Work Performed

I have reduced almost by half the time of the preprocessing phase, leading to a ~10% less time per iteration. This was done by:

  • Calculate dPdU, dTdU, dTvedU only for the implicit case
  • Avoid the calculation of eve_min and eve_max using Mutation++. Instead, return nonphysical if the vibrational temperatures reach the specified minimum and maximum value

Additionally, I have included the option of using Chapmann-Enskog for the calculation of transport equations and thermal conductivity using Mutation++

Common/src/CConfig.cpp Outdated Show resolved Hide resolved
SU2_CFD/src/variables/CNEMOEulerVariable.cpp Show resolved Hide resolved

V[RHOCVTR_INDEX] = rhoCvtr;
V[RHOCVVE_INDEX] = rhoCvve;
V[RHOCVTR_INDEX] = fluidmodel->ComputerhoCvtr();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

fluidmodel->ComputedTdU (V, val_dTdU );
fluidmodel->ComputedTvedU(V, eves, val_dTvedU);
if(implicit){
fluidmodel->ComputedPdU (V, eves, val_dPdU );
Copy link
Contributor

Choose a reason for hiding this comment

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

These may be required for some explicit schemes/viscous

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The rest of the code code seems okay, going to take a further look to see which schemes and routines use those quantities

Copy link
Member

Choose a reason for hiding this comment

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

If in doubt and the computations are not expensive...

@lgtm-com
Copy link

lgtm-com bot commented Aug 2, 2021

This pull request fixes 1 alert when merging 8450d94 into f47e22b - view on LGTM.com

fixed alerts:

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

Common/include/option_structure.hpp Outdated Show resolved Hide resolved
Common/include/option_structure.hpp Outdated Show resolved Hide resolved
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
@fmpmorgado
Copy link
Contributor Author

@WallyMaier @CatarinaGarbacz just checked with the testcases Wally provided. All of them pass

@fmpmorgado fmpmorgado marked this pull request as ready for review August 3, 2021 19:11
SU2_CFD/include/variables/CNEMOEulerVariable.hpp Outdated Show resolved Hide resolved
@@ -46,6 +46,9 @@ CNEMOEulerVariable::CNEMOEulerVariable(su2double val_pressure,
Gradient_Reconstruction(config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient_Primitive) {

unsigned short iDim, iSpecies;

/*--- Setting flags ---*/
implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT);
Copy link
Contributor

Choose a reason for hiding this comment

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

something like this?

Suggested change
implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT);
bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I initialize the variable inside the CNEMOEulerVariable instantiaton function, it can't be used for other functions. If I am not mistaken, that variable will be deleted when the function returns

Copy link
Contributor

Choose a reason for hiding this comment

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

is it used in other functions wuth the variable structure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry @WallyMaier didn't get it. What variable structure are you mentioning ?

Copy link
Contributor

Choose a reason for hiding this comment

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

If the boolean implicit is only used in this function in NEMOVariable, I dont think we should declare in the hpp.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think I can do it any other way, else the CConfig parameter would have to be passed as argument to the Cons2PrimVar function.

Copy link
Member

Choose a reason for hiding this comment

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

Don't rely on passing the config around too much.

@lgtm-com
Copy link

lgtm-com bot commented Aug 4, 2021

This pull request fixes 1 alert when merging fbbc6ee into f47e22b - view on LGTM.com

fixed alerts:

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

Common/include/option_structure.hpp Outdated Show resolved Hide resolved
Common/include/option_structure.hpp Outdated Show resolved Hide resolved
Common/src/CConfig.cpp Outdated Show resolved Hide resolved
@lgtm-com
Copy link

lgtm-com bot commented Aug 5, 2021

This pull request fixes 1 alert when merging 0cd78e4 into f47e22b - 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 Aug 9, 2021

This pull request fixes 1 alert when merging a8b0b93 into df2469f - view on LGTM.com

fixed alerts:

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

static const MapType<std::string, TRANSCOEFFMODEL> TransCoeffModel_Map = {
MakePair("WILKE", TRANSCOEFFMODEL::WILKE)
MakePair("GUPTA-YOS", TRANSCOEFFMODEL::GUPTAYOS)
MakePair("CHAPMANN-ENSKOG", TRANSCOEFFMODEL::CHAPMANN_ENSKOG)
Copy link
Member

Choose a reason for hiding this comment

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

Do you guys have these options documented somewhere? I don't see them in the config_template but maybe in one of NEMO testcases?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have now included this option in the config_template file. It's not used on NEMO test-cases though

@lgtm-com
Copy link

lgtm-com bot commented Aug 9, 2021

This pull request fixes 1 alert when merging b2a783e into df2469f - view on LGTM.com

fixed alerts:

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

@fmpmorgado fmpmorgado merged commit 3f745be into develop Aug 9, 2021
@fmpmorgado fmpmorgado deleted the NEMO_opt_init branch August 9, 2021 13:49
@pr-triage pr-triage bot added the PR: merged label Aug 9, 2021
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.

Yeah I'm late to the party... but lgtm @fmpmorgado . Just 2 very little comments one might consider for the next PR

Comment on lines +271 to +273
if (V[T_INDEX] <= Tmin) { nonPhys = true; return nonPhys;}
else if (V[T_INDEX] >= Tmax) { nonPhys = true; return nonPhys;}
else if (V[T_INDEX] != V[T_INDEX]){ nonPhys = true; return nonPhys;}
Copy link
Contributor

Choose a reason for hiding this comment

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

Here I would have gone with sth like

if ((V[T_INDEX] <= Tmin) || condition2 || condition3) {
  nonPhys = true; return nonPhys;
}

The same below for Tve

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @TobiKattmann, I'll address your comments in #1347

Comment on lines +46 to +47
Gradient_Reconstruction(config->GetReconstructionGradientRequired() ? Gradient_Aux : Gradient_Primitive),
implicit(config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT) {
Copy link
Contributor

Choose a reason for hiding this comment

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

here a little indentation more

Copy link
Member

Choose a reason for hiding this comment

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

A little clang-format you mean? 😄

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