-
Notifications
You must be signed in to change notification settings - Fork 123
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
Unify linear solvers #2848
Unify linear solvers #2848
Conversation
The replacement consists of using the FlexibleSolver code.
When using the ParallelOverlappingILU0 it is not necessary to fix the overlap rows.
jenkins build this serial please |
benchmark please |
Benchmark result overview:
View result details @ https://www.ytelses.com/opm/?page=result&id=922 |
Please note that the variance in results have been significantly reduced, performance differences at the 1% level should be detectable now. In this case, it is clear that there are no significant performance impact of this PR, |
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 I'd personally write the shouldCreateSolver()
function using early returns like below, but it's a style issue so I'm not going to insist. Otherwise this looks good to me.
bool shouldCreateSolver() const
{
// Decide if we should recreate the solver or just do
// a minimal preconditioner update.
if (!flexibleSolver_) {
return true;
}
if (this->parameters_.cpr_reuse_setup_ == 0) {
return true;
}
if (this->parameters_.cpr_reuse_setup_ == 1) {
// Recreate solver on the first iteration of every timestep.
return this->simulator_.model().newtonMethod().numIterations() == 0;
}
if (this->parameters_.cpr_reuse_setup_ == 2) {
// Recreate solver if the last solve used more than 10 iterations.
return this->iterations() > 10;
}
// Never recreate solver.
assert(this->parameters_.cpr_reuse_setup_ == 3);
return false;
}
I'll adopt your suggestion. |
The following changes have been made:
I have tested the amg option on Norne, and it seems to work, although slower than either "ilu0" (default) or "cpr_trueimpes" for that case. It could probably benefit from some tuning to be as good as possible for the two-phase cases mentioned where it was good before, such testing should be very easy using the JSON file approach (start testing from the tree printed in the DBG file) with no recompilation. When the best defaults are found, they can be changed in setupPropertyTree.cpp. The one change I have not made (yet) is changing the parameter name |
jenkins build this serial please |
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.
Thanks for the updates to shouldCreateSolver
. I just noticed a couple of problems with the new logic, but otherwise it looks good to me.
jenkins build this serial please |
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.
Please note, that with the deletion of some of the files we might also be loosing some implemented functionality. Not sure whether this is intended (because they proofed to be bad/not working) or not, but it might be hard to recover it:
- BlackoilAMG had the option to start the second step on the first coarse level pressure system (now it will be only the finest one).
- I think some different scaling techniques to recover the pressure system might be lost (or were already lost previously).
There has been a vast amount of refactoring. Please make sure that proper credit is given and that copyright for copied/refactored stuff is correct.
EWOMS_REGISTER_PARAM(TypeTag, int, CprReuseSetup, "Reuse Amg Setup"); | ||
EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolverConfiguration, "Configuration of solver valid is: ilu0 (default), cpr_quasiimpes, cpr_trueimpes or file (specified in LinearSolverConfigurationJsonFile) "); | ||
EWOMS_REGISTER_PARAM(TypeTag, int, CprReuseSetup, "Reuse preconditioner setup. Valid options are 0: recreate the preconditioner for every linear solve, 1: recreate once every timestep, 2: recreate if last linear solve took more than 10 iterations, 3: never recreate"); | ||
EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolverConfiguration, "Configuration of solver. Valid options are: ilu0 (default), cpr_quasiimpes, cpr_trueimpes or file (specified in LinearSolverConfigurationJsonFile) "); |
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.
Needs an update as it seems to be missing options: (e.g. amg)
Not sure: Does this build parallel, too? |
yes. |
I have another suggestion. Why not skip the --linear-solver-configuration-file option and just intrepret --linear-solver-configuration as a file if the name matches ".*.json"? |
I like that idea. Should we also shorten it to |
The shorter the better, if you ask me.
|
This is now handled by passing a string to --linear-solver-configuration that ends with ".json".
I have implemented that (--linsolver). I have also removed the separate file parameter, replacing it with passing "--linsolver=options.json" as suggested. The doc string has been updated.
I have added 2020 SINTEF and Equinor copyright to the ISTLSolver.hpp file. However I have not done any other additions to copyrights in the PR. Looking at the files changed by this PR, I see no other significant enough changes to warrant adding a SINTEF copyright, the rest is just removing stuff. Did you have any particular concern? With that, I hope this can be merged when green again. |
jenkins build this serial please |
I made a serious mistake in one of the last commits, and it is a very embarrassing one. I'll amend ASAP... |
jenkins build this serial please |
{ | ||
prm_ = setupPropertyTree<TypeTag>(parameters_); | ||
} | ||
prm_ = setupPropertyTree<TypeTag>(parameters_); | ||
const auto& gridForConn = simulator_.vanguard().grid(); |
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 object (gridForConn
) is unused now.
This is the last (I hope) take on this, replacing #2706. There are still two requests @blattms made in that PR that need to be addressed here:
Part of my goal was to get rid of parameters that were redundant or came into conflict with each other. Adding "cpr" to the set of strings accepted by "--linear-solver-configuration" is no problem, just not sure if we should choose the trueimpes or quasiimpes as default (probably trueimpes, as that is what you get with --use-cpr right now). However keeping the "--use-cpr" will then conflict with the other one potentially. Would it address your concern if we shortened "--linear-solver-configuration" to "--linear-solver" or even "--linsolver"?
I think adding the option string "amg" to the above-discussed parameter (and an associated setup like for "ilu0" and the "cpr_*" options) should handle this. Could you advise about the actual case that benefited from it @totto82 or @blattms? Would be good to verify that the new is no worse.