Skip to content

Commit

Permalink
allow broadcasting over horizontal spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
simonbyrne committed Jun 15, 2023
1 parent 9157f35 commit 4b8ab77
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 12 deletions.
7 changes: 7 additions & 0 deletions src/Fields/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ end
parent(Spaces.local_geometry_data(space2))
)
warn_mismatched_spaces(typeof(space1), typeof(space2))
elseif Spaces.issubspace(space2, space1)
return space1
elseif Spaces.issubspace(space1, space2)
return space2
else
error_mismatched_spaces(typeof(space1), typeof(space2))
end
Expand Down Expand Up @@ -229,6 +233,9 @@ end
parent(Spaces.local_geometry_data(space2))
)
warn_mismatched_spaces(typeof(space1), typeof(space2))
elseif Spaces.issubspace(space2, space1) ||
Spaces.issubspace(space1, space2)
nothing
else
error_mismatched_spaces(typeof(space1), typeof(space2))
end
Expand Down
2 changes: 2 additions & 0 deletions src/Spaces/Spaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ using StaticArrays, ForwardDiff, LinearAlgebra, UnPack, Adapt

abstract type AbstractSpace end

issubspace(::AbstractSpace, ::AbstractSpace) = false

undertype(space::AbstractSpace) =
Geometry.undertype(eltype(local_geometry_data(space)))

Expand Down
15 changes: 15 additions & 0 deletions src/Spaces/extruded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ struct ExtrudedFiniteDifferenceSpace{
face_ghost_geometry::LGG
end

function issubspace(
hspace::AbstractSpectralElementSpace,
extruded_space::ExtrudedFiniteDifferenceSpace,
)
if hspace === extruded_space.horizontal_space
return true
end
# TODO: improve level handling
return Spaces.topology(hspace) ===
Spaces.topology(extruded_space.horizontal_space) &&
quadrature_style(hspace) ===
quadrature_style(extruded_space.horizontal_space)
end


Adapt.adapt_structure(to, space::ExtrudedFiniteDifferenceSpace) =
ExtrudedFiniteDifferenceSpace(
space.staggering,
Expand Down
14 changes: 2 additions & 12 deletions test/Fields/field.jl
Original file line number Diff line number Diff line change
Expand Up @@ -430,18 +430,8 @@ end
ᶜx_surf = Spaces.level(Y.x, TU.fc_index(1, space))

# Still need to define broadcast rules for surface planes with 3D domains
if nameof(typeof(space)) == :ExtrudedFiniteDifferenceSpace
@test_broken begin
try
domain_surface_bc!(Y.x, ᶜz_surf)
true
catch
false
end
end
else
domain_surface_bc!(Y.x, ᶜz_surf, ᶜx_surf)
end
domain_surface_bc!(Y.x, ᶜz_surf, ᶜx_surf)

# Skip spaces incompatible with Fields.bycolumn:
TU.bycolumnable(space) || continue
column_surface_bc!(Y.x, ᶜz_surf, ᶜx_surf)
Expand Down

0 comments on commit 4b8ab77

Please sign in to comment.