Changeset 11679
- Timestamp:
- 03/12/12 09:35:33 (13 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 1 added
- 73 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r11670 r11679 344 344 ./modules/ResetCoordinateSystemx/ResetCoordinateSystemx.cpp\ 345 345 ./modules/Solverx/Solverx.cpp\ 346 ./modules/Solverx/SolverxPetsc.cpp\ 346 347 ./modules/Solverx/Solverx.h\ 347 348 ./modules/Solverx/DofTypesToIndexSet.cpp\ -
issm/trunk-jpl/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.cpp
r11327 r11679 10 10 #include "../../EnumDefinitions/EnumDefinitions.h" 11 11 12 void CreateJacobianMatrixx(Mat * pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax){12 void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax){ 13 13 14 14 int i,connectivity; … … 17 17 Element *element = NULL; 18 18 Load *load = NULL; 19 Mat 19 Matrix* Jff = NULL; 20 20 21 21 /*Checks*/ … … 29 29 30 30 /*Initialize Jacobian Matrix*/ 31 Jff= NewMat(fsize,fsize,connectivity,numberofdofspernode);31 Jff=new Matrix(fsize,fsize,connectivity,numberofdofspernode); 32 32 33 33 /*Create and assemble matrix*/ … … 41 41 if(load->InAnalysis(configuration_type)) load->PenaltyCreateJacobianMatrix(Jff,kmax); 42 42 } 43 MatAssemblyBegin(Jff,MAT_FINAL_ASSEMBLY); 44 MatAssemblyEnd(Jff,MAT_FINAL_ASSEMBLY); 43 Jff->Assemble(); 45 44 46 45 /*Assign output pointer*/ -
issm/trunk-jpl/src/c/modules/CreateJacobianMatrixx/CreateJacobianMatrixx.h
r11327 r11679 10 10 11 11 /* local prototypes: */ 12 void CreateJacobianMatrixx(Mat * pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax);12 void CreateJacobianMatrixx(Matrix** pJff,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,double kmax); 13 13 14 14 #endif /* _CREATEJACOBIANMATRIXX_H */ -
issm/trunk-jpl/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.cpp
r8816 r11679 10 10 #include "../../EnumDefinitions/EnumDefinitions.h" 11 11 12 void CreateNodalConstraintsx( Vec * pys, Nodes* nodes,int configuration_type){12 void CreateNodalConstraintsx( Vector** pys, Nodes* nodes,int configuration_type){ 13 13 14 14 int i; … … 18 18 19 19 /*output: */ 20 Vec ys=NULL;20 Vector* ys=NULL; 21 21 22 22 /*figure out how many dofs we have: */ … … 24 24 25 25 /*allocate:*/ 26 ys= NewVec(numberofdofs);26 ys=new Vector(numberofdofs); 27 27 28 28 /*go through all nodes, and for the ones corresponding to this configuration_type, fill the … … 36 36 37 37 /*Assemble: */ 38 VecAssemblyBegin(ys); 39 VecAssemblyEnd(ys); 38 ys->Assemble(); 40 39 41 40 /*Assign output pointers: */ -
issm/trunk-jpl/src/c/modules/CreateNodalConstraintsx/CreateNodalConstraintsx.h
r8816 r11679 9 9 10 10 /* local prototypes: */ 11 void CreateNodalConstraintsx( Vec * pys, Nodes* nodes,int configuration_type);11 void CreateNodalConstraintsx( Vector** pys, Nodes* nodes,int configuration_type); 12 12 13 13 #endif /* _CREATENODALCONSTRAINTSX_H */ -
issm/trunk-jpl/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.cpp
r8224 r11679 9 9 #include "../../EnumDefinitions/EnumDefinitions.h" 10 10 11 void GetSolutionFromInputsx( Vec * psolution, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters){11 void GetSolutionFromInputsx( Vector** psolution, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters){ 12 12 13 13 /*intermediary: */ … … 19 19 20 20 /*output: */ 21 Vec solution=NULL;21 Vector* solution=NULL; 22 22 23 23 /*retrive parameters: */ … … 29 29 30 30 /*Initialize solution: */ 31 solution= NewVec(gsize);31 solution=new Vector(gsize); 32 32 33 33 /*Go through elements and plug solution: */ … … 38 38 39 39 /*Assemble vector: */ 40 VecAssemblyBegin(solution); 41 VecAssemblyEnd(solution); 40 solution->Assemble(); 42 41 43 42 /*Assign output pointers:*/ -
issm/trunk-jpl/src/c/modules/GetSolutionFromInputsx/GetSolutionFromInputsx.h
r4236 r11679 10 10 11 11 /* local prototypes: */ 12 void GetSolutionFromInputsx( Vec * psolution, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters);12 void GetSolutionFromInputsx( Vector** psolution, Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters); 13 13 14 14 #endif /* _GETSOLUTIONFROMINPUTSXX_H */ -
issm/trunk-jpl/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.cpp
r4573 r11679 9 9 #include "../../EnumDefinitions/EnumDefinitions.h" 10 10 11 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vec solution){11 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,Vector* solution){ 12 12 13 13 double* serial_solution=NULL; 14 14 15 15 /*Serialize solution, so that elements can index into it on every CPU: */ 16 VecToMPISerial(&serial_solution,solution);16 serial_solution=solution->ToMPISerial(); 17 17 18 18 /*Call overloaded form of InputUpdateFromSolutionx: */ -
issm/trunk-jpl/src/c/modules/InputUpdateFromSolutionx/InputUpdateFromSolutionx.h
r4236 r11679 10 10 11 11 /* local prototypes: */ 12 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,Vec solution);12 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,Vector* solution); 13 13 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution); 14 14 15 15 //with timestep 16 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,Vec solution,int timestep);16 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads, Materials* materials, Parameters* parameters,Vector* solution,int timestep); 17 17 void InputUpdateFromSolutionx( Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* solution, int timestep); 18 18 -
issm/trunk-jpl/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.cpp
r9761 r11679 7 7 #include "./Mergesolutionfromftogx.h" 8 8 9 void Mergesolutionfromftogx( Vec * pug, Vec uf, Vecys, Nodes* nodes, Parameters* parameters, bool flag_ys0){9 void Mergesolutionfromftogx( Vector** pug, Vector* uf, Vector* ys, Nodes* nodes, Parameters* parameters, bool flag_ys0){ 10 10 11 11 /*output: */ 12 Vec ug=NULL;12 Vector* ug=NULL; 13 13 14 14 /*intermediary: */ … … 29 29 if(ssize){ 30 30 if(flag_ys0){ 31 VecSet(ys,0.0);31 ys->Set(0.0); 32 32 } 33 33 } 34 34 35 35 /*initialize ug: */ 36 ug= NewVec(gsize);36 ug=new Vector(gsize); 37 37 38 38 /*Merge f set back into g set: */ -
issm/trunk-jpl/src/c/modules/Mergesolutionfromftogx/Mergesolutionfromftogx.h
r8799 r11679 9 9 10 10 /* local prototypes: */ 11 void Mergesolutionfromftogx( Vec * pug, Vec uf, Vecys, Nodes* nodes, Parameters* parameters, bool flag_ys0=false);11 void Mergesolutionfromftogx( Vector** pug, Vector* uf, Vector* ys, Nodes* nodes, Parameters* parameters, bool flag_ys0=false); 12 12 13 13 #endif /* _MERGESOLUTIONFROMFTOGX_H */ -
issm/trunk-jpl/src/c/modules/Reduceloadx/Reduceloadx.cpp
r9761 r11679 12 12 #include "../../io/io.h" 13 13 14 void Reduceloadx( Vec pf, Mat Kfs, Vecy_s,bool flag_ys0){14 void Reduceloadx( Vector* pf, Matrix* Kfs, Vector* y_s,bool flag_ys0){ 15 15 16 16 /*intermediary*/ 17 Vec 18 Vec 17 Vector* y_s0 = NULL; 18 Vector* Kfsy_s = NULL; 19 19 int Kfsm,Kfsn; 20 20 int global_m,global_n; 21 PetscScalar a;22 21 bool fromlocalsize = true; 23 22 int verbose; … … 25 24 _printf_(VerboseModule()," Dirichlet lifting applied to load vector\n"); 26 25 27 MatGetSize(Kfs,&global_m,&global_n);26 Kfs->GetSize(&global_m,&global_n); 28 27 if(pf && global_m*global_n){ 29 28 … … 32 31 33 32 /*pf = pf - Kfs * y_s;*/ 34 MatGetLocalSize(Kfs,&Kfsm,&Kfsn);35 Kfsy_s= NewVec(Kfsm,fromlocalsize);33 Kfs->GetLocalSize(&Kfsm,&Kfsn); 34 Kfsy_s=new Vector(Kfsm,fromlocalsize); 36 35 if (flag_ys0){ 37 36 38 37 /*Create y_s0, full of 0: */ 39 VecDuplicate(y_s,&y_s0); 40 VecSet(y_s0,0.0); 41 VecAssemblyBegin(y_s0); 42 VecAssemblyEnd(y_s0); 38 y_s0=y_s->Duplicate(); 39 y_s0->Set(0.0); 40 y_s0->Assemble(); 43 41 44 MatMultPatch(Kfs,y_s0,Kfsy_s);42 Kfs->MatMult(y_s0,Kfsy_s); 45 43 } 46 44 else{ 47 MatMultPatch(Kfs,y_s,Kfsy_s);45 Kfs->MatMult(y_s,Kfsy_s); 48 46 } 49 47 50 a=-1; 51 VecAXPY(pf,a,Kfsy_s); 48 pf->AXPY(Kfsy_s,-1); 52 49 } 53 50 54 51 55 52 /*Free ressources and return*/ 56 VecFree(&y_s0);57 VecFree(&Kfsy_s);53 delete y_s0; 54 delete Kfsy_s; 58 55 59 56 } -
issm/trunk-jpl/src/c/modules/Reduceloadx/Reduceloadx.h
r6580 r11679 9 9 10 10 /* local prototypes: */ 11 void Reduceloadx( Vec pf, Mat Kfs, Vecys,bool flag_ys0=false);11 void Reduceloadx( Vector* pf, Matrix* Kfs, Vector* ys,bool flag_ys0=false); 12 12 13 13 #endif /* _REDUCELOADX_H */ -
issm/trunk-jpl/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.cpp
r8817 r11679 6 6 #include "./Reducevectorgtofx.h" 7 7 8 void Reducevectorgtofx(Vec * puf, Vecug, Nodes* nodes,Parameters* parameters){8 void Reducevectorgtofx(Vector** puf, Vector* ug, Nodes* nodes,Parameters* parameters){ 9 9 10 10 /*output: */ 11 Vec uf=NULL;11 Vector* uf=NULL; 12 12 13 13 /*variables: */ … … 26 26 else{ 27 27 /*allocate: */ 28 uf= NewVec(fsize);28 uf=new Vector(fsize); 29 29 30 30 if(nodes->NumberOfNodes(configuration_type)){ 31 31 32 32 /*serialize ug, so nodes can index into it: */ 33 VecToMPISerial(&ug_serial,ug);33 ug_serial=ug->ToMPISerial(); 34 34 35 35 /*Go through all nodes, and ask them to retrieve values from ug, and plug them into uf: */ … … 47 47 } 48 48 /*Assemble vector: */ 49 VecAssemblyBegin(uf); 50 VecAssemblyEnd(uf); 49 uf->Assemble(); 51 50 } 52 51 -
issm/trunk-jpl/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h
r8799 r11679 10 10 11 11 /* local prototypes: */ 12 void Reducevectorgtofx(Vec * puf, Vecug, Nodes* nodes,Parameters* parameters);12 void Reducevectorgtofx(Vector** puf, Vector* ug, Nodes* nodes,Parameters* parameters); 13 13 14 14 #endif /* _REDUCEVECTORGTOFX_H */ -
issm/trunk-jpl/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.cpp
r8816 r11679 6 6 #include "./Reducevectorgtosx.h" 7 7 8 void Reducevectorgtosx(Vec * pys, Vecyg, Nodes* nodes,Parameters* parameters){8 void Reducevectorgtosx(Vector** pys, Vector* yg, Nodes* nodes,Parameters* parameters){ 9 9 10 10 /*output: */ 11 Vec ys=NULL;11 Vector* ys=NULL; 12 12 13 13 /*variables: */ … … 26 26 else{ 27 27 /*allocate: */ 28 ys= NewVec(ssize);28 ys=new Vector(ssize); 29 29 30 30 if(nodes->NumberOfNodes(configuration_type)){ 31 31 32 32 /*serialize yg, so nodes can index into it: */ 33 VecToMPISerial(&yg_serial,yg);33 yg_serial=yg->ToMPISerial(); 34 34 35 35 /*Go throygh all nodes, and ask them to retrieve values from yg, and plyg them into ys: */ … … 47 47 } 48 48 /*Assemble vector: */ 49 VecAssemblyBegin(ys); 50 VecAssemblyEnd(ys); 49 ys->Assemble(); 51 50 } 52 51 -
issm/trunk-jpl/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h
r8799 r11679 10 10 11 11 /* local prototypes: */ 12 void Reducevectorgtosx(Vec * pys, Vecyg, Nodes* nodes,Parameters* parameters);12 void Reducevectorgtosx(Vector** pys, Vector* yg, Nodes* nodes,Parameters* parameters); 13 13 14 14 #endif /* _REDUCEVECTORGTOSX_H */ -
issm/trunk-jpl/src/c/modules/Solverx/Solverx.cpp
r11469 r11679 14 14 #endif 15 15 16 void Solverx(Vec * puf, Mat Kff, Vec pf, Vec uf0,Vecdf, Parameters* parameters){16 void Solverx(Vector** puf, Matrix* Kff, Vector* pf, Vector* uf0,Vector* df, Parameters* parameters){ 17 17 18 /*Output: */ 19 Vec uf = NULL; 18 /*output: */ 19 Vector* uf=NULL; 20 uf=new Vector(); 20 21 21 /*Intermediary: */22 int local_m,local_n,global_m,global_n;23 i nt analysis_type;22 #ifdef _HAVE_PETSC_ 23 Vec uf0_vector=NULL; 24 if (uf0)uf0_vector=uf0->vector; 24 25 25 /*Solver */ 26 KSP ksp = NULL; 27 PC pc = NULL; 28 int iteration_number; 29 int solver_type; 30 bool fromlocalsize = true; 31 #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2) 32 PetscTruth flag,flg; 26 SolverxPetsc(&uf->vector, Kff->matrix, pf->vector, uf0_vector, df->vector, parameters); 27 VecGetSize(uf->vector,&uf->M); 33 28 #else 34 PetscBool flag,flg;29 _error_("not supported yet!"); 35 30 #endif 36 31 37 /*Stokes: */ 38 IS isv=NULL; 39 IS isp=NULL; 40 41 #if _PETSC_MAJOR_ >= 3 42 char ksp_type[50]; 43 #endif 44 45 46 /*Display message*/ 47 _printf_(VerboseModule()," Solving\n"); 48 #if _PETSC_MAJOR_ < 3 || (_PETSC_MAJOR_ == 3 && _PETSC_MINOR_ < 2) 49 if(VerboseSolver())PetscOptionsPrint(stdout); 50 #else 51 if(VerboseSolver())PetscOptionsView(PETSC_VIEWER_STDOUT_WORLD); 52 #endif 53 54 /*First, check that f-set is not NULL, i.e. model is fully constrained: {{{*/ 55 _assert_(Kff); 56 MatGetSize(Kff,&global_m,&global_n); _assert_(global_m==global_m); 57 if(!global_n){ 58 *puf=NULL; return; 59 } 60 /*}}}*/ 61 /*Initial guess logic here: {{{1*/ 62 /*Now, check that we are not giving an initial guess to the solver, if we are running a direct solver: */ 63 #if _PETSC_MAJOR_ >= 3 64 PetscOptionsGetString(PETSC_NULL,"-ksp_type",ksp_type,49,&flg); 65 if (strcmp(ksp_type,"preonly")==0)uf0=NULL; 66 #endif 67 68 /*If initial guess for the solution exists, use it to create uf, otherwise, 69 * duplicate the right hand side so that the solution vector has the same structure*/ 70 if(uf0){ 71 VecDuplicate(uf0,&uf); VecCopy(uf0,uf); 72 } 73 else{ 74 MatGetLocalSize(Kff,&local_m,&local_n);uf=NewVec(local_n,fromlocalsize); 75 } 76 /*}}}*/ 77 /*Process petsc options to see if we are using special types of external solvers: {{{1*/ 78 PetscOptionsDetermineSolverType(&solver_type); 79 80 /*In serial mode, the matrices have been loaded as MPIAIJ or AIJ matrices. 81 We need to convert them if we are going to run the solvers successfully: */ 82 #ifdef _SERIAL_ 83 #if _PETSC_MAJOR_ == 2 84 if (solver_type==MUMPSPACKAGE_LU){ 85 /*Convert Kff to MATTAIJMUMPS: */ 86 MatConvert(Kff,MATAIJMUMPS,MAT_REUSE_MATRIX,&Kff); 87 } 88 if (solver_type==MUMPSPACKAGE_CHOL){ 89 /*Convert Kff to MATTSBAIJMUMPS: */ 90 MatConvert(Kff,MATSBAIJMUMPS,MAT_REUSE_MATRIX,&Kff); 91 } 92 if (solver_type==SPOOLESPACKAGE_LU){ 93 /*Convert Kff to MATTSBAIJMUMPS: */ 94 MatConvert(Kff,MATAIJSPOOLES,MAT_REUSE_MATRIX,&Kff); 95 } 96 if (solver_type==SPOOLESPACKAGE_CHOL){ 97 /*Convert Kff to MATTSBAIJMUMPS: */ 98 MatConvert(Kff,MATSBAIJSPOOLES,MAT_REUSE_MATRIX,&Kff); 99 } 100 if (solver_type==SUPERLUDISTPACKAGE){ 101 /*Convert Kff to MATTSBAIJMUMPS: */ 102 MatConvert(Kff,MATSUPERLU_DIST,MAT_REUSE_MATRIX,&Kff); 103 } 104 if (solver_type==StokesSolverEnum){ 105 _error_("Petsc 2 does not support multi-physics solvers"); 106 } 107 #endif 108 #endif 109 /*}}}*/ 110 /*Check the solver is available: {{{1*/ 111 if(solver_type==MUMPSPACKAGE_LU || solver_type==MUMPSPACKAGE_CHOL){ 112 #if _PETSC_MAJOR_ >=3 113 #ifndef _HAVE_MUMPS_ 114 _error_("requested MUMPS solver, which was not compiled into ISSM!\n"); 115 #endif 116 117 #endif 118 } 119 /*}}}*/ 120 /*Prepare solver:{{{1*/ 121 KSPCreate(MPI_COMM_WORLD,&ksp); 122 KSPSetOperators(ksp,Kff,Kff,DIFFERENT_NONZERO_PATTERN); 123 KSPSetFromOptions(ksp); 124 125 #if defined(_SERIAL_) && _PETSC_MAJOR_==3 126 /*Specific solver?: */ 127 KSPGetPC(ksp,&pc); 128 if (solver_type==MUMPSPACKAGE_LU){ 129 #if _PETSC_MINOR_==1 130 PCFactorSetMatSolverPackage(pc,MAT_SOLVER_MUMPS); 131 #else 132 PCFactorSetMatSolverPackage(pc,MATSOLVERMUMPS); 133 #endif 134 } 135 #endif 136 137 #if defined(_PARALLEL_) && _PETSC_MAJOR_==3 138 /*Stokes: */ 139 if (solver_type==StokesSolverEnum){ 140 /*Make indices out of doftypes: */ 141 if(!df)_error_("need doftypes for Stokes solver!\n"); 142 DofTypesToIndexSet(&isv,&isp,df,StokesSolverEnum); 143 144 /*Set field splits: */ 145 KSPGetPC(ksp,&pc); 146 #if _PETSC_MINOR_==1 147 PCFieldSplitSetIS(pc,isv); 148 PCFieldSplitSetIS(pc,isp); 149 #else 150 PCFieldSplitSetIS(pc,PETSC_NULL,isv); 151 PCFieldSplitSetIS(pc,PETSC_NULL,isp); 152 #endif 153 154 } 155 #endif 156 157 /*}}}*/ 158 /*If there is an initial guess for the solution, use it, except if we are using the MUMPS direct solver, where any initial guess will crash Petsc: {{{1*/ 159 if (uf0){ 160 if( (solver_type!=MUMPSPACKAGE_LU) && (solver_type!=MUMPSPACKAGE_CHOL) && (solver_type!=SPOOLESPACKAGE_LU) && (solver_type!=SPOOLESPACKAGE_CHOL) && (solver_type!=SUPERLUDISTPACKAGE)){ 161 KSPSetInitialGuessNonzero(ksp,PETSC_TRUE); 162 } 163 } 164 /*}}}*/ 165 166 if(VerboseSolver())KSPView(ksp,PETSC_VIEWER_STDOUT_WORLD); 167 168 /*Solve: */ 169 KSPSolve(ksp,pf,uf); 170 171 /*Check convergence*/ 172 KSPGetIterationNumber(ksp,&iteration_number); 173 if (iteration_number<0) _error_("%s%i"," Solver diverged at iteration number: ",-iteration_number); 174 175 /*Free resources:*/ 176 KSPFree(&ksp); 177 178 /*Assign output pointers:*/ 32 /*Assign output pointers: */ 179 33 *puf=uf; 180 34 } -
issm/trunk-jpl/src/c/modules/Solverx/Solverx.h
r7391 r11679 9 9 10 10 /* local prototypes: */ 11 void Solverx( Vec* puf, Mat Kff, Vec pf, Vec uf0,Vec df,Parameters* parameters); 11 void Solverx(Vector** puf, Matrix* Kff, Vector* pf, Vector* uf0,Vector* df, Parameters* parameters); 12 void SolverxPetsc(Vec* puf, Mat Kff, Vec pf, Vec uf0,Vec df, Parameters* parameters); 12 13 void DofTypesToIndexSet(IS* pisv, IS* pisp, Vec df,int typeenum); 13 14 #endif /* _SOLVERX_H */ -
issm/trunk-jpl/src/c/modules/SystemMatricesx/SystemMatricesx.cpp
r11324 r11679 10 10 #include "../../EnumDefinitions/EnumDefinitions.h" 11 11 12 void SystemMatricesx(Mat * pKff, Mat* pKfs, Vec* ppf, Vec* pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){12 void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,bool kflag,bool pflag,bool penalty_kflag,bool penalty_pflag){ 13 13 14 14 /*intermediary: */ … … 21 21 22 22 /*output: */ 23 Mat Kff = NULL;24 Mat Kfs = NULL;25 Vec pf = NULL;26 Vec df=NULL;23 Matrix* Kff = NULL; 24 Matrix* Kfs = NULL; 25 Vector* pf = NULL; 26 Vector* df=NULL; 27 27 double kmax = 0; 28 28 … … 49 49 if(kflag){ 50 50 51 Kff= NewMat(fsize,fsize,connectivity,numberofdofspernode);52 Kfs= NewMat(fsize,ssize,connectivity,numberofdofspernode);53 df= NewVec(fsize);51 Kff=new Matrix(fsize,fsize,connectivity,numberofdofspernode); 52 Kfs=new Matrix(fsize,ssize,connectivity,numberofdofspernode); 53 df=new Vector(fsize); 54 54 55 55 /*Fill stiffness matrix from elements: */ … … 66 66 67 67 /*Assemble matrix and doftypes and compress matrix to save memory: */ 68 MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY); 69 MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY); 70 #if _PETSC_MAJOR_ == 2 71 MatCompress(Kff); 72 #endif 68 Kff->Assemble(); 69 Kfs->Assemble(); 70 df->Assemble(); 73 71 74 MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY);75 MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY);76 #if _PETSC_MAJOR_ == 277 MatCompress(Kfs);78 #endif79 VecAssemblyBegin(df);80 VecAssemblyEnd(df);81 72 82 73 } … … 84 75 if(pflag){ 85 76 86 pf= NewVec(fsize);77 pf=new Vector(fsize); 87 78 88 79 /*Fill right hand side vector, from elements: */ … … 98 89 } 99 90 100 VecAssemblyBegin(pf); 101 VecAssemblyEnd(pf); 91 pf->Assemble(); 102 92 } 103 93 104 94 /*Now, figure out maximum value of K_gg, so that we can penalize it correctly: */ 105 MatNorm(Kff,NORM_INFINITY,&kmax);95 kmax=Kff->Norm(NORM_INFINITY); 106 96 107 97 /*Now, deal with penalties*/ … … 115 105 116 106 /*Assemble matrix and compress matrix to save memory: */ 117 MatAssemblyBegin(Kff,MAT_FINAL_ASSEMBLY); 118 MatAssemblyEnd(Kff,MAT_FINAL_ASSEMBLY); 119 #if _PETSC_MAJOR_ == 2 120 MatCompress(Kff); 121 #endif 122 123 MatAssemblyBegin(Kfs,MAT_FINAL_ASSEMBLY); 124 MatAssemblyEnd(Kfs,MAT_FINAL_ASSEMBLY); 125 #if _PETSC_MAJOR_ == 2 126 MatCompress(Kfs); 127 #endif 107 Kff->Assemble(); 108 Kfs->Assemble(); 128 109 } 129 110 … … 137 118 } 138 119 139 VecAssemblyBegin(pf);140 VecAssemblyEnd(pf);120 pf->Assemble(); 121 pf->Assemble(); 141 122 } 142 123 143 124 /*Assign output pointers: */ 144 125 if(pKff) *pKff=Kff; 145 else MatFree(&Kff);126 else delete Kff; 146 127 if(pKfs) *pKfs=Kfs; 147 else MatFree(&Kfs);128 else delete Kfs; 148 129 if(ppf) *ppf=pf; 149 else VecFree(&pf);130 else delete pf; 150 131 if(pdf) *pdf=df; 151 else VecFree(&df);132 else delete df; 152 133 if(pkmax) *pkmax=kmax; 153 134 } -
issm/trunk-jpl/src/c/modules/SystemMatricesx/SystemMatricesx.h
r8799 r11679 10 10 11 11 /* local prototypes: */ 12 void SystemMatricesx(Mat * pKff, Mat* pKfs, Vec* ppf, Vec* pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters,12 void SystemMatricesx(Matrix** pKff, Matrix** pKfs, Vector** ppf, Vector** pdf, double* pkmax,Elements* elements,Nodes* nodes, Vertices* vertices,Loads* loads,Materials* materials, Parameters* parameters, 13 13 bool kflag=true,bool pflag=true,bool penalty_kflag=true,bool penalty_pflag=true); 14 14 -
issm/trunk-jpl/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.cpp
r9883 r11679 10 10 #include "../../EnumDefinitions/EnumDefinitions.h" 11 11 12 void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vec yg){12 void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vector* yg){ 13 13 14 14 int configuration_type; … … 19 19 20 20 /*serialize yg, so nodes can index into it: */ 21 VecToMPISerial(&yg_serial,yg);21 yg_serial=yg->ToMPISerial(); 22 22 23 23 for(int i=0;i<constraints->Size();i++){ -
issm/trunk-jpl/src/c/modules/UpdateDynamicConstraintsx/UpdateDynamicConstraintsx.h
r9298 r11679 9 9 #include "../../objects/objects.h" 10 10 11 void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vec yg);11 void UpdateDynamicConstraintsx(Constraints* constraints,Nodes* nodes,Parameters* parameters,Vector* yg); 12 12 13 13 #endif /* _UPDATESPCSX_H */ -
issm/trunk-jpl/src/c/modules/VecMergex/VecMergex.cpp
r8809 r11679 10 10 #include "../../EnumDefinitions/EnumDefinitions.h" 11 11 12 void VecMergex(Vec ug, Vecuf, Nodes* nodes, Parameters* parameters, int SetEnum){12 void VecMergex(Vector* ug, Vector* uf, Nodes* nodes, Parameters* parameters, int SetEnum){ 13 13 14 14 /*variables: */ … … 21 21 22 22 /*serialize uf: */ 23 VecToMPISerial(&uf_serial,uf); 23 uf_serial=uf->ToMPISerial(); 24 24 25 25 26 /*Do we have any nodes for this configuration? :*/ … … 43 44 44 45 /*Assemble vector: */ 45 VecAssemblyBegin(ug); 46 VecAssemblyEnd(ug); 47 46 ug->Assemble(); 48 47 } -
issm/trunk-jpl/src/c/modules/VecMergex/VecMergex.h
r8799 r11679 10 10 11 11 /* local prototypes: */ 12 void VecMergex(Vec ug, Vecuf, Nodes* nodes, Parameters* parameters, int SetEnum);12 void VecMergex(Vector* ug, Vector* uf, Nodes* nodes, Parameters* parameters, int SetEnum); 13 13 14 14 #endif /* _VECMERGEX_H */ -
issm/trunk-jpl/src/c/objects/Elements/Element.h
r11656 r11679 16 16 class Parameters; 17 17 class Patch; 18 class Matrix; 19 class Vector; 18 20 19 21 #include "../../toolkits/toolkits.h" … … 28 30 virtual void Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0; 29 31 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters)=0; 30 virtual void CreateKMatrix(Mat Kff, Mat Kfs,Vecdf)=0;31 virtual void CreatePVector(Vec pf)=0;32 virtual void CreateJacobianMatrix(Mat Jff)=0;33 virtual void GetSolutionFromInputs(Vec solution)=0;32 virtual void CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df)=0; 33 virtual void CreatePVector(Vector* pf)=0; 34 virtual void CreateJacobianMatrix(Matrix* Jff)=0; 35 virtual void GetSolutionFromInputs(Vector* solution)=0; 34 36 virtual int GetNodeIndex(Node* node)=0; 35 37 virtual int Sid()=0; -
issm/trunk-jpl/src/c/objects/Elements/Penta.cpp
r11656 r11679 567 567 /*}}}*/ 568 568 /*FUNCTION Penta::CreateKMatrix {{{1*/ 569 void Penta::CreateKMatrix(Mat Kff, Mat Kfs,Vecdf){569 void Penta::CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df){ 570 570 571 571 /*retrieve parameters: */ … … 671 671 /*}}}*/ 672 672 /*FUNCTION Penta::CreatePVector {{{1*/ 673 void Penta::CreatePVector(Vec pf){673 void Penta::CreatePVector(Vector* pf){ 674 674 675 675 /*retrive parameters: */ … … 773 773 /*}}}*/ 774 774 /*FUNCTION Penta::CreateJacobianMatrix{{{1*/ 775 void Penta::CreateJacobianMatrix(Mat Jff){775 void Penta::CreateJacobianMatrix(Matrix* Jff){ 776 776 777 777 /*retrieve parameters: */ … … 1091 1091 /*}}}*/ 1092 1092 /*FUNCTION Penta::GetSolutionFromInputs{{{1*/ 1093 void Penta::GetSolutionFromInputs(Vec solution){1093 void Penta::GetSolutionFromInputs(Vector* solution){ 1094 1094 1095 1095 int analysis_type; … … 4180 4180 /*}}}*/ 4181 4181 /*FUNCTION Penta::GetSolutionFromInputsThermal{{{1*/ 4182 void Penta::GetSolutionFromInputsThermal(Vec solution){4182 void Penta::GetSolutionFromInputsThermal(Vector* solution){ 4183 4183 4184 4184 const int numdof=NDOF1*NUMVERTICES; … … 4203 4203 4204 4204 /*Add value to global vector*/ 4205 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);4205 solution->SetValues(numdof,doflist,values,INSERT_VALUES); 4206 4206 4207 4207 /*Free ressources:*/ … … 4211 4211 /*}}}*/ 4212 4212 /*FUNCTION Penta::GetSolutionFromInputsEnthalpy{{{1*/ 4213 void Penta::GetSolutionFromInputsEnthalpy(Vec solution){4213 void Penta::GetSolutionFromInputsEnthalpy(Vector* solution){ 4214 4214 4215 4215 const int numdof=NDOF1*NUMVERTICES; … … 4234 4234 4235 4235 /*Add value to global vector*/ 4236 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);4236 solution->SetValues(numdof,doflist,values,INSERT_VALUES); 4237 4237 4238 4238 /*Free ressources:*/ … … 7840 7840 /*}}}*/ 7841 7841 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticHoriz{{{1*/ 7842 void Penta::GetSolutionFromInputsDiagnosticHoriz(Vec solution){7842 void Penta::GetSolutionFromInputsDiagnosticHoriz(Vector* solution){ 7843 7843 7844 7844 const int numdof=NDOF2*NUMVERTICES; … … 7874 7874 7875 7875 /*Add value to global vector*/ 7876 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);7876 solution->SetValues(numdof,doflist,values,INSERT_VALUES); 7877 7877 7878 7878 /*Free ressources:*/ … … 7882 7882 /*}}}*/ 7883 7883 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticHutter{{{1*/ 7884 void Penta::GetSolutionFromInputsDiagnosticHutter(Vec solution){7884 void Penta::GetSolutionFromInputsDiagnosticHutter(Vector* solution){ 7885 7885 7886 7886 const int numdof=NDOF2*NUMVERTICES; … … 7910 7910 7911 7911 /*Add value to global vector*/ 7912 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);7912 solution->SetValues(numdof,doflist,values,INSERT_VALUES); 7913 7913 7914 7914 /*Free ressources:*/ … … 7918 7918 /*}}}*/ 7919 7919 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticVert{{{1*/ 7920 void Penta::GetSolutionFromInputsDiagnosticVert(Vec solution){7920 void Penta::GetSolutionFromInputsDiagnosticVert(Vector* solution){ 7921 7921 7922 7922 const int numdof=NDOF1*NUMVERTICES; … … 7943 7943 7944 7944 /*Add value to global vector*/ 7945 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);7945 solution->SetValues(numdof,doflist,values,INSERT_VALUES); 7946 7946 7947 7947 /*Free ressources:*/ … … 7951 7951 /*}}}*/ 7952 7952 /*FUNCTION Penta::GetSolutionFromInputsDiagnosticStokes{{{1*/ 7953 void Penta::GetSolutionFromInputsDiagnosticStokes(Vec solution){7953 void Penta::GetSolutionFromInputsDiagnosticStokes(Vector* solution){ 7954 7954 7955 7955 const int numdof=NDOF4*NUMVERTICES; … … 7988 7988 7989 7989 /*Add value to global vector*/ 7990 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);7990 solution->SetValues(numdof,doflist,values,INSERT_VALUES); 7991 7991 7992 7992 /*Free ressources:*/ -
issm/trunk-jpl/src/c/objects/Elements/Penta.h
r11656 r11679 86 86 void Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 87 87 void SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 88 void CreateKMatrix(Mat Kff, Mat Kfs,Vecdf);89 void CreatePVector(Vec pf);90 void CreateJacobianMatrix(Mat Jff);88 void CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df); 89 void CreatePVector(Vector* pf); 90 void CreateJacobianMatrix(Matrix* Jff); 91 91 void DeleteResults(void); 92 92 int GetNodeIndex(Node* node); 93 void GetSolutionFromInputs(Vec solution);93 void GetSolutionFromInputs(Vector* solution); 94 94 double GetZcoord(GaussPenta* gauss); 95 95 void GetVectorFromInputs(Vec vector,int name_enum); … … 183 183 void GetInputValue(double* pvalue,Node* node,int enumtype); 184 184 void GetPhi(double* phi, double* epsilon, double viscosity); 185 void GetSolutionFromInputsEnthalpy(Vec solutiong);185 void GetSolutionFromInputsEnthalpy(Vector* solutiong); 186 186 double GetStabilizationParameter(double u, double v, double w, double diameter, double kappa); 187 187 void GetStrainRate3dPattyn(double* epsilon,double* xyz_list, GaussPenta* gauss, Input* vx_input, Input* vy_input); … … 250 250 void InputUpdateFromSolutionDiagnosticVert( double* solutiong); 251 251 void InputUpdateFromSolutionDiagnosticStokes( double* solutiong); 252 void GetSolutionFromInputsDiagnosticHoriz(Vec solutiong);253 void GetSolutionFromInputsDiagnosticHutter(Vec solutiong);254 void GetSolutionFromInputsDiagnosticStokes(Vec solutiong);255 void GetSolutionFromInputsDiagnosticVert(Vec solutiong);252 void GetSolutionFromInputsDiagnosticHoriz(Vector* solutiong); 253 void GetSolutionFromInputsDiagnosticHutter(Vector* solutiong); 254 void GetSolutionFromInputsDiagnosticStokes(Vector* solutiong); 255 void GetSolutionFromInputsDiagnosticVert(Vector* solutiong); 256 256 ElementVector* CreatePVectorCouplingMacAyealStokes(void); 257 257 ElementVector* CreatePVectorCouplingMacAyealStokesViscous(void); … … 307 307 ElementVector* CreatePVectorThermalShelf(void); 308 308 ElementVector* CreatePVectorThermalSheet(void); 309 void GetSolutionFromInputsThermal(Vec solutiong);309 void GetSolutionFromInputsThermal(Vector* solutiong); 310 310 void InputUpdateFromSolutionThermal( double* solutiong); 311 311 void InputUpdateFromSolutionEnthalpy( double* solutiong); -
issm/trunk-jpl/src/c/objects/Elements/Tria.cpp
r11656 r11679 319 319 /*}}}*/ 320 320 /*FUNCTION Tria::CreateKMatrix {{{1*/ 321 void Tria::CreateKMatrix(Mat Kff, Mat Kfs,Vecdf){321 void Tria::CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df){ 322 322 323 323 /*retreive parameters: */ … … 672 672 /*}}}*/ 673 673 /*FUNCTION Tria::CreatePVector {{{1*/ 674 void Tria::CreatePVector(Vec pf){674 void Tria::CreatePVector(Vector* pf){ 675 675 676 676 /*retrive parameters: */ … … 892 892 /*}}}*/ 893 893 /*FUNCTION Tria::CreateJacobianMatrix{{{1*/ 894 void Tria::CreateJacobianMatrix(Mat Jff){894 void Tria::CreateJacobianMatrix(Matrix* Jff){ 895 895 896 896 /*retrieve parameters: */ … … 1274 1274 /*}}}*/ 1275 1275 /*FUNCTION Tria::GetSolutionFromInputs{{{1*/ 1276 void Tria::GetSolutionFromInputs(Vec solution){1276 void Tria::GetSolutionFromInputs(Vector* solution){ 1277 1277 1278 1278 /*retrive parameters: */ … … 3139 3139 /*}}}*/ 3140 3140 /*FUNCTION Tria::GetSolutionFromInputsDiagnosticHoriz{{{1*/ 3141 void Tria::GetSolutionFromInputsDiagnosticHoriz(Vec solution){3141 void Tria::GetSolutionFromInputsDiagnosticHoriz(Vector* solution){ 3142 3142 3143 3143 const int numdof=NDOF2*NUMVERTICES; … … 3170 3170 } 3171 3171 3172 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);3172 solution->SetValues(numdof,doflist,values,INSERT_VALUES); 3173 3173 3174 3174 /*Free ressources:*/ … … 3178 3178 /*}}}*/ 3179 3179 /*FUNCTION Tria::GetSolutionFromInputsDiagnosticHutter{{{1*/ 3180 void Tria::GetSolutionFromInputsDiagnosticHutter(Vec solution){3180 void Tria::GetSolutionFromInputsDiagnosticHutter(Vector* solution){ 3181 3181 3182 3182 const int numdof=NDOF2*NUMVERTICES; … … 3209 3209 } 3210 3210 3211 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);3211 solution->SetValues(numdof,doflist,values,INSERT_VALUES); 3212 3212 3213 3213 /*Free ressources:*/ … … 4881 4881 } 4882 4882 /*}}}*/ 4883 4883 4884 /*FUNCTION Tria::InputUpdateFromSolutionAdjointBalancethickness {{{1*/ 4884 4885 void Tria::InputUpdateFromSolutionAdjointBalancethickness(double* solution){ … … 5185 5186 /*}}}*/ 5186 5187 /*FUNCTION Tria::GetSolutionFromInputsHydrology{{{1*/ 5187 void Tria::GetSolutionFromInputsHydrology(Vec solution){5188 void Tria::GetSolutionFromInputsHydrology(Vector* solution){ 5188 5189 5189 5190 const int numdof=NDOF1*NUMVERTICES; … … 5213 5214 } 5214 5215 5215 VecSetValues(solution,numdof,doflist,(const double*)values,INSERT_VALUES);5216 solution->SetValues(numdof,doflist,values,INSERT_VALUES); 5216 5217 5217 5218 /*Free ressources:*/ -
issm/trunk-jpl/src/c/objects/Elements/Tria.h
r11656 r11679 82 82 void Configure(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 83 83 void SetCurrentConfiguration(Elements* elements,Loads* loads,DataSet* nodes,Materials* materials,Parameters* parameters); 84 void CreateKMatrix(Mat Kff, Mat Kfs,Vecdf);85 void CreatePVector(Vec pf);86 void CreateJacobianMatrix(Mat Jff);84 void CreateKMatrix(Matrix* Kff, Matrix* Kfs,Vector* df); 85 void CreatePVector(Vector* pf); 86 void CreateJacobianMatrix(Matrix* Jff); 87 87 int GetNodeIndex(Node* node); 88 88 int Sid(); … … 92 92 bool IsNodeOnShelfFromFlags(double* flags); 93 93 bool IsOnWater(); 94 void GetSolutionFromInputs(Vec solution);94 void GetSolutionFromInputs(Vector* solution); 95 95 void GetVectorFromInputs(Vec vector, int name_enum); 96 96 void GetVectorFromResults(Vec vector,int offset,int interp); … … 210 210 ElementVector* CreatePVectorDiagnosticHutter(void); 211 211 ElementMatrix* CreateJacobianDiagnosticMacayeal(void); 212 void GetSolutionFromInputsDiagnosticHoriz(Vec solution);213 void GetSolutionFromInputsDiagnosticHutter(Vec solution);212 void GetSolutionFromInputsDiagnosticHoriz(Vector* solution); 213 void GetSolutionFromInputsDiagnosticHutter(Vector* solution); 214 214 void InputUpdateFromSolutionDiagnosticHoriz( double* solution); 215 215 void InputUpdateFromSolutionDiagnosticHutter( double* solution); … … 230 230 ElementVector* CreatePVectorHydrology(void); 231 231 void CreateHydrologyWaterVelocityInput(void); 232 void GetSolutionFromInputsHydrology(Vec solution);232 void GetSolutionFromInputsHydrology(Vector* solution); 233 233 void InputUpdateFromSolutionHydrology(double* solution); 234 234 #endif -
issm/trunk-jpl/src/c/objects/Loads/Icefront.cpp
r11332 r11679 316 316 /*}}}*/ 317 317 /*FUNCTION Icefront::CreateKMatrix {{{1*/ 318 void Icefront::CreateKMatrix(Mat Kff, MatKfs){318 void Icefront::CreateKMatrix(Matrix* Kff, Matrix* Kfs){ 319 319 320 320 /*No stiffness loads applied, do nothing: */ … … 324 324 /*}}}*/ 325 325 /*FUNCTION Icefront::CreatePVector {{{1*/ 326 void Icefront::CreatePVector(Vec pf){326 void Icefront::CreatePVector(Vector* pf){ 327 327 328 328 /*Checks in debugging mode*/ … … 362 362 /*}}}*/ 363 363 /*FUNCTION Icefront::CreateJacobianMatrix{{{1*/ 364 void Icefront::CreateJacobianMatrix(Mat Jff){364 void Icefront::CreateJacobianMatrix(Matrix* Jff){ 365 365 this->CreateKMatrix(Jff,NULL); 366 366 } 367 367 /*}}}1*/ 368 368 /*FUNCTION Icefront::PenaltyCreateKMatrix {{{1*/ 369 void Icefront::PenaltyCreateKMatrix(Mat Kff, MatKfs, double kmax){369 void Icefront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, double kmax){ 370 370 /*do nothing: */ 371 371 return; … … 373 373 /*}}}*/ 374 374 /*FUNCTION Icefront::PenaltyCreatePVector{{{1*/ 375 void Icefront::PenaltyCreatePVector(Vec pf,double kmax){375 void Icefront::PenaltyCreatePVector(Vector* pf,double kmax){ 376 376 /*do nothing: */ 377 377 return; … … 379 379 /*}}}*/ 380 380 /*FUNCTION Icefront::PenaltyCreateJacobianMatrix{{{1*/ 381 void Icefront::PenaltyCreateJacobianMatrix(Mat Jff,double kmax){381 void Icefront::PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){ 382 382 this->PenaltyCreateKMatrix(Jff,NULL,kmax); 383 383 } -
issm/trunk-jpl/src/c/objects/Loads/Icefront.h
r11332 r11679 74 74 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 75 75 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 76 void CreateKMatrix(Mat Kff, MatKfs);77 void CreatePVector(Vec pf);78 void CreateJacobianMatrix(Mat Jff);79 void PenaltyCreateKMatrix(Mat Kff, Matkfs, double kmax);80 void PenaltyCreatePVector(Vec pf, double kmax);81 void PenaltyCreateJacobianMatrix(Mat Jff,double kmax);76 void CreateKMatrix(Matrix* Kff, Matrix* Kfs); 77 void CreatePVector(Vector* pf); 78 void CreateJacobianMatrix(Matrix* Jff); 79 void PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax); 80 void PenaltyCreatePVector(Vector* pf, double kmax); 81 void PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax); 82 82 bool InAnalysis(int analysis_type); 83 83 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Loads/Load.h
r11327 r11679 12 12 /*{{{1*/ 13 13 class Object; 14 class Matrix; 15 class Vector; 14 16 15 17 #include "../Object.h" … … 27 29 virtual void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 28 30 virtual void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters)=0; 29 virtual void CreateKMatrix(Mat Kff, MatKfs)=0;30 virtual void CreatePVector(Vec pf)=0;31 virtual void CreateJacobianMatrix(Mat Jff)=0;32 virtual void PenaltyCreateJacobianMatrix(Mat Jff,double kmax)=0;33 virtual void PenaltyCreateKMatrix(Mat Kff, MatKfs, double kmax)=0;34 virtual void PenaltyCreatePVector(Vec pf, double kmax)=0;31 virtual void CreateKMatrix(Matrix* Kff, Matrix* Kfs)=0; 32 virtual void CreatePVector(Vector* pf)=0; 33 virtual void CreateJacobianMatrix(Matrix* Jff)=0; 34 virtual void PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax)=0; 35 virtual void PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs, double kmax)=0; 36 virtual void PenaltyCreatePVector(Vector* pf, double kmax)=0; 35 37 virtual bool InAnalysis(int analysis_type)=0; 36 38 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Loads/Numericalflux.cpp
r10135 r11679 334 334 /*}}}*/ 335 335 /*FUNCTION Numericalflux::CreateKMatrix {{{1*/ 336 void Numericalflux::CreateKMatrix(Mat Kff, MatKfs){336 void Numericalflux::CreateKMatrix(Matrix* Kff, Matrix* Kfs){ 337 337 338 338 /*recover some parameters*/ … … 365 365 /*}}}*/ 366 366 /*FUNCTION Numericalflux::CreatePVector {{{1*/ 367 void Numericalflux::CreatePVector(Vec pf){367 void Numericalflux::CreatePVector(Vector* pf){ 368 368 369 369 /*recover some parameters*/ … … 395 395 /*}}}*/ 396 396 /*FUNCTION Numericalflux::PenaltyCreateKMatrix {{{1*/ 397 void Numericalflux::PenaltyCreateKMatrix(Mat Kff, MatKfs,double kmax){397 void Numericalflux::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){ 398 398 399 399 /*No stiffness loads applied, do nothing: */ … … 403 403 /*}}}*/ 404 404 /*FUNCTION Numericalflux::PenaltyCreatePVector{{{1*/ 405 void Numericalflux::PenaltyCreatePVector(Vec pf,double kmax){405 void Numericalflux::PenaltyCreatePVector(Vector* pf,double kmax){ 406 406 407 407 /*No penalty loads applied, do nothing: */ -
issm/trunk-jpl/src/c/objects/Loads/Numericalflux.h
r11327 r11679 70 70 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 71 71 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 72 void CreateKMatrix(Mat Kff, MatKfs);73 void CreatePVector(Vec pf);74 void CreateJacobianMatrix(Mat Jff){_error_("Not implemented yet");};75 void PenaltyCreateJacobianMatrix(Mat Jff,double kmax){_error_("Not implemented yet");};76 void PenaltyCreateKMatrix(Mat Kff, Matkfs, double kmax);77 void PenaltyCreatePVector(Vec pf, double kmax);72 void CreateKMatrix(Matrix* Kff, Matrix* Kfs); 73 void CreatePVector(Vector* pf); 74 void CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");}; 75 void PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");}; 76 void PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax); 77 void PenaltyCreatePVector(Vector* pf, double kmax); 78 78 bool InAnalysis(int analysis_type); 79 79 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Loads/Pengrid.cpp
r11656 r11679 295 295 /*}}}1*/ 296 296 /*FUNCTION Pengrid::CreateKMatrix {{{1*/ 297 void Pengrid::CreateKMatrix(Mat Kff, MatKfs){297 void Pengrid::CreateKMatrix(Matrix* Kff, Matrix* Kfs){ 298 298 299 299 /*No loads applied, do nothing: */ … … 303 303 /*}}}1*/ 304 304 /*FUNCTION Pengrid::CreatePVector {{{1*/ 305 void Pengrid::CreatePVector(Vec pf){305 void Pengrid::CreatePVector(Vector* pf){ 306 306 307 307 /*No loads applied, do nothing: */ … … 311 311 /*}}}1*/ 312 312 /*FUNCTION Pengrid::PenaltyCreateMatrix {{{1*/ 313 void Pengrid::PenaltyCreateKMatrix(Mat Kff, MatKfs,double kmax){313 void Pengrid::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){ 314 314 315 315 /*Retrieve parameters: */ … … 344 344 /*}}}1*/ 345 345 /*FUNCTION Pengrid::PenaltyCreatePVector {{{1*/ 346 void Pengrid::PenaltyCreatePVector(Vec pf,double kmax){346 void Pengrid::PenaltyCreatePVector(Vector* pf,double kmax){ 347 347 348 348 /*Retrieve parameters: */ -
issm/trunk-jpl/src/c/objects/Loads/Pengrid.h
r11656 r11679 75 75 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 76 76 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 77 void CreateKMatrix(Mat Kff, MatKfs);78 void CreatePVector(Vec pf);79 void CreateJacobianMatrix(Mat Jff){_error_("Not implemented yet");};80 void PenaltyCreateJacobianMatrix(Mat Jff,double kmax){_error_("Not implemented yet");};81 void PenaltyCreateKMatrix(Mat Kff, Matkfs, double kmax);82 void PenaltyCreatePVector(Vec pf, double kmax);77 void CreateKMatrix(Matrix* Kff, Matrix* Kfs); 78 void CreatePVector(Vector* pf); 79 void CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");}; 80 void PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");}; 81 void PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax); 82 void PenaltyCreatePVector(Vector* pf, double kmax); 83 83 bool InAnalysis(int analysis_type); 84 84 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Loads/Penpair.cpp
r11332 r11679 199 199 /*}}}1*/ 200 200 /*FUNCTION Penpair::CreateKMatrix {{{1*/ 201 void Penpair::CreateKMatrix(Mat Kff, MatKfs){201 void Penpair::CreateKMatrix(Matrix* Kff, Matrix* Kfs){ 202 202 /*If you code this piece, don't forget that a penalty will be inactive if it is dealing with clone nodes*/ 203 203 /*No loads applied, do nothing: */ … … 207 207 /*}}}1*/ 208 208 /*FUNCTION Penpair::CreatePVector {{{1*/ 209 void Penpair::CreatePVector(Vec pf){209 void Penpair::CreatePVector(Vector* pf){ 210 210 211 211 /*No loads applied, do nothing: */ … … 215 215 /*}}}1*/ 216 216 /*FUNCTION Penpair::CreateJacobianMatrix{{{1*/ 217 void Penpair::CreateJacobianMatrix(Mat Jff){217 void Penpair::CreateJacobianMatrix(Matrix* Jff){ 218 218 this->CreateKMatrix(Jff,NULL); 219 219 } 220 220 /*}}}1*/ 221 221 /*FUNCTION Penpair::PenaltyCreateKMatrix {{{1*/ 222 void Penpair::PenaltyCreateKMatrix(Mat Kff, MatKfs,double kmax){222 void Penpair::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){ 223 223 224 224 /*Retrieve parameters: */ … … 246 246 /*}}}1*/ 247 247 /*FUNCTION Penpair::PenaltyCreatePVector {{{1*/ 248 void Penpair::PenaltyCreatePVector(Vec pf,double kmax){248 void Penpair::PenaltyCreatePVector(Vector* pf,double kmax){ 249 249 /*No loads applied, do nothing: */ 250 250 return; … … 252 252 /*}}}1*/ 253 253 /*FUNCTION Penpair::PenaltyCreateJacobianMatrix{{{1*/ 254 void Penpair::PenaltyCreateJacobianMatrix(Mat Jff,double kmax){254 void Penpair::PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){ 255 255 this->PenaltyCreateKMatrix(Jff,NULL,kmax); 256 256 } -
issm/trunk-jpl/src/c/objects/Loads/Penpair.h
r11327 r11679 62 62 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 63 63 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 64 void CreateKMatrix(Mat Kff, MatKfs);65 void CreatePVector(Vec pf);66 void CreateJacobianMatrix(Mat Jff);67 void PenaltyCreateKMatrix(Mat Kff,MatKfs,double kmax);68 void PenaltyCreatePVector(Vec pf, double kmax);69 void PenaltyCreateJacobianMatrix(Mat Jff,double kmax);64 void CreateKMatrix(Matrix* Kff, Matrix* Kfs); 65 void CreatePVector(Vector* pf); 66 void CreateJacobianMatrix(Matrix* Jff); 67 void PenaltyCreateKMatrix(Matrix* Kff,Matrix* Kfs,double kmax); 68 void PenaltyCreatePVector(Vector* pf, double kmax); 69 void PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax); 70 70 bool InAnalysis(int analysis_type); 71 71 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Loads/Riftfront.cpp
r11294 r11679 428 428 /*}}}*/ 429 429 /*FUNCTION Riftfront::PenaltyCreateKMatrix {{{1*/ 430 void Riftfront::PenaltyCreateKMatrix(Mat Kff, MatKfs,double kmax){430 void Riftfront::PenaltyCreateKMatrix(Matrix* Kff, Matrix* Kfs,double kmax){ 431 431 432 432 /*Retrieve parameters: */ … … 454 454 /*}}}1*/ 455 455 /*FUNCTION Riftfront::PenaltyCreatePVector {{{1*/ 456 void Riftfront::PenaltyCreatePVector(Vec pf,double kmax){456 void Riftfront::PenaltyCreatePVector(Vector* pf,double kmax){ 457 457 458 458 /*Retrieve parameters: */ … … 480 480 /*}}}1*/ 481 481 /*FUNCTION Riftfront::CreateKMatrix {{{1*/ 482 void Riftfront::CreateKMatrix(Mat Kff, MatKfs){482 void Riftfront::CreateKMatrix(Matrix* Kff, Matrix* Kfs){ 483 483 /*do nothing: */ 484 484 return; … … 486 486 /*}}}1*/ 487 487 /*FUNCTION Riftfront::CreatePVector {{{1*/ 488 void Riftfront::CreatePVector(Vec pf){488 void Riftfront::CreatePVector(Vector* pf){ 489 489 /*do nothing: */ 490 490 return; -
issm/trunk-jpl/src/c/objects/Loads/Riftfront.h
r11327 r11679 82 82 void Configure(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 83 83 void SetCurrentConfiguration(Elements* elements,Loads* loads,Nodes* nodes,Vertices* vertices,Materials* materials,Parameters* parameters); 84 void CreateKMatrix(Mat Kff, MatKfs);85 void CreatePVector(Vec pf);86 void CreateJacobianMatrix(Mat Jff){_error_("Not implemented yet");};87 void PenaltyCreateJacobianMatrix(Mat Jff,double kmax){_error_("Not implemented yet");};88 void PenaltyCreateKMatrix(Mat Kff, Matkfs, double kmax);89 void PenaltyCreatePVector(Vec pf, double kmax);84 void CreateKMatrix(Matrix* Kff, Matrix* Kfs); 85 void CreatePVector(Vector* pf); 86 void CreateJacobianMatrix(Matrix* Jff){_error_("Not implemented yet");}; 87 void PenaltyCreateJacobianMatrix(Matrix* Jff,double kmax){_error_("Not implemented yet");}; 88 void PenaltyCreateKMatrix(Matrix* Kff, Matrix* kfs, double kmax); 89 void PenaltyCreatePVector(Vector* pf, double kmax); 90 90 bool InAnalysis(int analysis_type); 91 91 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Node.cpp
r11001 r11679 594 594 /*}}}*/ 595 595 /*FUNCTION Node::CreateNodalConstraints{{{1*/ 596 void Node::CreateNodalConstraints(Vec ys){596 void Node::CreateNodalConstraints(Vector* ys){ 597 597 598 598 int i; … … 613 613 614 614 /*Add values into constraint vector: */ 615 VecSetValues(ys,this->indexing.ssize,this->indexing.sdoflist,values,INSERT_VALUES);615 ys->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INSERT_VALUES); 616 616 } 617 617 … … 875 875 /*}}}*/ 876 876 /*FUNCTION Node::VecMerge {{{1*/ 877 void Node::VecMerge(Vec ug, double* vector_serial,int setenum){877 void Node::VecMerge(Vector* ug, double* vector_serial,int setenum){ 878 878 879 879 double* values=NULL; … … 897 897 898 898 /*Add values into ug: */ 899 VecSetValues(ug,this->indexing.fsize,indices,(const double*)values,INSERT_VALUES);899 ug->SetValues(this->indexing.fsize,indices,values,INSERT_VALUES); 900 900 } 901 901 } … … 915 915 916 916 /*Add values into ug: */ 917 VecSetValues(ug,this->indexing.ssize,indices,(const double*)values,INSERT_VALUES);917 ug->SetValues(this->indexing.ssize,indices,values,INSERT_VALUES); 918 918 } 919 919 } … … 926 926 /*}}}*/ 927 927 /*FUNCTION Node::VecReduce {{{1*/ 928 void Node::VecReduce(Vec vector, double* ug_serial,int setenum){928 void Node::VecReduce(Vector* vector, double* ug_serial,int setenum){ 929 929 930 930 double* values=NULL; … … 945 945 946 946 /*Add values into ug: */ 947 VecSetValues(vector,this->indexing.fsize,this->indexing.fdoflist,(const double*)values,INSERT_VALUES);947 vector->SetValues(this->indexing.fsize,this->indexing.fdoflist,values,INSERT_VALUES); 948 948 } 949 949 } … … 961 961 962 962 /*Add values into ug: */ 963 VecSetValues(vector,this->indexing.ssize,this->indexing.sdoflist,(const double*)values,INSERT_VALUES);963 vector->SetValues(this->indexing.ssize,this->indexing.sdoflist,values,INSERT_VALUES); 964 964 } 965 965 } -
issm/trunk-jpl/src/c/objects/Node.h
r10576 r11679 16 16 class DataSet; 17 17 class Vertices; 18 class Vector; 19 class Matrix; 18 20 #include "./Update.h" 19 21 /*}}}*/ … … 67 69 /*Node numerical routines {{{1*/ 68 70 void Configure(DataSet* nodes,Vertices* vertices); 69 void CreateNodalConstraints(Vec ys);71 void CreateNodalConstraints(Vector* ys); 70 72 void SetCurrentConfiguration(DataSet* nodes,Vertices* vertices); 71 73 int Sid(void); … … 101 103 int IsGrounded(); 102 104 void UpdateSpcs(double* ys); 103 void VecMerge(Vec ug, double* vector_serial,int setnum);104 void VecReduce(Vec vector, double* ug_serial,int setnum);105 void VecMerge(Vector* ug, double* vector_serial,int setenum); 106 void VecReduce(Vector* vector, double* ug_serial,int setnum); 105 107 106 108 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Numerics/ElementMatrix.cpp
r11327 r11679 245 245 246 246 /*ElementMatrix specific routines: */ 247 /*FUNCTION ElementMatrix::AddToGlobal(Mat Kff, MatKfs){{{1*/248 void ElementMatrix::AddToGlobal(Mat Kff, MatKfs){247 /*FUNCTION ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){{{1*/ 248 void ElementMatrix::AddToGlobal(Matrix* Kff, Matrix* Kfs){ 249 249 250 250 int i,j; … … 260 260 this->CheckConsistency(); 261 261 262 if(this->dofsymmetrical){ 263 /*only use row dofs to add values into global matrices: */ 264 265 if(this->row_fsize){ 266 /*first, retrieve values that are in the f-set from the g-set values matrix: */ 267 localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double)); 268 for(i=0;i<this->row_fsize;i++){ 269 for(j=0;j<this->row_fsize;j++){ 270 *(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]); 262 #ifdef _HAVE_PETSC_ 263 if(this->dofsymmetrical){ 264 /*only use row dofs to add values into global matrices: */ 265 266 if(this->row_fsize){ 267 /*first, retrieve values that are in the f-set from the g-set values matrix: */ 268 localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double)); 269 for(i=0;i<this->row_fsize;i++){ 270 for(j=0;j<this->row_fsize;j++){ 271 *(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]); 272 } 271 273 } 274 /*add local values into global matrix, using the fglobaldoflist: */ 275 MatSetValues(Kff->matrix,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES); 276 277 /*Free ressources:*/ 278 xfree((void**)&localvalues); 272 279 } 273 /*add local values into global matrix, using the fglobaldoflist: */ 274 MatSetValues(Kff,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES); 275 276 /*Free ressources:*/ 277 xfree((void**)&localvalues); 278 } 279 280 281 if((this->row_ssize!=0) && (this->row_fsize!=0)){ 282 /*first, retrieve values that are in the f and s-set from the g-set values matrix: */ 283 localvalues=(double*)xmalloc(this->row_fsize*this->row_ssize*sizeof(double)); 284 for(i=0;i<this->row_fsize;i++){ 285 for(j=0;j<this->row_ssize;j++){ 286 *(localvalues+this->row_ssize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_slocaldoflist[j]); 280 281 282 if((this->row_ssize!=0) && (this->row_fsize!=0)){ 283 /*first, retrieve values that are in the f and s-set from the g-set values matrix: */ 284 localvalues=(double*)xmalloc(this->row_fsize*this->row_ssize*sizeof(double)); 285 for(i=0;i<this->row_fsize;i++){ 286 for(j=0;j<this->row_ssize;j++){ 287 *(localvalues+this->row_ssize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_slocaldoflist[j]); 288 } 287 289 } 290 /*add local values into global matrix, using the fglobaldoflist: */ 291 MatSetValues(Kfs->matrix,this->row_fsize,this->row_fglobaldoflist,this->row_ssize,this->row_sglobaldoflist,(const double*)localvalues,ADD_VALUES); 292 293 /*Free ressources:*/ 294 xfree((void**)&localvalues); 288 295 } 289 /*add local values into global matrix, using the fglobaldoflist: */ 290 MatSetValues(Kfs,this->row_fsize,this->row_fglobaldoflist,this->row_ssize,this->row_sglobaldoflist,(const double*)localvalues,ADD_VALUES); 291 292 /*Free ressources:*/ 293 xfree((void**)&localvalues); 294 } 295 } 296 else{ 297 _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!"); 298 } 299 300 } 301 /*}}}*/ 302 /*FUNCTION ElementMatrix::AddToGlobal(Mat Jff){{{1*/ 303 void ElementMatrix::AddToGlobal(Mat Jff){ 296 } 297 else{ 298 _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!"); 299 } 300 #else 301 _error_("not supported yet!"); 302 #endif 303 304 } 305 /*}}}*/ 306 /*FUNCTION ElementMatrix::AddToGlobal(Matrix* Jff){{{1*/ 307 void ElementMatrix::AddToGlobal(Matrix* Jff){ 304 308 305 309 int i,j; … … 312 316 this->CheckConsistency(); 313 317 314 if(this->dofsymmetrical){ 315 /*only use row dofs to add values into global matrices: */ 316 317 if(this->row_fsize){ 318 /*first, retrieve values that are in the f-set from the g-set values matrix: */ 319 localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double)); 320 for(i=0;i<this->row_fsize;i++){ 321 for(j=0;j<this->row_fsize;j++){ 322 *(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]); 318 #ifdef _HAVE_PETSC_ 319 if(this->dofsymmetrical){ 320 /*only use row dofs to add values into global matrices: */ 321 322 if(this->row_fsize){ 323 /*first, retrieve values that are in the f-set from the g-set values matrix: */ 324 localvalues=(double*)xmalloc(this->row_fsize*this->row_fsize*sizeof(double)); 325 for(i=0;i<this->row_fsize;i++){ 326 for(j=0;j<this->row_fsize;j++){ 327 *(localvalues+this->row_fsize*i+j)=*(this->values+this->ncols*this->row_flocaldoflist[i]+this->row_flocaldoflist[j]); 328 } 323 329 } 330 /*add local values into global matrix, using the fglobaldoflist: */ 331 MatSetValues(Jff->matrix,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES); 332 333 /*Free ressources:*/ 334 xfree((void**)&localvalues); 324 335 } 325 /*add local values into global matrix, using the fglobaldoflist: */ 326 MatSetValues(Jff,this->row_fsize,this->row_fglobaldoflist,this->row_fsize,this->row_fglobaldoflist,(const double*)localvalues,ADD_VALUES); 327 328 /*Free ressources:*/ 329 xfree((void**)&localvalues); 330 } 331 332 } 333 else{ 334 _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!"); 335 } 336 337 } 338 else{ 339 _error_(" non dofsymmetrical matrix AddToGlobal routine not support yet!"); 340 } 341 #else 342 _error_("not supported yet!"); 343 #endif 336 344 337 345 } -
issm/trunk-jpl/src/c/objects/Numerics/ElementMatrix.h
r11322 r11679 58 58 /*}}}*/ 59 59 /*ElementMatrix specific routines {{{1*/ 60 void AddToGlobal(Mat Kff, MatKfs);61 void AddToGlobal(Mat Jff);60 void AddToGlobal(Matrix* Kff, Matrix* Kfs); 61 void AddToGlobal(Matrix* Jff); 62 62 void Echo(void); 63 63 void CheckConsistency(void); -
issm/trunk-jpl/src/c/objects/Numerics/ElementVector.cpp
r9320 r11679 160 160 161 161 /*ElementVector specific routines: */ 162 /*FUNCTION ElementVector::AddToGlobal(Vec pf){{{1*/163 void ElementVector::AddToGlobal(Vec pf){162 /*FUNCTION ElementVector::AddToGlobal(Vector* pf){{{1*/ 163 void ElementVector::AddToGlobal(Vector* pf){ 164 164 165 165 int i; 166 166 double* localvalues=NULL; 167 167 168 if(this->fsize){ 169 /*first, retrieve values that are in the f-set from the g-set values vector: */ 170 localvalues=(double*)xmalloc(this->fsize*sizeof(double)); 171 for(i=0;i<this->fsize;i++){ 172 localvalues[i]=this->values[this->flocaldoflist[i]]; 173 } 174 /*add local values into global vector, using the fglobaldoflist: */ 175 VecSetValues(pf,this->fsize,this->fglobaldoflist,(const double*)localvalues,ADD_VALUES); 176 177 /*Free ressources:*/ 178 xfree((void**)&localvalues); 179 } 180 } 181 /*}}}*/ 182 /*FUNCTION ElementVector::InsertIntoGlobal(Vec pf){{{1*/ 183 void ElementVector::InsertIntoGlobal(Vec pf){ 168 #ifdef _HAVE_PETSC_ 169 if(this->fsize){ 170 /*first, retrieve values that are in the f-set from the g-set values vector: */ 171 localvalues=(double*)xmalloc(this->fsize*sizeof(double)); 172 for(i=0;i<this->fsize;i++){ 173 localvalues[i]=this->values[this->flocaldoflist[i]]; 174 } 175 /*add local values into global vector, using the fglobaldoflist: */ 176 VecSetValues(pf->vector,this->fsize,this->fglobaldoflist,(const double*)localvalues,ADD_VALUES); 177 178 /*Free ressources:*/ 179 xfree((void**)&localvalues); 180 } 181 #else 182 _error_("not supported yet!"); 183 #endif 184 185 } 186 /*}}}*/ 187 /*FUNCTION ElementVector::InsertIntoGlobal(Vector* pf){{{1*/ 188 void ElementVector::InsertIntoGlobal(Vector* pf){ 184 189 185 190 int i; 186 191 double* localvalues=NULL; 187 192 188 if(this->fsize){ 189 /*first, retrieve values that are in the f-set from the g-set values vector: */ 190 localvalues=(double*)xmalloc(this->fsize*sizeof(double)); 191 for(i=0;i<this->fsize;i++){ 192 localvalues[i]=this->values[this->flocaldoflist[i]]; 193 } 194 /*add local values into global vector, using the fglobaldoflist: */ 195 VecSetValues(pf,this->fsize,this->fglobaldoflist,(const double*)localvalues,INSERT_VALUES); 196 197 /*Free ressources:*/ 198 xfree((void**)&localvalues); 199 } 193 #ifdef _HAVE_PETSC_ 194 if(this->fsize){ 195 /*first, retrieve values that are in the f-set from the g-set values vector: */ 196 localvalues=(double*)xmalloc(this->fsize*sizeof(double)); 197 for(i=0;i<this->fsize;i++){ 198 localvalues[i]=this->values[this->flocaldoflist[i]]; 199 } 200 /*add local values into global vector, using the fglobaldoflist: */ 201 VecSetValues(pf->vector,this->fsize,this->fglobaldoflist,(const double*)localvalues,INSERT_VALUES); 202 203 /*Free ressources:*/ 204 xfree((void**)&localvalues); 205 } 206 #else 207 _error_("not supported yet!"); 208 #endif 209 200 210 } 201 211 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Numerics/ElementVector.h
r8800 r11679 40 40 /*}}}*/ 41 41 /*ElementVector specific routines {{{1*/ 42 void AddToGlobal(Vec pf);43 void InsertIntoGlobal(Vec pf);42 void AddToGlobal(Vector* pf); 43 void InsertIntoGlobal(Vector* pf); 44 44 void Echo(void); 45 45 void Init(ElementVector* pe); -
issm/trunk-jpl/src/c/objects/Numerics/Matrix.cpp
r11670 r11679 140 140 _error_("not implemented yet!"); 141 141 #endif 142 return dataref; 142 143 143 144 } 144 145 /*}}}*/ 145 146 #endif 147 /*FUNCTION Matrix::Assemble{{{1*/ 148 void Matrix::Assemble(void){ 149 #ifdef _HAVE_PETSC_ 150 MatAssemblyBegin(this->matrix,MAT_FINAL_ASSEMBLY); 151 MatAssemblyEnd(this->matrix,MAT_FINAL_ASSEMBLY); 152 #if _PETSC_MAJOR_ == 2 153 MatCompress(this->matrix); 154 #endif 155 #else 156 /*do nothing:*/ 157 #endif 158 159 } 160 /*}}}*/ 161 /*FUNCTION Matrix::Norm{{{1*/ 162 double Matrix::Norm(int norm_type){ 163 164 double norm=0; 165 #ifdef _HAVE_PETSC_ 166 MatNorm(this->matrix,(NormType)norm_type,&norm); 167 #else 168 _error_("not implemented yet!"); 169 #endif 170 return norm; 171 } 172 /*}}}*/ 173 /*FUNCTION Matrix::GetSize{{{1*/ 174 void Matrix::GetSize(int* pM,int* pN){ 175 176 #ifdef _HAVE_PETSC_ 177 MatGetSize(this->matrix,pM,pN); 178 #else 179 _error_("not implemented yet!"); 180 #endif 181 } 182 /*}}}*/ 183 /*FUNCTION Matrix::GetLocalSize{{{1*/ 184 void Matrix::GetLocalSize(int* pM,int* pN){ 185 186 #ifdef _HAVE_PETSC_ 187 MatGetLocalSize(this->matrix,pM,pN); 188 #else 189 _error_("not implemented yet!"); 190 #endif 191 } 192 /*}}}*/ 193 /*FUNCTION Matrix::MatMult{{{1*/ 194 void Matrix::MatMult(Vector* X,Vector* AX){ 195 196 #ifdef _HAVE_PETSC_ 197 MatMultPatch(this->matrix,X->vector,AX->vector); 198 #else 199 _error_("not implemented yet!"); 200 #endif 201 } 202 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Numerics/Matrix.h
r11670 r11679 25 25 #include "mex.h" 26 26 #endif 27 class Vector; 27 28 28 29 /*}}}*/ … … 55 56 mxArray* ToMatlabMatrix(void); 56 57 #endif 58 void Assemble(void); 59 double Norm(int norm_type); 60 void GetSize(int* pM,int* pN); 61 void GetLocalSize(int* pM,int* pN); 62 void MatMult(Vector* X,Vector* AX); 57 63 /*}}}*/ 58 64 -
issm/trunk-jpl/src/c/objects/Numerics/Vector.cpp
r11670 r11679 24 24 Vector::Vector(){ 25 25 26 this->M=0; 26 27 #ifdef _HAVE_PETSC_ 27 28 this->vector=NULL; 28 29 #else 29 30 this->vector=NULL; 30 this->M=0;31 31 #endif 32 32 #ifdef _HAVE_ADOLC_ … … 98 98 _error_("not implemented yet!"); 99 99 #endif 100 return dataref; 100 101 101 102 } 102 103 /*}}}*/ 103 104 #endif 105 /*FUNCTION Vector::Assemble{{{1*/ 106 void Vector::Assemble(void){ 107 108 #ifdef _HAVE_PETSC_ 109 VecAssemblyBegin(this->vector); 110 VecAssemblyEnd(this->vector); 111 #else 112 /*do nothing*/ 113 #endif 114 115 } 116 /*}}}*/ 117 /*FUNCTION Vector::SetValues{{{1*/ 118 void Vector::SetValues(int ssize, int* list, double* values, int mode){ 119 120 121 #ifdef _HAVE_PETSC_ 122 VecSetValues(this->vector,ssize,list,values,(InsertMode)mode); 123 #else 124 _error_("not implemented yet!"); 125 #endif 126 127 } 128 /*}}}*/ 129 /*FUNCTION Vector::GetSize{{{1*/ 130 void Vector::GetSize(int* pM){ 131 132 #ifdef _HAVE_PETSC_ 133 VecGetSize(this->vector,pM); 134 #else 135 _error_("not implemented yet!"); 136 #endif 137 138 } 139 /*}}}*/ 140 /*FUNCTION Vector::GetLocalSize{{{1*/ 141 void Vector::GetLocalSize(int* pM){ 142 143 #ifdef _HAVE_PETSC_ 144 VecGetLocalSize(this->vector,pM); 145 #else 146 _error_("not implemented yet!"); 147 #endif 148 149 } 150 /*}}}*/ 151 /*FUNCTION Vector::Duplicate{{{1*/ 152 Vector* Vector::Duplicate(void){ 153 154 Vector* output=NULL; 155 output=new Vector(); 156 #ifdef _HAVE_PETSC_ 157 Vec vec_output=NULL; 158 VecDuplicate(this->vector,&vec_output); 159 output->vector=vec_output; 160 VecGetSize(output->vector,&output->M); 161 #else 162 _error_("not implemented yet!"); 163 #endif 164 return output; 165 166 } 167 /*}}}*/ 168 /*FUNCTION Vector::Set{{{1*/ 169 void Vector::Set(double value){ 170 171 #ifdef _HAVE_PETSC_ 172 this->Set(value); 173 #else 174 _error_("not implemented yet!"); 175 #endif 176 177 } 178 /*}}}*/ 179 /*FUNCTION Vector::AXPY{{{1*/ 180 void Vector::AXPY(Vector* X, double a){ 181 182 #ifdef _HAVE_PETSC_ 183 VecAXPY(this->vector,a,X->vector); 184 #else 185 _error_("not implemented yet!"); 186 #endif 187 188 } 189 /*}}}*/ 190 /*FUNCTION Vector::AYPX{{{1*/ 191 void Vector::AYPX(Vector* X, double a){ 192 193 #ifdef _HAVE_PETSC_ 194 VecAYPX(this->vector,a,X->vector); 195 #else 196 _error_("not implemented yet!"); 197 #endif 198 199 } 200 /*}}}*/ 201 /*FUNCTION Vector::ToMPISerial{{{1*/ 202 double* Vector::ToMPISerial(void){ 203 204 double* vec_serial=NULL; 205 206 #ifdef _HAVE_PETSC_ 207 VecToMPISerial(&vec_serial, this->vector); 208 #else 209 _error_("not implemented yet!"); 210 #endif 211 212 return vec_serial; 213 214 } 215 /*}}}*/ 216 /*FUNCTION Vector::Copy{{{1*/ 217 void Vector::Copy(Vector* to){ 218 219 #ifdef _HAVE_PETSC_ 220 VecCopy(this->vector,to->vector); 221 #else 222 _error_("not implemented yet!"); 223 #endif 224 225 } 226 /*}}}*/ 227 /*FUNCTION Vector::Norm{{{1*/ 228 double Vector::Norm(int norm_type){ 229 230 double norm=0; 231 #ifdef _HAVE_PETSC_ 232 VecNorm(this->vector,(NormType)norm_type,&norm); 233 #else 234 _error_("not implemented yet!"); 235 #endif 236 return norm; 237 } 238 /*}}}*/ 239 /*FUNCTION Vector::Scale{{{1*/ 240 void Vector::Scale(double scale_factor){ 241 242 #ifdef _HAVE_PETSC_ 243 VecScale(this->vector,scale_factor); 244 #else 245 _error_("not implemented yet!"); 246 #endif 247 } 248 /*}}}*/ -
issm/trunk-jpl/src/c/objects/Numerics/Vector.h
r11670 r11679 54 54 mxArray* ToMatlabVector(void); 55 55 #endif 56 void Assemble(void); 57 void SetValues(int ssize, int* list, double* values, int mode); 58 void GetSize(int* pM); 59 void GetLocalSize(int* pM); 60 Vector* Duplicate(void); 61 void Set(double value); 62 void AXPY(Vector* X, double a); 63 void AYPX(Vector* X, double a); 64 double* ToMPISerial(void); 65 void Copy(Vector* to); 66 double Norm(int norm_type); 67 void Scale(double scale_factor); 56 68 /*}}}*/ 57 69 }; -
issm/trunk-jpl/src/c/shared/Alloc/alloc.cpp
r9320 r11679 29 29 #include "../Exceptions/exceptions.h" 30 30 #include "../../include/include.h" 31 #include "../../objects/objects.h" 31 32 32 33 void* xmalloc(int size){ … … 80 81 } 81 82 83 void xdelete( Matrix** pv){ 84 85 if (pv && *pv) { 86 87 delete *pv; 88 *pv=NULL; 89 } 90 } 91 92 void xdelete( Vector** pv){ 93 94 if (pv && *pv) { 95 96 delete *pv; 97 *pv=NULL; 98 } 99 } 100 101 82 102 void* xrealloc ( void* pv, int size){ 83 103 -
issm/trunk-jpl/src/c/shared/Alloc/alloc.h
r5768 r11679 5 5 #ifndef _ALLOC_H_ 6 6 #define _ALLOC_H_ 7 7 class Matrix; 8 class Vector; 8 9 void* xmalloc(int size); 9 10 void* xcalloc(int n,int size); 10 11 void xfree(void** pvptr); 11 12 void* xrealloc ( void* pv, int size); 13 void xdelete(Matrix** pvptr); 14 void xdelete(Vector** pvptr); 12 15 13 16 #endif -
issm/trunk-jpl/src/c/solutions/ResetBoundaryConditions.cpp
r9761 r11679 11 11 12 12 /*variables: */ 13 Vec yg = NULL;13 Vector* yg = NULL; 14 14 Nodes *nodes = NULL; 15 15 int i; … … 30 30 31 31 /*Free ressources:*/ 32 VecFree(&yg);32 delete yg; 33 33 } -
issm/trunk-jpl/src/c/solutions/convergence.cpp
r11285 r11679 8 8 #include "../EnumDefinitions/EnumDefinitions.h" 9 9 10 void convergence(bool* pconverged, Mat Kff,Vec pf,Vec uf,Vecold_uf,Parameters* parameters){10 void convergence(bool* pconverged, Matrix* Kff,Vector* pf,Vector* uf,Vector* old_uf,Parameters* parameters){ 11 11 12 12 /*output*/ … … 14 14 15 15 /*intermediary*/ 16 Vec KU=NULL;17 Vec KUF=NULL;18 Vec KUold=NULL;19 Vec KUoldF=NULL;20 Vec duf=NULL;16 Vector* KU=NULL; 17 Vector* KUF=NULL; 18 Vector* KUold=NULL; 19 Vector* KUoldF=NULL; 20 Vector* duf=NULL; 21 21 double ndu,nduinf,nu; 22 22 double nKUF; … … 48 48 49 49 //compute KUF = KU - F = K*U - F 50 VecDuplicate(uf,&KU); MatMultPatch(Kff,uf,KU);51 VecDuplicate(KU,&KUF);VecCopy(KU,KUF); VecAYPX(KUF,-1.0,pf);50 KU=uf->Duplicate(); Kff->MatMult(uf,KU); 51 KUF=KU->Duplicate(); KU->Copy(KUF); KUF->AYPX(pf,-1.0); 52 52 53 53 //compute norm(KUF), norm(F) and residue 54 VecNorm(KUF,NORM_2,&nKUF);55 VecNorm(pf,NORM_2,&nF);54 nKUF=KUF->Norm(NORM_2); 55 nF=pf->Norm(NORM_2); 56 56 solver_residue=nKUF/nF; 57 57 _printf_(true,"\n%s%g\n"," solver residue: norm(KU-F)/norm(F)=",solver_residue); 58 58 59 59 //clean up 60 VecFree(&KU);61 VecFree(&KUF);60 delete KU; 61 delete KUF; 62 62 } 63 63 … … 65 65 66 66 //compute K[n]U[n-1]F = K[n]U[n-1] - F 67 VecDuplicate(uf,&KUold); MatMultPatch(Kff,old_uf,KUold);68 VecDuplicate(KUold,&KUoldF);VecCopy(KUold,KUoldF); VecAYPX(KUoldF,-1.0,pf);69 VecNorm(KUoldF,NORM_2,&nKUoldF);70 VecNorm(pf,NORM_2,&nF);67 KUold=uf->Duplicate(); Kff->MatMult(old_uf,KUold); 68 KUoldF=KUold->Duplicate();KUold->Copy(KUoldF); KUoldF->AYPX(pf,-1.0); 69 nKUoldF=KUoldF->Norm(NORM_2); 70 nF=pf->Norm(NORM_2); 71 71 res=nKUoldF/nF; 72 72 if (isnan(res)){ … … 76 76 77 77 //clean up 78 VecFree(&KUold);79 VecFree(&KUoldF);78 delete KUold; 79 delete KUoldF; 80 80 81 81 //print … … 93 93 94 94 //compute norm(du)/norm(u) 95 VecDuplicate(old_uf,&duf);VecCopy(old_uf,duf); VecAYPX(duf,-1.0,uf);96 VecNorm(duf,NORM_2,&ndu); VecNorm(old_uf,NORM_2,&nu);95 duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0); 96 ndu=duf->Norm(NORM_2); nu=old_uf->Norm(NORM_2); 97 97 98 98 if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!"); 99 99 100 100 //clean up 101 VecFree(&duf);101 delete duf; 102 102 103 103 //print … … 119 119 120 120 //compute max(du) 121 VecDuplicate(old_uf,&duf);VecCopy(old_uf,duf); VecAYPX(duf,-1.0,uf);122 VecNorm(duf,NORM_2,&ndu); VecNorm(duf,NORM_INFINITY,&nduinf);121 duf=old_uf->Duplicate(); old_uf->Copy(duf); duf->AYPX(uf,-1.0); 122 ndu=duf->Norm(NORM_2); nduinf=duf->Norm(NORM_INFINITY); 123 123 if (isnan(ndu) || isnan(nu)) _error_("convergence criterion is NaN!"); 124 124 125 125 //clean up 126 VecFree(&duf);126 delete duf; 127 127 128 128 //print -
issm/trunk-jpl/src/c/solutions/solutions.h
r11306 r11679 35 35 36 36 //convergence: 37 void convergence(bool* pconverged, Mat K_ff,Vec p_f,Vec u_f,Vecu_f_old,Parameters* parameters);37 void convergence(bool* pconverged, Matrix* K_ff,Vector* p_f,Vector* u_f,Vector* u_f_old,Parameters* parameters); 38 38 bool controlconvergence(double J,double tol_cm); 39 39 bool steadystateconvergence(FemModel* femmodel); -
issm/trunk-jpl/src/c/solvers/solver_adjoint_linear.cpp
r9271 r11679 13 13 14 14 /*intermediary: */ 15 Mat Kff = NULL, Kfs = NULL; 16 Vec ug = NULL, uf = NULL; 17 Vec pf = NULL; 18 Vec df = NULL; 19 Vec ys = NULL; 15 Matrix* Kff = NULL; 16 Matrix* Kfs = NULL; 17 Vector* ug = NULL; 18 Vector* uf = NULL; 19 Vector* pf = NULL; 20 Vector* df = NULL; 21 Vector* ys = NULL; 20 22 int configuration_type; 21 23 … … 26 28 SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 27 29 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 28 Reduceloadx(pf, Kfs, ys,true); MatFree(&Kfs); //true means spc = 029 Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); MatFree(&Kff); VecFree(&pf); VecFree(&df);30 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters,true); VecFree(&uf);VecFree(&ys); //true means spc030 Reduceloadx(pf, Kfs, ys,true); xdelete(&Kfs); //true means spc = 0 31 Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); xdelete(&Kff); xdelete(&pf); xdelete(&df); 32 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters,true); xdelete(&uf);xdelete(&ys); //true means spc0 31 33 InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); 32 VecFree(&ug); VecFree(&uf);34 xdelete(&ug); xdelete(&uf); 33 35 } -
issm/trunk-jpl/src/c/solvers/solver_linear.cpp
r9225 r11679 11 11 12 12 /*intermediary: */ 13 Mat Kff = NULL, Kfs = NULL; 14 Vec ug = NULL; 15 Vec uf = NULL; 16 Vec pf = NULL; 17 Vec df = NULL; 18 Vec ys = NULL; 13 Matrix* Kff = NULL; 14 Matrix* Kfs = NULL; 15 Vector* ug = NULL; 16 Vector* uf = NULL; 17 Vector* pf = NULL; 18 Vector* df = NULL; 19 Vector* ys = NULL; 19 20 int configuration_type; 20 21 … … 25 26 SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 26 27 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 27 Reduceloadx(pf, Kfs, ys); MatFree(&Kfs); 28 Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); MatFree(&Kff); VecFree(&pf); VecFree(&df); 29 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);VecFree(&uf);VecFree(&ys); 28 Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); 29 Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); 30 xdelete(&Kff); xdelete(&pf); xdelete(&df); 31 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&uf); xdelete(&ys); 30 32 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); 31 VecFree(&ug); VecFree(&uf);33 xdelete(&ug); xdelete(&uf); 32 34 } -
issm/trunk-jpl/src/c/solvers/solver_newton.cpp
r11338 r11679 18 18 int count; 19 19 double kmax; 20 Mat Kff = NULL, Kfs = NULL, Jff = NULL; 21 Vec ug = NULL, old_ug = NULL; 22 Vec uf = NULL, old_uf = NULL, duf = NULL; 23 Vec pf = NULL, pJf = NULL; 24 Vec df = NULL; 25 Vec ys = NULL; 20 Matrix* Kff = NULL; 21 Matrix* Kfs = NULL; 22 Matrix* Jff = NULL; 23 Vector* ug = NULL; 24 Vector* old_ug = NULL; 25 Vector* uf = NULL; 26 Vector* old_uf = NULL; 27 Vector* duf = NULL; 28 Vector* pf = NULL; 29 Vector* pJf = NULL; 30 Vector* df = NULL; 31 Vector* ys = NULL; 26 32 27 33 /*parameters:*/ … … 47 53 for(;;){ 48 54 49 VecFree(&old_ug);old_ug=ug;50 VecFree(&old_uf);old_uf=uf;55 xdelete(&old_ug);old_ug=ug; 56 xdelete(&old_uf);old_uf=uf; 51 57 52 58 /*Solver forward model*/ 53 59 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 54 60 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 55 Reduceloadx(pf,Kfs,ys); MatFree(&Kfs);56 Solverx(&uf,Kff,pf,old_uf,df,femmodel->parameters); VecFree(&df);57 Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters); VecFree(&ys);58 InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug); VecFree(&ug);61 Reduceloadx(pf,Kfs,ys);xdelete(&Kfs); 62 Solverx(&uf,Kff,pf,old_uf,df,femmodel->parameters);xdelete(&df); 63 Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys); 64 InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug);xdelete(&ug); 59 65 60 66 /*Check convergence*/ 61 67 convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); 62 MatFree(&Kff);VecFree(&pf);68 xdelete(&Kff); xdelete(&pf); 63 69 if(converged==true) break; 64 70 if(count>=max_nonlinear_iterations){ … … 70 76 SystemMatricesx(&Kff,&Kfs,&pf,NULL,&kmax,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 71 77 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 72 Reduceloadx(pf,Kfs,ys); MatFree(&Kfs);78 Reduceloadx(pf,Kfs,ys); xdelete(&Kfs); 73 79 74 VecDuplicate(pf,&pJf); 75 MatMultPatch(Kff,uf,pJf); MatFree(&Kff); 76 VecScale(pJf,-1.); 77 VecAXPY(pJf,+1.,pf); VecFree(&pf); 80 pJf=pf->Duplicate(); Kff->MatMult(uf,pJf); xdelete(&Kff); 81 pJf->Scale(-1.0); pJf->AXPY(pf,+1.0); xdelete(&pf); 78 82 79 83 CreateJacobianMatrixx(&Jff,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,kmax); 80 Solverx(&duf,Jff,pJf,NULL,NULL,femmodel->parameters); MatFree(&Jff);VecFree(&pJf);81 VecAXPY(uf,1.,duf); VecFree(&duf);82 Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters); VecFree(&ys);84 Solverx(&duf,Jff,pJf,NULL,NULL,femmodel->parameters); xdelete(&Jff); xdelete(&pJf); 85 uf->AXPY(duf, 1.0); xdelete(&duf); 86 Mergesolutionfromftogx(&ug,uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys); 83 87 InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,ug); 84 88 … … 89 93 90 94 /*clean-up*/ 91 VecFree(&uf);92 VecFree(&ug);93 VecFree(&old_ug);94 VecFree(&old_uf);95 xdelete(&uf); 96 xdelete(&ug); 97 xdelete(&old_ug); 98 xdelete(&old_uf); 95 99 } -
issm/trunk-jpl/src/c/solvers/solver_nonlinear.cpp
r11347 r11679 14 14 15 15 /*intermediary: */ 16 Mat Kff = NULL, Kfs = NULL; 17 Vec ug = NULL, old_ug = NULL; 18 Vec uf = NULL, old_uf = NULL; 19 Vec pf = NULL; 20 Vec df = NULL; 21 Vec ys = NULL; 16 Matrix* Kff = NULL; 17 Matrix* Kfs = NULL; 18 Vector* ug = NULL; 19 Vector* old_ug = NULL; 20 Vector* uf = NULL; 21 Vector* old_uf = NULL; 22 Vector* pf = NULL; 23 Vector* df = NULL; 24 Vector* ys = NULL; 22 25 23 26 Loads* loads=NULL; … … 56 59 57 60 //save pointer to old velocity 58 VecFree(&old_ug);old_ug=ug;59 VecFree(&old_uf);old_uf=uf;61 xdelete(&old_ug);old_ug=ug; 62 xdelete(&old_uf);old_uf=uf; 60 63 61 64 SystemMatricesx(&Kff, &Kfs, &pf, &df, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,loads,femmodel->materials,femmodel->parameters); 62 65 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 63 Reduceloadx(pf, Kfs, ys); MatFree(&Kfs);66 Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); 64 67 Solverx(&uf, Kff, pf, old_uf, df, femmodel->parameters); 65 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters); VecFree(&ys);68 Mergesolutionfromftogx(&ug, uf,ys,femmodel->nodes,femmodel->parameters);xdelete(&ys); 66 69 67 convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); MatFree(&Kff);VecFree(&pf); VecFree(&df);70 convergence(&converged,Kff,pf,uf,old_uf,femmodel->parameters); xdelete(&Kff); xdelete(&pf); xdelete(&df); 68 71 InputUpdateFromConstantx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,converged,ConvergedEnum); 69 72 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug); … … 96 99 /*clean-up*/ 97 100 if(conserve_loads) delete loads; 98 VecFree(&uf);99 VecFree(&ug);100 VecFree(&old_ug);101 VecFree(&old_uf);101 xdelete(&uf); 102 xdelete(&ug); 103 xdelete(&old_ug); 104 xdelete(&old_uf); 102 105 } -
issm/trunk-jpl/src/c/solvers/solver_stokescoupling_nonlinear.cpp
r11284 r11679 14 14 15 15 /*intermediary: */ 16 Mat Kff_horiz = NULL, Kfs_horiz = NULL; 17 Vec ug_horiz = NULL, uf_horiz = NULL, old_uf_horiz = NULL; 18 Vec pf_horiz = NULL; 19 Vec df_horiz = NULL; 20 Mat Kff_vert = NULL, Kfs_vert = NULL; 21 Vec ug_vert = NULL, uf_vert = NULL; 22 Vec pf_vert = NULL; 23 Vec df_vert = NULL; 24 Vec ys = NULL; 16 Matrix* Kff_horiz = NULL; 17 Matrix* Kfs_horiz = NULL; 18 Vector* ug_horiz = NULL; 19 Vector* uf_horiz = NULL; 20 Vector* old_uf_horiz = NULL; 21 Vector* pf_horiz = NULL; 22 Vector* df_horiz = NULL; 23 Matrix* Kff_vert = NULL; 24 Matrix* Kfs_vert = NULL; 25 Vector* ug_vert = NULL; 26 Vector* uf_vert = NULL; 27 Vector* pf_vert = NULL; 28 Vector* df_vert = NULL; 29 Vector* ys = NULL; 25 30 bool converged; 26 31 int constraints_converged; … … 54 59 //Update once again the solution to make sure that vx and vxold are similar (for next step in transient or steadystate) 55 60 InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug_horiz); 56 VecFree(&ug_horiz);61 xdelete(&ug_horiz); 57 62 58 63 //save pointer to old velocity 59 VecFree(&old_uf_horiz);old_uf_horiz=uf_horiz;64 xdelete(&old_uf_horiz); old_uf_horiz=uf_horiz; 60 65 61 66 /*solve: */ 62 67 SystemMatricesx(&Kff_horiz, &Kfs_horiz, &pf_horiz, &df_horiz, NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 63 68 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 64 Reduceloadx(pf_horiz, Kfs_horiz, ys); MatFree(&Kfs_horiz);69 Reduceloadx(pf_horiz, Kfs_horiz, ys); xdelete(&Kfs_horiz); 65 70 Solverx(&uf_horiz, Kff_horiz, pf_horiz, old_uf_horiz, df_horiz,femmodel->parameters); 66 Mergesolutionfromftogx(&ug_horiz, uf_horiz,ys,femmodel->nodes,femmodel->parameters); VecFree(&ys);71 Mergesolutionfromftogx(&ug_horiz, uf_horiz,ys,femmodel->nodes,femmodel->parameters); xdelete(&ys); 67 72 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug_horiz); 68 73 69 convergence(&converged,Kff_horiz,pf_horiz,uf_horiz,old_uf_horiz,femmodel->parameters); MatFree(&Kff_horiz);VecFree(&pf_horiz); VecFree(&df_horiz);74 convergence(&converged,Kff_horiz,pf_horiz,uf_horiz,old_uf_horiz,femmodel->parameters); xdelete(&Kff_horiz); xdelete(&pf_horiz); xdelete(&df_horiz); 70 75 71 76 /*Second compute vertical velocity: */ … … 76 81 SystemMatricesx(&Kff_vert, &Kfs_vert, &pf_vert, &df_vert,NULL,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 77 82 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 78 Reduceloadx(pf_vert, Kfs_vert, ys); MatFree(&Kfs_vert);79 Solverx(&uf_vert, Kff_vert, pf_vert, NULL, df_vert,femmodel->parameters); MatFree(&Kff_vert); VecFree(&pf_vert); VecFree(&df_vert);80 Mergesolutionfromftogx(&ug_vert, uf_vert,ys,femmodel->nodes,femmodel->parameters); VecFree(&uf_vert); VecFree(&ys);83 Reduceloadx(pf_vert, Kfs_vert, ys); xdelete(&Kfs_vert); 84 Solverx(&uf_vert, Kff_vert, pf_vert, NULL, df_vert,femmodel->parameters); xdelete(&Kff_vert); xdelete(&pf_vert); xdelete(&df_vert); 85 Mergesolutionfromftogx(&ug_vert, uf_vert,ys,femmodel->nodes,femmodel->parameters);xdelete(&uf_vert); xdelete(&ys); 81 86 InputUpdateFromSolutionx( femmodel->elements,femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,ug_vert); 82 VecFree(&ug_vert); VecFree(&uf_vert);87 xdelete(&ug_vert); xdelete(&uf_vert); 83 88 84 89 /*Increase count: */ … … 92 97 93 98 /*clean-up*/ 94 VecFree(&old_uf_horiz);95 VecFree(&uf_horiz);96 VecFree(&ug_horiz);97 VecFree(&ys);99 xdelete(&old_uf_horiz); 100 xdelete(&uf_horiz); 101 xdelete(&ug_horiz); 102 xdelete(&ys); 98 103 } -
issm/trunk-jpl/src/c/solvers/solver_thermal_nonlinear.cpp
r11197 r11679 12 12 13 13 /*solution : */ 14 Vec tg=NULL;15 Vec tf=NULL;16 Vec tf_old=NULL;17 Vec ys=NULL;14 Vector* tg=NULL; 15 Vector* tf=NULL; 16 Vector* tf_old=NULL; 17 Vector* ys=NULL; 18 18 double melting_offset; 19 19 20 20 /*intermediary: */ 21 Mat Kff=NULL;22 Mat Kfs=NULL;23 Vec pf=NULL;24 Vec df=NULL;21 Matrix* Kff=NULL; 22 Matrix* Kfs=NULL; 23 Vector* pf=NULL; 24 Vector* df=NULL; 25 25 26 26 bool converged; … … 56 56 SystemMatricesx(&Kff, &Kfs, &pf,&df, &melting_offset,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 57 57 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); 58 Reduceloadx(pf, Kfs, ys); MatFree(&Kfs); VecFree(&tf);58 Reduceloadx(pf, Kfs, ys); xdelete(&Kfs); xdelete(&tf); 59 59 Solverx(&tf, Kff, pf,tf_old, df, femmodel->parameters); 60 VecFree(&tf_old); VecDuplicatePatch(&tf_old,tf);61 MatFree(&Kff);VecFree(&pf);VecFree(&tg); VecFree(&df);62 Mergesolutionfromftogx(&tg, tf,ys,femmodel->nodes,femmodel->parameters); VecFree(&ys);60 xdelete(&tf_old); tf_old=tf->Duplicate(); 61 xdelete(&Kff);xdelete(&pf);xdelete(&tg); xdelete(&df); 62 Mergesolutionfromftogx(&tg, tf,ys,femmodel->nodes,femmodel->parameters); xdelete(&ys); 63 63 InputUpdateFromSolutionx(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,tg); 64 64 … … 84 84 85 85 /*Free ressources: */ 86 VecFree(&tg);87 VecFree(&tf);88 VecFree(&tf_old);89 VecFree(&ys);86 xdelete(&tg); 87 xdelete(&tf); 88 xdelete(&tf_old); 89 xdelete(&ys); 90 90 } -
issm/trunk-jpl/src/mex/CreateJacobianMatrix/CreateJacobianMatrix.cpp
r11335 r11679 17 17 18 18 /* output datasets: */ 19 Mat Jff = NULL;19 Matrix* Jff = NULL; 20 20 21 21 /*Boot module: */ … … 53 53 delete materials; 54 54 delete parameters; 55 MatFree(&Jff);55 delete Jff; 56 56 57 57 /*end module: */ -
issm/trunk-jpl/src/mex/CreateNodalConstraints/CreateNodalConstraints.cpp
r8910 r11679 12 12 13 13 /* output datasets: */ 14 Vec ys=NULL;14 Vector* ys=NULL; 15 15 16 16 /*Boot module: */ … … 32 32 /*Free ressources: */ 33 33 delete nodes; 34 VecFree(&ys);34 delete ys; 35 35 36 36 /*end module: */ -
issm/trunk-jpl/src/mex/GetSolutionFromInputs/GetSolutionFromInputs.cpp
r8910 r11679 14 14 Materials* materials=NULL; 15 15 Parameters* parameters=NULL; 16 Vec ug=NULL;16 Vector* ug=NULL; 17 17 18 18 /* output datasets: elements and loads*/ -
issm/trunk-jpl/src/mex/InputUpdateFromSolution/InputUpdateFromSolution.cpp
r8910 r11679 14 14 Materials* materials=NULL; 15 15 Parameters* parameters=NULL; 16 Vec solution=NULL;16 Vector* solution=NULL; 17 17 18 18 /*Boot module: */ … … 50 50 delete materials; 51 51 delete parameters; 52 VecFree(&solution);52 delete solution; 53 53 54 54 /*end module: */ -
issm/trunk-jpl/src/mex/Mergesolutionfromftog/Mergesolutionfromftog.cpp
r8910 r11679 9 9 /*input datasets: */ 10 10 bool flag_ys0; 11 Vec uf = NULL;12 Vec ys = NULL;11 Vector* uf = NULL; 12 Vector* ys = NULL; 13 13 Nodes* nodes = NULL; 14 14 Parameters* parameters = NULL; 15 15 16 16 /* output datasets: */ 17 Vec ug=NULL;17 Vector* ug=NULL; 18 18 19 19 /*Boot module: */ … … 45 45 46 46 /*Free ressources: */ 47 VecFree(&uf);48 VecFree(&ug);49 VecFree(&ys);47 delete uf; 48 delete ug; 49 delete ys; 50 50 delete nodes; 51 51 delete parameters; -
issm/trunk-jpl/src/mex/Reduceload/Reduceload.cpp
r8910 r11679 8 8 9 9 /*input datasets: */ 10 Vec pf = NULL;11 Mat Kfs = NULL;12 Vec ys = NULL;10 Vector* pf = NULL; 11 Matrix* Kfs = NULL; 12 Vector* ys = NULL; 13 13 bool flag_ys0=false; 14 14 … … 40 40 41 41 /*Free ressources: */ 42 VecFree(&pf);43 MatFree(&Kfs);44 VecFree(&ys);42 delete pf; 43 delete Kfs; 44 delete ys; 45 45 46 46 MODULEEND(); -
issm/trunk-jpl/src/mex/Reducevectorgtof/Reducevectorgtof.cpp
r8910 r11679 8 8 9 9 /*input datasets: */ 10 Vec ug=NULL;10 Vector* ug=NULL; 11 11 Nodes* nodes=NULL; 12 12 Parameters* parameters=NULL; 13 13 14 14 /* output datasets: */ 15 Vec uf=NULL;15 Vector* uf=NULL; 16 16 17 17 /*Boot module: */ … … 35 35 delete nodes; 36 36 delete parameters; 37 VecFree(&ug);38 VecFree(&uf);37 delete ug; 38 delete uf; 39 39 40 40 /*end module: */ -
issm/trunk-jpl/src/mex/Reducevectorgtos/Reducevectorgtos.cpp
r8910 r11679 8 8 9 9 /*input datasets: */ 10 Vec yg=NULL;10 Vector* yg=NULL; 11 11 Nodes* nodes=NULL; 12 12 Parameters* parameters=NULL; 13 13 14 14 /* output datasets: */ 15 Vec ys=NULL;15 Vector* ys=NULL; 16 16 17 17 /*Boot module: */ … … 35 35 delete nodes; 36 36 delete parameters; 37 VecFree(&yg);38 VecFree(&ys);37 delete yg; 38 delete ys; 39 39 40 40 /*end module: */ -
issm/trunk-jpl/src/mex/Solver/Solver.cpp
r11252 r11679 8 8 9 9 /*input datasets: */ 10 Mat Kff = NULL;11 Vec pf = NULL;12 Vec uf0 = NULL;13 Vec uf = NULL;14 Vec df = NULL;10 Matrix* Kff = NULL; 11 Vector* pf = NULL; 12 Vector* uf0 = NULL; 13 Vector* uf = NULL; 14 Vector* df = NULL; 15 15 Parameters *parameters = NULL; 16 16 int analysis_type; … … 66 66 67 67 /*Free ressources: */ 68 MatFree(&Kff);69 VecFree(&pf);70 VecFree(&uf0);71 VecFree(&uf);72 VecFree(&df);68 delete Kff; 69 delete pf; 70 delete uf0; 71 delete uf; 72 delete df; 73 73 delete parameters; 74 74 -
issm/trunk-jpl/src/mex/SystemMatrices/SystemMatrices.cpp
r8910 r11679 17 17 18 18 /* output datasets: */ 19 Mat Kff = NULL;20 Mat Kfs = NULL;21 Vec pf = NULL;22 Vec df = NULL;19 Matrix* Kff = NULL; 20 Matrix* Kfs = NULL; 21 Vector* pf = NULL; 22 Vector* df = NULL; 23 23 24 24 double kmax; … … 72 72 delete materials; 73 73 delete parameters; 74 MatFree(&Kff);75 MatFree(&Kfs);76 VecFree(&pf);77 VecFree(&df);74 delete Kff; 75 delete Kfs; 76 delete pf; 77 delete df; 78 78 79 79 /*end module: */ -
issm/trunk-jpl/src/mex/UpdateDynamicConstraints/UpdateDynamicConstraints.cpp
r9302 r11679 11 11 Nodes *nodes = NULL; 12 12 Parameters *parameters = NULL; 13 Vec yg = NULL;13 Vector* yg = NULL; 14 14 15 15 /*Boot module: */ … … 32 32 33 33 /*Free ressources: */ 34 VecFree(&yg);34 delete yg; 35 35 delete constraints; 36 36 delete nodes;
Note:
See TracChangeset
for help on using the changeset viewer.