Changeset 26710
- Timestamp:
- 12/06/21 12:48:51 (3 years ago)
- Location:
- issm/trunk-jpl/src/jl/solve
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/jl/solve/analyses/stressbalanceanalysis.jl
r26706 r26710 177 177 178 178 if(IsIcefront(element)) 179 error("not supported") 179 A = zeros(6) 180 181 #Get additional parameters and inputs 182 b_input = GetInput(element, BaseEnum) 183 rho_water = FindParam(element, MaterialsRhoSeawaterEnum) 184 185 #Get normal and ice front coordinates 186 xyz_list_front = Matrix{Float64}(undef,2,3) 187 GetIcefrontCoordinates!(element, xyz_list_front, xyz_list, MaskIceLevelsetEnum) 188 nx, ny = NormalSection(element, xyz_list_front) 189 #println("nx ",nx," ny:",ny) 190 191 gauss = GaussTria(element, xyz_list, xyz_list_front, 3) 192 for ig in 1:gauss.numgauss 193 194 Jdet = JacobianDeterminantSurface(xyz_list_front, gauss) 195 NodalFunctions(element, basis, gauss, ig, P1Enum) 196 197 H = GetInputValue(H_input, gauss, ig) 198 b = GetInputValue(b_input, gauss, ig) 199 sl = 0 200 201 term = 0.5*g*rho_ice*H^2 + 0.5*g*rho_water*(min(0, H+b-sl)^2 - min(0, b-sl)^2) 202 203 for i in 1:numnodes 204 #println("1: ",gauss.weights[ig]*Jdet*term*nx*basis[i]," 2: ",gauss.weights[ig]*Jdet*term*ny*basis[i]) 205 pe.values[2*i-1] += gauss.weights[ig]*Jdet*term*nx*basis[i] 206 pe.values[2*i ] += gauss.weights[ig]*Jdet*term*ny*basis[i] 207 A[2*i-1] += gauss.weights[ig]*Jdet*term*nx*basis[i] 208 A[2*i ] += gauss.weights[ig]*Jdet*term*ny*basis[i] 209 end 210 end 211 #error("S") 212 display(A) 180 213 end 181 214 -
issm/trunk-jpl/src/jl/solve/elements.jl
r26706 r26710 176 176 end 177 177 end#}}} 178 function GetIcefrontCoordinates!(element::Tria, xyz_front::Matrix{Float64}, xyz_list::Matrix{Float64}, levelsetenum::IssmEnum) #{{{ 179 180 #Intermediaries 181 level = Vector{Float64}(undef,3) 182 indicesfront = Vector{Int64}(undef,3) 183 184 #Recover value of levelset for all vertices 185 GetInputListOnVertices!(element, level, levelsetenum) 186 187 #Get nodes where there is no ice 188 num_frontnodes = 0 189 for i in 1:3 190 if(level[i]>=0.) 191 num_frontnodes += 1 192 indicesfront[num_frontnodes] = i 193 end 194 end 195 @assert num_frontnodes==2 196 197 #Arrange order of frontnodes such that they are oriented counterclockwise 198 NUMVERTICES = 3 199 if((NUMVERTICES+indicesfront[1]-indicesfront[2])%NUMVERTICES != NUMVERTICES-1) 200 index=indicesfront[1] 201 indicesfront[1]=indicesfront[2] 202 indicesfront[2]=index 203 end 204 205 #Return nodes 206 xyz_front[1,:]=xyz_list[indicesfront[1],:] 207 xyz_front[2,:]=xyz_list[indicesfront[2],:] 208 209 end#}}} 210 function GetArea(element::Tria)#{{{ 211 212 #Get xyz list 213 xyz_list = GetVerticesCoordinates(element.vertices) 214 x1 = xyz_list[1,1]; y1 = xyz_list[1,2] 215 x2 = xyz_list[2,1]; y2 = xyz_list[2,2] 216 x3 = xyz_list[3,1]; y3 = xyz_list[3,2] 217 218 @assert x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1>0 219 return (x2*y3 - y2*x3 + x1*y2 - y1*x2 + x3*y1 - y3*x1)/2 220 end#}}} 221 function NormalSection(element::Tria, xyz_front::Matrix{Float64}) #{{{ 222 223 #Build output pointing vector 224 nx = xyz_front[2,2] - xyz_front[1,2] 225 ny = -xyz_front[2,1] + xyz_front[1,1] 226 227 #normalize 228 norm = sqrt(nx^2 + ny^2) 229 nx = nx/norm 230 ny = ny/norm 231 232 return nx, ny 233 end#}}} 178 234 179 235 #Finite Element stuff … … 185 241 #Get its determinant 186 242 Jdet = Matrix2x2Determinant(J) 243 244 #check and return 245 if(Jdet<0) error("negative Jacobian Determinant") end 246 return Jdet 247 248 end#}}} 249 function JacobianDeterminantSurface(xyz_list::Matrix{Float64}, gauss::GaussTria) #{{{ 250 251 x1 = xyz_list[1,1]; y1 = xyz_list[1,2] 252 x2 = xyz_list[2,1]; y2 = xyz_list[2,2] 253 Jdet = .5*sqrt((x2-x1)^2 + (y2-y1)^2) 187 254 188 255 #check and return … … 281 348 end 282 349 end#}}} 350 function GaussTria(element::Tria, xyz_list::Matrix{Float64}, xyz_list_front::Matrix{Float64}, order::Int64) #{{{ 351 352 area_coordinates = Matrix{Float64}(undef,2,3) 353 GetAreaCoordinates!(element, area_coordinates, xyz_list_front, xyz_list) 354 355 return GaussTria(area_coordinates, order) 356 end# }}} 357 function GetAreaCoordinates!(element::Tria, area_coordinates::Matrix{Float64}, xyz_zero::Matrix{Float64}, xyz_list::Matrix{Float64})#{{{ 358 359 numpoints = size(area_coordinates,1) 360 area = GetArea(element) 361 362 #Copy original xyz_list 363 xyz_bis=copy(xyz_list) 364 for i in 1:numpoints 365 for j in 1:3 366 367 #Change appropriate line 368 xyz_bis[j,:] = xyz_zero[i,:] 369 370 #Compute area fraction 371 area_portion=abs(xyz_bis[2,1]*xyz_bis[3,2] - xyz_bis[2,2]*xyz_bis[3,1] + xyz_bis[1,1]*xyz_bis[2,2] - xyz_bis[1,2]*xyz_bis[2,1] + xyz_bis[3,1]*xyz_bis[1,2] - xyz_bis[3,2]*xyz_bis[1,1])/2 372 area_coordinates[i,j] = area_portion/area 373 374 #reinitialize xyz_list 375 xyz_bis[j,:] = xyz_list[j,:] 376 end 377 end 378 end #}}} -
issm/trunk-jpl/src/jl/solve/gauss.jl
r26659 r26710 7 7 coords3::Vector{Float64} 8 8 end #}}} 9 function Base.show(io::IO, this::GaussTria)# {{{ 10 11 println(io,"GaussTria:") 12 println(io," numgauss: ",this.numgauss) 13 println(io," weights: ",this.weights) 14 println(io," coords1: ",this.coords1) 15 println(io," coords2: ",this.coords2) 16 println(io," coords3: ",this.coords3) 17 end# }}} 9 18 10 19 #Gauss constructor … … 60 69 return GaussTria(npoints,weights,coords1,coords2,coords3) 61 70 end# }}} 71 function GaussTria(area_coordinates::Matrix{Float64}, order::Int64) #{{{ 72 #=Gauss-Legendre quadrature points. 73 74 The recurrence coefficients for Legendre polynomials on (-1,1) 75 are defined (from the ORTHPOL subroutine RECUR with ipoly=1) as: 76 77 alpha(i)=0. 78 beta (i)=1./(4.-1./(i-1)^2)) 79 80 For degree p, the required number of Gauss-Legendre points is 81 n>=(p+1)/2.=# 82 83 if(order==1) 84 npoint = 1 85 weights = [2.000000000000000] 86 coords = [0.000000000000000] 87 elseif(order==2) 88 npoints = 2 89 weights = [1.000000000000000, 1.000000000000000] 90 coords = [-0.577350269189626, 0.577350269189626] 91 elseif(order==3) 92 npoints = 3 93 weights = [0.555555555555556, 0.888888888888889, 0.555555555555556] 94 coords = [-0.774596669241483, 0.000000000000000, 0.774596669241483] 95 elseif(order==4) 96 npoints = 4 97 weights = [0.347854845137454, 0.652145154862546, 0.652145154862546, 0.347854845137454] 98 coords = [-0.861136311594053,-0.339981043584856, 0.339981043584856, 0.861136311594053] 99 else 100 error("order ",order," not supported yet"); 101 end 102 103 coords1 = Vector{Float64}(undef,npoints) 104 coords2 = Vector{Float64}(undef,npoints) 105 coords3 = Vector{Float64}(undef,npoints) 106 for i in 1:npoints 107 coords1[i] = 0.5*(area_coordinates[1,1]+area_coordinates[2,1]) + 0.5*coords[i]*(area_coordinates[2,1]-area_coordinates[1,1]); 108 coords2[i] = 0.5*(area_coordinates[1,2]+area_coordinates[2,2]) + 0.5*coords[i]*(area_coordinates[2,2]-area_coordinates[1,2]); 109 coords3[i] = 0.5*(area_coordinates[1,3]+area_coordinates[2,3]) + 0.5*coords[i]*(area_coordinates[2,3]-area_coordinates[1,3]); 110 end 111 112 return GaussTria(npoints, weights, coords1, coords2, coords3) 113 end# }}} -
issm/trunk-jpl/src/jl/solve/solutionsequences.jl
r26702 r26710 35 35 #Increase count 36 36 count += 1 37 if(count> maxiter)37 if(count>=maxiter) 38 38 println(" maximum number of nonlinear iterations (",maxiter,") exceeded") 39 39 converged = true
Note:
See TracChangeset
for help on using the changeset viewer.