-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add Backward Euler solver (rebased) #2239
Conversation
Convert the SNES solver (which never converged for real problems) into a backward Euler solver. Both `beuler` and `snes` solver type names can be used for now. Nearly twice as fast as CVODE for same atol/rtol settings (10 mins vs 19) on quite complex 1D Hermes simulation with neon (https://github.com/bendudson/hermes-3/tree/master/examples/1D-neon)
Explicit comparisons against zero error code
Out of domain errors should be handled by calling PETSc function, rather than returning an error 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.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 25 out of 33. Check the log or trigger a new build to see more.
* next: Remove the Karniadakis time solver clang-tidy suggetion Manual entry on provenance-tracking metadata Save provenance tracking info from grid file
Fiddling about this to try and get it to pass constexpr int beuler_nout = 1e5;
root["beuler"]["nout"] = beuler_nout;
root["beuler"]["output_step"] = end / beuler_nout; Making the initial timestep very small, or tightening the tolerances makes very little difference. |
This is really a steady-state solver, and not suitable for oscillatory solutions like the one in this test
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.
clang-tidy made some suggestions
@@ -47,39 +47,55 @@ class SNESSolver; | |||
|
|||
namespace { | |||
RegisterSolver<SNESSolver> registersolversnes("snes"); | |||
} | |||
RegisterSolver<SNESSolver> registersolverbeuler("beuler"); |
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.
warning: variable registersolverbeuler
defined in a header file; variable definitions in header files can lead to ODR violations [misc-definitions-in-headers]
RegisterSolver<SNESSolver> registersolverbeuler("beuler");
^
public: | ||
SNESSolver(Options *opt = nullptr) : Solver(opt) {} | ||
public: | ||
SNESSolver(Options* opt = nullptr) : Solver(opt) {} |
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.
warning: constructor does not initialize these fields: timestep, dt, lower_its, upper_its, out_timestep, nsteps, diagnose, nlocal, neq, snes_f, snes_x, x0, predictor, x1, snes, Jmf [cppcoreguidelines-pro-type-member-init]
SNESSolver(Options* opt = nullptr) : Solver(opt) {}
^
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.
clang-tidy made some suggestions
// "solver" section, as we run into problems when solvers use the same | ||
// name for an option with inconsistent defaults | ||
auto options = Options::getRoot()->getSection("beuler"); | ||
auto solver = std::unique_ptr<Solver>{Solver::create("beuler", options)}; |
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.
warning: auto options
can be declared as auto *options
[readability-qualified-auto]
auto options = Options::getRoot()->getSection("beuler");
^~~~~
auto *
Evolves to steady state, compares against known solution.
Co-authored-by: Peter Hill <zed.three@gmail.com>
Replaces #2238, based on an updated
next
branch to avoid conflicts.