@@ -17,13 +17,17 @@ Constuct a 1D mesh on `domain` with `nelems` elements, using `stretching`. Possi
1717- [`ExponentialStretching(H)`](@ref)
1818- [`GeneralizedExponentialStretching(dz_bottom, dz_top)`](@ref)
1919- [`HyperbolicTangentStretching(dz_bottom)`](@ref)
20+
21+ If `reverse_mode` is `true`, the smallest element is at the top, and the largest at the bottom
22+ (this is typical for land model configurations).
2023"""
2124struct IntervalMesh{S, I <: IntervalDomain , V <: AbstractVector , M} < :
2225 AbstractMesh1D
2326 stretch:: S
2427 domain:: I
2528 faces:: V
2629 meta:: M
30+ reverse_mode:: Bool
2731end
2832
2933# implies isequal
@@ -141,7 +145,8 @@ function IntervalMesh(domain::IntervalDomain, faces::AbstractArray)
141145 nelems = length (faces)
142146 nelems < 1 && throw (ArgumentError (" `nelems` must be ≥ 1" ))
143147 monotonic_check (faces)
144- IntervalMesh (UnknownStretch (), domain, faces, nothing )
148+ reverse_mode = false
149+ IntervalMesh (UnknownStretch (), domain, faces, nothing , reverse_mode)
145150end
146151
147152"""
@@ -161,7 +166,8 @@ function IntervalMesh(
161166 end
162167 faces = range (domain. coord_min, domain. coord_max; length = nelems + 1 )
163168 monotonic_check (faces)
164- IntervalMesh (stretch, domain, faces, nothing )
169+ reverse_mode = false
170+ IntervalMesh (stretch, domain, faces, nothing , reverse_mode)
165171end
166172
167173
@@ -217,7 +223,7 @@ function IntervalMesh(
217223 reverse! (faces)
218224 end
219225 monotonic_check (faces)
220- IntervalMesh (stretch, domain, faces, nothing )
226+ IntervalMesh (stretch, domain, faces, nothing , reverse_mode )
221227end
222228
223229"""
@@ -338,7 +344,7 @@ function IntervalMesh(
338344 faces[end ] = faces[end ] == - z_bottom ? z_bottom : faces[1 ]
339345 end
340346 monotonic_check (faces)
341- IntervalMesh (stretch, domain, CT .(faces), (; h_top))
347+ IntervalMesh (stretch, domain, CT .(faces), (; h_top), reverse_mode )
342348end
343349
344350"""
@@ -356,13 +362,13 @@ For an interval ``[z_0,z_1]``, this makes the elements uniformally spaced in
356362\\ eta = 1 - \\ frac{tanh[\\ gamma(1-\\ zeta)]}{tanh(\\ gamma)},
357363```
358364where ``\\ eta = \\ frac{z - z_0}{z_1-z_0}``. The stretching parameter ``\\ gamma``
359- is chosen to achieve a given resolution `dz_surface` at the surface.
365+ is chosen to achieve a given resolution `dz_surface` at the surface.
360366
361367Then, the user can define a stretched mesh via
362368
363369 ClimaCore.Meshes.IntervalMesh(interval_domain, HyperbolicTangentStretching(dz_surface); nelems::Int, reverse_mode)
364370
365- `reverse_mode` is default to false for atmosphere configurations. For land configurations,
371+ `reverse_mode` is default to false for atmosphere configurations. For land configurations,
366372use `reverse_mode` = `true`.
367373
368374`faces` contain reference z without any warping.
@@ -427,7 +433,13 @@ function IntervalMesh(
427433 faces[end ] = faces[end ] == - z_bottom ? z_bottom : faces[1 ]
428434 end
429435 monotonic_check (faces)
430- IntervalMesh (stretch, domain, CT .(faces), (; γ_sol = γ_sol. root))
436+ IntervalMesh (
437+ stretch,
438+ domain,
439+ CT .(faces),
440+ (; γ_sol = γ_sol. root),
441+ reverse_mode,
442+ )
431443end
432444
433445"""
0 commit comments