11include (" dependencies_for_runtests.jl"  )
22
3- using  Oceananigans. Models:  BoundaryConditionOperation, BoundaryConditionField
3+ using  Oceananigans. Forcings:  ContinuousForcing
4+ using  Oceananigans. Models:  BoundaryConditionOperation, BoundaryConditionField,
5+                            ForcingOperation, ForcingField, ForcingKernelFunction
46
57u_bottom_drag_continuous (x, y, t, grid, u, v, Cᴰ) =  - Cᴰ *  u *  sqrt (u^ 2  +  v^ 2 )
68v_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] /
8587
8688                @test  location (c_bottom_bc) ==  (Center, Center, Nothing)
8789                @test  location (c_top_bc)    ==  (Center, Center, Nothing)
88-              
90+ 
8991                initial_c (x, y, z) =  1  +  1  *  (z >  0 )
9092                set! (model, c= initial_c)
91-              
93+ 
9294                c_bottom_bc_field =  BoundaryConditionField (c, :bottom , model)
9395                c_top_bc_field =  BoundaryConditionField (c, :top , model)
9496
@@ -97,11 +99,38 @@ c_bottom_flux(i, j, grid, clock, fields, t★) = - @inbounds fields.c[i, j, 1] /
9799
98100                @test  c_bottom_bc_field isa  BoundaryConditionField
99101                @test  c_top_bc_field isa  BoundaryConditionField
100-                  
102+ 
101103                @test  all (interior (c_bottom_bc_field) .≈  -  1  /  t★)
102104                @test  all (interior (c_top_bc_field) .≈  +  2  /  t★)
103105            end 
104106        end 
105107    end 
106108end 
107109
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