Changeset 26738
- Timestamp:
- 12/17/21 12:21:15 (3 years ago)
- Location:
- issm/trunk-jpl/src/jl/core
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/jl/core/analyses/masstransportanalysis.jl
r26736 r26738 22 22 numdof = 1 23 23 for i in 1:md.mesh.numberofvertices 24 push!(nodes,Node(i,i,true, numdof,-ones(Int64,numdof), ones(Int64,numdof), -ones(Int64,numdof), zeros(numdof)))24 push!(nodes,Node(i,i,true,true,numdof,-ones(Int64,numdof), ones(Int64,numdof), -ones(Int64,numdof), zeros(numdof))) 25 25 end 26 26 end#}}} … … 70 70 end #}}} 71 71 function CreateKMatrix(analysis::MasstransportAnalysis,element::Tria)# {{{ 72 73 #Return if there is no ice in this element 74 if(!IsIceInElement(element)) return end 72 75 73 76 #Internmediaries … … 136 139 end #}}} 137 140 function CreatePVector(analysis::MasstransportAnalysis,element::Tria)# {{{ 141 142 #Return if there is no ice in this element 143 if(!IsIceInElement(element)) return end 138 144 139 145 #Internmediaries … … 265 271 AddInput(element, BaseEnum, newbase, P1Enum) 266 272 end#}}} 273 function UpdateConstraints(analysis::MasstransportAnalysis, femmodel::FemModel) #{{{ 274 SetActiveNodesLSMx(femmodel) 275 end#}}} -
issm/trunk-jpl/src/jl/core/analyses/stressbalanceanalysis.jl
r26731 r26738 27 27 numdof = 2 28 28 for i in 1:md.mesh.numberofvertices 29 push!(nodes,Node(i,i,true, numdof,-ones(Int64,numdof), ones(Int64,numdof), -ones(Int64,numdof), zeros(numdof)))29 push!(nodes,Node(i,i,true,true,numdof,-ones(Int64,numdof), ones(Int64,numdof), -ones(Int64,numdof), zeros(numdof))) 30 30 end 31 31 end#}}} … … 91 91 function CreateKMatrix(analysis::StressbalanceAnalysis,element::Tria)# {{{ 92 92 93 if(!IsIceInElement(element)) return end 94 93 95 #Internmediaries 94 96 numnodes = 3 … … 153 155 end #}}} 154 156 function CreatePVector(analysis::StressbalanceAnalysis,element::Tria)# {{{ 157 158 if(!IsIceInElement(element)) return end 155 159 156 160 #Internmediaries … … 271 275 AddInput(element, VelEnum, vel, P1Enum) 272 276 end#}}} 277 function UpdateConstraints(analysis::StressbalanceAnalysis, femmodel::FemModel) #{{{ 278 SetActiveNodesLSMx(femmodel) 279 end#}}} -
issm/trunk-jpl/src/jl/core/elements.jl
r26736 r26738 46 46 end 47 47 end #}}} 48 function InputUpdateFromVector(element::Tria, vector::Vector{Float64}, enum::IssmEnum, layout::IssmEnum) #{{{ 49 50 lidlist = element.vertexids 51 data = Vector{Float64}(undef, 3) 52 53 if(layout==VertexSIdEnum) 54 for i in 1:3 55 data[i] = vector[element.vertices[i].sid] 56 @assert isfinite(data[i]) 57 end 58 SetTriaInput(element.inputs, enum, P1Enum, lidlist, data) 59 else 60 error("layout ", layout, " not supported yet"); 61 end 62 end #}}} 48 63 function Update(element::Tria, inputs::Inputs, index::Int64, md::model, finiteelement::IssmEnum) #{{{ 49 64 … … 108 123 InputServe!(element,input) 109 124 return input 125 126 end # }}} 127 function GetInputListOnNodes!(element::Tria, vector::Vector{Float64}, enum::IssmEnum) # {{{ 128 129 #Get Input first 130 input = GetInput(element, enum) 131 132 #Get value at each vertex (i.e. P1 Nodes) 133 gauss=GaussTria(P1Enum) 134 for i in 1:gauss.numgauss 135 vector[i] = GetInputValue(input, gauss, i) 136 end 110 137 111 138 end # }}} … … 197 224 end 198 225 end#}}} 226 function IsIceInElement(element::Tria) #{{{ 227 #We consider that an element has ice if at least one of its nodes has a negative level set 228 229 input=GetInput(element, MaskIceLevelsetEnum) 230 231 if GetInputMin(input)<0 232 return true 233 else 234 return false 235 end 236 237 end#}}} 199 238 function GetIcefrontCoordinates!(element::Tria, xyz_front::Matrix{Float64}, xyz_list::Matrix{Float64}, levelsetenum::IssmEnum) #{{{ 200 239 -
issm/trunk-jpl/src/jl/core/inputs.jl
r26731 r26738 109 109 110 110 end#}}} 111 function GetInputMin(input::ElementInput) #{{{ 112 113 return minimum(input.element_values) 114 115 end#}}} 111 116 function GetInputValue(input::ElementInput,gauss::GaussTria,i::Int64) #{{{ 112 117 -
issm/trunk-jpl/src/jl/core/modules.jl
r26736 r26738 49 49 #Configure objects 50 50 ConfigureObjectx(elements, nodes[i], vertices, parameters, inputs, i) 51 52 #Constrain and Number nodes53 SpcNodesx(nodes[i], constraints[i], parameters)54 NodesDofx(nodes[i], parameters)55 51 end 56 52 57 53 #Build FemModel 58 return FemModel(analyses, elements, vertices, 59 Vector{Node}(undef,0), nodes, 60 parameters, inputs, 61 Vector{Constraint}(undef,0), constraints, 62 results) 54 femmodel = FemModel(analyses, elements, vertices, 55 Vector{Node}(undef,0), nodes, 56 parameters, inputs, 57 Vector{Constraint}(undef,0), constraints, 58 results) 59 60 println(" detecting active vertices") 61 GetMaskOfIceVerticesLSMx0(femmodel) 62 63 return femmodel 64 63 65 end# }}} 64 66 function CreateElements(elements::Vector{Tria},md::model) #{{{ … … 205 207 206 208 end#}}} 209 function InputUpdateFromVectorx(femmodel::FemModel, vector::Vector{Float64}, enum::IssmEnum, layout::IssmEnum) 210 211 #Go through elements and plug in solution 212 for i=1:length(femmodel.elements) 213 InputUpdateFromVector(femmodel.elements[i], vector, enum, layout) 214 end 215 216 end#}}} 207 217 function InputDuplicatex(femmodel::FemModel, oldenum::IssmEnum, newenum::IssmEnum) #{{{ 208 218 DuplicateInput(femmodel.inputs, oldenum, newenum) … … 266 276 pe = CreatePVector(analysis,femmodel.elements[i]) 267 277 268 AddToGlobal!(Ke,Kff,Kfs)269 AddToGlobal!(pe,pf)278 if(!isnothing(Ke)) AddToGlobal!(Ke,Kff,Kfs) end 279 if(!isnothing(pe)) AddToGlobal!(pe,pf) end 270 280 end 271 281 … … 320 330 321 331 end# }}} 332 function UpdateConstraintsx(femmodel::FemModel, analysis::Analysis)# {{{ 333 334 #First, see if the analysis needs to change constraints 335 UpdateConstraints(analysis, femmodel) 336 337 #Second, constraints might be time dependent 338 SpcNodesx(femmodel.nodes, femmodel.constraints, femmodel.parameters) 339 340 #Now, update degrees of freedoms 341 NodesDofx(femmodel.nodes, femmodel.parameters) 342 343 end# }}} 344 function SetActiveNodesLSMx(femmodel::FemModel) #{{{ 345 346 #Check mask of each element to see if element is active 347 numnodes = 3 348 mask = Vector{Float64}(undef, numnodes) 349 for i in 1:length(femmodel.elements) 350 GetInputListOnNodes!(femmodel.elements[i], mask, IceMaskNodeActivationEnum) 351 for j in 1:numnodes 352 node = femmodel.elements[i].nodes[j] 353 if(mask[j]==1.) Activate!(node) 354 else Deactivate!(node) 355 end 356 end 357 358 end 359 end#}}} 360 function GetMaskOfIceVerticesLSMx0(femmodel::FemModel) #{{{ 361 362 #Initialize vector with number of vertices 363 numvertices=length(femmodel.vertices) 364 if(numvertices==0) return end 365 366 #Initialize vector 367 nbv = 3 368 onesvec = ones(nbv) 369 vec_mask_ice = IssmVector(numvertices) 370 vertexids = Vector{Int64}(undef, nbv) 371 372 #Assign values to vector 373 for i in 1:length(femmodel.elements) 374 if (IsIceInElement(femmodel.elements[i])) 375 for j in 1:nbv 376 vertexids[j] = femmodel.elements[i].vertices[j].sid 377 end 378 SetValues!(vec_mask_ice, nbv, vertexids, onesvec) 379 end 380 end 381 Assemble!(vec_mask_ice) 382 383 #Serialize vector 384 vec_mask_ice_serial = ToSerial(vec_mask_ice) 385 386 #Update IceMaskNodeActivationEnum in elements 387 InputUpdateFromVectorx(femmodel, vec_mask_ice_serial, IceMaskNodeActivationEnum, VertexSIdEnum) 388 end#}}} -
issm/trunk-jpl/src/jl/core/nodes.jl
r26698 r26738 4 4 sid::Int64 5 5 indexingupdate::Bool 6 active::Bool 6 7 gsize::Int64 7 8 gdoflist::Vector{Int64} … … 24 25 println(io," svalues: ",this.svalues) 25 26 end# }}} 27 function Activate!(node::Node) #{{{ 28 29 if(!node.active) 30 node.indexingupdate = true 31 node.active = true 32 for i in 1:node.gsize 33 node.fdoflist[i] = +1 34 node.sdoflist[i] = -1 35 node.svalues[i] = 0.0 36 end 37 end 38 39 end# }}} 40 function Deactivate!(node::Node) #{{{ 41 42 if(node.active) 43 node.indexingupdate = true 44 node.active = false 45 for i in 1:node.gsize 46 node.fdoflist[i] = -1 47 node.sdoflist[i] = +1 48 node.svalues[i] = 0.0 49 end 50 end 51 52 end# }}} 26 53 function ApplyConstraint(node::Node,dof::Int8,value::Float64) #{{{ 27 54 … … 42 69 43 70 if setenum==GsetEnum 44 for i =1:node.gsize71 for i in 1:node.gsize 45 72 node.gdoflist[i] = dofcount 46 73 dofcount += 1 47 74 end 48 75 elseif setenum==FsetEnum 49 for i =1:node.gsize76 for i in 1:node.gsize 50 77 if node.fdoflist[i]!=-1 51 78 @assert node.sdoflist[i]==-1 … … 55 82 end 56 83 elseif setenum==SsetEnum 57 for i =1:node.gsize84 for i in 1:node.gsize 58 85 if node.sdoflist[i]!=-1 59 86 @assert node.fdoflist[i]==-1 -
issm/trunk-jpl/src/jl/core/solutionsequences.jl
r26731 r26738 1 1 function solutionsequence_linear(femmodel::FemModel,analysis::Analysis) # {{{ 2 3 #First, update constraints in case the levelset has changed 4 UpdateConstraintsx(femmodel, analysis) 2 5 3 6 #Get new matrices … … 20 23 end# }}} 21 24 function solutionsequence_nonlinear(femmodel::FemModel,analysis::Analysis,maxiter::Int64,restol::Float64,reltol::Float64,abstol::Float64) # {{{ 25 26 #First, update constraints in case the levelset has changed 27 UpdateConstraintsx(femmodel, analysis) 22 28 23 29 #Initialize number of iterations -
issm/trunk-jpl/src/jl/core/toolkits.jl
r26731 r26738 92 92 93 93 end#}}} 94 function ToSerial(vector::IssmVector)#{{{ 95 96 return vector.vector 97 98 end#}}} 94 99 function Norm(x::IssmVector,type::Int64)#{{{ 95 100
Note:
See TracChangeset
for help on using the changeset viewer.