Skip to content

Commit

Permalink
Merge #1353
Browse files Browse the repository at this point in the history
1353: Modify warning in case SLEVE scale height is poorly specified, add test.  r=akshaysridhar a=akshaysridhar

Modifies the warning message when decay scale parameter `s` is poorly specified. 
Additionally adds a test for this warning using the `at-test_logs` macro. 

Co-authored-by: Akshay Sridhar <[email protected]>
  • Loading branch information
bors[bot] and Akshay Sridhar authored Jun 28, 2023
2 parents 54fd09e + 6a18955 commit a7ae37d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
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

0 comments on commit a7ae37d

Please sign in to comment.