NeoPZ
pzstepsolver.h
Go to the documentation of this file.
1 
6 #ifndef TPZSTEPSOLVER_H
7 #define TPZSTEPSOLVER_H
8 #include "pzsolve.h"
9 
10 #include "pzfmatrix.h"
11 
12 #include "TPZStream.h"
13 
14 #include <list>
15 
20 template<class TVar>
21 class TPZStepSolver: public TPZMatrixSolver<TVar>
22 {
23 public:
25 
26  TPZStepSolver(const TPZStepSolver<TVar> & copy);
27 
28  virtual ~TPZStepSolver();
29 
30  void SetSOR(const int64_t numiterations, const REAL overrelax, const REAL tol, const int64_t FromCurrent);
31 
32  void SetSSOR(const int64_t numiterations, const REAL overrelax, const REAL tol, const int64_t FromCurrent);
33 
34  void SetJacobi(const int64_t numiterations, const REAL tol, const int64_t FromCurrent);
35 
36  void SetCG(const int64_t numiterations, const TPZMatrixSolver<TVar> &pre, const REAL tol, const int64_t FromCurrent);
37 
38  void SetGMRES(const int64_t numiterations, const int numvectors, const TPZMatrixSolver<TVar> &pre, const REAL tol, const int64_t FromCurrent);
39 
40  void SetBiCGStab(const int64_t numiterations, const TPZMatrixSolver<TVar> &pre, const REAL tol, const int64_t FromCurrent);
41 
42  void SetDirect(const DecomposeType decomp);
43 
44  void SetMultiply();
45 
46  virtual TPZSolver<TVar> *Clone() const override
47  {
48  return new TPZStepSolver<TVar>(*this);
49  }
50 
51  void SetTolerance(REAL tol)
52  {
53  fTol = tol;
54  }
55 
57  REAL GetTolerance() const
58  {
59  return fTol;
60  }
61 
63  void ResetSolver();
64 
65  virtual typename TPZMatrixSolver<TVar>::MSolver Solver() override
66  {
67  return fSolver;
68  }
69 
71  std::list<int64_t> &Singular()
72  {
73  return fSingular;
74  }
75 
78  virtual void ResetMatrix() override;
79 
82  {
83  if (fPrecond)
84  fPrecond->UpdateFrom(matrix);
86  }
87 
88 
89  void Solve(const TPZFMatrix<TVar> &F, TPZFMatrix<TVar> &result, TPZFMatrix<TVar> *residual = 0) override;
90 
92  virtual void Decompose() override;
93 
96 
99  {
100  return fNumIterations;
101  }
102 
105  {
106  return fPrecond;
107  }
108 
110  public:
111  int ClassId() const override;
112 
113  void Write(TPZStream &buf, int withclassid) const override;
114  void Read(TPZStream &buf, void *context) override;
115 
116 
117 private:
120 
122  int64_t fMaxIterations;
123 
125  int64_t fNumIterations;
127  REAL fTol;
129 
132  int64_t fFromCurrent;
133 
134  std::list<int64_t> fSingular;
135 };
136 
137 template<class TVar>
139  return Hash("TPZStepSolver") ^ TPZMatrixSolver<TVar>::ClassId() << 1;
140 }
141 #endif
void SetSOR(const int64_t numiterations, const REAL overrelax, const REAL tol, const int64_t FromCurrent)
int ClassId() const override
Serialization methods.
Definition: pzstepsolver.h:138
virtual TPZSolver< TVar > * Clone() const override
Clones the current object returning a pointer of type TPZSolver.
Definition: pzstepsolver.h:46
virtual void UpdateFrom(TPZAutoPointer< TPZMatrix< TVar > > matrix) override
Updates the values of the current matrix based on the values of the matrix.
Definition: pzsolve.h:121
void SetPreconditioner(TPZSolver< TVar > &solve)
Define the preconditioner as a solver object.
virtual ~TPZStepSolver()
Defines a abstract class of solvers which will be used by matrix classes. Solver. ...
Definition: pzmatrix.h:32
int64_t fFromCurrent
Definition: pzstepsolver.h:132
Defines step solvers class. Solver.
Definition: pzmganalysis.h:17
virtual void ResetMatrix() override
This method will reset the matrix associated with the solver.
Defines a class of matrix solvers. Solver.
Definition: pzanalysis.h:24
virtual TPZMatrixSolver< TVar >::MSolver Solver() override
Definition: pzstepsolver.h:65
REAL GetTolerance() const
return the value of tolerance from the solver
Definition: pzstepsolver.h:57
void SetSSOR(const int64_t numiterations, const REAL overrelax, const REAL tol, const int64_t FromCurrent)
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
TPZSkylMatrix< REAL > matrix
Definition: numatst.cpp:255
DecomposeType fDecompose
Definition: pzstepsolver.h:119
void SetJacobi(const int64_t numiterations, const REAL tol, const int64_t FromCurrent)
std::list< int64_t > & Singular()
returns the equations for which the equations had zero pivot
Definition: pzstepsolver.h:71
void SetCG(const int64_t numiterations, const TPZMatrixSolver< TVar > &pre, const REAL tol, const int64_t FromCurrent)
static const double tol
Definition: pzgeoprism.cpp:23
MSolver
Defines a series of solvers available in PZ.
Definition: pzsolve.h:88
virtual void Decompose() override
Decompose the system of equations if a direct solver is used.
virtual void UpdateFrom(TPZAutoPointer< TPZMatrix< TVar > > matrix) override
Updates the values of the current matrix based on the values of the matrix.
Definition: pzstepsolver.h:81
Contains TPZMatrixclass which implements full matrix (using column major representation).
TPZMatrixSolver< TVar >::MSolver fSolver
Definition: pzstepsolver.h:118
void SetTolerance(REAL tol)
Definition: pzstepsolver.h:51
void SetBiCGStab(const int64_t numiterations, const TPZMatrixSolver< TVar > &pre, const REAL tol, const int64_t FromCurrent)
TPZStepSolver(TPZAutoPointer< TPZMatrix< TVar > > refmat=0)
Full matrix class. Matrix.
Definition: pzfmatrix.h:32
void Solve(const TPZFMatrix< TVar > &F, TPZFMatrix< TVar > &result, TPZFMatrix< TVar > *residual=0) override
Solves the system of linear equations.
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
int64_t fNumIterations
Number of iterations of last solve.
Definition: pzstepsolver.h:125
int64_t fMaxIterations
Maximum number of iterations.
Definition: pzstepsolver.h:122
TPZSolver< TVar > * PreConditioner()
access method to the preconditioner
Definition: pzstepsolver.h:104
int NumIterations()
Number of iterations of last solve.
Definition: pzstepsolver.h:98
Contains TPZSolver class which defines a abstract class of solvers which will be used by matrix class...
TPZSolver< TVar > * fPrecond
Solver using preconditioner matrix.
Definition: pzstepsolver.h:131
int ClassId() const override
Saveable specific methods.
Definition: pzsolve.h:180
Contains declaration of the abstract TPZStream class. TPZStream defines the interface for saving and ...
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void Read(TPZStream &buf, void *context) override
read objects from the stream
void SetDirect(const DecomposeType decomp)
std::list< int64_t > fSingular
Definition: pzstepsolver.h:134
void ResetSolver()
reset the data structure of the solver object
DecomposeType
Defines decomposition type for any matrix classes.
Definition: pzmatrix.h:52
void SetGMRES(const int64_t numiterations, const int numvectors, const TPZMatrixSolver< TVar > &pre, const REAL tol, const int64_t FromCurrent)
Root matrix class (abstract). Matrix.
Definition: pzmatrix.h:60
This class implements a reference counter mechanism to administer a dynamically allocated object...