Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify warning in case SLEVE scale height is poorly specified, add test. #1353

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Hypsography/Hypsography.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,8 @@ function ExtrudedFiniteDifferenceSpace(
@assert s >= FT(0)
η = @. z_ref ./ z_top
if s * z_top <= maximum(z_surface)
@warn "Decay scale (s*z_top = $(s*z_top)) must be higher than max surface elevation (max(z_surface) = $(maximum(z_surface))).
\n Returning (5/3)*max(zₛ)"
s = @. maximum(z_surface) / z_top * eltype(z_surface) * (5 // 3)
@warn "Decay scale (s*z_top = $(s*z_top)) must be higher than max surface elevation (max(z_surface) = $(maximum(z_surface))). Returning s = FT(0.8). Scale height is therefore s=$(0.8 * z_top) m."
s = @. FT(8 / 10)
end
fZ_data = @. ifelse(
η <= ηₕ,
Expand Down
46 changes: 46 additions & 0 deletions test/Spaces/terrain_warp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -466,3 +466,49 @@ end
end
end
end
@testset "Interior Mesh `Adaption`: Test Warnings" begin
# Test interior mesh in different adaptation types
for meshadapt in (Hypsography.SLEVEAdaption,)
for FT in (Float32, Float64)
xlim = (FT(0), FT(π))
zlim = (FT(0), FT(1))
nl = 10
np = 3
nh = 4
vertdomain = Domains.IntervalDomain(
Geometry.ZPoint{FT}(zlim[1]),
Geometry.ZPoint{FT}(zlim[2]);
boundary_names = (:bottom, :top),
)
vertmesh = Meshes.IntervalMesh(vertdomain, nelems = nl)
vert_face_space = Spaces.FaceFiniteDifferenceSpace(vertmesh)

horzdomain = Domains.IntervalDomain(
Geometry.XPoint{FT}(xlim[1]),
Geometry.XPoint{FT}(xlim[2]);
periodic = true,
)
horzmesh = Meshes.IntervalMesh(horzdomain, nelems = nh)
horztopology = Topologies.IntervalTopology(horzmesh)

quad = Spaces.Quadratures.GLL{np + 1}()
hspace = Spaces.SpectralElementSpace1D(horztopology, quad)

# Generate surface elevation profile
z_surface = warp_sin_2d.(Fields.coordinate_field(hspace))
# Generate space with known mesh-warp parameters ηₕ = 1; s = 0.1
# Scale height is poorly specified, so code should throw warning.
@test_logs (
:warn,
"Decay scale (s*z_top = 0.1) must be higher than max surface elevation (max(z_surface) = 0.5). Returning s = FT(0.8). Scale height is therefore s=0.8 m.",
)
(
fspace = Spaces.ExtrudedFiniteDifferenceSpace(
hspace,
vert_face_space,
Hypsography.SLEVEAdaption(z_surface, FT(1), FT(0.1)),
)
)
end
end
end
Loading