1+ using ClimaCore: Geometry, Spaces, Fields
2+
3+ # #
4+ # # Topography profiles for 2D and 3D boxes
5+ # #
6+
7+ # The parameters of these profiles should be defined separately so that they
8+ # can also be used to compute analytic solutions.
9+
10+ abstract type AbstractTopography end
11+ Base. broadcastable (t:: AbstractTopography ) = tuple (t)
12+ topography_function (topo) = Base. Fix1 (topography_function, topo)
13+
14+ struct NoTopography <: AbstractTopography end
15+
16+ # Analytical topography types for idealized test cases
17+
18+ """
19+ CosineTopography{D, FT}(; h_max = 25, λ = 25e3)
20+
21+ Cosine hill topography in 2D or 3D.
22+
23+ # Arguments
24+ - `h_max::FT`: Maximum elevation (m)
25+ - `λ::FT`: Wavelength of the cosine hills (m)
26+ """
27+ Base. @kwdef struct CosineTopography{D, FT} <: AbstractTopography
28+ h_max:: FT = 25.0
29+ λ:: FT = 25e3
30+ end
31+
32+ topography_function (t:: CosineTopography{2} , coord) =
33+ topography_cosine (coord. x, zero (coord. x), t. λ, oftype (t. λ, Inf ), t. h_max)
34+
35+ topography_function (t:: CosineTopography{3} , coord) =
36+ topography_cosine (coord. x, coord. y, t. λ, t. λ, t. h_max)
37+
38+ topography_cosine (x, y, λ_x, λ_y, h_max) =
39+ h_max * cospi (2 * x / λ_x) * cospi (2 * y / λ_y)
40+
41+ """
42+ AgnesiTopography{FT}(; h_max = 25, x_center = 50e3, a = 5e3)
43+
44+ Witch of Agnesi mountain topography for 2D simulations.
45+
46+ # Arguments
47+ - `h_max`: Maximum elevation (m)
48+ - `x_center`: Center position (m)
49+ - `a`: Mountain width parameter (m)
50+ """
51+ Base. @kwdef struct AgnesiTopography{FT} <: AbstractTopography
52+ h_max:: FT = 25.0
53+ x_center:: FT = 50e3
54+ a:: FT = 5e3
55+ end
56+
57+ topography_function ((; h_max, x_center, a):: AgnesiTopography , (; x)) =
58+ h_max / (1 + ((x - x_center) / a)^ 2 )
59+
60+ """
61+ ScharTopography{FT}(; h_max = 25, x_center = 50e3, λ = 4e3, a = 5e3)
62+
63+ Schar mountain topography for 2D simulations.
64+
65+ # Arguments
66+ - `h_max`: Maximum elevation (m)
67+ - `x_center`: Center position (m)
68+ - `λ`: Wavelength parameter (m)
69+ - `a`: Mountain width parameter (m)
70+ """
71+ Base. @kwdef struct ScharTopography{FT} <: AbstractTopography
72+ h_max:: FT = 25.0
73+ x_center:: FT = 50e3
74+ λ:: FT = 4e3
75+ a:: FT = 5e3
76+ end
77+
78+ topography_function ((; h_max, x_center, λ, a):: ScharTopography , (; x)) =
79+ h_max * exp (- (x - x_center)^ 2 / a^ 2 ) * cospi ((x - x_center) / λ)^ 2
80+
81+ # Data-based topography types
82+
83+ """
84+ EarthTopography()
85+
86+ Earth topography from ETOPO2022 data files.
87+ """
88+ struct EarthTopography <: AbstractTopography end
89+
190"""
2- topography_dcmip200(coord )
91+ DCMIP200Topography( )
392
493Surface elevation for the DCMIP-2-0-0 test problem.
594"""
95+ struct DCMIP200Topography <: AbstractTopography end
96+
97+ topography_function (:: DCMIP200Topography , coord) = topography_dcmip200 (coord)
98+
699function topography_dcmip200 (coord)
7100 FT = Geometry. float_type (coord)
8101 λ, ϕ = coord. long, coord. lat
@@ -21,10 +114,14 @@ function topography_dcmip200(coord)
21114end
22115
23116"""
24- topography_hughes2023(coord )
117+ Hughes2023Topography( )
25118
26119Surface elevation for baroclinic wave test from Hughes and Jablonowski (2023).
27120"""
121+ struct Hughes2023Topography <: AbstractTopography end
122+
123+ topography_function (:: Hughes2023Topography , coord) = topography_hughes2023 (coord)
124+
28125function topography_hughes2023 (coord)
29126 FT = Geometry. float_type (coord)
30127 λ, ϕ = coord. long, coord. lat
@@ -50,66 +147,3 @@ function topography_hughes2023(coord)
50147 ),
51148 )
52149end
53-
54- # #
55- # # Topography profiles for 2D and 3D boxes
56- # #
57-
58- # The parameters of these profiles should be defined separately so that they
59- # can also be used to compute analytic solutions.
60-
61- """
62- topography_agnesi(coord)
63-
64- Surface elevation for a 2D Witch of Agnesi mountain, centered at `x = 50 km`.
65- """
66- function topography_agnesi (coord)
67- FT = Geometry. float_type (coord)
68- (; x) = coord
69- (; h_max, x_center, a) = agnesi_params (FT)
70- return h_max / (1 + ((x - x_center) / a)^ 2 )
71- end
72- agnesi_params (:: Type{FT} ) where {FT} =
73- (; h_max = FT (25 ), x_center = FT (50e3 ), a = FT (5e3 ))
74-
75- """
76- topography_schar(coord)
77-
78- Surface elevation for a 2D Schar mountain, centered at `x = 50 km`.
79- """
80- function topography_schar (coord)
81- FT = Geometry. float_type (coord)
82- (; x) = coord
83- (; h_max, x_center, λ, a) = schar_params (FT)
84- return h_max * exp (- (x - x_center)^ 2 / a^ 2 ) * cospi ((x - x_center) / λ)^ 2
85- end
86- schar_params (:: Type{FT} ) where {FT} =
87- (; h_max = FT (25 ), x_center = FT (50e3 ), λ = FT (4e3 ), a = FT (5e3 ))
88-
89- """
90- topography_cosine_2d(coord)
91-
92- Surface elevation for 2D cosine hills.
93- """
94- function topography_cosine_2d (coord)
95- FT = Geometry. float_type (coord)
96- (; x) = coord
97- (; h_max, λ) = cosine_params (FT)
98- return topography_cosine (x, FT (0 ), λ, FT (Inf ), h_max)
99- end
100-
101- """
102- topography_cosine_3d(coord)
103-
104- Surface elevation for 3D cosine hills.
105- """
106- function topography_cosine_3d (coord)
107- FT = Geometry. float_type (coord)
108- (; x, y) = coord
109- (; h_max, λ) = cosine_params (FT)
110- return topography_cosine (x, y, λ, λ, h_max)
111- end
112-
113- topography_cosine (x, y, λ_x, λ_y, h_max) =
114- h_max * cospi (2 * x / λ_x) * cospi (2 * y / λ_y)
115- cosine_params (:: Type{FT} ) where {FT} = (; h_max = FT (25 ), λ = FT (25e3 ))
0 commit comments