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 for discrete adjoint: axisymmetry + SST turbulence model #1571

Merged
merged 8 commits into from
Mar 23, 2022

Conversation

lkusch
Copy link
Contributor

@lkusch lkusch commented Mar 22, 2022

Proposed Changes

The velocity component used in the axisymmetric residual is now considered as an input for preaccumulation in the residual computation. When not considered, the use of axisymmetry and the SST model will result in wrong sensitivities when using the discrete adjoint method.

I also wanted to note that there does not seem to be any treatment of axisymmetric cases for the SA model. Is this correct or does it make sense to include a warning? We could, for example, do that in the context of this pull request.

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

Comment on lines 601 to 602
AD::SetPreaccIn(Coord_i[1]);
AD::SetPreaccIn(V_i[2]);
Copy link
Member

Choose a reason for hiding this comment

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

Thank you for the fix, this is probably something I broke recently.
Can you add a simple regression test case? It can be a pipe or something very small, just enough to prevent this in the future.

There is an issue opened for the SA problem you mention #1565, we should check for this in CConfig::SetPostprocessing and throw an error (if axisymetry and the turbulence model is not NONE, SST, or SST_SUST).

@pcarruscag
Copy link
Member

Oh and last thing, add yourself to AUTHORS.md

Replacing hardcoded 2 in velocity preaccumulation

Co-authored-by: Pedro Gomes <[email protected]>
@lkusch
Copy link
Contributor Author

lkusch commented Mar 22, 2022

Thanks for the fast reply! I changed the hardcoded 2 (just as a remark: the hardcoded values also appear in the calculations), added myself as an author and inserted some lines for throwing an error if the issue in #1565 occurs. I did not know exactly where to put it best.

Concerning a regression test: I strongly support the idea of introducing an axisymmetric regression test. However, I was using a testcase from @bigfooted , and I never set up such a test case on my own. There do not seem to be any axisymmetric pipe setups in the Testcases folder so far. @bigfooted , could we maybe use your mesh for the jet flow test case and, if necessary, switch to a standard flow setup?

@pcarruscag
Copy link
Member

Yep that's what I meant, replace it in the calculations as well please, and also in PrimVarGrad, the leading 2 is "velocity + 1" and the leading one is "velocity".
The reason for this replacing is to make the turbulence sources compatible with NEMO.

@pcarruscag
Copy link
Member

We have some small flat plates here and there, I can convert one to axisymmetric.

@lkusch
Copy link
Contributor Author

lkusch commented Mar 22, 2022

Okay, done. Sorry, I read over that comment before. Hope I picked the correct component in PrimVarGrad.

Copy link
Member

@pcarruscag pcarruscag left a comment

Choose a reason for hiding this comment

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

That's perfect thanks.
I had a look in the testcases and there is an axisym sst regression for the primal solver, in TestCases/axisymmetric_rans/air_nozzle.
It has a restart file already (in the TestCases repo), so it should be easy to add a regression to parallel_regression_AD.py

Copy link
Member

@pcarruscag pcarruscag left a comment

Choose a reason for hiding this comment

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

Everything else LGTM, thanks again.

@bigfooted
Copy link
Contributor

bigfooted commented Mar 22, 2022

Thanks for the fast reply! I changed the hardcoded 2 (just as a remark: the hardcoded values also appear in the calculations), added myself as an author and inserted some lines for throwing an error if the issue in #1565 occurs. I did not know exactly where to put it best.

Concerning a regression test: I strongly support the idea of introducing an axisymmetric regression test. However, I was using a testcase from @bigfooted , and I never set up such a test case on my own. There do not seem to be any axisymmetric pipe setups in the Testcases folder so far. @bigfooted , could we maybe use your mesh for the jet flow test case and, if necessary, switch to a standard flow setup?

Yes, you can use that mesh. It can be used for pipe flow setup and jets with coflows, so we can reuse it in different testcases as well if needed. But any simple rectangular mesh is fine, so a mesh from the existing testcases as @pcarruscag mentions would also work.

@lkusch
Copy link
Contributor Author

