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