@@ -3,50 +3,45 @@ import RootSolvers
3
3
import ClimaComms
4
4
5
5
"""
6
- column_integral_definite!(∫field, ᶜfield , [init ])
6
+ column_integral_definite!(ϕ_top, ᶜ∂ϕ∂z , [ϕ_bot ])
7
7
8
- Sets `∫field ```{}= \\ int_{z_{min }}^{z_{max }}\\ ,```ᶜfield ```(z)\\ ,dz +{}```init `,
9
- where ``z_{min }`` and ``z_{max }`` are the values of `z` at the bottom and top of
10
- the domain, respectively. The input `ᶜfield` must lie on a cell-center space,
11
- and the output `∫field` must lie on the corresponding horizontal space. The
12
- default value of `init ` is 0.
8
+ Sets `ϕ_top ```{}= \\ int_{z_{bot }}^{z_{top }}\\ ,```ᶜ∂ϕ∂z ```(z)\\ ,dz +{}```ϕ_bot `,
9
+ where ``z_{bot }`` and ``z_{top }`` are the values of `z` at the bottom and top of
10
+ the domain, respectively. The input `ᶜ∂ϕ∂z` should be a cell-center `Field` or
11
+ `AbstractBroadcasted`, and the output `ϕ_top` should be a horizontal `Field`.
12
+ The default value of `ϕ_bot ` is 0.
13
13
"""
14
- function column_integral_definite! (∫field, ᶜfield, init = rzero (eltype (∫field)))
15
- ᶜfield_times_Δz =
16
- Base. Broadcast. broadcasted (⊠ , ᶜfield, Fields. Δz_field (ᶜfield))
17
- column_reduce! (⊞ , ∫field, ᶜfield_times_Δz; init)
14
+ function column_integral_definite! (ϕ_top, ᶜ∂ϕ∂z, ϕ_bot = rzero (eltype (ϕ_top)))
15
+ ᶜΔϕ = Base. Broadcast. broadcasted (⊠ , ᶜ∂ϕ∂z, Fields. Δz_field (axes (ᶜ∂ϕ∂z)))
16
+ column_reduce! (⊞ , ϕ_top, ᶜΔϕ; init = ϕ_bot)
18
17
end
19
18
20
19
"""
21
- column_integral_indefinite!(ᶠ∫field, ᶜfield , [init ])
20
+ column_integral_indefinite!(ᶠϕ, ᶜ∂ϕ∂z , [ϕ_bot ])
22
21
23
- Sets `ᶠ∫field ```(z) = \\ int_{z_{min }}^z\\ ,```ᶜfield ```(z')\\ ,dz' +{}```init`,
24
- where ``z_{min }`` is the value of `z` at the bottom of the domain. The input
25
- `ᶜfield` must lie on a cell-center space , and the output `ᶠ∫field` must lie on
26
- the corresponding cell-face space . The default value of `init ` is 0.
22
+ Sets `ᶠϕ ```(z) = \\ int_{z_{bot }}^z\\ ,```ᶜ∂ϕ∂z ```(z')\\ ,dz' +{}```ϕ_bot`, where
23
+ ``z_{bot }`` is the value of `z` at the bottom of the domain. The input `ᶜ∂ϕ∂z`
24
+ should be a cell-center `Field` or `AbstractBroadcasted` , and the output `ᶠϕ`
25
+ should be a cell-face `Field` . The default value of `ϕ_bot ` is 0.
27
26
28
- column_integral_indefinite!(∂ϕ∂z, ᶠϕ, [ϕ₀ ], [rtol])
27
+ column_integral_indefinite!(∂ϕ∂z, ᶠϕ, [ϕ_bot ], [rtol])
29
28
30
- Sets `ᶠϕ```(z) = \\ int_{z_{min}}^z\\ ,```∂ϕ∂z```(```ᶠϕ```(z'), z')\\ ,dz' +{}```ϕ₀`
31
- for any scalar-valued two-argument function `∂ϕ∂z`. That is, the output `ᶠϕ` is
32
- such that `ᶜgradᵥ.(ᶠϕ) ≈ ∂ϕ∂z.(ᶜint.(ᶠϕ), ᶜz)`, where `ᶜgradᵥ = GradientF2C()`,
33
- `ᶜint = InterpolateF2C()`, and `ᶜz = Fields.coordinate_field(ᶜint.(ᶠϕ)).z`. The
34
- approximation is accurate to a relative tolerance of `rtol`. The default value
35
- of `ϕ₀` is 0, and the default value of `rtol` is 0.001.
29
+ Sets
30
+ `ᶠϕ```(z) = \\ int_{z_{bot}}^z\\ ,```∂ϕ∂z```(```ᶠϕ```(z'), z')\\ ,dz' +{}```ϕ_bot`,
31
+ where `∂ϕ∂z` can be any scalar-valued two-argument function. The output `ᶠϕ`
32
+ satisfies `ᶜgradᵥ.(ᶠϕ) ≈ ∂ϕ∂z.(ᶜint.(ᶠϕ), ᶜz)`, where `ᶜgradᵥ = GradientF2C()`,
33
+ `ᶜint = InterpolateF2C()`, and `ᶜz = Fields.coordinate_field(ᶜint.(ᶠϕ)).z`, and
34
+ where the approximation is accurate to a relative tolerance of `rtol`. The
35
+ default value of `ϕ_bot` is 0, and the default value of `rtol` is 0.001.
36
36
"""
37
- function column_integral_indefinite! (
38
- ᶠ∫field,
39
- ᶜfield,
40
- init = rzero (eltype (ᶠ∫field)),
41
- )
42
- ᶜfield_times_Δz =
43
- Base. Broadcast. broadcasted (⊠ , ᶜfield, Fields. Δz_field (ᶜfield))
44
- column_accumulate! (⊞ , ᶠ∫field, ᶜfield_times_Δz; init)
37
+ function column_integral_indefinite! (ᶠϕ, ᶜ∂ϕ∂z, ϕ_bot = rzero (eltype (ᶠϕ)))
38
+ ᶜΔϕ = Base. Broadcast. broadcasted (⊠ , ᶜ∂ϕ∂z, Fields. Δz_field (axes (ᶜ∂ϕ∂z)))
39
+ column_accumulate! (⊞ , ᶠϕ, ᶜΔϕ; init = ϕ_bot)
45
40
end
46
41
function column_integral_indefinite! (
47
42
∂ϕ∂z:: F ,
48
43
ᶠϕ,
49
- ϕ₀ = eltype (ᶠϕ)(0 ),
44
+ ϕ_bot = eltype (ᶠϕ)(0 ),
50
45
rtol = eltype (ᶠϕ)(0.001 ),
51
46
) where {F <: Function }
52
47
device = ClimaComms. device (ᶠϕ)
@@ -61,7 +56,7 @@ function column_integral_indefinite!(
61
56
ᶜz = Fields. coordinate_field (center_space). z
62
57
ᶜΔz = Fields. Δz_field (center_space)
63
58
ᶜz_and_Δz = Base. Broadcast. broadcasted (tuple, ᶜz, ᶜΔz)
64
- column_accumulate! (ᶠϕ, ᶜz_and_Δz; init = ϕ₀ ) do ϕ_prev, (z, Δz)
59
+ column_accumulate! (ᶠϕ, ᶜz_and_Δz; init = ϕ_bot ) do ϕ_prev, (z, Δz)
65
60
residual (ϕ_new) = (ϕ_new - ϕ_prev) / Δz - ∂ϕ∂z ((ϕ_prev + ϕ_new) / 2 , z)
66
61
(; converged, root) = RootSolvers. find_zero (
67
62
residual,
0 commit comments