Changeset 26686
- Timestamp:
- 12/01/21 18:34:02 (3 years ago)
- Location:
- issm/trunk-jpl/src/jl/solve
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/jl/solve/analyses/stressbalanceanalysis.jl
r26682 r26686 138 138 return pe 139 139 end #}}} 140 function GetSolutionFromInputs(analysis::StressbalanceAnalysis,ug:: Vector{Float64},element::Tria) #{{{140 function GetSolutionFromInputs(analysis::StressbalanceAnalysis,ug::IssmVector,element::Tria) #{{{ 141 141 142 142 #Get dofs for this finite element … … 156 156 157 157 count += 1 158 ug [doflist[count]] = vx158 ug.vector[doflist[count]] = vx 159 159 count += 1 160 ug [doflist[count]] = vy160 ug.vector[doflist[count]] = vy 161 161 end 162 162 -
issm/trunk-jpl/src/jl/solve/modules.jl
r26682 r26686 125 125 126 126 #Initialize solution vector 127 ug = Vector{Float64}(undef,gsize)127 ug = IssmVector(gsize) 128 128 129 129 #Go through elements and plug in solution … … 135 135 136 136 end#}}} 137 function InputUpdateFromSolutionx(analysis::Analysis,ug:: Vector{Float64},femmodel::FemModel) #{{{137 function InputUpdateFromSolutionx(analysis::Analysis,ug::IssmVector,femmodel::FemModel) #{{{ 138 138 139 139 #Go through elements and plug in solution 140 140 for i=1:length(femmodel.elements) 141 InputUpdateFromSolution(analysis,ug ,femmodel.elements[i])141 InputUpdateFromSolution(analysis,ug.vector,femmodel.elements[i]) 142 142 end 143 143 … … 145 145 146 146 end#}}} 147 function Reducevectorgtofx(ug:: Vector{Float64},nodes::Vector{Node}) #{{{147 function Reducevectorgtofx(ug::IssmVector,nodes::Vector{Node}) #{{{ 148 148 149 149 #Get size of output vector … … 151 151 152 152 #Initialize output vector 153 uf = Vector{Float64}(undef,fsize)153 uf = IssmVector(fsize) 154 154 155 155 #Go through elements and plug in solution 156 156 for i=1:length(nodes) 157 VecReduce(nodes[i],ug ,uf)157 VecReduce(nodes[i],ug.vector,uf) 158 158 end 159 159 160 160 return ug 161 161 162 end#}}} 163 function Reduceloadx!(pf::IssmVector, Kfs::IssmMatrix, ys::IssmVector) #{{{ 164 165 #Is there anything to do? 166 m, n = GetSize(Kfs) 167 168 if(m*n>0) 169 170 #Allocate Kfs*ys 171 Kfsy_s=IssmVector(m) 172 173 #Perform multiplication 174 MatMult!(Kfs,ys,Kfsy_s) 175 176 #Subtract Kfs*ys from pf 177 AXPY!(pf,-1.0,Kfsy_s) 178 179 end 162 180 end#}}} 163 181 function SystemMatricesx(femmodel::FemModel,analysis::Analysis)# {{{ -
issm/trunk-jpl/src/jl/solve/nodes.jl
r26682 r26686 136 136 137 137 end# }}} 138 function VecReduce(node::Node,ug::Vector{Float64},uf:: Vector{Float64}) #{{{138 function VecReduce(node::Node,ug::Vector{Float64},uf::IssmVector) #{{{ 139 139 140 140 for i=1:node.gsize 141 141 if node.fdoflist[i]!=-1 142 uf [node.fdoflist[i]] = ug[node.gdoflist[i]]142 uf.vector[node.fdoflist[i]] = ug[node.gdoflist[i]] 143 143 end 144 144 end -
issm/trunk-jpl/src/jl/solve/solutionsequences.jl
r26682 r26686 20 20 #Enforce constraints 21 21 ys = CreateNodalConstraintsx(femmodel.nodes) 22 Reduceloadx!(pf, Kfs, ys) 22 23 23 error("not implemented yet") 24 #Solve! 25 old_uf = uf 26 uf = Solverx(Kff, pf, old_uf) 27 28 print(uf) 29 error("compare with ISSM...") 24 30 25 31 #Increase count -
issm/trunk-jpl/src/jl/solve/toolkits.jl
r26682 r26686 2 2 #Toolkit #1: serial sparse arrays 3 3 using SparseArrays 4 5 #Matrix 4 6 mutable struct IssmMatrix #{{{ 5 7 matrix::SparseMatrixCSC{Float64,Int64} … … 20 22 21 23 end#}}} 24 function GetSize(matrix::IssmMatrix)#{{{ 22 25 26 return size(matrix.matrix) 27 28 end#}}} 29 30 #Vector 23 31 mutable struct IssmVector #{{{ 24 32 vector::Vector{Float64} … … 26 34 function IssmVector(M::Int64)#{{{ 27 35 return IssmVector(zeros(M)) 36 end#}}} 37 function GetSize(vector::IssmVector)#{{{ 38 39 return length(vector.vector) 40 28 41 end#}}} 29 42 function AddValues!(vector::IssmVector,m::Int64,midx::Vector{Int64},values::Vector{Float64})#{{{ … … 45 58 46 59 end#}}} 60 61 #Operations 62 function MatMult!(A::IssmMatrix,x::IssmVector,y::IssmVector) #{{{ 63 64 y.vector = A.matrix*x.vector 65 66 end#}}} 67 function AXPY!(y::IssmVector,alpha::Float64,x::IssmVector) #{{{ 68 69 y.vector = alpha*x.vector + y.vector 70 71 end#}}} 72 function Solverx(A::IssmMatrix,b::IssmVector,xold::IssmVector) #{{{ 73 74 x = IssmVector(GetSize(xold)) 75 x.vector = (b.vector\A.matrix)' #not sure why we need to transpose... that's a mystery! 76 77 return x 78 79 80 end#}}} 81
Note:
See TracChangeset
for help on using the changeset viewer.