Skip to content

Commit

Permalink
Access field mask struct as Tuple (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
luraess authored May 15, 2024
2 parents 6677cf7 + 69cc558 commit 0bfa360
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Chmy"
uuid = "33a72cf0-4690-46d7-b987-06506c2248b9"
authors = ["Ivan Utkin <[email protected]>, Ludovic Raess <[email protected]>, and contributors"]
version = "0.1.12"
version = "0.1.13"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
4 changes: 4 additions & 0 deletions src/GridOperators/field_mask.jl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ FieldMask(arch::Architecture, grid::StructuredGrid{1}, args...; kwargs...) = Fie
FieldMask(arch::Architecture, grid::StructuredGrid{2}, args...; kwargs...) = FieldMask2D(arch, grid, args...; kwargs...)
FieldMask(arch::Architecture, grid::StructuredGrid{3}, args...; kwargs...) = FieldMask3D(arch, grid, args...; kwargs...)

Tuple(f::FieldMask1D) = (f.c, f.v)
Tuple(f::FieldMask2D) = (f.cc, f.vv, f.vc, f.cv)
Tuple(f::FieldMask3D) = (f.ccc, f.ccc, f.vvv, f.vcc, f.cvc, f.ccv, f.vvc, f.vcv, f.cvv)

# Adapt rules

Adapt.adapt_structure(to, f::FieldMask1D{T}) where {T} = FieldMask1D{T}(Adapt.adapt(to, f.c), Adapt.adapt(to, f.v))
Expand Down

0 comments on commit 0bfa360

Please sign in to comment.