Skip to content
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

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft

Parameter management utilities #163

wants to merge 4 commits into from

Conversation

pelesh
Copy link
Collaborator

@pelesh pelesh commented Jun 13, 2024

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 and LinSolverIterativeRandGMRES for now.

Closes #96

@pelesh pelesh added enhancement New feature or request question Further information is requested labels Jun 13, 2024
@pelesh pelesh self-assigned this Jun 13, 2024
Copy link
Collaborator

@cameronrutherford cameronrutherford left a 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...

Comment on lines +52 to +55
virtual int setCliParam(const std::string /* id */, const std::string /* value */)
{
return 1;
}
Copy link
Collaborator

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//real_type tol = 1e-12;

Copy link
Collaborator Author

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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// solver.getIterativeSolver().setRestart(200);

Comment on lines +532 to +541
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;
}
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Comment on lines +163 to +173
// 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)));
// }
// }
// }
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Comprehensive way to manage ReSolve configuration parameters
2 participants