[26740] | 1 | Index: ../trunk-jpl/src/jl/plotmodel.jl
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/jl/plotmodel.jl (revision 26491)
|
---|
| 4 | +++ ../trunk-jpl/src/jl/plotmodel.jl (revision 26492)
|
---|
| 5 | @@ -27,7 +27,7 @@
|
---|
| 6 | fig, ax, h = Makie.mesh( [md.mesh.x md.mesh.y], md.mesh.elements, shading = false, color = data, colormap = jet)
|
---|
| 7 |
|
---|
| 8 | #Add colorbar
|
---|
| 9 | - Colorbar(fig[1, 2], h, width=25)
|
---|
| 10 | + #Colorbar(fig[1, 2], h, width=25)
|
---|
| 11 | else
|
---|
| 12 | error("data of size "*string(length(data))*" not supported yet!")
|
---|
| 13 | end
|
---|
| 14 | Index: ../trunk-jpl/src/jl/issm.jl
|
---|
| 15 | ===================================================================
|
---|
| 16 | --- ../trunk-jpl/src/jl/issm.jl (revision 26491)
|
---|
| 17 | +++ ../trunk-jpl/src/jl/issm.jl (revision 26492)
|
---|
| 18 | @@ -12,6 +12,19 @@
|
---|
| 19 | function Mesh2dTriangle() #{{{
|
---|
| 20 | return Mesh2dTriangle( 0, 0, Vector{Float64}(undef,0), Vector{Float64}(undef, 0), Matrix{Int32}(undef, 0, 0))
|
---|
| 21 | end# }}}
|
---|
| 22 | +function Base.show(io::IO, this::Mesh2dTriangle)# {{{
|
---|
| 23 | +
|
---|
| 24 | + println(io,typeof(this),":")
|
---|
| 25 | + for name in fieldnames(typeof(this))
|
---|
| 26 | + a=getfield(this,name)
|
---|
| 27 | + print(io," $(name) = ")
|
---|
| 28 | + if !isempty(a)
|
---|
| 29 | + println(io, typeof(a), " of size ", size(a))
|
---|
| 30 | + else
|
---|
| 31 | + println(io,"empty")
|
---|
| 32 | + end
|
---|
| 33 | + end
|
---|
| 34 | +end# }}}
|
---|
| 35 | mutable struct Mesh3dPrism{T} <: AbstractMesh
|
---|
| 36 | numberofvertices::Int32
|
---|
| 37 | numberofelements::Int32
|
---|
| 38 | @@ -40,14 +53,44 @@
|
---|
| 39 | function Mask() #{{{
|
---|
| 40 | return Mask( Vector{Float64}(undef,0), Vector{Float64}(undef,0))
|
---|
| 41 | end# }}}
|
---|
| 42 | +mutable struct Initialization
|
---|
| 43 | + vx::Vector{Float64}
|
---|
| 44 | + vy::Vector{Float64}
|
---|
| 45 | +end
|
---|
| 46 | +function Initialization() #{{{
|
---|
| 47 | + return Initialization( Vector{Float64}(undef,0), Vector{Float64}(undef,0))
|
---|
| 48 | +end# }}}
|
---|
| 49 | +mutable struct Materials
|
---|
| 50 | + rho_ice::Float64
|
---|
| 51 | + rho_water::Float64
|
---|
| 52 | + rho_freshwater::Float64
|
---|
| 53 | + mu_water::Float64
|
---|
| 54 | + heatcapacity::Float64
|
---|
| 55 | + latentheat::Float64
|
---|
| 56 | + thermalconductivity::Float64
|
---|
| 57 | + temperateiceconductivity::Float64
|
---|
| 58 | + effectiveconductivity_averaging::Int32
|
---|
| 59 | + meltingpoint::Float64
|
---|
| 60 | + beta::Float64
|
---|
| 61 | + mixed_layer_capacity::Float64
|
---|
| 62 | + thermal_exchange_velocity::Float64
|
---|
| 63 | + rheology_B::Vector{Float64}
|
---|
| 64 | + rheology_n::Vector{Float64}
|
---|
| 65 | + rheology_law::String
|
---|
| 66 | +end
|
---|
| 67 | +function Materials() #{{{
|
---|
| 68 | + return Materials(917., 1023., 1000., 0.001787, 2093., 3.34*10^5, 2.4, .24, 1, 273.15, 9.8*10^-8, 3974., 1.00*10^-4, Vector{Float64}(undef,0), Vector{Float64}(undef,0), "Cuffey")
|
---|
| 69 | +end# }}}
|
---|
| 70 |
|
---|
| 71 | mutable struct model
|
---|
| 72 | mesh::AbstractMesh
|
---|
| 73 | geometry::Geometry
|
---|
| 74 | mask::Mask
|
---|
| 75 | + materials::Materials
|
---|
| 76 | + initialization::Initialization
|
---|
| 77 | end
|
---|
| 78 | function model() #{{{
|
---|
| 79 | - return model( Mesh2dTriangle(), Geometry(), Mask())
|
---|
| 80 | + return model( Mesh2dTriangle(), Geometry(), Mask(), Materials(), Initialization())
|
---|
| 81 | end#}}}
|
---|
| 82 | function Base.show(io::IO, md::model)# {{{
|
---|
| 83 |
|
---|
| 84 | @@ -57,12 +100,58 @@
|
---|
| 85 | @printf "%19s: %-22s -- %s\n" "mesh" typeof(md.mesh) "mesh properties"
|
---|
| 86 | @printf "%19s: %-22s -- %s\n" "geometry" typeof(md.geometry) "surface elevation, bedrock topography, ice thickness,..."
|
---|
| 87 | @printf "%19s: %-22s -- %s\n" "mask" typeof(md.mask) "defines grounded and floating regions"
|
---|
| 88 | + @printf "%19s: %-22s -- %s\n" "materials" typeof(md.materials) "material properties"
|
---|
| 89 | + @printf "%19s: %-22s -- %s\n" "initialization" typeof(md.initialization) "initial state"
|
---|
| 90 |
|
---|
| 91 | end# }}}
|
---|
| 92 |
|
---|
| 93 | -# Probably actually want something more like:
|
---|
| 94 | -# function solve(mesh::AbstractMesh, data::AbstractDataset)
|
---|
| 95 | -# do_something_with_mesh(mesh) # This will dispatch
|
---|
| 96 | -# do_something_with_data(data) # This will dispatch
|
---|
| 97 | -# # do something
|
---|
| 98 | -# end
|
---|
| 99 | +#utils
|
---|
| 100 | +function issmdir() #{{{
|
---|
| 101 | + issmdir = ENV["ISSM_DIR"]
|
---|
| 102 | +
|
---|
| 103 | + if isempty(issmdir)
|
---|
| 104 | + error("Could not determine the location of ISSM")
|
---|
| 105 | + else
|
---|
| 106 | + return issmdir
|
---|
| 107 | + end
|
---|
| 108 | +end#}}}
|
---|
| 109 | +function archread(filename::String,variablename::String) #{{{
|
---|
| 110 | +
|
---|
| 111 | + #initialize variables
|
---|
| 112 | + found = false
|
---|
| 113 | +
|
---|
| 114 | + #open file
|
---|
| 115 | + output = open(filename, "r") do f
|
---|
| 116 | +
|
---|
| 117 | + while !eof(f)
|
---|
| 118 | + reclen = bswap(read(f, Int32))
|
---|
| 119 | + rectype = bswap(read(f, Int32))
|
---|
| 120 | + if rectype!=1
|
---|
| 121 | + error("Expected variable of type string")
|
---|
| 122 | + else
|
---|
| 123 | + fieldname_length = bswap(read(f, Int32))
|
---|
| 124 | + field_name = String(read(f, fieldname_length))
|
---|
| 125 | + end
|
---|
| 126 | + rec_length = bswap(read(f, Int32))
|
---|
| 127 | + field_type = bswap(read(f, Int32))
|
---|
| 128 | + if field_type==2
|
---|
| 129 | + data = bswap(read(f, Float64))
|
---|
| 130 | + elseif field_type==3
|
---|
| 131 | + rows = bswap(read(f, Int32))
|
---|
| 132 | + cols = bswap(read(f, Int32))
|
---|
| 133 | + data = reinterpret(Float64, read(f, sizeof(Float64)*rows*cols))
|
---|
| 134 | + data .= ntoh.(data)
|
---|
| 135 | + data = reshape(data, (rows,cols))
|
---|
| 136 | + else
|
---|
| 137 | + error("Error: Encountered invalid field type when reading data.")
|
---|
| 138 | + end
|
---|
| 139 | +
|
---|
| 140 | + if field_name == variablename
|
---|
| 141 | + found = true
|
---|
| 142 | + return data
|
---|
| 143 | + end
|
---|
| 144 | + end
|
---|
| 145 | + end
|
---|
| 146 | +
|
---|
| 147 | + return output
|
---|
| 148 | +end# }}}
|
---|