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
Clarify function argument names. #5291
Conversation
I am not sure the bool is duplicative. This function can be called in three ways:
There may be better ways to indicate which operation is requested, but I think a single pointer is probably not enough (unless we use |
@gassmoeller Oh, I should have checked here. I think you also figured out what I describe in #5300. |
5799b0e
to
f9020a7
Compare
Let's see if this actually works finally. I think that I finally understood how this is supposed to work; perhaps I have managed to even express my understanding in code. The PR was initially called "Remove a function argument", which I've come to believe is not actually possible, but perhaps the clarification of the argument names is still useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I find the new version easier to understand than the old one, but it is not worse either. If you address my comments this is ok to merge.
source/simulator/solver_schemes.cc
Outdated
@@ -993,10 +987,12 @@ namespace aspect | |||
particle_world->restore_particles(); | |||
|
|||
const double relative_temperature_residual = | |||
assemble_and_solve_temperature(nonlinear_iteration == 0, &initial_temperature_residual); | |||
assemble_and_solve_temperature(initial_temperature_residual, | |||
nonlinear_iteration == 0 ? &initial_temperature_residual : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nonlinear_iteration == 0 ? &initial_temperature_residual : 0); | |
nonlinear_iteration == 0 ? &initial_temperature_residual : nullptr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
source/simulator/solver_schemes.cc
Outdated
|
||
const std::vector<double> relative_composition_residual = | ||
assemble_and_solve_composition(nonlinear_iteration == 0, &initial_composition_residual); | ||
assemble_and_solve_composition(initial_composition_residual, | ||
nonlinear_iteration == 0 ? &initial_composition_residual : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nonlinear_iteration == 0 ? &initial_composition_residual : 0); | |
nonlinear_iteration == 0 ? &initial_composition_residual : nullptr); |
Yes, I ended up going around a bit with this PR and ended up in a not vastly different place. Perhaps the biggest difference is to rename the variables. My confusion, as stated in #5300, was mainly that the variable was called "initial_residual", but that it is computed based on a boolean argument that at least in this function we don't know is only ever true the first time around. It looks like we're putting the current residual into the |
We have three functions that can optionally compute something. Whether they do is controlled by a
bool
argument, and the output is put into a pointer variable. This is duplicative: We should just use whether the pointer is non-nullptr
to control whether or not to compute the optional thing.