Changeset 24679
- Timestamp:
- 04/01/20 00:38:51 (5 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
r24433 r24679 8 8 #include "../AllocateSystemMatricesx/AllocateSystemMatricesx.h" 9 9 10 void SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax,FemModel* femmodel ){10 void SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax,FemModel* femmodel, bool isAllocated){ 11 11 12 12 /*intermediary: */ … … 64 64 65 65 /*Allocate stiffness matrices and load vector*/ 66 AllocateSystemMatricesx(&Kff,&Kfs,&df,&pf,femmodel); 66 if(isAllocated) { 67 Kff = *pKff; 68 Kfs = *pKfs; 69 pf = *ppf; 70 df = *pdf; 71 } 72 else { 73 AllocateSystemMatricesx(&Kff,&Kfs,&df,&pf,femmodel); 74 } 67 75 68 76 /*Display size*/ -
issm/trunk-jpl/src/c/modules/SystemMatricesx/SystemMatricesx.h
r16789 r24679 9 9 10 10 /* local prototypes: */ 11 void SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax,FemModel* femmodel );11 void SystemMatricesx(Matrix<IssmDouble>** pKff, Matrix<IssmDouble>** pKfs, Vector<IssmDouble>** ppf, Vector<IssmDouble>** pdf, IssmDouble* pkmax,FemModel* femmodel, bool isAllocated=false); 12 12 13 13 #endif /* _SYSTEMMATRICESX_H */ -
issm/trunk-jpl/src/c/solutionsequences/solutionsequence_nonlinear.cpp
r23587 r24679 58 58 InputUpdateFromSolutionx(femmodel,ug); 59 59 60 // allocate the matrices once and reuce them per iteration 61 AllocateSystemMatricesx(&Kff,&Kfs,&df,&pf,femmodel); 62 60 63 for(;;){ 61 64 … … 64 67 delete ug; 65 68 66 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel );69 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel, true); 67 70 CreateNodalConstraintsx(&ys,femmodel->nodes); 68 Reduceloadx(pf, Kfs, ys); delete Kfs;71 Reduceloadx(pf, Kfs, ys); 69 72 femmodel->profiler->Start(SOLVER); 70 73 Solverx(&uf, Kff, pf, old_uf, df, femmodel->parameters); … … 73 76 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);delete ys; 74 77 75 convergence(&converged,Kff,pf,uf,old_uf,eps_res,eps_rel,eps_abs); delete Kff; delete pf; delete df;78 convergence(&converged,Kff,pf,uf,old_uf,eps_res,eps_rel,eps_abs); 76 79 InputUpdateFromConstantx(femmodel,converged,ConvergedEnum); 77 80 InputUpdateFromSolutionx(femmodel,ug); … … 102 105 break; 103 106 } 107 108 // Set the matrix entries to zero if we do an other iteration 109 Kff->SetZero(); 110 Kfs->SetZero(); 111 df->Set(0); 112 pf->Set(0); 104 113 } 114 115 // delete matrices after the iteration loop 116 delete Kff; delete pf; delete df; 117 delete Kfs; 105 118 106 119 if(VerboseConvergence()) _printf0_("\n total number of iterations: " << count << "\n"); -
issm/trunk-jpl/src/c/toolkits/issm/IssmAbsMat.h
r15777 r24679 43 43 virtual void SetValues(int m,int* idxm,int n,int* idxn,doubletype* values,InsMode mode)=0; 44 44 virtual void Convert(MatrixType type)=0; 45 virtual void SetZero(void){}; 45 46 #ifndef _HAVE_WRAPPERS_ 46 47 virtual IssmAbsVec<IssmDouble>* Solve(IssmAbsVec<IssmDouble>* pf, Parameters* parameters)=0; -
issm/trunk-jpl/src/c/toolkits/issm/IssmMat.h
r23044 r24679 239 239 matrix->convert(type); 240 240 }/*}}}*/ 241 void SetZero(void){/*{{{*/ 242 matrix->SetZero(); 243 }/*}}}*/ 241 244 #ifndef _HAVE_WRAPPERS_ 242 245 IssmVec<doubletype>* Solve(IssmVec<doubletype>* pf, Parameters* parameters){ /*{{{*/ -
issm/trunk-jpl/src/c/toolkits/objects/Matrix.h
r22558 r24679 307 307 } 308 308 /*}}}*/ 309 309 /* 310 * sets all values to 0 but keeps the structure of a sparse matrix 311 */ 312 void SetZero(void) {/*{{{*/ 313 if(type==PetscMatType){ 314 #ifdef _HAVE_PETSC_ 315 this->pmatrix->SetZero(); 316 #endif 317 } 318 else{ 319 this->imatrix->SetZero(); 320 } 321 } 322 /*}}}*/ 310 323 }; 311 324 -
issm/trunk-jpl/src/c/toolkits/petsc/objects/PetscMat.cpp
r23255 r24679 193 193 } 194 194 /*}}}*/ 195 void PetscMat::SetZero(void){/*{{{*/ 196 MatZeroEntries(this->matrix); 197 } 198 /*}}}*/ -
issm/trunk-jpl/src/c/toolkits/petsc/objects/PetscMat.h
r23255 r24679 52 52 void SetValues(int m,int* idxm,int n,int* idxn,IssmDouble* values,InsMode mode); 53 53 void Convert(MatrixType type); 54 void SetZero(void); 54 55 }; 55 56
Note:
See TracChangeset
for help on using the changeset viewer.