Changeset 26703
- Timestamp:
- 12/03/21 07:51:10 (3 years ago)
- Location:
- issm/trunk-jpl/src/jl
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/jl/md/classes.jl
r26629 r26703 15 15 end# }}} 16 16 function Base.show(io::IO, this::Mesh2dTriangle)# {{{ 17 18 println(io,typeof(this),":") 19 for name in fieldnames(typeof(this)) 20 a=getfield(this,name) 21 #print(io," $(name) = ") 22 @printf "%19s: " name 23 if isa(a,String) 24 println(io, a) 25 elseif length(a)>1 26 if !isempty(a) 27 println(io, typeof(a), " of size ", size(a)) 28 else 29 println(io,"empty") 30 end 31 else 32 println(io, a) 33 end 34 end 17 IssmStructDisp(io, this) 35 18 end# }}} 36 19 mutable struct Mesh3dPrism{T} <: AbstractMesh … … 66 49 return Mask( Vector{Float64}(undef,0), Vector{Float64}(undef,0)) 67 50 end# }}} 51 function Base.show(io::IO, this::Mask)# {{{ 52 IssmStructDisp(io, this) 53 end# }}} 68 54 69 55 mutable struct Initialization … … 87 73 end# }}} 88 74 function Base.show(io::IO, this::Stressbalance)# {{{ 89 90 println(io,typeof(this),":") 91 for name in fieldnames(typeof(this)) 92 a=getfield(this,name) 93 #print(io," $(name) = ") 94 @printf "%19s: " name 95 if isa(a,String) 96 println(io, a) 97 elseif length(a)>1 98 if !isempty(a) 99 println(io, typeof(a), " of size ", size(a)) 100 else 101 println(io,"empty") 102 end 103 else 104 println(io, a) 105 end 106 end 75 IssmStructDisp(io, this) 107 76 end# }}} 108 77 … … 137 106 end# }}} 138 107 108 abstract type AbstractFriction end 109 mutable struct BuddFriction <: AbstractFriction 110 coefficient::Vector{Float64} 111 end 112 function BuddFriction() #{{{ 113 return BuddFriction(Vector{Float64}(undef,0)) 114 end# }}} 115 function Base.show(io::IO, this::BuddFriction)# {{{ 116 IssmStructDisp(io, this) 117 end# }}} 118 mutable struct WeertmanFriction <: AbstractFriction 119 C::Vector{Float64} 120 m::Vector{Float64} 121 end 122 139 123 mutable struct model 140 124 mesh::AbstractMesh … … 145 129 stressbalance::Stressbalance 146 130 constants::Constants 131 results 132 friction::AbstractFriction 147 133 end 148 134 function model() #{{{ 149 return model( Mesh2dTriangle(), Geometry(), Mask(), Materials(), Initialization(),Stressbalance(), Constants() )135 return model( Mesh2dTriangle(), Geometry(), Mask(), Materials(), Initialization(),Stressbalance(), Constants(), [], BuddFriction()) 150 136 end#}}} 151 137 function Base.show(io::IO, md::model)# {{{ … … 161 147 @printf "%19s: %-26s -- %s\n" "stressbalance" typeof(md.stressbalance) "stress balance parameters" 162 148 @printf "%19s: %-26s -- %s\n" "constants" typeof(md.constants) "physical constants" 149 @printf "%19s: %-26s -- %s\n" "friction" typeof(md.friction) "basal friction" 163 150 164 151 end# }}} -
issm/trunk-jpl/src/jl/md/utils.jl
r26629 r26703 107 107 return md 108 108 end #}}} 109 function IssmStructDisp(io::IO, modelfield::Any) # {{{ 110 println(io,typeof(modelfield),":") 111 for name in fieldnames(typeof(modelfield)) 112 a=getfield(modelfield,name) 113 #print(io," $(name) = ") 114 @printf "%19s: " name 115 if isa(a,String) 116 println(io, a) 117 elseif length(a)>1 118 if !isempty(a) 119 println(io, typeof(a), " of size ", size(a)) 120 else 121 println(io,"empty") 122 end 123 else 124 println(io, a) 125 end 126 end 127 end #}}} -
issm/trunk-jpl/src/jl/solve/analyses/stressbalanceanalysis.jl
r26702 r26703 176 176 #Now split solution vector into x and y components 177 177 numnodes = 3 178 vx= Vector{Float64}(undef,numnodes) 179 vy= Vector{Float64}(undef,numnodes) 178 vx = Vector{Float64}(undef,numnodes) 179 vy = Vector{Float64}(undef,numnodes) 180 vel = Vector{Float64}(undef,numnodes) 180 181 for i in 1:numnodes 181 182 vx[i]=values[2*i-1] … … 183 184 @assert isfinite(vx[i]) 184 185 @assert isfinite(vy[i]) 186 187 vel[i] =sqrt(vx[i]^2 + vy[i]^2) 185 188 end 186 189 187 AddInput(element,VxEnum,vx,P1Enum) 188 AddInput(element,VyEnum,vy,P1Enum) 190 AddInput(element, VxEnum, vx, P1Enum) 191 AddInput(element, VyEnum, vy, P1Enum) 192 AddInput(element, VelEnum, vel, P1Enum) 189 193 end#}}} -
issm/trunk-jpl/src/jl/solve/femmodel.jl
r26629 r26703 8 8 constraints::Vector{Constraint} 9 9 #loads::Vector{Loads} 10 results::Vector{Result} 10 11 end#}}} 11 12 -
issm/trunk-jpl/src/jl/solve/modules.jl
r26702 r26703 12 12 nodes = Vector{Node}(undef,0) 13 13 constraints = Vector{Constraint}(undef,0) 14 results = Vector{Result}(undef,0) 14 15 parameters = Parameters(Dict{IssmEnum,Parameter}()) 15 16 inputs = Inputs(md.mesh.numberofelements,md.mesh.numberofvertices,Dict{IssmEnum,Input}()) … … 36 37 37 38 #Build FemModel 38 return FemModel(elements, vertices,nodes,parameters,inputs,constraints)39 return FemModel(elements, vertices, nodes, parameters, inputs, constraints, results) 39 40 end# }}} 40 41 function CreateElements(elements::Vector{Tria},md::model) #{{{ … … 80 81 AddParam(parameters,md.materials.rho_freshwater,MaterialsRhoFreshwaterEnum) 81 82 AddParam(parameters,md.constants.g,ConstantsGEnum) 83 84 #Set step and time, this will be overwritten if we run a transient 85 AddParam(parameters,1,StepEnum) 86 AddParam(parameters,0.0,TimeEnum) 82 87 end# }}} 83 88 function CreateInputs(inputs::Inputs,elements::Vector{Tria},md::model) #{{{ … … 86 91 FetchDataToInput(md,inputs,elements,md.materials.rheology_B,MaterialsRheologyBEnum) 87 92 FetchDataToInput(md,inputs,elements,md.materials.rheology_n,MaterialsRheologyNEnum) 93 end# }}} 94 function OutputResultsx(femmodel::FemModel, md::model)# {{{ 95 96 md.results = Dict("Stressbalance"=> femmodel.results) 97 88 98 end# }}} 89 99 … … 224 234 function RequestedOutputsx(femmodel::FemModel,outputlist::Vector{IssmEnum})# {{{ 225 235 226 error("not implemented") 227 end# }}} 236 #Get Step and Time from parameters 237 step = FindParam(femmodel.parameters,StepEnum) 238 time = FindParam(femmodel.parameters,TimeEnum) 239 240 #Now fetch results 241 for i in 1:length(outputlist) 242 243 #See if outputlist[i] is an input 244 if outputlist[i]>InputsSTARTEnum && outputlist[i]<InputsENDEnum 245 246 #Create Result 247 input = GetInput(femmodel.inputs,outputlist[i]) 248 result = Result(step, time, copy(input.values)) 249 250 #Add to femmodel.results dataset 251 push!(femmodel.results,result) 252 253 else 254 println("Output ",outputlist[i]," not supported yet") 255 end 256 end 257 end# }}} -
issm/trunk-jpl/src/jl/solve/solve.jl
r26702 r26703 9 9 include("./elements.jl") 10 10 include("./constraints.jl") 11 include("./results.jl") 11 12 include("./matice.jl") 12 13 include("./femmodel.jl") … … 20 21 function IssmCore(md::model) #{{{ 21 22 23 22 24 #Construct FemModel 23 25 femmodel=ModelProcessor(md) … … 25 27 #Solve 26 28 analysis = StressbalanceAnalysis() 27 Core(analysis, femmodel)29 Core(analysis, femmodel) 28 30 29 31 #Save output 30 RequestedOutputsx(femmodel,[VxEnum,VyEnum]) 31 error("STOP") 32 RequestedOutputsx(femmodel, [VxEnum,VyEnum,VelEnum]) 33 34 #move results to md 35 OutputResultsx(femmodel, md) 32 36 33 37 end# }}} -
issm/trunk-jpl/src/jl/test101.jl
r26659 r26703 4 4 5 5 md = ISSM.model() 6 #md = ISSM.triangle(md,"../../test/Exp/Square.exp",180000.)7 md = ISSM.triangle(md,"../../test/Exp/Square.exp",250000.)6 md = ISSM.triangle(md,"../../test/Exp/Square.exp",50000.) 7 #md = ISSM.triangle(md,"../../test/Exp/Square.exp",250000.) 8 8 #md = ISSM.triangle(md,"../../test/Exp/Square.exp",1000.) 9 9 md = ISSM.setmask(md,"all","")
Note:
See TracChangeset
for help on using the changeset viewer.