lkusch commented Mar 22, 2022

I was aware of that test case. But I did not use it for the verification of sensitivities since I could not manage to set up a working derivative computation (different combination of markers/objective functions were leading to a memory error). However, I could use it to set up a regression test for the comparison of residuals.

Copy link
Member

@pcarruscag pcarruscag left a comment

Choose a reason for hiding this comment

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

Where did you get memory errors? SU2_DOT_AD?

@lkusch
Copy link
Contributor Author

lkusch commented Mar 23, 2022

Sorry for the confusion. I must have mixed something up yesterday - the test case was crashing directly for SU2_CFD_AD when I set MARKER_MONITORING. But now it is working. So I think we can stick to the regression case and the way I set it up. Thanks again for the reviews!

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 for this fix Lisa 💐 The code bits look good to me.

When it comes to the cfg I much prefer (and that is also a bit current SU2 strategy) stripping all the comments away instead of a few ones you want to highlight. This cfg is of course very close to an existing one and I am wondering whether we can make both cases work with just one cfg.

The first step would be to not remove MATH PROBLEM as then the usage of SU2_CFD or SU2_CFD_AD indicates primal or adjoint.

The second step is to get rid of the restart which I guess we could do with this part from Testcase.py

# Indicate whether to disable restart
 self.no_restart = False

Did you change any other options? If not I guess this is the way how we could avoid duplicating the cfg. So it might be more appropriate to not apply the suggestions here on github but to do it on your machine and test it, and if it works push 👍

TestCases/axisymmetric_rans/air_nozzle/air_nozzle_adj.cfg Outdated Show resolved Hide resolved
TestCases/axisymmetric_rans/air_nozzle/air_nozzle_adj.cfg Outdated Show resolved Hide resolved
TestCases/axisymmetric_rans/air_nozzle/air_nozzle_adj.cfg Outdated Show resolved Hide resolved
TestCases/axisymmetric_rans/air_nozzle/air_nozzle_adj.cfg Outdated Show resolved Hide resolved
TestCases/axisymmetric_rans/air_nozzle/air_nozzle_adj.cfg Outdated Show resolved Hide resolved
TestCases/axisymmetric_rans/air_nozzle/air_nozzle_adj.cfg Outdated Show resolved Hide resolved
TestCases/axisymmetric_rans/air_nozzle/air_nozzle_adj.cfg Outdated Show resolved Hide resolved
TestCases/axisymmetric_rans/air_nozzle/air_nozzle_adj.cfg Outdated Show resolved Hide resolved
TestCases/parallel_regression_AD.py Outdated Show resolved Hide resolved
TestCases/parallel_regression_AD.py Outdated Show resolved Hide resolved
@lkusch
Copy link
Contributor Author

lkusch commented Mar 23, 2022

This is confusing me a bit. Before I set it up: Do you want me to use the original config (without the _adj), remove the comments and the model and then run SU2_CFD_AD in the regression test?

@TobiKattmann
Copy link
Contributor

In the first instance I would just try to run the new and original Testcase with just the original config. And from what I can see you need to do the 2 steps mentioned above (Remove MATH_PROBLEM and use SU2_CFD_AD directly for the adjoint test + use the no_restart = True option for the reg test). If nothing else (apart from Math_Problem and restart_sol) was changed then this should work without an extra *_adj.cfg.

In a next step (which is then more of a cosmetic, optional nature) you could strip the comments and unnecessary options from the cfg

@TobiKattmann
Copy link
Contributor

27d35a2 -> awesome.

Concerning the option(-comment) stripping; I am still in favor, although @FlorianDm is the original author. Especially I would strip the AOA, SIDESLIP_ANGLE, CFD_ADAPT_PARAM, SYSTEM_MEASUREMENTS, MESH_FORMAT as they seem superfluous to me.

But for the sake of keeping this PR concise the current state is fine as well 👍

@lkusch lkusch merged commit 3a5b668 into su2code:develop Mar 23, 2022
@lkusch lkusch deleted the fix_axisymmetric_adjoint branch March 23, 2022 14:49
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