NeoPZ
pzspblockdiagpivot.cpp
Go to the documentation of this file.
1 
6 #include "pzspblockdiagpivot.h"
7 #include "pzfmatrix.h"
8 using namespace std;
9 
10 template<class TVar>
12 : TPZSparseBlockDiagonal<TVar>(), fPivotIndices()
13 {}
14 
15 template<class TVar>
17 {}
18 
19 template<class TVar>
21  if ( this->fDecomposed && this->fDecomposed == ELU) {
22  return ELU;
23  } else if(this->fDecomposed) {
24  PZError << __PRETTY_FUNCTION__ << endl;
25  PZError << "TPZSpBlockDiagPivot::Decompose_LU() - Matrix is already decomposed with other scheme" << endl;
26  }
27 
28  this->fPivotIndices.Resize( this->fBlock.NElements() );
29 #ifdef PZDEBUG
30  this->fPivotIndices.Fill( -1 );
31 #endif
32  TPZManVector<int> pivot;
33  int pivotindex = 0;
34  const int nb = this->fBlockSize.NElements();
35  for(int b = 0; b < nb; b++) {
36  const int pos = this->fBlockPos[b];
37  const int bsize = this->fBlockSize[b];
38  if(!bsize) continue;
39  TPZFMatrix<TVar> temp(bsize,bsize,&this->fStorage[pos],bsize*bsize);
40  temp.Decompose_LU(pivot);
41  for(int id = 0; id < bsize; id++){
42  this->fPivotIndices[pivotindex + id] = pivot[id];
43  }
44  pivotindex += bsize;
45  }
46  this->fDecomposed = ELUPivot;
47 #ifdef PZDEBUG
48  {
49  int n = this->fPivotIndices.NElements();
50  for(int i = 0; i < n; i++){
51  if ( this->fPivotIndices[i] == -1 ){
52  PZError << __PRETTY_FUNCTION__ << endl;
53  PZError << "TPZSpBlockDiagPivot::Decompose_LU() - fPivotIndices attribute has error" << endl;
54  }
55  }
56  }
57 #endif
58  return 1;
59 }
60 
61 template<class TVar>
64  Gather(*B,BG,1);
65  int result = this->Substitution2(&BG);
66  B->Zero();
67  Scatter(BG,*B,1);
68  return result;
69 }
70 
71 template<class TVar>
73 {
74  if(this->fDecomposed != ELUPivot) {
75  PZError << __PRETTY_FUNCTION__ << "TPZSpBlockDiagPivot::Decompose_LU is decomposed with other scheme than ELUPivot." << endl;
76  }
77 
79  int b,eq=0;
80  const int nb = this->fBlockSize.NElements();
81  int c, nc = B->Cols();
82  for(c=0; c<nc; c++) {
83  eq = 0;
84  int pivotindex = 0;
85  for(b=0;b<nb; b++) {
86  const int bsize = this->fBlockSize[b];
87  if(!bsize) continue;
88  TPZFMatrix<TVar> BTemp(bsize,1,&(B->operator()(eq,c)),bsize);
89  pivot.Resize(bsize);
90  for(int id = 0; id < bsize; id++){
91  pivot[id] = this->fPivotIndices[pivotindex+id];
92  }
93  pivotindex += bsize;
94  TPZFMatrix<TVar>::Substitution(this->fStorage,bsize,&BTemp);
95  eq+= bsize;
96  }
97  }
98  return 1;
99 }
virtual int Decompose_LU(std::list< int64_t > &singular) override
LU Decomposition. Stores L and U matrices at the storage of the same matrix.
Definition: pzfmatrix.cpp:1246
Implements a block diagonal matrix where the blocks are not contiguous. Matrix.
char fDecomposed
Decomposition type used to decompose the current matrix.
Definition: pzmatrix.h:783
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
void Gather(const TPZFMatrix< TVar > &in, TPZFMatrix< TVar > &out) const
int Zero() override
Makes Zero all the elements.
Definition: pzfmatrix.h:651
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
TPZVec< int > fPivotIndices
Attribute to store equation changes in LU decomposition.
Contains TPZMatrixclass which implements full matrix (using column major representation).
Definition: pzmatrix.h:52
void Scatter(const TPZFMatrix< TVar > &in, TPZFMatrix< TVar > &out) const
TPZVec< int > fBlockSize
Stores block sizes data.
Definition: pzblockdiag.h:142
Contains TPZSpBlockDiagPivot class which does derivation using decompose LU with pivot.
static int Substitution(const TVar *ptr, int64_t rows, TPZFMatrix< TVar > *B)
Definition: pzfmatrix.cpp:1323
Full matrix class. Matrix.
Definition: pzfmatrix.h:32
TPZVec< TVar > fStorage
Stores matrix data.
Definition: pzblockdiag.h:138
TPZVec< int64_t > fBlockPos
Stores blocks data.
Definition: pzblockdiag.h:140
void Fill(const T &copy, const int64_t from=0, const int64_t numelem=-1)
Will fill the elements of the vector with a copy object.
Definition: pzvec.h:460
virtual int Substitution(TPZFMatrix< TVar > *B) const
Makes the backward and forward substitutions whether the matrix was LU decomposed.
int64_t Cols() const
Returns number of cols.
Definition: pzmatrix.h:809
TPZVec< int64_t > fBlock
Equation numbers for each block.
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
int Substitution2(TPZFMatrix< TVar > *B) const
Non abstract class which implements full matrices with preallocated storage with (N+1) entries...
Definition: pzfmatrix.h:716
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15