diff --git a/src/Hypsography/Hypsography.jl b/src/Hypsography/Hypsography.jl index f8c61d84f4..78603a00da 100644 --- a/src/Hypsography/Hypsography.jl +++ b/src/Hypsography/Hypsography.jl @@ -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( η <= ηₕ, diff --git a/test/Spaces/terrain_warp.jl b/test/Spaces/terrain_warp.jl index c1da7420ac..7706245e83 100644 --- a/test/Spaces/terrain_warp.jl +++ b/test/Spaces/terrain_warp.jl @@ -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