-
Notifications
You must be signed in to change notification settings - Fork 2
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
Parameter management utilities #163
base: develop
Are you sure you want to change the base?
Conversation
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 don't really have substantial feedback...
virtual int setCliParam(const std::string /* id */, const std::string /* value */) | ||
{ | ||
return 1; | ||
} |
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 have a personal preference for these functions being one line, but that has been discussed in #151
@@ -129,17 +129,23 @@ int test(int argc, char *argv[]) | |||
real_type norm_b = 0.0; | |||
|
|||
// Set solver options | |||
real_type tol = 1e-12; | |||
//real_type tol = 1e-12; |
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.
//real_type tol = 1e-12; |
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 catch!
solver.getIterativeSolver().setMaxit(2500); | ||
solver.getIterativeSolver().setTol(tol); | ||
// solver.getIterativeSolver().setTol(tol); |
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.
// solver.getIterativeSolver().setTol(tol); |
|
||
matrix_handler.setValuesChanged(true, memspace); | ||
|
||
// Set system matrix and initialize iterative solver | ||
status = solver.setMatrix(A); | ||
error_sum += status; | ||
|
||
solver.getIterativeSolver().setRestart(200); | ||
// solver.getIterativeSolver().setRestart(200); |
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.
// solver.getIterativeSolver().setRestart(200); |
int LinSolverIterativeRandFGMRES::getCliParam(const std::string id, std::string& /* value */) | ||
{ | ||
switch (params_list_[id]) | ||
{ | ||
default: | ||
out::error() << "Unknown string parameter " << id << "\n"; | ||
return 1; | ||
} | ||
return 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.
I am a little confused about the purpose of this function. Is that to say no parameters have a string as their value?
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 are right. The base class should implement parameter getters returning error messages. Derived classes should implement parameter getters only for parameters that are defined for that specific solver.
// if (conv_cond_ == 0) { | ||
// exit_cond = ((std::abs(rnorm - ZERO) <= EPSILON)); | ||
// } else { | ||
// if (conv_cond_ == 1) { | ||
// exit_cond = ((std::abs(rnorm - ZERO) <= EPSILON) || (rnorm < tol_)); | ||
// } else { | ||
// if (conv_cond_ == 2) { | ||
// exit_cond = ((std::abs(rnorm - ZERO) <= EPSILON) || (rnorm < (tol_*bnorm))); | ||
// } | ||
// } | ||
// } |
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.
Should probably remove this if it's unnecessary as the switch statement is cleaner.
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!
Managing different solver parameters in Re::Solve becomes a nontrivial task and there is a need for consistent parameter management across all Re::Solve modules. This draft PR is a proposal how to handle this. Parameter management is implemented only for classes
LinSolverIterativeFGMRES
andLinSolverIterativeRandGMRES
for now.Closes #96