@@ -191,13 +191,16 @@ function IntervalMesh(
191
191
domain:: IntervalDomain{CT} ,
192
192
stretch:: GeneralizedExponentialStretching{FT} ;
193
193
nelems:: Int ,
194
+ FT_solve = Float64,
195
+ tol = 1e-3 ,
194
196
reverse_mode:: Bool = false ,
195
197
) where {CT <: Geometry.Abstract1DPoint{FT} } where {FT}
196
198
if nelems ≤ 1
197
199
throw (ArgumentError (" `nelems` must be ≥ 2" ))
198
200
end
199
201
200
- dz_bottom, dz_top = stretch. dz_bottom, stretch. dz_top
202
+ dz_bottom = FT_solve (stretch. dz_bottom)
203
+ dz_top = FT_solve (stretch. dz_top)
201
204
if ! (dz_bottom ≤ dz_top) && ! reverse_mode
202
205
throw (ArgumentError (" dz_bottom must be ≤ dz_top" ))
203
206
end
@@ -222,20 +225,22 @@ function IntervalMesh(
222
225
exp_stretch (ζ, h) = ζ == 1 ? ζ : - h * log (1 - (1 - exp (- 1 / h)) * ζ)
223
226
224
227
# nondimensional vertical coordinate (]0.0, 1.0])
225
- ζ_n = LinRange (one (FT ), nelems, nelems) / nelems
228
+ ζ_n = LinRange (one (FT_solve ), nelems, nelems) / nelems
226
229
227
230
# find bottom height variation
228
231
find_bottom (h) = dz_bottom - z_top * exp_stretch (ζ_n[1 ], h)
229
232
# we use linearization
230
233
# h_bottom ≈ -dz_bottom / (z_top - z_bottom) / log(1 - 1/nelems)
231
234
# to approx bracket the lower / upper bounds of root sol
232
- guess₋ = - dz_bottom / (z_top - z_bottom) / log (1 - FT (1 / (nelems - 1 )))
233
- guess₊ = - dz_bottom / (z_top - z_bottom) / log (1 - FT (1 / (nelems + 1 )))
235
+ guess₋ =
236
+ - dz_bottom / (z_top - z_bottom) / log (1 - FT_solve (1 / (nelems - 1 )))
237
+ guess₊ =
238
+ - dz_bottom / (z_top - z_bottom) / log (1 - FT_solve (1 / (nelems + 1 )))
234
239
h_bottom_sol = RootSolvers. find_zero (
235
240
find_bottom,
236
241
RootSolvers. SecantMethod (guess₋, guess₊),
237
242
RootSolvers. CompactSolution (),
238
- RootSolvers. ResidualTolerance (FT ( 1e-3 )),
243
+ RootSolvers. ResidualTolerance (FT_solve (tol )),
239
244
)
240
245
if h_bottom_sol. converged != = true
241
246
error (
@@ -249,13 +254,13 @@ function IntervalMesh(
249
254
# we use the linearization
250
255
# h_top ≈ (z_top - dz_top) / z_top / log(nelem)
251
256
# to approx braket the lower, upper bounds of root sol
252
- guess₋ = ((z_top - z_bottom) - dz_top) / z_top / FT (log (nelems + 1 ))
253
- guess₊ = ((z_top - z_bottom) - dz_top) / z_top / FT (log (nelems - 1 ))
257
+ guess₋ = ((z_top - z_bottom) - dz_top) / z_top / FT_solve (log (nelems + 1 ))
258
+ guess₊ = ((z_top - z_bottom) - dz_top) / z_top / FT_solve (log (nelems - 1 ))
254
259
h_top_sol = RootSolvers. find_zero (
255
260
find_top,
256
261
RootSolvers. SecantMethod (guess₋, guess₊),
257
262
RootSolvers. CompactSolution (),
258
- RootSolvers. ResidualTolerance (FT (1e-3 )),
263
+ RootSolvers. ResidualTolerance (FT_solve (1e-3 )),
259
264
)
260
265
if h_top_sol. converged != = true
261
266
error (
@@ -271,7 +276,7 @@ function IntervalMesh(
271
276
faces = (z_bottom + (z_top - z_bottom)) * exp_stretch .(ζ_n, h)
272
277
273
278
# add the bottom level
274
- faces = [z_bottom; faces... ]
279
+ faces = FT_solve [z_bottom; faces... ]
275
280
if reverse_mode
276
281
reverse! (faces)
277
282
faces = map (f -> eltype (faces)(- f), faces)
0 commit comments