Skip to content

Commit

Permalink
- improve the way we deal with scaling (use Units to convert)
Browse files Browse the repository at this point in the history
- add more parameters when adding topography
  • Loading branch information
boriskaus committed Jul 20, 2023
1 parent ba274b5 commit 314ebda
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/LaMEM_ModelGeneration/FreeSurface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Base.@kwdef mutable struct FreeSurface
surf_corr_phase::Int64 = 1

"initial level of the free surface"
surf_level::Float64 = 0.5
surf_level::Union{Float64,Nothing} = nothing

"phase ID of sticky air layer"
surf_air_phase::Int64 = 0
surf_air_phase::Union{Int64,Nothing} = nothing

"maximum angle with horizon (smoothed if larger)"
surf_max_angle::Float64 = 45.0
Expand Down
12 changes: 8 additions & 4 deletions src/LaMEM_ModelGeneration/Scaling.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ function Write_LaMEM_InputFile(io, d::Scaling)
elseif isa(d,Scaling{GeoUnits{SI}})
println(io," units = si")
end
println(io," unit_temperature = $(d.Scaling.temperature)")
println(io," unit_length = $(d.Scaling.length*1e3)")
println(io," unit_viscosity = $(d.Scaling.viscosity)")
println(io," unit_stress = $(d.Scaling.stress)")
char_T = ustrip(d.Scaling.temperature)
char_L = uconvert(u"m",d.Scaling.length);
char_η = uconvert(u"Pa*s",d.Scaling.viscosity);
char_τ = uconvert(u"Pa",d.Scaling.stress);
println(io," unit_temperature = $char_T")
println(io," unit_length = $char_L")
println(io," unit_viscosity = $char_η")
println(io," unit_stress = $char_τ")

elseif isa(d,Scaling{GeoUnits{NONE}})
println(io," units = none")
Expand Down
9 changes: 7 additions & 2 deletions src/LaMEM_ModelGeneration/Utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,12 @@ end


"""
add_topography!(model::Model, topography::CartData; surf_air_phase=0, surf_topo_file="topography.txt")
add_topography!(model::Model, topography::CartData; surf_air_phase=0, surf_topo_file="topography.txt", open_top_bound=1, surf_level=0.0)
Adds the topography surface to the model
"""
function add_topography!(model::Model, topography::CartData; surf_air_phase=0, surf_topo_file="topography.txt")
function add_topography!(model::Model, topography::CartData; surf_air_phase=0, surf_topo_file="topography.txt",
open_top_bound=1, surf_level=0.0)
if !is_rectilinear(topography)
error("topography grid must be rectilinear")
end
Expand All @@ -310,9 +311,13 @@ function add_topography!(model::Model, topography::CartData; surf_air_phase=0, s
model.FreeSurface.Topography = topography # add topo
model.FreeSurface.surf_use = 1
model.FreeSurface.surf_air_phase = surf_air_phase
model.FreeSurface.surf_level = surf_level
if isempty(model.FreeSurface.surf_topo_file)
model.FreeSurface.surf_topo_file = surf_topo_file
end

# usually we want an open top boundary when we have a free surface:
model.BoundaryConditions.open_top_bound=open_top_bound

return nothing
end

0 comments on commit 314ebda

Please sign in to comment.