Changeset 18207
- Timestamp:
- 07/01/14 10:37:09 (11 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/analyses/UzawaPressureAnalysis.cpp
r18182 r18207 92 92 int dim; 93 93 IssmDouble Jdet,r,divu; 94 IssmDouble dvx[3],dvy[3],dvz[3];95 94 IssmDouble *xyz_list = NULL; 96 95 int numnodes = element->GetNumberOfNodes(); 97 98 /*Initialize Element matrix and vectors*/99 ElementVector* pe = element->NewElementVector();100 IssmDouble* basis = xNew<IssmDouble>(numnodes);101 96 102 97 /*Retrieve all inputs and parameters*/ … … 105 100 element->GetVerticesCoordinates(&xyz_list); 106 101 102 /*Initialize Element matrix and vectors*/ 103 ElementVector* pe = element->NewElementVector(); 104 IssmDouble* basis = xNew<IssmDouble>(numnodes); 105 IssmDouble* dvx = xNew<IssmDouble>(dim); 106 IssmDouble* dvy = xNew<IssmDouble>(dim); 107 IssmDouble* dvz = xNew<IssmDouble>(dim); 108 107 109 Input* vx_input=element->GetInput(VxEnum); _assert_(vx_input); 108 110 Input* vy_input=element->GetInput(VyEnum); _assert_(vy_input); 109 Input* vz_input ;111 Input* vz_input = NULL; 110 112 if(dim==3){vz_input=element->GetInput(VzEnum); _assert_(vz_input);} 111 113 … … 122 124 } 123 125 126 divu=dvx[0]+dvy[1]; 127 if (dim==3) divu=divu+dvz[2]; 128 124 129 for(int i=0;i<numnodes;i++){ 125 divu=dvx[0]+dvy[1]; 126 if (dim==3) divu=divu+dvz[2]; 127 pe->values[i]+=divu*r*Jdet*gauss->weight*basis[i]; 130 pe->values[i] += - r * divu * Jdet * gauss->weight * basis[i]; 128 131 } 129 132 } … … 133 136 xDelete<IssmDouble>(xyz_list); 134 137 xDelete<IssmDouble>(basis); 138 xDelete<IssmDouble>(dvx); 139 xDelete<IssmDouble>(dvy); 140 xDelete<IssmDouble>(dvz); 135 141 return pe; 136 142 }/*}}}*/ -
issm/trunk-jpl/src/c/solutionsequences/solutionsequence_la.cpp
r18186 r18207 13 13 Matrix<IssmDouble>* Kff = NULL; 14 14 Matrix<IssmDouble>* Kfs = NULL; 15 Vector<IssmDouble>* ug_old = NULL;16 15 Vector<IssmDouble>* ug = NULL; 17 16 Vector<IssmDouble>* uf = NULL; … … 23 22 IssmDouble eps_rel,r,theta; // 0<theta<.5 -> .15<theta<.45 24 23 int configuration_type,max_nonlinear_iterations; 24 bool vel_converged = false; 25 bool pressure_converged = false; 25 26 26 27 /*Create analysis*/ … … 40 41 /*Convergence criterion*/ 41 42 int count = 0; 42 GetSolutionFromInputsx(&ug,femmodel);43 Vector<IssmDouble>* v x= NULL;44 Vector<IssmDouble>* vx_old = NULL;45 GetVectorFromInputsx(& vx,femmodel,VxEnum,VertexEnum);43 Vector<IssmDouble>* vel = NULL; 44 Vector<IssmDouble>* vel_old = NULL; 45 GetVectorFromInputsx(&vel,femmodel,VxEnum,VertexEnum); 46 GetVectorFromInputsx(&pug,femmodel,PressureEnum,VertexEnum); 46 47 47 48 while(true){ … … 49 50 50 51 /*save pointer to old velocity*/ 51 delete ug_old;ug_old=ug;52 delete vx_old;vx_old=vx;53 delete pug_old;pug_old=pug;52 delete vel_old;vel_old=vel; 53 delete pug_old;pug_old=pug; 54 pressure_converged=false; vel_converged=false; 54 55 55 56 /*Solve KU=F*/ 56 57 femmodel->SetCurrentConfiguration(StressbalanceAnalysisEnum); 58 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 57 59 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel); 58 60 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); … … 63 65 64 66 /*Update solution*/ 65 InputUpdateFromSolutionx(femmodel,ug); 66 GetVectorFromInputsx(&v x,femmodel,VxEnum,VertexEnum);67 InputUpdateFromSolutionx(femmodel,ug); delete ug; 68 GetVectorFromInputsx(&vel,femmodel,VxEnum,VertexEnum); 67 69 68 70 femmodel->SetCurrentConfiguration(UzawaPressureAnalysisEnum); 71 femmodel->parameters->FindParam(&configuration_type,ConfigurationTypeEnum); 69 72 SystemMatricesx(&Kff,&Kfs,&pf,&df,NULL,femmodel); 70 73 CreateNodalConstraintsx(&ys,femmodel->nodes,configuration_type); … … 72 75 Solverx(&uf, Kff, pf, NULL, df, femmodel->parameters); 73 76 delete Kff; delete pf; delete df; 74 Mergesolutionfromftogx(&pug, uf,ys,femmodel->nodes,femmodel->parameters); delete uf; delete ys;77 Mergesolutionfromftogx(&pug, uf,ys,femmodel->nodes,femmodel->parameters); delete uf; delete ys; 75 78 76 79 /*Update solution*/ 77 InputUpdateFromSolutionx(femmodel,pug); 80 InputUpdateFromSolutionx(femmodel,pug); delete pug; 81 GetVectorFromInputsx(&pug,femmodel,PressureEnum,VertexEnum); 78 82 79 83 /*Check for convergence*/ 80 //Vector<IssmDouble>* dug=ug_old->Duplicate(); ug_old->Copy(dug); dug->AYPX(ug,-1.0); 81 //IssmDouble ndu=dug->Norm(NORM_TWO); delete dug; 82 //IssmDouble nu =ug_old->Norm(NORM_TWO); 83 Vector<IssmDouble>* dvx=vx_old->Duplicate(); vx_old->Copy(dvx); dvx->AYPX(vx,-1.0); 84 IssmDouble ndu=dvx->Norm(NORM_TWO); delete dvx; 85 IssmDouble nu =vx_old->Norm(NORM_TWO); 84 Vector<IssmDouble>* dvel=vel_old->Duplicate(); vel_old->Copy(dvel); dvel->AYPX(vel,-1.0); 85 IssmDouble ndu=dvel->Norm(NORM_TWO); delete dvel; 86 IssmDouble nu =vel_old->Norm(NORM_TWO); 86 87 if (xIsNan<IssmDouble>(ndu) || xIsNan<IssmDouble>(nu)) _error_("convergence criterion is NaN!"); 87 88 if((ndu/nu)<eps_rel){ 88 89 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " < " << eps_rel*100 << " %\n"); 89 break;90 vel_converged=true; 90 91 } 91 92 else{ 92 93 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: norm(du)/norm(u)" << ndu/nu*100 << " > " << eps_rel*100 << " %\n"); 94 vel_converged=false; 95 } 96 Vector<IssmDouble>* dup=pug_old->Duplicate(); pug_old->Copy(dup); dup->AYPX(pug,-1.0); 97 IssmDouble ndp=dup->Norm(NORM_TWO); delete dup; 98 IssmDouble np =pug_old->Norm(NORM_TWO); 99 if (xIsNan<IssmDouble>(ndp) || xIsNan<IssmDouble>(np)) _error_("convergence criterion is NaN!"); 100 if((ndp/np)<eps_rel){ 101 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: norm(dp)/norm(p)" << ndp/np*100 << " < " << eps_rel*100 << " %\n"); 102 pressure_converged=true; 103 } 104 else{ 105 if(VerboseConvergence()) _printf0_(setw(50) << left << " Convergence criterion: norm(dp/)/norm(p)" << ndp/np*100 << " > " << eps_rel*100 << " %\n"); 106 pressure_converged=false; 93 107 } 94 108 109 if(pressure_converged && vel_converged) break; 95 110 if(count>=max_nonlinear_iterations){ 96 111 _printf0_(" maximum number of nonlinear iterations (" << max_nonlinear_iterations << ") exceeded\n"); … … 101 116 if(VerboseConvergence()) _printf0_("\n total number of iterations: " << count-1 << "\n"); 102 117 103 delete ug;104 delete ug_old;105 118 delete pug; 106 119 delete pug_old; 107 delete v x;108 delete v x_old;120 delete vel; 121 delete vel_old; 109 122 delete stressanalysis; 110 123 delete pressureanalysis;
Note:
See TracChangeset
for help on using the changeset viewer.