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

Fixes to inlet files #1427

Merged
merged 5 commits into from
Nov 10, 2021
Merged

Fixes to inlet files #1427

merged 5 commits into from
Nov 10, 2021

Conversation

TobiKattmann
Copy link
Contributor

@TobiKattmann TobiKattmann commented Nov 7, 2021

Hi all,

I noticed problems when using multiple inlet files: At the template values were mixed between the inlets because there is a (in my eyes) superfluous sort done. So the problem is just with the template-writing and would not happen if alphabetical and nMarker_all order between the inlet marker_tags were identical. This PR fixes this, at least for the tests I did over at #1388 where I will also add a inc+turb+2species-with-2-inlets reg test (and hopefully also non-dimensional).

Inlet file non-dimensionalization: The inlet file writes dimensional values for the mean flow, and the values that are read are non-dimensionalized in the BC_Inlet routine itself -> I personally find this approach quite good, but I dont believe the SA+SST are adhering to that. See also this cfd-online issue. I will try to fix this here as well.

  • nu tilde is non-dimensionalized by multiplying with densityRef/viscosityRef (which I guess from the code)
  • TKE by multiplying with 1/VelocityRef^2 (which I guess from the code, and would fit with Feng Liu Non-Dim paper i have)
  • Omega by multiplying with length_Ref/VelocityRef (which would fit with Feng Liu) or by multiplying with ViscRef/(rhoRef*VelocityRef^2)
    Any info on this is appreciated.
    My approach would be non-dimensionalize in the BC_Inlet routine for Turb as well to stay consistent with the mean flow, For the mean flow it has to be done like that because the meaning of the values is determined in the inlet routine. Otherwise one could do all that consistently a bit earlier.

I have to remember to add a little hint to the laminar step tutorial to state that the inlet file should be dimensional

Related Work

#516 initial implementation

PR Checklist

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

So problem was a classic mismatch between what iMarkers are loop over in
the function that sets sth and the other that writes sth.
At one point there is an alphabetical sort of marker tags which destroys
the order given by the config which implicitly can be used to stay
consistent.
The sort was removed and during template inlet writing the same iMarker
loop is used to be consistent with the value preparation.

sort(profileTags.begin(), profileTags.end());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

so this destroys the order that was always given implicitly by the loop:

for (unsigned short iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
  if (config->GetMarker_All_KindBC(iMarker) == markerType) {

That loop is consequently used during the template writing as well

TobiKattmann added a commit that referenced this pull request Nov 7, 2021
Add necessary functions. Add template output. Make BC_Inlet use the
correct container which stores the inlet values. In the process a little
bug was fixed for multiple inlets that will be fixed in PR #1427.
@pcarruscag
Copy link
Member

👍 for doing it in BC_Inlet

@su2code su2code deleted a comment from lgtm-com bot Nov 9, 2021
The example_inlet_file.dat is always written with dimensional values.
For all variables.
The values are therefore also read dimesnional and stay dimensional
right until they are used in BC_INLET. That is now consistent between
mean flow and turbulence.
Comment on lines 631 to 639
/*--- Non-dimensionalize Inlet_TurbVars if Inlet-Files are used. ---*/
su2double Inlet_Vars[MAXNVAR];
Inlet_Vars[0] = Inlet_TurbVars[val_marker][iVertex][0];
Inlet_Vars[1] = Inlet_TurbVars[val_marker][iVertex][1];
if (config->GetInlet_Profile_From_File()) {
Inlet_Vars[0] *= 1 / (config->GetVelocity_Ref() * config->GetVelocity_Ref());
Inlet_Vars[1] *= config->GetViscosity_Ref() / (config->GetDensity_Ref() * config->GetVelocity_Ref() * config->GetVelocity_Ref());
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok now this works but maybe it is not the most performant or elegant solution.

The test I made is to write the example_inlet (by not having an inlet in the first place) and run a simulation with that. Then take the same config without inlet file and run another simulation --> These two simulation should be identical. For SA, the diff between the history files is empty and for SST I see differences in the 9th digit (the last in that case) popping up after 150 iterations which then accumulate in the residual. I would guess these are floating point errors but the analytical computation is the same.

@TobiKattmann
Copy link
Contributor Author

From my perspective this is finished. As mentioned above I will add a testcase with Mean-flow+SST+2Species for 2 inlets over at #1388 once this is merged.

@su2code su2code deleted a comment from lgtm-com bot Nov 10, 2021
@lgtm-com
Copy link

lgtm-com bot commented Nov 10, 2021

This pull request fixes 1 alert when merging f6bd942 into ccc1c6e - view on LGTM.com

fixed alerts:

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

SU2_CFD/src/solvers/CTurbSSTSolver.cpp Outdated Show resolved Hide resolved
SU2_CFD/src/solvers/CTurbSSTSolver.cpp Outdated Show resolved Hide resolved
Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com>
@lgtm-com
Copy link

lgtm-com bot commented Nov 10, 2021

This pull request fixes 1 alert when merging e242f47 into ccc1c6e - view on LGTM.com

fixed alerts:

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

@TobiKattmann TobiKattmann merged commit 1e5d4ff into develop Nov 10, 2021
@TobiKattmann TobiKattmann deleted the fix_inletfiles branch November 10, 2021 15:36
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.

2 participants