File tree Expand file tree Collapse file tree 2 files changed +30
-6
lines changed
Expand file tree Collapse file tree 2 files changed +30
-6
lines changed Original file line number Diff line number Diff line change @@ -12,16 +12,25 @@ ProblemOperatorBase::ConstructJacobianSolver()
1212 precond->SetPrintLevel (GetGlobalPrintLevel ());
1313
1414 auto solver = std::make_unique<mfem::HypreGMRES>(_problem._comm );
15-
16- solver->SetTol (1e-16 );
17- solver->SetAbsTol (1e-16 );
18- solver->SetMaxIter (1000 );
19- solver->SetKDim (10 );
20- solver->SetPrintLevel (GetGlobalPrintLevel ());
2115 solver->SetPreconditioner (*precond);
2216
2317 _jacobian_preconditioner = std::move (precond);
2418 _jacobian_solver = std::move (solver);
19+
20+ SolverOptions default_options;
21+ SetSolverOptions (default_options);
22+ }
23+
24+ void
25+ ProblemOperatorBase::SetSolverOptions (SolverOptions & options)
26+ {
27+ auto & solver = static_cast <mfem::HypreGMRES &>(*_jacobian_solver);
28+
29+ solver.SetTol (options._tolerance );
30+ solver.SetAbsTol (options._abs_tolerance );
31+ solver.SetMaxIter (options._max_iteration );
32+ solver.SetKDim (options._k_dim );
33+ solver.SetPrintLevel (options._print_level );
2534}
2635
2736void
Original file line number Diff line number Diff line change @@ -26,6 +26,21 @@ class ProblemOperatorBase
2626 return static_cast <TSolver *>(_jacobian_preconditioner.get ());
2727 }
2828
29+ // / A structure for setting solver options. Defaults have been set.
30+ struct SolverOptions
31+ {
32+ double _tolerance{1e-16 };
33+ double _abs_tolerance{1e-16 };
34+
35+ unsigned int _max_iteration{1000 };
36+
37+ int _print_level{GetGlobalPrintLevel ()};
38+ int _k_dim{10 };
39+ };
40+
41+ // / Sets the solver's options. Override in derived classes.
42+ virtual void SetSolverOptions (SolverOptions & options);
43+
2944protected:
3045 // / Use of protected constructor to only allow construction by derived classes.
3146 // / All problem operator classes are built on-top of this class and it should not
You can’t perform that action at this time.
0 commit comments