-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix reinstantiation of spectral broadcasted
- Loading branch information
1 parent
bbad885
commit e2693e7
Showing
3 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#= | ||
julia --project=.buildkite | ||
using Revise; include("test/Operators/unit_reinstantiate_bc.jl") | ||
=# | ||
|
||
# TODO: make this unit test more low-level | ||
using ClimaComms | ||
ClimaComms.@import_required_backends | ||
using ClimaCore.CommonSpaces | ||
using ClimaCore: Spaces, Fields, Geometry, ClimaCore, Operators | ||
using LazyBroadcast: lazy | ||
using Test | ||
using Base.Broadcast: materialize | ||
|
||
const divₕ = Operators.Divergence() | ||
const wgradₕ = Operators.WeakGradient() | ||
const curlₕ = Operators.Curl() | ||
const wcurlₕ = Operators.WeakCurl() | ||
|
||
using ClimaCore.CommonSpaces | ||
|
||
function foo_tendency_uₕ(ᶜuₕ, zmax) | ||
return lazy.( | ||
@. ( | ||
wgradₕ(divₕ(ᶜuₕ)) - Geometry.project( | ||
Geometry.Covariant12Axis(), | ||
wcurlₕ(Geometry.project(Geometry.Covariant3Axis(), curlₕ(ᶜuₕ))), | ||
) | ||
) | ||
) | ||
end | ||
|
||
@testset "Reinstantiation of SpectralBroadcasted" begin | ||
FT = Float64 | ||
ᶜspace = ExtrudedCubedSphereSpace( | ||
FT; | ||
z_elem = 10, | ||
z_min = 0, | ||
z_max = 1, | ||
radius = 10, | ||
h_elem = 10, | ||
n_quad_points = 4, | ||
staggering = CellCenter(), | ||
) | ||
ᶠspace = Spaces.face_space(ᶜspace) | ||
ᶠz = Fields.coordinate_field(ᶠspace).z | ||
ᶜz = Fields.coordinate_field(ᶜspace).z | ||
ᶜuₕ = map(z -> zero(Geometry.Covariant12Vector{eltype(z)}), ᶜz) | ||
zmax = Spaces.z_max(axes(ᶠz)) | ||
vst_uₕ = foo_tendency_uₕ(ᶜuₕ, zmax) | ||
ᶜuₕₜ = zero(ᶜuₕ) | ||
@. ᶜuₕₜ += vst_uₕ | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters