Skip to content

Commit b7adf2d

Browse files
committed
rm curlc2f setvalue bc
1 parent 973eafe commit b7adf2d

9 files changed

Lines changed: 27 additions & 99 deletions

File tree

.buildkite/pipeline.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,6 @@ steps:
252252
retry: *retry_policy
253253
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/Geometry/geometry.jl"
254254

255-
- label: "Unit: tensors"
256-
key: unit_tensors
257-
retry: *retry_policy
258-
command: "julia --color=yes --check-bounds=yes --project=.buildkite test/Geometry/tensors.jl"
259-
260255
- label: "Unit: mul_with_projection"
261256
key: unit_mul_with_projection
262257
retry: *retry_policy

examples/column/step.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import ClimaCore:
99
DataLayouts,
1010
Operators,
1111
Geometry,
12-
Spaces
12+
Spaces,
13+
Utilities
1314

1415
using OrdinaryDiffEqSSPRK: ODEProblem, solve, SSPRK33
1516

src/Operators/finitedifference.jl

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,7 +3082,7 @@ The following boundary conditions are supported:
30823082
struct DivergenceC2F{BC} <: DivergenceOperator
30833083
bcs::BC
30843084
function DivergenceC2F(; kwargs...)
3085-
assert_valid_bcs("DivergenceC2F", kwargs, (SetValue, SetDivergence))
3085+
assert_valid_bcs("DivergenceC2F", kwargs, (SetDivergence,))
30863086
new{typeof(NamedTuple(kwargs))}(NamedTuple(kwargs))
30873087
end
30883088
DivergenceC2F(bcs) = DivergenceC2F(; bcs...)
@@ -3171,19 +3171,13 @@ where ``v₁`` and ``v₂`` are the 1st and 2nd covariant components of ``v``, a
31713171
31723172
The following boundary conditions are supported:
31733173
3174-
- [`SetValue(v₀)`](@ref): calculate the curl assuming the value of ``v`` at the
3175-
boundary is `v₀`. For the left boundary, this becomes:
3176-
```math
3177-
C(v)[\\tfrac{1}{2}]^1 = -\\frac{2}{J[i]} (v_2[1] - (v₀)_2)
3178-
C(v)[\\tfrac{1}{2}]^2 = \\frac{2}{J[i]} (v_1[1] - (v₀)_1)
3179-
```
31803174
- [`SetCurl(v⁰)`](@ref): enforce the curl operator output at the boundary to be
31813175
the contravariant vector `v⁰`.
31823176
"""
31833177
struct CurlC2F{BC} <: CurlFiniteDifferenceOperator
31843178
bcs::BC
31853179
function CurlC2F(; kwargs...)
3186-
assert_valid_bcs("CurlC2F", kwargs, (SetValue, SetCurl))
3180+
assert_valid_bcs("CurlC2F", kwargs, (SetCurl,))
31873181
new{typeof(NamedTuple(kwargs))}(NamedTuple(kwargs))
31883182
end
31893183
CurlC2F(bcs) = CurlC2F(; bcs...)
@@ -3219,32 +3213,6 @@ Base.@propagate_inbounds function stencil_interior(
32193213
end
32203214

32213215
boundary_width(::CurlC2F, ::AbstractBoundaryCondition) = 1
3222-
Base.@propagate_inbounds function stencil_left_boundary(
3223-
::CurlC2F,
3224-
bc::SetValue,
3225-
space,
3226-
idx,
3227-
hidx,
3228-
arg,
3229-
)
3230-
u₊ = getidx(space, arg, idx + half, hidx)
3231-
u = getidx(space, bc.val, nothing, hidx)
3232-
local_geometry = Geometry.LocalGeometry(space, idx, hidx)
3233-
return fd3_curl(u₊, u, local_geometry.invJ * 2)
3234-
end
3235-
Base.@propagate_inbounds function stencil_right_boundary(
3236-
::CurlC2F,
3237-
bc::SetValue,
3238-
space,
3239-
idx,
3240-
hidx,
3241-
arg,
3242-
)
3243-
u = getidx(space, bc.val, nothing, hidx)
3244-
u₋ = getidx(space, arg, idx - half, hidx)
3245-
local_geometry = Geometry.LocalGeometry(space, idx, hidx)
3246-
return fd3_curl(u, u₋, local_geometry.invJ * 2)
3247-
end
32483216

32493217
Base.@propagate_inbounds function stencil_left_boundary(
32503218
::CurlC2F,

test/MatrixFields/operator_matrices.jl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ end
172172
test_op_matrix(DivergenceF2C, SetDivergence, (ᶠuvw,))
173173
test_op_matrix(DivergenceF2C, Extrapolate, (ᶠuvw,))
174174
test_op_matrix(CurlC2F, Nothing, (ᶜc12,), true)
175-
test_op_matrix(CurlC2F, SetValue, (ᶜc12,))
176175
test_op_matrix(CurlC2F, SetCurl, (ᶜc12,))
177176

178177
@test_throws "nonlinear" MatrixFields.operator_matrix(FCTBorisBook())
@@ -197,7 +196,6 @@ end
197196
set_nested_values =
198197
(; bottom = SetValue(nested_zero), top = SetValue(nested_zero))
199198
c12_zero = zero(Geometry.Covariant12Vector{FT})
200-
set_c12_values = (; bottom = SetValue(c12_zero), top = SetValue(c12_zero))
201199
extrapolate = (; bottom = Extrapolate(), top = Extrapolate())
202200

203201
ᶠinterp = InterpolateC2F(; set_nested_values...)
@@ -207,15 +205,13 @@ end
207205
ᶜadvect = AdvectionC2C(; extrapolate...)
208206
ᶜflux_correct = FluxCorrectionC2C(; extrapolate...)
209207
ᶜdiv = DivergenceF2C()
210-
ᶠcurl = CurlC2F(; set_c12_values...)
211208
ᶠinterp_matrix = MatrixFields.operator_matrix(ᶠinterp)
212209
ᶜlbias_matrix = MatrixFields.operator_matrix(ᶜlbias)
213210
ᶠrbias_matrix = MatrixFields.operator_matrix(ᶠrbias)
214211
ᶜwinterp_matrix = MatrixFields.operator_matrix(ᶜwinterp)
215212
ᶜadvect_matrix = MatrixFields.operator_matrix(ᶜadvect)
216213
ᶜflux_correct_matrix = MatrixFields.operator_matrix(ᶜflux_correct)
217214
ᶜdiv_matrix = MatrixFields.operator_matrix(ᶜdiv)
218-
ᶠcurl_matrix = MatrixFields.operator_matrix(ᶠcurl)
219215

220216
@test_throws "does not contain any Fields" @. ᶜlbias_matrix() *
221217
ᶠinterp_matrix()

test/Operators/finitedifference/benchmark_stencils_utils.jl

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,6 @@ function set_curl_bcs(c)
164164
top = Operators.SetCurl(contra12(FT(0), FT(0))))
165165
end
166166

167-
function set_curl_value_bcs(c)
168-
FT = Spaces.undertype(axes(c))
169-
cov12 = Geometry.Covariant12Vector
170-
return (;bottom = Operators.SetValue(cov12(FT(0), FT(0))),
171-
top = Operators.SetValue(cov12(FT(0), FT(0))))
172-
end
173-
174167
function bc_name(bcs::NamedTuple)
175168
if haskey(bcs, :inner) && haskey(bcs, :outer)
176169
return (bc_name_base(bcs.inner)..., bc_name_base(bcs.outer)...)
@@ -200,7 +193,7 @@ bcs_tested(c, ::typeof(op_broadcast_example1!)) = ((;), )
200193
bcs_tested(c, ::typeof(op_broadcast_example2!)) = ((;), )
201194

202195
bcs_tested(c, ::typeof(op_GradientF2C!)) = ((;), set_value_bcs(c))
203-
bcs_tested(c, ::typeof(op_GradientC2F!)) = (set_gradient_value_bcs(c), set_value_bcs(c))
196+
bcs_tested(c, ::typeof(op_GradientC2F!)) = (set_gradient_value_bcs(c),)
204197
bcs_tested(c, ::typeof(op_DivergenceF2C!)) = ((;), extrapolate_bcs(c))
205198
bcs_tested(c, ::typeof(op_DivergenceC2F!)) = (set_divergence_bcs(c), )
206199
bcs_tested(c, ::typeof(op_InterpolateF2C!)) = ((;), )
@@ -209,8 +202,8 @@ bcs_tested(c, ::typeof(op_LeftBiasedC2F!)) = (set_bot_value_bc(c),)
209202
bcs_tested(c, ::typeof(op_LeftBiasedF2C!)) = ((;), set_bot_value_bc(c))
210203
bcs_tested(c, ::typeof(op_RightBiasedC2F!)) = (set_top_value_bc(c),)
211204
bcs_tested(c, ::typeof(op_RightBiasedF2C!)) = ((;), set_top_value_bc(c))
212-
bcs_tested(c, ::typeof(op_CurlC2F!)) = (set_curl_bcs(c), set_curl_value_bcs(c))
213-
bcs_tested(c, ::typeof(op_UpwindBiasedProductC2F!)) = (set_value_bcs(c), extrapolate_bcs(c))
205+
bcs_tested(c, ::typeof(op_CurlC2F!)) = (set_curl_bcs(c),)
206+
bcs_tested(c, ::typeof(op_UpwindBiasedProductC2F!)) = (extrapolate_bcs(c),)
214207
bcs_tested(c, ::typeof(op_Upwind3rdOrderBiasedProductC2F!)) = (set_upwind_biased_3_bcs(c), extrapolate_bcs(c))
215208

216209
# Composed operators (bcs handled case-by-case)
@@ -221,7 +214,7 @@ bcs_tested(c, ::typeof(op_divgrad_FF!)) =
221214
bcs_tested(c, ::typeof(op_div_interp_CC!)) =
222215
((; inner = set_value_contra3_bcs(c), outer = (;)), )
223216
bcs_tested(c, ::typeof(op_div_interp_FF!)) =
224-
((; inner = (;), outer = set_value_contra3_bcs(c)), )
217+
((; inner = (;), outer = set_divergence_bcs(c)), )
225218
bcs_tested(c, ::typeof(op_divgrad_uₕ!)) =
226219
(
227220
(; inner = (;), outer = set_value_divgrad_uₕ_bcs(c)),
@@ -432,7 +425,6 @@ function test_results_column(t_min)
432425
[(op_GradientF2C!, :none), 253.100*ns*buffer],
433426
[(op_GradientF2C!, :SetValue, :SetValue), 270.448*ns*buffer],
434427
[(op_GradientC2F!, :SetGradient, :SetGradient), 242.053*ns*buffer],
435-
[(op_GradientC2F!, :SetValue, :SetValue), 241.647*ns*buffer],
436428
[(op_DivergenceF2C!, :none), 1.005*μs*buffer],
437429
[(op_DivergenceF2C!, :Extrapolate, :Extrapolate), 1.076*μs*buffer],
438430
[(op_DivergenceC2F!, :SetDivergence, :SetDivergence), 878.028*ns*buffer],
@@ -447,13 +439,11 @@ function test_results_column(t_min)
447439
[(op_RightBiasedF2C!, :none), 142.120*ns*buffer],
448440
[(op_RightBiasedF2C!, :SetValue), 141.446*ns*buffer],
449441
[(op_CurlC2F!, :SetCurl, :SetCurl), 1.692*μs*buffer],
450-
[(op_CurlC2F!, :SetValue, :SetValue), 1.616*μs*buffer],
451-
[(op_UpwindBiasedProductC2F!, :SetValue, :SetValue), 754.856*ns*buffer],
452442
[(op_UpwindBiasedProductC2F!, :Extrapolate, :Extrapolate), 765.401*ns*buffer],
453443
[(op_divUpwind3rdOrderBiasedProductC2F!, :ThirdOrderOneSided, :ThirdOrderOneSided, :SetValue, :SetValue), 2.540*μs*buffer],
454444
[(op_divgrad_FF!, :none, :SetDivergence, :SetDivergence), 876.510*ns*buffer],
455445
[(op_div_interp_CC!, :SetValue, :SetValue, :none), 721.119*ns*buffer],
456-
[(op_div_interp_FF!, :none, :SetValue, :SetValue), 686.581*ns*buffer],
446+
[(op_div_interp_FF!, :none, :SetDivergence, :SetDivergence), 686.581*ns*buffer],
457447
[(op_divgrad_uₕ!, :none, :SetValue, :Extrapolate), 4.960*μs*buffer],
458448
[(op_divgrad_uₕ!, :none, :SetValue, :SetValue), 5.047*μs*buffer],
459449
]
@@ -475,7 +465,6 @@ function test_results_sphere(t_min)
475465
[(op_GradientF2C!, :none), 1.746*ms*buffer],
476466
[(op_GradientF2C!, :SetValue, :SetValue), 1.754*ms*buffer],
477467
[(op_GradientC2F!, :SetGradient, :SetGradient), 1.899*ms*buffer],
478-
[(op_GradientC2F!, :SetValue, :SetValue), 1.782*ms*buffer],
479468
[(op_DivergenceF2C!, :none), 6.792*ms*buffer],
480469
[(op_DivergenceF2C!, :Extrapolate, :Extrapolate), 6.776*ms*buffer],
481470
[(op_DivergenceC2F!, :SetDivergence, :SetDivergence), 6.720*ms*buffer],
@@ -492,13 +481,11 @@ function test_results_sphere(t_min)
492481
[(op_RightBiasedF2C!, :none), 1.582*ms*buffer],
493482
[(op_RightBiasedF2C!, :SetValue), 1.551*ms*buffer],
494483
[(op_CurlC2F!, :SetCurl, :SetCurl), 4.669*ms*buffer],
495-
[(op_CurlC2F!, :SetValue, :SetValue), 4.568*ms*buffer],
496-
[(op_UpwindBiasedProductC2F!, :SetValue, :SetValue), 3.444*ms*buffer],
497484
[(op_UpwindBiasedProductC2F!, :Extrapolate, :Extrapolate), 3.432*ms*buffer],
498485
[(op_divUpwind3rdOrderBiasedProductC2F!, :ThirdOrderOneSided, :ThirdOrderOneSided, :SetValue, :SetValue), 5.650*ms*buffer],
499486
[(op_divgrad_FF!, :none, :SetDivergence, :SetDivergence), 4.470*ms*buffer],
500487
[(op_div_interp_CC!, :SetValue, :SetValue, :none), 3.566*ms*buffer],
501-
[(op_div_interp_FF!, :none, :SetValue, :SetValue), 3.663*ms*buffer],
488+
[(op_div_interp_FF!, :none, :SetDivergence, :SetDivergence), 3.663*ms*buffer],
502489
[(op_divgrad_uₕ!, :none, :SetValue, :Extrapolate), 7.470*ms*buffer],
503490
[(op_divgrad_uₕ!, :none, :SetValue, :SetValue), 7.251*ms*buffer],
504491
]

test/Operators/finitedifference/convergence_column.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,8 @@ end
297297
divcosᶠ = divᶠ¹.(Geometry.WVector.(cos.(centers)))
298298

299299
curlᶠ = Operators.CurlC2F(
300-
left = Operators.SetValue(Geometry.Covariant12Vector(zero(FT), zero(FT))),
301-
right = Operators.SetValue(Geometry.Covariant12Vector(zero(FT), zero(FT))),
300+
left = Operators.SetCurl(Geometry.Contravariant12Vector(zero(FT), one(FT))),
301+
right = Operators.SetCurl(Geometry.Contravariant12Vector(zero(FT), -one(FT))),
302302
)
303303
curlsinᶠ = curlᶠ.(Geometry.Covariant12Vector.(sin.(centers), zero(FT)))
304304

@@ -328,7 +328,7 @@ end
328328
# DivergenceC2F conv, with f(z) = sin(z), SetValue
329329
# DivergenceC2F conv, with f(z) = cos(z), SetDivergence
330330
conv_div_cos_f = convergence_rate(err_div_cos_f, Δh)
331-
# CurlC2F with f(z) = sin(z), SetValue
331+
# CurlC2F with f(z) = sin(z), SetCurl
332332
conv_curl_sin_f = convergence_rate(err_curl_sin_f, Δh)
333333

334334
# GradientF2C conv, with f(z) = sin(z)
@@ -363,7 +363,7 @@ end
363363
@test conv_div_cos_f[3] 2 atol = 0.1
364364
@test conv_div_cos_f[1] conv_div_cos_f[2] conv_div_cos_f[3]
365365

366-
# CurlC2F with f(z) = sin(z), SetValue
366+
# CurlC2F with f(z) = sin(z), SetCurl
367367
@test err_curl_sin_f[3] err_curl_sin_f[2] err_curl_sin_f[1] 0.1
368368
@test conv_curl_sin_f[1] 2 atol = 0.1
369369
@test conv_curl_sin_f[2] 2 atol = 0.1

test/Operators/finitedifference/opt.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,6 @@ function opt_DivergenceC2F_SetDivergence(center_field)
164164
end
165165

166166

167-
function opt_CurlC2F_SetValue(center_field)
168-
# DivergenceC2F, SetDivergence
169-
curlᶠ = Operators.CurlC2F(
170-
left = Operators.SetValue(Geometry.Covariant1Vector(0.0)),
171-
right = Operators.SetValue(Geometry.Covariant1Vector(0.0)),
172-
)
173-
return curlᶠ.(Geometry.Covariant1Vector.(cos.(center_field)))
174-
end
175-
176167
# Test that Julia ia able to optimize Stencil operations v1.7+
177168
@static if @isdefined(var"@test_opt")
178169
@testset "Scalar Field FiniteDifferenceSpaces optimizations" begin
@@ -256,7 +247,6 @@ end
256247
@test_opt opt_GradientC2F_SetGradient(centers)
257248

258249
@test_opt opt_DivergenceC2F_SetDivergence(centers)
259-
@test_opt opt_CurlC2F_SetValue(centers)
260250
end
261251
end
262252
end

test/Operators/hybrid/opt.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,6 @@ function opt_DivergenceC2F_SetDivergence(center_field)
164164
return divᶠ.(Geometry.WVector.(cos.(center_field)))
165165
end
166166

167-
function opt_CurlC2F_SetValue(center_field)
168-
# DivergenceC2F, SetDivergence
169-
curlᶠ = Operators.CurlC2F(
170-
left = Operators.SetValue(Geometry.Covariant1Vector(0.0)),
171-
right = Operators.SetValue(Geometry.Covariant1Vector(0.0)),
172-
)
173-
return curlᶠ.(Geometry.Covariant1Vector.(cos.(center_field)))
174-
end
175-
176167
function hspace1d(FT)
177168
hdomain = Domains.IntervalDomain(
178169
Geometry.XPoint{FT}(-pi) .. Geometry.XPoint{FT}(pi),
@@ -288,7 +279,6 @@ end
288279
@test_opt opt_GradientC2F_SetGradient(centers)
289280

290281
@test_opt opt_DivergenceC2F_SetDivergence(centers)
291-
@test_opt opt_CurlC2F_SetValue(centers)
292282
end
293283
end
294284

test/Operators/hybrid/unit_2d.jl

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,11 @@ end
145145

146146
diffu = zeros(eltype(u), hv_center_space)
147147
gradc2f = Operators.GradientC2F(
148-
top = Operators.SetValue(0.0),
149-
bottom = Operators.SetValue(0.0),
150148
)
151-
divf2c = Operators.DivergenceF2C()
149+
divf2c = Operators.DivergenceF2C(;
150+
top = Operators.SetDivergence(0.0),
151+
bottom = Operators.SetDivergence(0.0),
152+
)
152153
@. diffu = divf2c(K * gradc2f(u))
153154

154155
hgrad = Operators.Gradient()
@@ -197,11 +198,11 @@ end
197198
function vec_diff(K, U)
198199

199200
vec_diff = zeros(eltype(U), hv_center_space)
200-
gradc2f = Operators.GradientC2F(
201-
top = Operators.SetValue(Geometry.UVector(0.0)),
202-
bottom = Operators.SetValue(Geometry.UVector(0.0)),
201+
gradc2f = Operators.GradientC2F()
202+
divf2c = Operators.DivergenceF2C(;
203+
top = Operators.SetDivergence(Geometry.UVector(0.0)),
204+
bottom = Operators.SetDivergence(Geometry.UVector(0.0)),
203205
)
204-
divf2c = Operators.DivergenceF2C()
205206
@. vec_diff = divf2c(K * gradc2f(U))
206207

207208
hgrad = Operators.Gradient()
@@ -262,8 +263,8 @@ end
262263

263264
curl = Operators.Curl()
264265
curlC2F = Operators.CurlC2F(
265-
bottom = Operators.SetValue(Geometry.Covariant1Vector(0.0)),
266-
top = Operators.SetValue(Geometry.Covariant1Vector(0.0)),
266+
bottom = Operators.SetCurl(Geometry.Contravariant2Vector(2.0)),
267+
top = Operators.SetCurl(Geometry.Contravariant2Vector(2.0)),
267268
)
268269

269270
curlu = curlC2F.(u)
@@ -297,7 +298,7 @@ end
297298
ccoords = Fields.coordinate_field(hv_center_space)
298299
fcoords = Fields.coordinate_field(hv_face_space)
299300
fcoords_1 = Fields.level(fcoords, ClimaCore.Utilities.half)
300-
curl_bcfield₁ = Geometry.Covariant1Vector.(0.0 .* fcoords_1.z)
301+
curl_bcfield₁ = Geometry.Contravariant2Vector(2.0)
301302
curl_bcfield² = Geometry.Contravariant2Vector.(0.0 .* fcoords_1.z)
302303

303304
u =
@@ -313,8 +314,8 @@ end
313314

314315
curl = Operators.Curl()
315316
curlC2F = Operators.CurlC2F(
316-
bottom = Operators.SetValue(curl_bcfield₁),
317-
top = Operators.SetValue(Geometry.Covariant1Vector(0.0)),
317+
bottom = Operators.SetCurl(curl_bcfield₁),
318+
top = Operators.SetCurl(Geometry.Contravariant2Vector(2.0)),
318319
)
319320

320321
curlu = curlC2F.(u)

0 commit comments

Comments
 (0)