Changeset 26699
- Timestamp:
- 12/02/21 12:35:35 (3 years ago)
- Location:
- issm/trunk-jpl/src/jl/solve
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/jl/solve/inputs.jl
r26681 r26699 112 112 113 113 if input.interp==P0Enum 114 return input.element_values 114 return input.element_values[1] 115 115 elseif input.interp==P1Enum 116 116 value = input.element_values[1]*gauss.coords1[i] + input.element_values[2]*gauss.coords2[i] + input.element_values[3]*gauss.coords3[i] -
issm/trunk-jpl/src/jl/solve/modules.jl
r26698 r26699 158 158 end 159 159 160 return u g160 return uf 161 161 162 162 end#}}} -
issm/trunk-jpl/src/jl/solve/solutionsequences.jl
r26698 r26699 29 29 Mergesolutionfromftogx(ug, uf, ys, femmodel.nodes) 30 30 31 print(ug) 32 error("compare with ISSM...") 31 #Check for convergence 32 converged = convergence(Kff,pf,uf,old_uf,restol,reltol,abstol) 33 InputUpdateFromSolutionx(analysis,ug,femmodel) 33 34 34 35 #Increase count … … 40 41 end 41 42 43 print("\n total number of iterations: ", count, "\n") 44 42 45 error("STOP") 43 46 44 47 end# }}} 48 function convergence(Kff::IssmMatrix, pf::IssmVector, uf::IssmVector, old_uf::IssmVector, restol::Float64, reltol::Float64, abstol::Float64)#{{{ 49 50 print(" checking convergence\n"); 51 52 #If solution vector is empty, return true 53 if(IsEmpty(uf)) 54 return true 55 end 56 57 #Convergence criterion #1: force equilibrium (Mandatory) 58 #compute K[n]U[n-1] - F 59 KUold = Duplicate(uf); MatMult!(Kff,old_uf,KUold) 60 KUoldF = Duplicate(KUold); VecCopy!(KUold, KUoldF); AXPY!(KUoldF, -1.0, pf) 61 nKUoldF = Norm(KUoldF,2) 62 nF = Norm(pf,2) 63 res = nKUoldF/nF 64 if ~isfinite(res) 65 println("norm nf = ", nF, " and norm kuold = ",nKUoldF) 66 error("mechanical equilibrium convergence criterion is not finite!") 67 end 68 if(res<restol) 69 print(" mechanical equilibrium convergence criterion ", res*100, " < ", restol*100, " %\n") 70 converged=true 71 else 72 print(" mechanical equilibrium convergence criterion ", res*100, " > ", restol*100, " %\n") 73 converged=false; 74 end 75 76 #Convergence criterion #2: norm(du)/norm(u) 77 if ~isnan(reltol) 78 duf = Duplicate(old_uf); VecCopy!(old_uf,duf); AXPY!(duf, -1.0, uf) 79 ndu = Norm(duf, 2); nu = Norm(old_uf, 2) 80 if ~isfinite(ndu) | ~isfinite(nu) 81 error("convergence criterion is not finite!") 82 end 83 if((ndu/nu)<reltol) 84 print(" Convergence criterion: norm(du)/norm(u) ", ndu/nu*100, " < ", reltol*100, " %\n") 85 else 86 print(" Convergence criterion: norm(du)/norm(u) ", ndu/nu*100, " > ", reltol*100, " %\n") 87 converged=false; 88 end 89 end 90 91 #Convergence criterion #3: max(du) 92 if ~isnan(abstol) 93 duf = Duplicate(old_uf); VecCopy!(old_uf,duf); AXPY!(duf, -1.0, uf) 94 nduinf= Norm(duf, 3) 95 if ~isfinite(nduinf) 96 error("convergence criterion is not finite!") 97 end 98 if(nduinf<abstol) 99 print(" Convergence criterion: max(du) ", nduinf, " < ", abstol, "\n") 100 else 101 print(" Convergence criterion: max(du) ", nduinf, " > ", abstol, "\n") 102 converged=false; 103 end 104 end 105 106 return converged 107 108 end#}}} -
issm/trunk-jpl/src/jl/solve/toolkits.jl
r26698 r26699 58 58 59 59 end#}}} 60 function IsEmpty(vector::IssmVector)#{{{ 61 62 return GetSize(vector)==0 63 64 end#}}} 65 function Duplicate(vector::IssmVector)#{{{ 66 67 #Copy data structure 68 M=GetSize(vector) 69 return IssmVector(M) 70 71 end#}}} 72 function VecCopy!(x::IssmVector,y::IssmVector)#{{{ 73 74 y.vector = x.vector 75 76 end#}}} 77 function Norm(x::IssmVector,type::Int64)#{{{ 78 79 norm = 0 80 81 if type==2 82 for i in 1:length(x.vector) 83 norm += x.vector[i]^2 84 end 85 norm = sqrt(norm) 86 elseif type==3 87 #Infinite norm 88 for i in 1:length(x.vector) 89 if(abs(x.vector[i])>norm) norm = abs(x.vector[i]) end 90 end 91 else 92 error("type ",type," not supported yet") 93 end 94 95 return norm 96 97 end#}}} 60 98 61 99 #Operations
Note:
See TracChangeset
for help on using the changeset viewer.