1
1
include (" dependencies_for_runtests.jl" )
2
2
3
- using Oceananigans. Models: BoundaryConditionOperation, BoundaryConditionField
3
+ using Oceananigans. Forcings: ContinuousForcing
4
+ using Oceananigans. Models: BoundaryConditionOperation, BoundaryConditionField,
5
+ ForcingOperation, ForcingField, ForcingKernelFunction
4
6
5
7
u_bottom_drag_continuous (x, y, t, grid, u, v, Cᴰ) = - Cᴰ * u * sqrt (u^ 2 + v^ 2 )
6
8
v_bottom_drag_discrete (i, j, grid, clock, fields, Cᴰ) = - @inbounds Cᴰ * fields. v[i, j, 1 ]
@@ -85,10 +87,10 @@ c_bottom_flux(i, j, grid, clock, fields, t★) = - @inbounds fields.c[i, j, 1] /
85
87
86
88
@test location (c_bottom_bc) == (Center, Center, Nothing)
87
89
@test location (c_top_bc) == (Center, Center, Nothing)
88
-
90
+
89
91
initial_c (x, y, z) = 1 + 1 * (z > 0 )
90
92
set! (model, c= initial_c)
91
-
93
+
92
94
c_bottom_bc_field = BoundaryConditionField (c, :bottom , model)
93
95
c_top_bc_field = BoundaryConditionField (c, :top , model)
94
96
@@ -97,11 +99,38 @@ c_bottom_flux(i, j, grid, clock, fields, t★) = - @inbounds fields.c[i, j, 1] /
97
99
98
100
@test c_bottom_bc_field isa BoundaryConditionField
99
101
@test c_top_bc_field isa BoundaryConditionField
100
-
102
+
101
103
@test all (interior (c_bottom_bc_field) .≈ - 1 / t★)
102
104
@test all (interior (c_top_bc_field) .≈ + 2 / t★)
103
105
end
104
106
end
105
107
end
106
108
end
107
109
110
+ damping (x, y, z, t, c, τ) = - c / τ
111
+
112
+ @testset " ForcingOperation and ForcingField" begin
113
+ for arch in archs
114
+ grid = RectilinearGrid (arch,
115
+ size= (4 , 4 , 4 ),
116
+ x = (0 , 1 ),
117
+ y = (0 , 1 ),
118
+ z = (- 1 , 1 ),
119
+ topology= (Bounded, Bounded, Bounded))
120
+
121
+
122
+ c_forcing = Forcing (damping, field_dependencies= :c , parameters= 60 )
123
+ model = NonhydrostaticModel (; grid, tracers= :c , forcing= (; c= c_forcing))
124
+ c_forcing_op = ForcingOperation (:c , model)
125
+ @test c_forcing_op isa KernelFunctionOperation
126
+ @test c_forcing_op. kernel_function isa ForcingKernelFunction
127
+ @test c_forcing_op. kernel_function. forcing isa ContinuousForcing
128
+ @test c_forcing_op. kernel_function. forcing. parameters == 60
129
+
130
+ set! (model, c= 1 )
131
+ c_forcing_field = ForcingField (:c , model)
132
+ compute! (c_forcing_field)
133
+ @test c_forcing_field isa Field
134
+ @test all (interior (c_forcing_field) .== - 1 / 60 )
135
+ end
136
+ end
0 commit comments