23#ifndef _GEMA_HYPRE_SOLVER_H_
24#define _GEMA_HYPRE_SOLVER_H_
31#include <HYPRE_parcsr_ls.h>
33typedef HYPRE_Solver HYPRE_SOLVER;
38using HypreTolF = HYPRE_Int (*)(HYPRE_SOLVER, hypre_double);
39using HypreMaxItF = HYPRE_Int(*)(HYPRE_SOLVER, HYPRE_Int);
40using HypreSolveF = HYPRE_Int(*)(HYPRE_SOLVER, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
41using HypreSetupF = HYPRE_Int(*)(HYPRE_SOLVER, HYPRE_ParCSRMatrix, HYPRE_ParVector, HYPRE_ParVector);
42using HypreSetPreconF = HYPRE_Int(*)(HYPRE_Solver, HYPRE_PtrToParSolverFcn, HYPRE_PtrToParSolverFcn, HYPRE_Solver);
43using HypreGetResF = HYPRE_Int(*)(HYPRE_SOLVER, hypre_double*);
44using HypreGetItCountF = HYPRE_Int(*)(HYPRE_SOLVER, HYPRE_Int*);
45using HypreSetLogF = HYPRE_Int(*)(HYPRE_SOLVER, HYPRE_Int);
46using HypreDestroyF = HYPRE_Int(*)(HYPRE_SOLVER);
53 HypreSetPreconF setPrecon;
55 HypreGetItCountF getItCount;
57 HypreDestroyF destroy;
94 virtual const char* pluginName()
const {
return "HypreSolver"; }
97 virtual const char* pluginType()
const {
return "hypre"; }
99 virtual bool loadPrivateData(
LuaTable& table);
102 int numThreads = -1)
const;
110 virtual QString quickDescription()
const;
113 virtual int trackItemId()
const {
return _trackSolveItem; }
116 void destroyHS(HYPRE_SOLVER s, SolverType type);
117 int createHS(HYPRE_SOLVER* s, SolverType type);
118 int solveHS(HYPRE_ParCSRMatrix A, HYPRE_ParVector b, HYPRE_ParVector x)
const;
121 bool parseOptions(HYPRE_SOLVER s, SolverType t,
LuaTable& options);
123 const char* typeToName(SolverType t)
const ;
124 SolverType nameToType(
const QString& name)
const;
145 int _trackSolveItem = -1;
146 int _trackSolveIterAttr = -1;
147 int _trackSolveResidualAttr = -1;
148 int _trackSolveInternalTimeAttr = -1;
150 int _trackDetailedVectorMatrixSetupItem = -1;
151 int _trackDetailedVectorMatrixSolveItem = -1;
virtual const GmLogCategory & logger() const
QString description() const
A class for creating a GeMA solver based on the HYPRE library.
Definition hypreSolver.h:67
bool _printResidual
Should the solver print, after solving, the residual?
Definition hypreSolver.h:142
static int _maxThreads
The maximum number of threads used to configure the Hypre library.
Definition hypreSolver.h:130
void fetchSolveMetrics(GmRunProgress *ps) const
Get (and possibly print) iterations, residual and time statistics.
Definition hypreSolver.cpp:900
int _nthreads
The configured number of threads for the HYPRE solver.
Definition hypreSolver.h:139
HYPRE_SOLVER _precon
The preconditioner (it is also a solver)
Definition hypreSolver.h:136
QStringList _solverOptions
List with the set of options to be configured on the solver.
Definition hypreSolver.h:140
SolverType _stype
solver type
Definition hypreSolver.h:137
GmSparseMatrixOptions _hypreMatrixOptions
The set of options used for building the sparse matrix.
Definition hypreSolver.h:133
virtual bool setSolverTolerance(double tol)
Updates the current solver tolerance. Will be used by any successive calls to solve()
Definition hypreSolver.cpp:660
virtual ~HypreSolver()
Destructor.
Definition hypreSolver.cpp:216
static void libraryFinalize()
Closes the Hypre library on plugin destruction.
Definition hypreSolver.cpp:110
bool _printHypreMsgs
Enable or disable HYPRE messages to the CONSOLE only.
Definition hypreSolver.h:143
HypreSolver(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition hypreSolver.cpp:120
static int _numSolvers
The number of instanced solvers.
Definition hypreSolver.h:131
static void libraryInit(const GmLogCategory &logger)
Initializes the Hypre library on plugin loading.
Definition hypreSolver.cpp:92
SolverType _ptype
preconditioner type
Definition hypreSolver.h:138
bool _printIterations
Should the solver print, after solving, the number of iterations used by the numeric solver?
Definition hypreSolver.h:141
HYPRE_SOLVER _solver
The solver.
Definition hypreSolver.h:135
bool armadilloSolve(GmRunProgress *ps, GmSolverMatrix *A, const GmVector &b, GmVector &x, bool xIsGuess=false) const
Solve implementation.
Definition hypreSolver.cpp:776
Definition hypreSolver.h:48