GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmNumSolver.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_NUMSOLVER_H_
25#define _GEMA_NUMSOLVER_H_
26
27#include "gmPluginObject.h"
28#include "gmPluginCategory.h"
29#include "gmVector.h"
30#include "gmSolverMatrix.h"
31
32class GmSolverMatrix;
33
36{
37public:
38 GmNumSolver(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
39 virtual ~GmNumSolver();
40
41 // Comments on the base class
42 virtual const char* pluginCategory() const { return GM_PLUGIN_NUMSOLVER; }
43
54 virtual GmSolverMatrix* newMatrix(int nlin, int ncol, const GmSolverMatrix* sharedLayout,
55 int numThreads = -1) const = 0;
56
58 virtual bool setSolverTolerance(double tol) = 0;
59
82 bool solve(GmSolverMatrix* A, const GmVector& b, GmVector& x, bool xIsGuess = false) const
83 {
84 if(!checkNanInf(A, b))
85 return false;
86 return solveImpl(A, b, x, xIsGuess);
87 }
88
89 virtual void printParameters(const GmLogCategory& logger);
90
92 virtual QString quickDescription() const = 0;
93
95 virtual int trackItemId() const { return -1; }
96
97protected:
99 virtual bool solveImpl(GmSolverMatrix* A, const GmVector& b, GmVector& x, bool xIsGuess) const = 0;
100
101private:
102 friend class GmNumSolverPrinter; // Allow access from GmNumSolverPrinter to the solver's simulation data and logger
103
104 bool checkNanInf (const GmSolverMatrix* A, const GmVector& b) const;
105
107};
108
109#endif
110
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for NumSolver type plugins.
Definition gmNumSolver.h:36
virtual const char * pluginCategory() const
Returns the plugin category.
Definition gmNumSolver.h:42
virtual QString quickDescription() const =0
Returns a quick description of the linear solver to be used on the FEM report.
virtual int trackItemId() const
If the solver creates a ProgressStatsItem to track execution time, returns the item id....
Definition gmNumSolver.h:95
bool _checkNanInf
Should we check for NaN or Inf values in the vectors before solving the system?
Definition gmNumSolver.h:106
virtual bool setSolverTolerance(double tol)=0
Updates the desired tolerance before a call to solve(). Returns false if not supported by the solver.
bool solve(GmSolverMatrix *A, const GmVector &b, GmVector &x, bool xIsGuess=false) const
Solves the linear system Ax = b, filling the vector x with the calculated result.
Definition gmNumSolver.h:82
virtual GmSolverMatrix * newMatrix(int nlin, int ncol, const GmSolverMatrix *sharedLayout, int numThreads=-1) const =0
Creates and returns a new matrix with size nlin x ncol, of the appropriate type for use in a later ca...
virtual bool solveImpl(GmSolverMatrix *A, const GmVector &b, GmVector &x, bool xIsGuess) const =0
Actual implementation of the solve function. Should be implemented by derived classes.
A proxy class that can wrap and behave like a GmNumSolver object, adding the possibility for printing...
Definition gmNumSolverPrinter.h:36
Base interface class for all object plugins.
Definition gmPluginObject.h:37
virtual void printParameters(const GmLogCategory &logger)=0
Asks the object to print all of its parameters using the provided logger.
Definition gmPluginObject.cpp:62
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
Base interface class for Solver Matrix objects.
Definition gmSolverMatrix.h:100
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Declaration of macros for standard plugin categories.
#define GM_PLUGIN_NUMSOLVER
Plugin implements numerical solvers.
Definition gmPluginCategory.h:30
Declaration of the GmPluginObject base class.
Declaration of the GmSolverMatrix interface classes.
Declaration of the GmVector class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34