Use enum for SystemSolver preconditioner side - #456
Conversation
shakedregev
left a comment
There was a problem hiding this comment.
Please see how we use enums within ReSolve for SparseFormat and PermutationType and follow that. I've changed the target of your branch, as our CI tests don't work on mirrors. So once you make the changes, I will merge into this new target branch, and then if CLI passes, merge to develop.
d4db1c8 to
ec4787f
Compare
371f980 to
d169084
Compare
|
@shakedregev Updated to follow the existing enum usage pattern.
CPU validation completed:
|
|
@shakedregev Just wanted to follow-up: the requested enum-pattern changes are in Could you please take another look when you have a chance? The local CPU validation results are summarized in the comment above. |
|
hi @shakedregev, could you please take another look when you have a chance? the requested enum changes are in, the branch is mergeable, and the cpu checks passed; if it looks good, could you please clear the requested changes and merge it? thank you. |
pelesh
left a comment
There was a problem hiding this comment.
@verma-divyanshu-git thank you for your contribution. If we are to make this change, it would need to be a wholesale change for SystemSolver I/O (see comments below).
| int refactorize(); | ||
| int refactorizationSetup(); | ||
| int preconditionerSetup(std::string side); | ||
| int preconditionerSetup(Preconditioner::Side side); |
There was a problem hiding this comment.
I don't think that we want to expose internal enum in SystemSolver API. The SystemSolver class is a wrapper for Re::Solve solvers and it is intended to simplify user interaction with the rest of the library. It takes string inputs as these are read from the command line interface.
I agree that it would be better to avoid string arguments in the SystemSolver class but that would then require expanding parser to select correct enumeration entries based on the CLI inputs. Should we decide to go that route, we should make appropriate changes to all string inputs, not only preconditioner type, to make the code consistent.
Description
Use
Preconditioner::Sideat the CLI boundary for thesysGmresexample and functionality test while preserving the typedSystemSolverAPI.Closes #439
Proposed changes
SystemSolver::preconditionerSetup(Preconditioner::Side)typed inresolve/SystemSolver.hppandresolve/SystemSolver.cpp-p left|rightintoPreconditioner::Sideinexamples/sysGmres.cppandtests/functionality/testSysGmres.cpp, defaulting toRIGHTonly when-pis omitted-pvalues instead of silently falling through to right preconditioningsys_gmres_invalid_preconditioner_side_testwithWILL_FAIL TRUEintests/functionality/CMakeLists.txttests/functionality/testSysGmres.cpptoReSolve::io::Logger::misc()so the functionality target builds during warning-enabled CPU validationChecklist
make testandmake test_installper testing instructions). Code tested on./examples/<your_example>.exe -hto get instructions how to run examples). Code tested on:-Wall -Wpedantic -Wconversion -Wextra.Further comments
make test:51/51passed.make test_install: consumerctest1/1passed.sys_gmres_invalid_preconditioner_side_testrunssys_rand_gmres_test.exe -p boguswithWILL_FAIL TRUE; explicit invalid-pnow printsPreconditioning side 'bogus' not recognized. Use 'left' or 'right'.and exits1.sys_rand_gmres_test.exe -x no -i fgmres -g cgs2: residual2.1137376763106819e-16-p right: residual2.1137376763106819e-16-p left: residual2.0607333461083850e-16-p: residual9.9464723774203639e-13-x no -p right: residual1.0545376349847963e-12-x no -p left: residual3.7412173369307980e-14Flexible GMRES does not support left preconditioning. Use right preconditioning or disable flexible GMRES.