Changeset 1669
- Timestamp:
- 08/13/09 14:50:04 (15 years ago)
- Location:
- issm/trunk/src
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/Makefile.am
r1665 r1669 580 580 ./parallel/diagnostic_core_linear.cpp\ 581 581 ./parallel/diagnostic_core_nonlinear.cpp\ 582 ./parallel/convergence.cpp\ 582 583 ./parallel/thermal_core.cpp\ 583 584 ./parallel/thermal_core_nonlinear.cpp\ -
issm/trunk/src/c/parallel/diagnostic_core_nonlinear.cpp
r1666 r1669 10 10 #include "../EnumDefinitions/EnumDefinitions.h" 11 11 #include "../issm.h" 12 #include "./parallel.h" 12 13 13 14 void diagnostic_core_nonlinear(Vec* pug,Mat* pKff0,Mat* pKfs0, FemModel* fem,ParameterInputs* inputs,int analysis_type,int sub_analysis_type){ … … 20 21 Vec old_uf=NULL; 21 22 DataSet* loads=NULL; 22 Vec KU=NULL;23 Vec KUF=NULL;24 Vec KUold=NULL;25 Vec KUoldF=NULL;26 23 27 24 /*intermediary: */ … … 37 34 int numberofnodes; 38 35 39 Vec dug=NULL;40 double ndu,nduinf,nu;41 double nKUF;42 double nKUoldF;43 double nF;44 double solver_residue,res;45 46 36 /*parameters:*/ 47 37 int kflag,pflag,connectivity,numberofdofspernode; 48 38 char* solver_string=NULL; 49 39 int debug=0; 50 double eps_res,eps_rel,eps_abs,yts;51 40 int dofs[4]={1,1,0,0}; //recover vx,vy by default. vz and pressure may be. 52 41 53 42 /*Recover parameters: */ 54 43 kflag=1; pflag=1; 55 56 44 fem->parameters->FindParam((void*)&connectivity,"connectivity"); 57 45 fem->parameters->FindParam((void*)&numberofdofspernode,"numberofdofspernode"); 58 46 fem->parameters->FindParam((void*)&numberofnodes,"numberofnodes"); 59 47 fem->parameters->FindParam((void*)&solver_string,"solverstring"); 60 fem->parameters->FindParam((void*)&eps_res,"eps_res");61 fem->parameters->FindParam((void*)&eps_rel,"eps_rel");62 fem->parameters->FindParam((void*)&eps_abs,"eps_abs");63 fem->parameters->FindParam((void*)&yts,"yts");64 fem->parameters->FindParam((void*)&debug,"debug");65 48 66 49 /*Copy loads for backup: */ … … 119 102 Solverx(&uf, Kff, pf, old_uf, solver_string); 120 103 121 /*print solver residue = norm(KU-F)/norm(F)*/ 122 if (debug>1){ 123 //compute KUF = KU - F = K*U - F 124 VecDuplicate(uf,&KU); MatMultPatch(Kff,uf,KU); 125 VecDuplicate(KU,&KUF);VecCopy(KU,KUF); VecAYPX(KUF,-1.0,pf); 126 //compute norm(KUF), norm(F) and residue 127 VecNorm(KUF,NORM_2,&nKUF); 128 VecNorm(pf,NORM_2,&nF); 129 solver_residue=nKUF/nF; 130 //clean up 131 VecFree(&KU); 132 VecFree(&KUF); 133 _printf_("%s%g\n"," solver residue: norm(K[n]U[n]-F)/norm(F)",solver_residue); 134 } 135 104 //Merge back to g set 136 105 if (debug) _printf_(" merging solution from f to g set\n"); 137 //Merge back to g set138 106 Mergesolutionfromftogx(&ug, uf,fem->Gmn,fem->ys,fem->nodesets); 139 107 … … 145 113 146 114 /*Figure out if convergence is reached.*/ 147 148 /*1 mechanical equilibrium residue = norm(K[n]U[n-1]-F)/norm(F)*/ 149 //compute K[n]U[n-1]F = K[n]U[n-1] - F 150 VecDuplicate(uf,&KUold); MatMultPatch(Kff,old_uf,KUold); 151 VecDuplicate(KUold,&KUoldF);VecCopy(KUold,KUoldF); VecAYPX(KUoldF,-1.0,pf); 152 //compute norm(KUF), norm(F) and residue 153 VecNorm(KUoldF,NORM_2,&nKUoldF); 154 res=nKUoldF/nF; 155 //clean up 156 VecFree(&KUold); 157 VecFree(&KUoldF); 158 if (isnan(res)) throw ErrorException(__FUNCT__,exprintf("mechanical equilibrium convergence criterion is NaN! ")); 159 if((res)<eps_res){ 160 if (debug) _printf_("%-50s%g%s%g%s\n"," mechanical equilibrium convergence criterion",res*100," < ",eps_res*100," \%"); 161 converged=1; 162 } 163 else{ 164 if (debug) _printf_("%-50s%g%s%g%s\n"," mechanical equilibrium convergence criterion",res*100," > ",eps_res*100," \%"); 165 converged=1;//TTTTTTTTTTTTTTTTTTFTYICGWFYUOGCYEUOGCYEUWGCHLWGWI 166 } 167 168 /*relative criterion = norm(du)/norm(u)*/ 169 VecDuplicate(old_ug,&dug);VecCopy(old_ug,dug); VecAYPX(dug,-1.0,ug); 170 VecNorm(dug,NORM_2,&ndu);VecNorm(old_ug,NORM_2,&nu);VecNorm(dug,NORM_INFINITY,&nduinf); VecFree(&dug); 171 if (isnan(ndu) || isnan(nu)) throw ErrorException(__FUNCT__,exprintf("convergence criterion is NaN! ")); 172 if((ndu/nu)<eps_rel){ 173 if (debug) _printf_("%-50s%g%s%g%s\n"," Convergence criterion: norm(du)/norm(u)",ndu/nu*100," < ",eps_rel*100," \%"); 174 converged=1; 175 } 176 else{ 177 if (debug) _printf_("%-50s%g%s%g%s\n"," Convergence criterion: norm(du)/norm(u)",ndu/nu*100," > ",eps_rel*100," \%"); 178 converged=0; 179 } 180 181 /*Absolute criterion (Optional) = max(du)*/ 182 if (!isnan(eps_abs)){ 183 if ((nduinf*yts)<eps_abs){ 184 if (debug) _printf_("%-50s%g%s%g%s\n"," Convergence criterion: max(du)",nduinf*yts," < ",eps_abs," m/yr"); 185 } 186 else{ 187 if (debug) _printf_("%-50s%g%s%g%s\n"," Convergence criterion: max(du)",nduinf*yts," > ",eps_abs," m/yr"); 188 converged=0; 189 } 190 } 115 convergence(&converged,Kff,pf,uf,old_uf,fem->parameters); 116 MatFree(&Kff);VecFree(&pf); 191 117 192 118 //rift convergence 193 119 if (!constraints_converged) converged=0; 194 120 195 //no need for Kff and pf anymore196 MatFree(&Kff);VecFree(&pf);197 198 121 /*Increase count: */ 199 122 count++; 200 123 if(converged==1)break; 201 124 202 125 } 203 126 … … 212 135 213 136 SystemMatricesx(&Kgg, &pg,fem->elements,fem->nodes,fem->loads,fem->materials,kflag,pflag,connectivity,numberofdofspernode,inputs,analysis_type,sub_analysis_type); 214 215 137 Reducematrixfromgtofx(&Kff,&Kfs,Kgg,fem->Gmn,fem->nodesets); 216 217 138 MatFree(&Kgg);VecFree(&pg); 218 139 -
issm/trunk/src/c/parallel/parallel.h
r1648 r1669 20 20 void diagnostic_core_nonlinear(Vec* pug,Mat* pK_ff0,Mat* pK_fs0, FemModel* fem,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 21 21 void diagnostic_core_linear(Vec* ppg,FemModel* fem,ParameterInputs* inputs,int analysis_type,int sub_analysis_type); 22 void convergence(int* pconverged, Mat K_ff,Vec p_f,Vec u_f,Vec u_f_old,DataSet* parameters); 22 23 23 24 void transient_core(DataSet* results,FemModel* fems, ParameterInputs* inputs); -
issm/trunk/src/m/solutions/cielo/convergence.m
r1668 r1669 16 16 solver_res=norm(K_ff*u_f-p_f,2)/norm(p_f,2); 17 17 displaystring(debug>1,'%s%g',' condition number of stiffness matrix: ',condest(K_ff)); 18 displaystring(debug>1,'%s%g',' solver residue : norm(K[n]U[n]-F)/norm(F)',solver_res);18 displaystring(debug>1,'%s%g',' solver residue norm(K[n]U[n]-F)/norm(F): ',solver_res); 19 19 end 20 20 … … 33 33 34 34 %Relative criterion (optional) 35 if ~isnan(eps_rel),35 if ((~isnan(eps_rel)) | (debug>1)), 36 36 37 %compute ndu/nu 37 38 duf=u_f-u_f_old; 38 39 ndu=norm(duf,2); 39 nu=norm(u_f ,2);40 nu=norm(u_f_old,2); 40 41 if isnan(ndu), 41 42 error('convergence error message: relative convergence criterion is NaN!'); 42 43 end 43 44 44 if (ndu/nu<=eps_rel), 45 displaystring(debug,'%-60s%g%s%g%s',' relative convergence criterion: norm(du)/norm(u)',ndu/nu*100,' < ',eps_rel*100,' %'); 46 converged=1; 45 %print criterion 46 if ~isnan(eps_rel), 47 if (ndu/nu<=eps_rel), 48 displaystring(debug,'%-60s%g%s%g%s',' relative convergence criterion: norm(du)/norm(u)',ndu/nu*100,' < ',eps_rel*100,' %'); 49 converged=1; 50 else 51 displaystring(debug,'%-60s%g%s%g%s',' relative convergence criterion: norm(du)/norm(u)',ndu/nu*100,' > ',eps_rel*100,' %'); 52 converged=0; 53 end 47 54 else 48 displaystring(debug,'%-60s%g%s%g%s',' relative convergence criterion: norm(du)/norm(u)',ndu/nu*100,' > ',eps_rel*100,' %'); 49 converged=0; 55 displaystring(debug,'%-60s%g%s',' relative convergence criterion: norm(du)/norm(u)',ndu/nu*100,' %'); 50 56 end 51 57 … … 53 59 54 60 %Absolute criterion (optional) 55 if ~isnan(eps_abs),61 if ((~isnan(eps_abs)) | (debug>1)), 56 62 63 %compute max(du) 64 duf=u_f-u_f_old; 57 65 nduinf=norm(duf,inf)*yts; 58 66 if isnan(nduinf), … … 60 68 end 61 69 62 if (nduinf<=eps_abs), 63 displaystring(debug,'%-60s%g%s%g%s',' absolute convergence criterion: max(du)',nduinf,' < ',eps_abs,' m/yr'); 70 %print criterion 71 if ~isnan(eps_abs), 72 if (nduinf<=eps_abs), 73 displaystring(debug,'%-60s%g%s%g%s',' absolute convergence criterion: max(du)',nduinf,' < ',eps_abs,' m/yr'); 74 else 75 displaystring(debug,'%-60s%g%s%g%s',' absolute convergence criterion: max(du)',nduinf,' > ',eps_abs,' m/yr'); 76 converged=0; 77 end 64 78 else 65 displaystring(debug,'%-60s%g%s%g%s',' absolute convergence criterion: max(du)',nduinf,' > ',eps_abs,' m/yr'); 66 converged=0; 79 displaystring(debug,'%-60s%g%s',' absolute convergence criterion: max(du)',nduinf,' m/yr'); 67 80 end 68 81
Note:
See TracChangeset
for help on using the changeset viewer.