|
1 | 1 | using Test
|
2 | 2 | using StaticArrays, IntervalSets, LinearAlgebra
|
3 |
| - |
| 3 | +using ClimaCore |
4 | 4 | using ClimaComms
|
5 | 5 | ClimaComms.@import_required_backends
|
6 | 6 | import ClimaCore: slab, Domains, Meshes, Topologies, Spaces, Fields, Operators
|
|
298 | 298 | cy_ref = [i == length(cyp) ? FT(10) : fyp[i + 1] for i in 1:length(cyp)]
|
299 | 299 | @test all(cy_ref .== cyp)
|
300 | 300 | end
|
| 301 | + |
| 302 | +# https://github.com/CliMA/ClimaCore.jl/issues/994 |
| 303 | +# TODO: make this test more low-level / granular (test `getidx`). |
| 304 | +@testset "Spatially varying BC with Grad" begin |
| 305 | + FT = Float64 |
| 306 | + zmin = FT(1.0) |
| 307 | + zmax = FT(2.0) |
| 308 | + xlim = FT.((0.0, 10.0)) |
| 309 | + ylim = FT.((0.0, 1.0)) |
| 310 | + zlim = FT.((zmin, zmax)) |
| 311 | + nelements = (1, 1, 5) |
| 312 | + npolynomial = 3 |
| 313 | + domain_x = Domains.IntervalDomain( |
| 314 | + Geometry.XPoint(xlim[1]), |
| 315 | + Geometry.XPoint(xlim[2]); |
| 316 | + periodic = true, |
| 317 | + ) |
| 318 | + domain_y = Domains.IntervalDomain( |
| 319 | + Geometry.YPoint(ylim[1]), |
| 320 | + Geometry.YPoint(ylim[2]); |
| 321 | + periodic = true, |
| 322 | + ) |
| 323 | + plane = Domains.RectangleDomain(domain_x, domain_y) |
| 324 | + context = ClimaComms.context() |
| 325 | + mesh = Meshes.RectilinearMesh(plane, nelements[1], nelements[2]) |
| 326 | + grid_topology = Topologies.Topology2D(context, mesh) |
| 327 | + quad = Spaces.Quadratures.GLL{npolynomial + 1}() |
| 328 | + horzspace = Spaces.SpectralElementSpace2D(grid_topology, quad) |
| 329 | + |
| 330 | + |
| 331 | + vertdomain = Domains.IntervalDomain( |
| 332 | + Geometry.ZPoint(zlim[1]), |
| 333 | + Geometry.ZPoint(zlim[2]); |
| 334 | + boundary_names = (:bottom, :top), |
| 335 | + ) |
| 336 | + vertmesh = Meshes.IntervalMesh(vertdomain, nelems = nelements[3]) |
| 337 | + vert_center_space = Spaces.CenterFiniteDifferenceSpace(vertmesh) |
| 338 | + |
| 339 | + hv_center_space = |
| 340 | + Spaces.ExtrudedFiniteDifferenceSpace(horzspace, vert_center_space) |
| 341 | + |
| 342 | + surface_field = Fields.zeros(horzspace) |
| 343 | + |
| 344 | + ψ = Fields.ones(hv_center_space) |
| 345 | + value = surface_field # same type/instance of underlying space as horizontal space of \psi |
| 346 | + |
| 347 | + gradc2f_no_bc = Operators.GradientC2F() |
| 348 | + divf2c = Operators.DivergenceF2C( |
| 349 | + top = Operators.SetValue(Geometry.WVector.(value)), |
| 350 | + bottom = Operators.SetValue(Geometry.WVector(FT(0.0))), |
| 351 | + ) |
| 352 | + @. divf2c(gradc2f_no_bc(ψ)) # runs |
| 353 | + |
| 354 | + gradc2f = Operators.GradientC2F(; |
| 355 | + top = Operators.SetValue(value), |
| 356 | + bottom = Operators.SetValue{FT}(0.0), |
| 357 | + ) |
| 358 | + gradc2f.(ψ) # fails |
| 359 | +end |
0 commit comments