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

Removed CSolver::Convective_Residual #1222

Merged
merged 4 commits into from
Mar 8, 2021
Merged

Conversation

maxaehle
Copy link
Contributor

@maxaehle maxaehle commented Mar 4, 2021

Proposed Changes

Remove CSolver::Convective_Residual, as it does nothing and no derived class overrides it. There is one call in CIntegration.cpp, which I would like to replace by an error message.

Note that in the present version, usage of numerics[CONV_TERM] would not be thread-safe, it should be numerics[CONV_TERM + omp_get_thread_num()*MAX_TERMS] (see also #1214).

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.

Comment on lines 61 to 63
case FINITE_ELEMENT:
solver_container[MainSolver]->Convective_Residual(geometry, solver_container, numerics[CONV_TERM], config, iMesh, iRKStep);
SU2_MPI::Error("Computation of FEM convective flux in non-FEM integration attempted.", CURRENT_FUNCTION);
break;
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 going after dead code 👍
It should also be fairly safe to not cover the FINITE_ELEMENT case or just handle default, I doubt the execution will reach here if the wrong integration class is instantiated (multiple things would have to go wrong).
But looks good to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the way, there is dead code even in SU2_CFD.cpp, the else branch is unreachable: If it were reached, then turbo and harmonic_balance would both be false. As (multizone && !turbo) has to be false, multizone must be false as well. But then ((!multizone && !harmonic_balance && !turbo) || (turbo && disc_adj)) is true ;)

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 didn't touch this until now because I don't understand the principle behind these nested if-statement. Do you think the else branch in SU2_CFD.cpp should be removed?

Copy link
Member

Choose a reason for hiding this comment

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

I'm not even going to try unfolding the logic, take it out or throw an error, if the tests pass it's fine by me.

Copy link
Member

Choose a reason for hiding this comment

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

🍝

Copy link
Member

Choose a reason for hiding this comment

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

We can even make the constructors of CFluidDriver protected since it is not meant for standalone use anymore (it exists as the base for the legacy drivers).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in commit 7825b3b

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should also be fairly safe to not cover the FINITE_ELEMENT case or just handle default, I doubt the execution will reach here if the wrong integration class is instantiated (multiple things would have to go wrong).

I agree, commit 42fab4f

and the corresponding clause removed from SU2_CFD.cpp.
If it were reached, then turbo and harmonic_balance would both be
false. As (multizone && !turbo) has to be false, multizone must be
false as well. But then
((!multizone && !harmonic_balance && !turbo)
  || (turbo && disc_adj))
is true.
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 @maxaehle for removing unused code 👍 Always really valuable to have those cleanups 🧹

@maxaehle
Copy link
Contributor Author

maxaehle commented Mar 8, 2021

When the tests have run, I'll ignore this annoying CodeFactor test and merge, right?

@TobiKattmann
Copy link
Contributor

When the tests have run, I'll ignore this annoying CodeFactor test and merge, right?

👍 Yep, I guess this Complex code without any further detail of codeFactor is a bug or sth

@maxaehle maxaehle merged commit 048394c into develop Mar 8, 2021
@maxaehle maxaehle deleted the fix_remove_convectiveresidual branch March 8, 2021 09:43
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.

3 participants