LisSolver
The GeMA Lis Numeric Solver Plugin
Loading...
Searching...
No Matches
lisSolver.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_LIS_SOLVER_H_
25#define _GEMA_LIS_SOLVER_H_
26
27#include <gmNumSolver.h>
28#include <gmSparseMatrix.h>
29#include <QObject>
30
31struct LIS_SOLVER_STRUCT;
32typedef struct LIS_SOLVER_STRUCT* LIS_SOLVER;
33
34class GmRunProgress;
35
42class LisSolver: public QObject, public GmNumSolver
43{
44public:
45
46 static void libraryInit(const GmLogCategory& logger);
47 static void libraryFinalize();
48
50 virtual ~LisSolver();
51
52 // Comments on the base class
53 virtual const char* pluginName() const { return "LisSolver"; }
54
55 // Comments on the base class
56 virtual const char* pluginType() const { return "lis"; }
57
58 virtual bool loadPrivateData(LuaTable& table);
59
60 virtual GmSolverMatrix* newMatrix(int nlin, int ncol, const GmSolverMatrix* sharedLayout,
61 int numThreads = -1) const;
62
63 virtual bool setSolverTolerance(double tol);
64
65 virtual bool solveImpl(GmSolverMatrix* A, const GmVector& b, GmVector& x, bool xIsGuess = false) const;
66
67 virtual void printParameters(const GmLogCategory& logger);
68
69 virtual QString quickDescription() const;
70
71 // Comments on the base class
72 virtual int trackItemId() const { return _trackSolveItem; }
73
74private:
75
76 bool armadilloSolve(GmRunProgress* ps, GmSolverMatrix* A, const GmVector& b, GmVector& x, bool xIsGuess = false) const;
77
78 bool loadLisParameters(LuaTable& table);
79 void fetchSolveMetrics(GmRunProgress* ps) const;
80
81 static int _maxThreads;
82 static int _numSolvers;
83
85
86 LIS_SOLVER _solver;
94
95 int _trackSolveItem = -1;
96 int _trackSolveIterAttr = -1;
97 int _trackSolveResidualAttr = -1;
98 int _trackSolveInternalTimeAttr = -1;
99
100 int _trackDetailedVectorMatrixSetupItem = -1;
101 int _trackDetailedVectorMatrixSolveItem = -1;
102};
103
104#endif
virtual const GmLogCategory & logger() const
QString description() const
A class for creating a GeMA solver based on th Lis library.
Definition lisSolver.h:43
LisSolver(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition lisSolver.cpp:109
static void libraryInit(const GmLogCategory &logger)
Initializes the Lis library on plugin loading.
Definition lisSolver.cpp:65
static void libraryFinalize()
Closes the Lis library on plugin destruction.
Definition lisSolver.cpp:99
static int _numSolvers
The number of instanced solvers.
Definition lisSolver.h:82
GmSparseMatrixOptions _lisMatrixOptions
The set of options used for building the sparse matrix.
Definition lisSolver.h:84
static int _maxThreads
The maximum number of threads used to configure the Lis library.
Definition lisSolver.h:81
bool loadLisParameters(LuaTable &table)
Loads LIS options from the given Lua table, filling _solverOptions with the set of options that shoul...
Definition lisSolver.cpp:175
bool _printIterations
Should the solver print, after solving, the number of iterations used by the numeric solver?
Definition lisSolver.h:89
int _nthreads
The configured number of threads for the Lis solver.
Definition lisSolver.h:87
bool _printLisMsgs
Enable or disable LIS messages to the CONSOLE only.
Definition lisSolver.h:92
LIS_SOLVER _solver
The solver.
Definition lisSolver.h:86
void fetchSolveMetrics(GmRunProgress *ps) const
Get (and possibly print) iterations, residual and time statistics.
Definition lisSolver.cpp:679
virtual bool setSolverTolerance(double tol)
Updates the current solver tolerance. Will be used by any successive calls to solve()
Definition lisSolver.cpp:428
QStringList _solverOptions
List with the set of options to be configured on the solver.
Definition lisSolver.h:88
virtual ~LisSolver()
Destructor.
Definition lisSolver.cpp:160
bool armadilloSolve(GmRunProgress *ps, GmSolverMatrix *A, const GmVector &b, GmVector &x, bool xIsGuess=false) const
Solve implementation.
Definition lisSolver.cpp:545
bool _printResidual
Should the solver print, after solving, the residual?
Definition lisSolver.h:90
bool _lisAlwaysInitx
If set to true, the initial guess will always be zero, independently of the value of the xIsGuess par...
Definition lisSolver.h:93
bool _printTimes
Should the solver print, after solving, a breakdown of solving and preconditioning times?
Definition lisSolver.h:91
arma::vec GmVector