/
cfl.jl
69 lines (51 loc) 路 1.67 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
using Oceananigans.Utils: cell_advection_timescale
using Oceananigans.TurbulenceClosures: cell_diffusion_timescale
"""
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.cell_advection_timescale])
Returns an object for computing the Courant-Freidrichs-Lewy (CFL) number
associated with time step or `TimeStepWizard` `螖t` and `timescale`.
See also `AdvectiveCFL` and `DiffusiveCFL`.
"""
CFL(螖t) = CFL(螖t, cell_advection_timescale)
(c::CFL)(model) = c.螖t / c.timescale(model)
"""
AdvectiveCFL(螖t)
Returns an object for computing the Courant-Freidrichs-Lewy (CFL) number
associated with time step or `TimeStepWizard` `螖t` and the time scale
for advection across a cell.
Example
=======
```julia
julia> model = IncompressibleModel(grid=RegularCartesianGrid(size=(16, 16, 16), length=(8, 8, 8)));
julia> cfl = AdvectiveCFL(1.0);
julia> data(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 or `TimeStepWizard` `螖t` and the time scale for diffusion
across a cell associated with `model.closure`.
The maximum diffusive CFL number among viscosity and all tracer diffusivities is
returned.
Example
=======
```julia
julia> model = IncompressibleModel(grid=RegularCartesianGrid(size=(16, 16, 16), length=(1, 1, 1)));
julia> dcfl = DiffusiveCFL(0.1);
julia> dcfl(model)
2.688e-5
```
"""
DiffusiveCFL(螖t) = CFL(螖t, cell_diffusion_timescale)