Skip to content

Commit

Permalink
Fix some conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Aug 29, 2024
1 parent 78ac7bb commit 515b92b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
14 changes: 8 additions & 6 deletions ext/cuda/topologies_dss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,13 @@ function dss_transform_kernel!(
elem = localelems[localelemno]
(ip, jp) = perimeter[p]
loc = CI(ip, jp, 1, level, elem)
wt = weight[loc]
perimeter_data[CI(p, 1, 1, level, elem)] = Topologies.dss_transform(
src = Topologies.dss_transform(
data[loc],
local_geometry[CI(ip, jp, 1, level, elem)],
wt,
local_geometry[loc],
weight[loc],
)
perimeter_data[CI(p, 1, 1, level, elem)] =
Topologies.drop_vert_dim(eltype(perimeter_data), src)
end
return nothing
end
Expand Down Expand Up @@ -291,10 +292,11 @@ function dss_untransform_kernel!(
elem = localelems[localelemno]
ip, jp = perimeter[p]

data[CI(ip, jp, 1, level, elem)] = Topologies.dss_untransform(
loc = CI(ip, jp, 1, level, elem)
data[loc] = Topologies.dss_untransform(
eltype(data),
perimeter_data[CI(p, 1, 1, level, elem)],
local_geometry[CI(ip, jp, 1, level, elem)],
local_geometry[loc],
)
end
return nothing
Expand Down
17 changes: 14 additions & 3 deletions src/Topologies/dss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ function dss_transform!(
return nothing
end

# For DSS of Covariant123Vector, the third component is treated like a scalar
# and is not transformed
@inline drop_vert_dim(
::Type{T},
x::Geometry.UVWVector,
) where {T <: Geometry.UVVector} = Geometry.UVVector(x.u, x.v)
@inline drop_vert_dim(::Type{T}, x::T) where {T} = x
@inline drop_vert_dim(::Type{T}, x::Real) where {T <: Real} = x

"""
function dss_transform!(
::ClimaComms.AbstractCPUDevice,
Expand Down Expand Up @@ -215,12 +224,14 @@ function dss_transform!(
for (p, (ip, jp)) in enumerate(perimeter)
for level in 1:nlevels
loc = CI(ip, jp, 1, level, elem)
wt = weight[loc]
perimeter_data[CI(p, 1, 1, level, elem)] = dss_transform(
src = dss_transform(
data[loc],
local_geometry[CI(ip, jp, 1, level, elem)],
wt,
weight[loc],
)
perimeter_data[CI(p, 1, 1, level, elem)] =
drop_vert_dim(eltype(perimeter_data), src)

end
end
end
Expand Down

0 comments on commit 515b92b

Please sign in to comment.