30 return this->fDecomposeType;
36 for(i=0;i<this->fLocal.NElements();i++){
37 if(this->fLocal[i]!=-1) out << i <<
" ";
40 for(i=0;i<this->fLocal.NElements();i++){
41 if(this->fLocal[i]==-1)
continue;
42 for(j=0;j<this->fLocal.NElements();j++){
43 if(this->fLocal[j]==-1)
continue;
44 out << Element(this->fLocal[i],this->fLocal[j]) <<
" ";
53 if(name) out << name << endl;
54 int64_t i,j,loop_limit;
57 out <<
"Frontal Matrix Size "<< this->fFront << endl;
58 out <<
"Maximum Frontal Matrix Size "<< this->fMaxFront << endl;
61 out <<
"Local Indexation "<< endl;
62 out <<
"Position "<<
" Local index"<< endl;
63 for(i=0;i<this->fLocal.NElements();i++){
64 out << i <<
" " << this->fLocal[i] << endl;
68 out <<
"Global Indexation "<< endl;
69 out <<
"Position "<<
" Global index"<< endl;
71 for(i=0;i<this->fGlobal.NElements();i++){
72 out << i <<
" "<< this->fGlobal[i] << endl;
76 out <<
"Local Freed Equatoins "<< this->fFree.NElements() << endl;
77 out <<
"position "<<
"Local Equation "<<endl;
78 loop_limit=this->fFree.NElements();
79 for(i=0;i<loop_limit;i++){
80 out << i <<
" " << this->fFree[i] << endl;
82 out <<
"Frontal Matrix "<< endl;
83 if(this->fData.NElements() > 0) {
84 for(i=0;i<this->fFront;i++){
85 for(j=0;j<this->fFront;j++) out << ((i<j) ? Element(i,j) : Element(j,i)) <<
" ";
93 this->fData.Resize(this->fMaxFront*(this->fMaxFront+1)/2);
94 this->fGlobal.Fill(-1);
102 this->fData.Resize(0);
103 this->fFree.Resize(0);
105 this->fGlobal.Resize(0);
106 this->fLocal.Resize(GlobalSize);
107 this->fLocal.Fill(-1);
113 return this->fFree.NElements();
119 if(this->fLocal[global]!=-1)
return this->fLocal[global];
120 if(this->fFree.NElements()){
121 index=this->fFree.Pop();
123 index=this->fFront++;
125 this->fLocal[global]=index;
127 if(index >= this->fMaxFront) {
130 Expand(index+this->fExpandRatio);
132 if(this->fGlobal.NElements()<=index) this->fGlobal.Resize(index+1);
133 this->fGlobal[index]=global;
139 if(this->fLocal[global]==-1){
140 cout <<
"TPZFront FreeGlobal was called with wrong parameters !" << endl;
144 index=this->fLocal[global];
145 this->fGlobal[index]=-1;
146 this->fLocal[global]=-1;
147 this->fFree.Push(index);
175 for(i=0;i<ilocal;i++) AuxVec[i]=Element(i,ilocal);
176 for(i=ilocal;i<this->fFront;i++) AuxVec[i]=Element(ilocal,i);
178 if(AuxVec[ilocal]<0 && this->fDecomposeType ==
ECholesky) {
179 cout <<
"TPZFront::DecomposeOneEquation AuxVec[ilocal] < 0 " << AuxVec[ilocal] <<
" ilocal=" << ilocal <<
" fGlobal=" << this->fGlobal[ilocal] << endl;
183 diag =
sqrt(AuxVec[ilocal]);
184 for(i=0;i<this->fFront;i++) AuxVec[i]/=diag;
188 diag = AuxVec[ilocal];
189 for(i=0;i<this->fFront;i++) AuxVec[i]/=diag;
226 if(this->fProductMTData){
227 this->ProductTensorMT( AuxVec, AuxVec );
230 for(int64_t j=0;j<this->fFront;j++){
231 for(int64_t i=0;i<=j;i++){
232 Element(i,j)-=AuxVec[i]*AuxVec[j];
240 if(this->fProductMTData){
241 this->fProductMTData->fDiagonal = diag;
242 this->ProductTensorMT( AuxVec, AuxVec );
245 for(int64_t j=0;j<this->fFront;j++){
246 for(int64_t i=0;i<=j;i++){
247 Element(i,j)-=AuxVec[i]*AuxVec[j]*diag;
256 for(i=0;i<this->fFront;i++) {
257 if(i!=ilocal && this->fGlobal[i]!= -1 && AuxVec[i] != 0.) eqnarray.
AddTerm(this->fGlobal[i],AuxVec[i]);
261 for(i=0;i<ilocal;i++)Element(i,ilocal)=0.;
262 for(i=ilocal;i<this->fFront;i++) Element(ilocal,i)=0.;
269 template <
class TVar>
280 const int Nthreads = data->
NThreads();
282 if (data->
fMat->GetDecomposeType() ==
ELDLt) {
283 for(
int j = 0+ithread; j < n; j += Nthreads){
286 TVar * ColValPtr = &(data->
fAuxVecCol->operator[](i));
287 TVar * elemPtr = &this->Element4JGreatEqualI(i,j);
288 for( ; i <= j; i++, ColValPtr++, elemPtr++ ){
289 (*elemPtr) -= (*ColValPtr) * RowVal;
296 for(
int j = 0+ithread; j < n; j += Nthreads){
298 const TVar RowVal = data->
fAuxVecRow->operator[](j);
299 TVar * ColValPtr = &(data->
fAuxVecCol->operator[](i));
300 TVar * elemPtr = &this->Element4JGreatEqualI(i,j);
301 for( ; i <= j; i++, ColValPtr++, elemPtr++ ){
302 (*elemPtr) -= (*ColValPtr) * RowVal;
314 int64_t i, j, ilocal, jlocal, nel;
316 for (i = 0; i < nel; i++) {
318 ilocal = this->Local(destinationindex[i]);
319 for (j = i; j < nel; j++) {
321 jlocal = this->Local(destinationindex[j]);
324 this->Element(ilocal, jlocal)+=elmat(sourceindex[i],sourceindex[j]);
331 int64_t i, j, ilocal, jlocal, nel;
334 ilocal = this->Local(destinationindex[i]);
336 jlocal=this->Local(destinationindex[j]);
337 this->Element(ilocal, jlocal)+=elmat(i,j);
360 this->fData.Resize(larger*(larger+1)/2,0.);
361 this->fMaxFront = larger;
370 for(i = 0; i < this->fFront; i++){
371 if(this->fGlobal[i] != -1) from.
Push(i);
379 for(i=0;i<nfound;i++) {
380 this->fGlobal[i]=this->fGlobal[from[i]];
382 this->fLocal[this->fGlobal[i]] = i;
384 for(;i<this->fGlobal.NElements();i++) this->fGlobal[i] = -1;
386 if(nfound+this->fFree.NElements()!=this->fFront) cout <<
"TPZFront.Compress inconsistent data structure\n";
387 int frontold = this->fFront;
388 this->fFront = nfound;
389 this->fFree.Resize(0);
390 this->fGlobal.Resize(this->fFront);
391 if(this->fData.NElements()==0)
return;
393 for(j = 0; j < nfound; j++){
394 for(i = 0; i <= j; i++){
395 Element(i,j) = Element(from[i], from[j]);
400 for(;j<frontold;j++) {
401 for(i=0;i<= j; i++) Element(i,j) = 0.;
410 int64_t i, loop_limit, aux;
412 for(i=0;i<loop_limit;i++){
413 aux=destinationindex[i];
415 this->fFront = this->fGlobal.NElements();
417 this->fMaxFront=(this->fFront<this->fMaxFront)?this->fMaxFront:this->fFront;
424 for(i=mineq;i<=maxeq;i++) FreeGlobal(i);
434 for (ieq = mineq; ieq <= maxeq; ieq++) {
436 this->DecomposeOneEquation(ieq, eqnarray);
464 for(i=0;i<matsize;i++) {
465 for(j=i;j<matsize;j++) {
467 double rnd = (random*matsize)/0x7fff;
469 TestMatrix(j,i)=TestMatrix(i,j);
470 if(i==j) TestMatrix(i,j)=6000.;
478 Prova.
Print(
"TPZFMatrix<TVar> Cholesky");
484 for(i=0;i<matsize;i++) DestIndex[i]=i;
490 OutFile =
"TPZFrontSymTest.txt";
492 ofstream output(OutFile.c_str(),ios::app);
498 TestFront.
AddKel(TestMatrix, DestIndex);
513 ofstream outeqn(
"TestEQNArray.txt",ios::app);
515 Result.
Print(
"TestEQNArray.txt",outeqn);
520 for(i=0;i<matsize;i++) {
522 double rnd = (random*matsize)/0x7fff;
550 return "Symmetric matrix";
558 for(mineq=0; mineq<maxeq; mineq++)
if(this->
fLocal[mineq] != -1)
break;
559 int64_t numeq = maxeq-mineq;
560 front.
Redim(numeq,numeq);
562 for(ieq=mineq;ieq<maxeq;ieq++) {
563 if(this->
fLocal[ieq] == -1)
continue;
564 int64_t il = ieq-mineq;
565 for(jeq=ieq;jeq<maxeq;jeq++) {
566 if(this->
fLocal[jeq] == -1)
continue;
567 int64_t jl = jeq-mineq;
569 front(jl,il) = front(il,jl);
Contains the TPZFrontSym class which implements decomposition process of the frontal matrix (case sym...
void Expand(int largefrontsize)
Expand the front matrix.
void Reset(int64_t GlobalSize=0)
Resets data structure.
void EqnForward(TPZFMatrix< TVar > &F, DecomposeType dec)
Forward substitution on equations stored in EqnArray.
int Local(int64_t global)
return a local index corresponding to a global equation number
void SymbolicDecomposeEquations(int64_t mineq, int64_t maxeq)
Decompose these equations in a symbolic way and store freed indexes in fFree.
It is an equation array, generally in its decomposed form. Frontal.
TPZVec< int64_t > fLocal
Front equation to each global equation.
TVar fDiagonal
valor da diagonal
TPZVec< TVar > * fAuxVecCol
vetores de operacao
TPZVec< TVar > * fAuxVecRow
void AddKel(TPZFMatrix< TVar > &elmat, TPZVec< int64_t > &destinationindex)
Add a contribution of a stiffness matrix.
struct para paralelizar a decomposicao da matriz
void SymbolicAddKel(TPZVec< int64_t > &destinationindex)
Add a contribution of a stiffness matrix using the indexes to compute the frontwidth.
~TPZFrontSym()
Simple destructor.
Abstract class implements storage and decomposition process of the frontal matrix involving simmetry ...
int NThreads()
num threads
void BeginEquation(int eq)
It starts an equation storage.
Contains the TPZEqnArray class which implements an equation array.
void Print(const char *name, std::ostream &out)
It prints all terms stored in TPZEqnArray.
TPZVec< pz_semaphore_t > fWorkSem
semaforos para sincronizar os threads de calculo
TPZSkylMatrix< REAL > matrix
Abstract class implements storage and decomposition process of the frontal matrix. Frontal.
virtual void TensorProductIJ(int ithread, typename TPZFront< TVar >::STensorProductMTData *data) override
Does the tensor product betweem two vectors in the positions dependent of ithread.
void DecomposeEquations(int64_t mineq, int64_t maxeq, TPZEqnArray< TVar > &result)
Decompose these equations and put the result in eqnarray Default decompose method is Cholesky...
DecomposeType fDecomposeType
Used Decomposition method.
void Push(const T object)
Pushes a copy of the object on the stack.
#define DebugStop()
Returns a message to user put a breakpoint in.
void EqnBackward(TPZFMatrix< TVar > &U, DecomposeType dec)
Backward substitution on equations stored in EqnArray.
void Reset()
Resets data structure.
TVar & Element(int64_t i, int64_t j)
Returns ith, jth element of matrix. .
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
void SetSymmetric()
Sets fSymmetric to the symmetric value.
void AddTerm(int col, TVar val)
Add a term to the current equation.
void DecomposeOneEquation(int64_t ieq, TPZEqnArray< TVar > &eqnarray)
Decomposes ieq equation and add the result to EqnArray.
DecomposeType GetDecomposeType() const
Returns decomposition type.
Full matrix class. Matrix.
int Redim(const int64_t newRows, const int64_t newCols) override
Redimension a matrix and ZERO your elements.
int32_t Hash(std::string str)
virtual void ExtractFrontMatrix(TPZFMatrix< TVar > &front) override
Reorders the elements of the frontmatrix into the full matrix.
void EndEquation()
Ends the current equation.
virtual int64_t NFree() override
Returns the number of free equations.
int ClassId() const override
Define the class id associated with the class.
void SemaphoreWait(pz_semaphore_t &s)
void Print(const char *name, std::ostream &out=std::cout) const
Prints TPZFront data.
void FreeGlobal(int64_t global)
Sets the global equation as freed, allowing the space.
void AllocData()
Allocates data for Front.
std::string GetMatrixType()
Returns its type.
virtual void Print(std::ostream &out) const
int64_t NElements() const
Returns the number of elements of the vector.
void PrintGlobal(const char *name, std::ostream &out=std::cout)
TPZFrontSym()
Simple constructor.
TPZFront< TVar > * fMat
matriz TPZFront
int ClassId() const override
Define the class id associated with the class.
virtual int SolveDirect(TPZFMatrix< TVar > &F, const DecomposeType dt, std::list< int64_t > &singular)
Solves the linear system using Direct methods.
DecomposeType
Defines decomposition type for any matrix classes.
void Compress()
Compress data structure.