NeoPZ
pzmatred.h
Go to the documentation of this file.
1 
6 #ifndef _TMATREDHH_
7 #define _TMATREDHH_
8 
9 //#include "tintvec.h"
10 #include "pzmatrix.h"
11 #include "pzreal.h"
12 #include "pzfmatrix.h"
13 #include "pzsolve.h"
14 
15 template<class TVar>
17 
18 #ifdef OOPARLIB
19 #include "pzsaveable.h"
20 #include "pzmatdefs.h"
21 #endif
22 
33 template<class TVar, class TSideMatrix >
34 class TPZMatRed: public TPZMatrix<TVar>
35 {
36 public:
37 
38  friend class TPZMatRed<TVar, TPZFMatrix<TVar> >;
39  friend class TPZMatRed<TVar ,TPZVerySparseMatrix<TVar> >;
41  TPZMatRed();
42 
48  TPZMatRed(const int64_t dim, const int64_t dim00);
49 
50  template<class TSideCopy>
51  TPZMatRed<TVar ,TSideMatrix>(const TPZMatRed<TVar, TSideCopy> &cp): TPZMatrix<TVar>(cp), fK11(cp.fK11), fK01(cp.fK01), fK10(cp.fK10), fF0(cp.fF0), fF1(cp.fF1),fMaxRigidBodyModes(cp.fMaxRigidBodyModes),fNumberRigidBodyModes(cp.fNumberRigidBodyModes), fF0IsComputed(cp.fF0IsComputed)
52  {
53  fDim0=cp.fDim0;
54  fDim1=cp.fDim1;
55  fK01IsComputed = cp.fK01IsComputed;
56  fIsReduced = cp.fIsReduced;
57  fSolver = cp.fSolver;
58 
59  if(cp.fK00) fK00 = cp.fK00;
60  }
61 
64  ~TPZMatRed();
65 
67  virtual int IsSimetric() const override;
68 
70  void SetReduced()
71  {
73  fIsReduced = 1;
74  }
75 
76  void ReallocSolver() {
77  fSolver->ReallocMatrix();
78  }
83  virtual int PutVal(const int64_t row, const int64_t col, const TVar& value) override;
84  virtual const TVar &GetVal(const int64_t row, const int64_t col) const override;
85  virtual TVar &s(const int64_t row, const int64_t col) override;
86 
88  virtual int Zero() override;
89 
95 
99  void SetK01IsComputed (bool directive)
100  {
101  fK01IsComputed = directive;
102  }
103 
107  void SetF0IsComputed (bool directive)
108  {
109  fF0IsComputed = directive;
110  }
111 
113  {
114  return fK00;
115  }
116  TSideMatrix &K01()
117  {
118  return fK01;
119  }
120  TSideMatrix &K10()
121  {
122  return fK10;
123  }
124 
126  {
127  return fK11;
128  }
129 
131  {
132  return fF1;
133  }
134 
136  {
137  return fF0;
138  }
139 
140  int64_t Dim0()
141  {
142  return fDim0;
143  }
144 
145  int64_t Dim1()
146  {
147  return fDim1;
148  }
149 
152  {
153  return fSolver;
154  }
159  void SetF(const TPZFMatrix<TVar> & F);
160 
162  void SetMaxNumberRigidBodyModes(int maxrigid)
163  {
164  fMaxRigidBodyModes = maxrigid;
165  }
166 
169  {
170  return fNumberRigidBodyModes;
171  }
172 
173 
175  void F1Red(TPZFMatrix<TVar> &F1);
176 
179 
184  void U1(TPZFMatrix<TVar> & F);
185 
191  void UGlobal(const TPZFMatrix<TVar> & U1, TPZFMatrix<TVar> & result);
192  void UGlobal2(TPZFMatrix<TVar> & U1, TPZFMatrix<TVar> & result);
193 
195  void Print(const char *name = NULL, std::ostream &out = std::cout,
196  const MatrixOutputFormat = EFormatted) const override;
197 
199  int Redim(const int64_t dim,const int64_t dim00) override; //Cesar 19/12/00
200 
211  void MultAdd(const TPZFMatrix<TVar> &x, const TPZFMatrix<TVar> &y, TPZFMatrix<TVar> &z,
212  const TVar alpha, const TVar beta, const int opt) const override;
213 
216  void SimetrizeMatRed();
217 
219  public:
220 int ClassId() const override;
221 
222 
223  void Write(TPZStream &buf, int withclassid) const override;
224  void Read(TPZStream &buf, void *context) override;
225 
226 private:
227 
233  static void Swap(int64_t *row, int64_t *col);
234 
236  void DecomposeK00();
237 
240 
243 
246 
247  TSideMatrix fK01, fK10;
248 
251 
253  int64_t fDim0, fDim1;
254 
257 
259  bool fK01IsComputed = false;
260 
262  bool fF0IsComputed = false;
263 
266 
269 };
270 
271 template<class TVar, class TSideMatrix>
273  return Hash("TPZMatRed") ^ TPZMatrix<TVar>::ClassId() << 1 ^ TSideMatrix().ClassId() << 2;
274 }
275 
276 /************/
277 /*** Swap ***/
278 /* @note Modificacao por Philippe Devloo (insercao de inline )*/
279 template<class TVar, class TSideMatrix>
280 inline void TPZMatRed<TVar, TSideMatrix>::Swap(int64_t *a, int64_t *b)
281 {
282  int64_t aux = *a;
283  *a = *b;
284  *b = aux;
285 }
286 
287 #endif
void SetMaxNumberRigidBodyModes(int maxrigid)
indicate how many degrees of freedom are reserved for rigid body modes
Definition: pzmatred.h:162
int ClassId() const override
Saveable methods.
Definition: pzmatred.h:272
TSideMatrix & K10()
Definition: pzmatred.h:120
void SetReduced()
changes the declared dimension of the matrix to fDim1
Definition: pzmatred.h:70
int64_t Dim1()
Definition: pzmatred.h:145
void SimetrizeMatRed()
If fK00 is simetric, only part of the matrix is accessible to external objects.
Definition: pzmatred.cpp:67
void F1Red(TPZFMatrix< TVar > &F1)
Computes the reduced version of the right hand side .
Definition: pzmatred.cpp:171
static void Swap(int64_t *row, int64_t *col)
Swaps the row and column index.
Definition: pzmatred.h:280
void UGlobal(const TPZFMatrix< TVar > &U1, TPZFMatrix< TVar > &result)
Computes the complete vector based on the solution u1.
Definition: pzmatred.cpp:342
TPZFMatrix< TVar > & K11()
Definition: pzmatred.h:125
MatrixOutputFormat
Defines output format.
Definition: pzmatrix.h:55
virtual int Resize(const int64_t newRows, const int64_t newCols)
Redimensions a matriz keeping the previous values.
Definition: pzmatrix.h:278
void SetF(const TPZFMatrix< TVar > &F)
Copies the F vector in the internal data structure.
Definition: pzmatred.cpp:140
void UGlobal2(TPZFMatrix< TVar > &U1, TPZFMatrix< TVar > &result)
Definition: pzmatred.cpp:397
Defines a class of matrix solvers. Solver.
Definition: pzanalysis.h:24
int64_t Dim0()
Definition: pzmatred.h:140
void SetF0IsComputed(bool directive)
Sets F0 as computed.
Definition: pzmatred.h:107
void ReallocSolver()
Definition: pzmatred.h:76
void SetK00(TPZAutoPointer< TPZMatrix< TVar > > K00)
Sets the matrix pointer of the upper left matrix to K00.
Definition: pzmatred.cpp:134
void MultAdd(const TPZFMatrix< TVar > &x, const TPZFMatrix< TVar > &y, TPZFMatrix< TVar > &z, const TVar alpha, const TVar beta, const int opt) const override
It computes z = beta * y + alpha * opt(this)*x but z and x can not overlap in memory.
Definition: pzmatred.cpp:521
bool fK01IsComputed
Is true if has been computed and overwritten .
Definition: pzmatred.h:259
void SetSolver(TPZAutoPointer< TPZMatrixSolver< TVar > > solver)
Definition: pzmatred.cpp:125
virtual TVar & s(const int64_t row, const int64_t col) override
The operators check on the bounds if the DEBUG variable is defined.
Definition: pzmatred.cpp:113
void SetK01IsComputed(bool directive)
Sets K01 as computed.
Definition: pzmatred.h:99
void Print(const char *name=NULL, std::ostream &out=std::cout, const MatrixOutputFormat=EFormatted) const override
Prints the object data structure.
Definition: pzmatred.cpp:454
TSideMatrix fK10
Definition: pzmatred.h:247
void Read(TPZStream &buf, void *context) override
read objects from the stream
Definition: pzmatred.cpp:696
TPZFMatrix< TVar > & F0()
Definition: pzmatred.h:135
TPZFMatrix< TVar > fF0
Right hand side or force matrix.
Definition: pzmatred.h:250
TPZAutoPointer< TPZMatrixSolver< TVar > > fSolver
Solution method for inverting .
Definition: pzmatred.h:242
Contains TPZMatrixclass which implements full matrix (using column major representation).
Implements a matrix whose nonzero elements are stored in binary tree. Matrix.
Definition: pzfmatrix.h:33
bool fF0IsComputed
Is true if has been computed and overwritten .
Definition: pzmatred.h:262
bool fIsReduced
Is true if the declared dimension of the matrix is fDim0.
Definition: pzmatred.h:256
TPZAutoPointer< TPZMatrix< TVar > > fK00
Stiffnes matrix.
Definition: pzmatred.h:239
TPZFMatrix< TVar > fF1
Definition: pzmatred.h:250
TPZFMatrix< TVar > fK11
Full Stiffnes matrix.
Definition: pzmatred.h:245
Full matrix class. Matrix.
Definition: pzfmatrix.h:32
int Redim(const int64_t dim, const int64_t dim00) override
Redim: Set the dimension of the complete matrix and reduced matrix.
Definition: pzmatred.cpp:481
void DecomposeK00()
Decompose K00 and adjust K01 and K10 to reflect rigid body modes.
Definition: pzmatred.cpp:582
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
Contains TPZMatrix<TVar>class, root matrix class.
TPZAutoPointer< TPZMatrixSolver< TVar > > Solver()
Definition: pzmatred.h:151
virtual int PutVal(const int64_t row, const int64_t col, const TVar &value) override
Put and Get values without bounds checking these methods are faster than "Put" e "Get" if DEBUG is de...
Definition: pzmatred.cpp:88
int fNumberRigidBodyModes
Number of rigid body modes identified during the decomposition of fK00.
Definition: pzmatred.h:268
Implements a simple substructuring of a linear system of equations, composed of 4 submatrices...
Definition: pzmatred.h:34
TPZAutoPointer< TPZMatrix< TVar > > K00()
Definition: pzmatred.h:112
void Write(TPZStream &buf, int withclassid) const override
Writes this object to the TPZStream buffer. Include the classid if withclassid = true.
Definition: pzmatred.cpp:659
TSideMatrix fK01
Definition: pzmatred.h:247
void K11Reduced(TPZFMatrix< TVar > &K11, TPZFMatrix< TVar > &F1)
Computes the K11 reduced .
Definition: pzmatred.cpp:223
Contains TPZSolver class which defines a abstract class of solvers which will be used by matrix class...
virtual int IsSimetric() const override
returns 1 or 0 depending on whether the fK00 matrix is zero or not
Definition: pzmatred.cpp:61
int64_t fDim1
Definition: pzmatred.h:253
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
#define CLONEDEF(A)
To create clone matrix.
Definition: pzmatrix.h:28
Contains the declaration of TPZFlopCounter class and TPZCounter struct.
int64_t fDim0
Stores matricess dimensions.
Definition: pzmatred.h:253
TPZFMatrix< TVar > & F1()
Definition: pzmatred.h:130
virtual const TVar & GetVal(const int64_t row, const int64_t col) const override
Get values without bounds checking This method is faster than "Get" if DEBUG is defined.
Definition: pzmatred.cpp:101
int fMaxRigidBodyModes
Number of rigid body modes foreseen in the computational mesh.
Definition: pzmatred.h:265
~TPZMatRed()
Simple destructor.
Definition: pzmatred.cpp:57
int NumberRigidBodyModes()
return the number of rigid body modes detected during decomposition
Definition: pzmatred.h:168
virtual int Zero() override
This method will zero all submatrices associated with this reducable matrix class.
Definition: pzmatred.cpp:505
TPZMatRed()
Simple constructor.
Definition: pzmatred.cpp:31
int ClassId() const override
Define the class id associated with the class.
Definition: pzmatrix.h:957
void U1(TPZFMatrix< TVar > &F)
Returns the second vector, inverting K11.
Definition: pzmatred.cpp:289
Root matrix class (abstract). Matrix.
Definition: pzmatrix.h:60
This class implements a reference counter mechanism to administer a dynamically allocated object...
TSideMatrix & K01()
Definition: pzmatred.h:116