/
cfl.jl
80 lines (58 loc) 路 2.04 KB
/
cfl.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using Oceananigans.Advection: cell_advection_timescale
using Oceananigans.TurbulenceClosures: cell_diffusion_timescale
"""
struct CFL{D, S}
An object for computing the Courant-Freidrichs-Lewy (CFL) number.
"""
struct CFL{D, S}
螖t :: D
timescale :: S
end
"""
CFL(螖t [, timescale = Oceananigans.Advection.cell_advection_timescale])
Return an object for computing the Courant-Freidrichs-Lewy (CFL) number
associated with time step `螖t` or `TimeStepWizard` and `timescale`.
See also [`AdvectiveCFL`](@ref Oceananigans.Diagnostics.AdvectiveCFL)
and [`DiffusiveCFL`](Oceananigans.Diagnostics.DiffusiveCFL).
"""
CFL(螖t) = CFL(螖t, cell_advection_timescale)
(c::CFL)(model) = c.螖t / c.timescale(model)
"""
AdvectiveCFL(螖t)
Return an object for computing the Courant-Freidrichs-Lewy (CFL) number
associated with time step `螖t` or `TimeStepWizard` and the time scale
for advection across a cell. The advective CFL is, e.g., ``U 螖t / 螖x``.
Example
=======
```jldoctest
julia> using Oceananigans
julia> model = NonhydrostaticModel(grid = RectilinearGrid(size=(16, 16, 16), extent=(8, 8, 8)));
julia> 螖t = 1.0;
julia> cfl = AdvectiveCFL(螖t);
julia> model.velocities.u .= 蟺;
julia> cfl(model)
6.283185307179586
```
"""
AdvectiveCFL(螖t) = CFL(螖t, cell_advection_timescale)
"""
DiffusiveCFL(螖t)
Returns an object for computing the diffusive Courant-Freidrichs-Lewy (CFL) number
associated with time step `螖t` or `TimeStepWizard` and the time scale for diffusion
across a cell associated with `model.closure`. The diffusive CFL, e.g., for viscosity
is ``谓 螖t / 螖x虏``.
The maximum diffusive CFL number among viscosity and all tracer diffusivities is
returned.
Example
=======
```jldoctest
julia> using Oceananigans
julia> model = NonhydrostaticModel(grid = RectilinearGrid(size=(16, 16, 16), extent=(1, 1, 1)),
closure = ScalarDiffusivity(; 谓 = 1e-2));
julia> 螖t = 0.1;
julia> dcfl = DiffusiveCFL(螖t);
julia> dcfl(model)
0.256
```
"""
DiffusiveCFL(螖t) = CFL(螖t, cell_diffusion_timescale)