-
Notifications
You must be signed in to change notification settings - Fork 260
Refactored line search functionality for do_one_defect_correction_Stokes_step in solver_schemes.cc #6772
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
base: main
Are you sure you want to change the base?
Refactored line search functionality for do_one_defect_correction_Stokes_step in solver_schemes.cc #6772
Conversation
source/simulator/helper_functions.cc
Outdated
| * Performs a Newton line search for the do_one_defect_correction_Stokes_step function | ||
| */ | ||
| template <int dim> | ||
| void Simulator<dim>::perform_line_search(const DefectCorrectionResiduals &dcr, const bool use_picard, LinearAlgebra::BlockVector &search_direction) |
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.
same here:
- return step length
- one argument per line
include/aspect/simulator.h
Outdated
|
|
||
| /** | ||
| * Perform a newton line search to determine the optimal step length | ||
| * along the search direction. |
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.
Also say that the result of the function is that current_linearization_point is set to the old current_linearization_point plus a suitable update in direction of search_direction.
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.
You'll still want to address this point.
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.
Also, document what the function returns.
8a53156 to
90b1500
Compare
bangerth
left a comment
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.
Only the two comments I'm leaving below.
include/aspect/simulator.h
Outdated
|
|
||
| /** | ||
| * Perform a newton line search to determine the optimal step length | ||
| * along the search direction. |
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.
You'll still want to address this point.
include/aspect/simulator.h
Outdated
|
|
||
| /** | ||
| * Perform a newton line search to determine the optimal step length | ||
| * along the search direction. |
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.
Also, document what the function returns.
0de2e51 to
c537189
Compare
bangerth
left a comment
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.
This looks good to me. @arnoldkk13 is one of my undergraduate research students, so I would like someone else to take a second look and approve/disapprove.
We have some follow-ups in the pipeline. For example, the search_direction argument to the refactored function should really be const, but the original code modified it so the current code does too. We'll work on that next, once this patch is in.
gassmoeller
left a comment
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.
Looks all correct to me, I just have some code style suggestion, and a question about a change in the screen output. Let me know when you want me to take another look, and thanks @arnoldkk13!
include/aspect/simulator.h
Outdated
| * is set to the old current_linearlization_point plus a suitable update. | ||
| * | ||
| * @return This function returns the updated residual after the line | ||
| * search is performed. |
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.
Could you indent this comment like the other lines? Unfortunately make indent does not affect doxygen comments so you will have to do it manually.
Also please add documentation for the other input parameters before @return in this format: * @param use_picard Whether a Picard iteration was used to ... and the same for the other parameters.
source/simulator/helper_functions.cc
Outdated
| /** | ||
| * Performs a Newton line search for the do_one_defect_correction_Stokes_step function | ||
| */ |
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.
Remove this comment here. The place to put these comments is the declaration of this function in the header file. And please add two more empty lines, we have a stylistic convention of having 3 empty lines between functions in all source files, and following this convention makes it easier to read the code.
source/simulator/helper_functions.cc
Outdated
| // Do the loop for the line search at least once with the full step length. | ||
| // If line search is disabled we will exit the loop in the first iteration. | ||
|
|
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 think the code would be easier to read if you had an empty line before the comment and no empty line between comment and the loop. It is just a quesiton of coding style, but code is typically read much more often than (re-)written and this is closer to our usual style.
source/simulator/solver_schemes.cc
Outdated
| pcout << " The linear solver tolerance is set to " << parameters.linear_stokes_solver_tolerance << std::endl; | ||
| pcout << " The linear solver tolerance is set to " | ||
| << parameters.linear_stokes_solver_tolerance | ||
| << ". "; |
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.
You removed an std::endl at the end of this line. Was this on purpose? If it was: Can you post how the output looked like before and now? I just want to check if it makes sense to remove the newline in this context.
12ce145 to
c637833
Compare
|
@gassmoeller Thank you for the comments and changes! I’ve finished adding your comments, so please take a look when you have the chance. |
| /** | ||
| * Perform a Newton line search to determine the optimal step length | ||
| * along the search direction. After the update, the current_linearization_point | ||
| * is set to the old current_linearlization_point plus a suitable update. | ||
| * | ||
| * @param dcr The defect correction residuals associated with the current nonlinear | ||
| * iteration. | ||
| * @param use_picard Whether a Picard iteration was used to update the nonlinear | ||
| * iteration (true) or a Newton update (false). | ||
| * @param search_direction The proposed update direction for the solution vector. | ||
| * | ||
| * @return This function returns the updated residual after the line | ||
| * search is performed. | ||
| * | ||
| * This function is implemented in | ||
| * <code>source/simulator/helper_functions.cc</code> | ||
| */ |
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.
You'll still want to align the stars at the beginning of each line.
0604575 to
0528889
Compare
gassmoeller
left a comment
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.
Yes, looks all good now. Thanks!
|
Ah this PR has acquired a conflict because I merged #6782. Could you update your main branch and then rebase this PR to resolve the conflict? Let us know if you need instructions for how that works. |
|
@arnoldkk13 Let me know if you need help with resolving the merge conflict! |
9416939 to
679066c
Compare
|
I believe that the merge conflict should be resolved. Please let me know if any changes are needed! |
Pull Request Checklist. Please read and check each box with an X. Delete any part not applicable. Ask on the forum if you need help with any step.
Refactored the Newton line search functionality in do_one_defect_correction_Stokes_step into a new function in helper_functions.cc.
Before your first pull request:
For all pull requests:
For new features/models or changes of existing features: