NeoPZ
pzsolve.h
Go to the documentation of this file.
1 
6 #ifndef TPREH
7 #define TPREH
8 
9 #include "pzfmatrix.h"
10 
11 template<class TVar>
12 class TPZMatrixSolver;
13 
18 template<class TVar>
19 class TPZSolver: public TPZSavable
20 {
21 
22 public:
23 
24  public:
25 int ClassId() const override;
26 
33  virtual void Solve(const TPZFMatrix<TVar> &F, TPZFMatrix<TVar> &result,
34  TPZFMatrix<TVar> *residual = 0) = 0;
35 
37  virtual void Decompose()
38  {
39  }
40 
42  virtual TPZSolver *Clone() const = 0;
44  virtual ~TPZSolver();
45 
48  virtual void ResetMatrix()
49  {
50  }
53  {
54  std::cout << __PRETTY_FUNCTION__ << " called\n";
55  }
56 
57 };
58 
59 
60 template<class TVar>
62  return Hash("TPZSolver") ^ ClassIdOrHash<TVar>() << 1;
63 }
64 
66 #define TPZMATRIXSOLVER_ID 28291005;
67 
68 
73 template<class TVar>
74 class TPZMatrixSolver: public TPZSolver<TVar>
75 {
76 
77 public:
88  enum MSolver
89  {
90  ENoSolver, EJacobi, ESOR, ESSOR, ECG, EGMRES, EBICGSTAB, EDirect, EMultiply
91  };
92 
99 
100  TPZMatrixSolver();
101 
106  TPZMatrixSolver(const TPZMatrixSolver<TVar> &Source);
107 
109  virtual ~TPZMatrixSolver();
110 
115  virtual void SetMatrix(TPZAutoPointer<TPZMatrix<TVar> > Refmat)
116  {
117  fContainer = Refmat;
118  }
119 
122  {
123  if (fReferenceMatrix == matrix && matrix)
124  {
125  if(this->fContainer) this->fContainer->UpdateFrom(matrix);
126  }
127  }
129  void ResetMatrix() override;
130 
133  {
134  fReferenceMatrix = matrix;
135  }
136 
139  {
140  return fContainer;
141  }
142 
143  void ReallocMatrix() {
144  fContainer.ReallocForNuma(0);
145  }
146 
151  void ShareMatrix(TPZMatrixSolver<TVar> & other);
152 
153  virtual MSolver Solver()
154  {
155  return ENoSolver;
156  }
157 
158 protected:
159 
160 private:
163 protected:
166 
167 protected:
170 public:
172  public:
173 int ClassId() const override;
174 
175  void Write(TPZStream &buf, int withclassid) const override;
176  void Read(TPZStream &buf, void *context) override;
177 };
178 
179 template<class TVar>
181  return Hash("TPZMatrixSolver") ^ TPZSolver<TVar>::ClassId() << 1;
182 }
183 
184 #endif // TPREH
virtual void UpdateFrom(TPZAutoPointer< TPZMatrix< TVar > > matrix)
Updates the values of the current matrix based on the values of the matrix.
Definition: pzsolve.h:52
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
Defines a abstract class of solvers which will be used by matrix classes. Solver. ...
Definition: pzmatrix.h:32
virtual void ResetMatrix()
This method will reset the matrix associated with the solver.
Definition: pzsolve.h:48
Defines a class of matrix solvers. Solver.
Definition: pzanalysis.h:24
virtual void Solve(const TPZFMatrix< TVar > &F, TPZFMatrix< TVar > &result, TPZFMatrix< TVar > *residual=0)=0
Solves the system of linear equations.
virtual void Read(TPZStream &buf, void *context)
read objects from the stream
Definition: TPZSavable.cpp:61
void ReallocMatrix()
Definition: pzsolve.h:143
TPZAutoPointer< TPZMatrix< TVar > > fReferenceMatrix
Reference matrix used to update the current matrix.
Definition: pzsolve.h:165
TPZSkylMatrix< REAL > matrix
Definition: numatst.cpp:255
virtual MSolver Solver()
Definition: pzsolve.h:153
MSolver
Defines a series of solvers available in PZ.
Definition: pzsolve.h:88
Contains TPZMatrixclass which implements full matrix (using column major representation).
virtual void SetMatrix(TPZAutoPointer< TPZMatrix< TVar > > Refmat)
Sets a matrix to the current object.
Definition: pzsolve.h:115
virtual void SetReferenceMatrix(TPZAutoPointer< TPZMatrix< TVar > > matrix)
This method gives a preconditioner to share a matrix with the referring solver object.
Definition: pzsolve.h:132
virtual void Write(TPZStream &buf, int withclassid) const
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: TPZSavable.cpp:47
TPZFMatrix< TVar > fScratch
Manipulation matrix.
Definition: pzsolve.h:169
Full matrix class. Matrix.
Definition: pzfmatrix.h:32
int ClassId() const override
Define the class id associated with the class.
Definition: pzsolve.h:61
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
virtual TPZSolver * Clone() const =0
Clones the current object returning a pointer of type TPZSolver.
virtual ~TPZSolver()
Destructor.
Definition: pzsolve.cpp:19
TPZAutoPointer< TPZMatrix< TVar > > Matrix() const
Returns a pointer to TPZMatrix<>
Definition: pzsolve.h:138
int ClassId() const override
Saveable specific methods.
Definition: pzsolve.h:180
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
virtual void Decompose()
Decompose the system of equations if a direct solver is used.
Definition: pzsolve.h:37
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
Definition: TPZSavable.h:67
TPZAutoPointer< TPZMatrix< TVar > > fContainer
Container classes.
Definition: pzsolve.h:162
Root matrix class (abstract). Matrix.
Definition: pzmatrix.h:60
This class implements a reference counter mechanism to administer a dynamically allocated object...