Skip to content

Commit

Permalink
For Covariant123Vector types, transforms the
Browse files Browse the repository at this point in the history
3rd velocity component instead of treating it
as a scalar variable
	modified:   ext/cuda/topologies_dss.jl
	modified:   src/Topologies/dss.jl
	modified:   src/Topologies/dss_transform.jl
        modified:   test/Spaces/terrain_warp.jl
	modified:   test/Spaces/ddss1_cs.jl
        +format

Remove dss-op on surface elevation horizontal gradient
	modified:   src/Hypsography/Hypsography.jl
	modified:   test/Spaces/terrain_warp.jl
	modified:   src/Topologies/dss_transform.jl
  • Loading branch information
akshaysridhar committed Jul 31, 2024
1 parent cf881de commit c38d9f8
Show file tree
Hide file tree
Showing 6 changed files with 461 additions and 24 deletions.
131 changes: 131 additions & 0 deletions ext/cuda/topologies_dss.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,8 @@ function Topologies.dss_transform!(
scalarfidx::AbstractVector{Int},
covariant12fidx::AbstractVector{Int},
contravariant12fidx::AbstractVector{Int},
covariant123fidx::AbstractVector{Int},
contravariant123fidx::AbstractVector{Int},
localelems::AbstractVector{Int},
)
nlocalelems = length(localelems)
Expand All @@ -212,6 +214,8 @@ function Topologies.dss_transform!(
scalarfidx,
covariant12fidx,
contravariant12fidx,
covariant123fidx,
contravariant123fidx,
localelems,
)
auto_launch!(
Expand All @@ -236,6 +240,8 @@ function dss_transform_kernel!(
scalarfidx::AbstractVector{Int},
covariant12fidx::AbstractVector{Int},
contravariant12fidx::AbstractVector{Int},
covariant123fidx::AbstractVector{Int},
contravariant123fidx::AbstractVector{Int},
localelems::AbstractVector{Int},
) where {FT <: AbstractFloat, Nq}
gidx = threadIdx().x + (blockIdx().x - 1) * blockDim().x
Expand Down Expand Up @@ -288,6 +294,81 @@ function dss_transform_kernel!(
p∂x∂ξ[idx22] * pdata[data_idx2]
) * weight
end
for fidx in covariant123fidx
data_idx1 =
Topologies.linear_ind(sizet_data, (level, ip, jp, fidx, elem))
data_idx2 = Topologies.linear_ind(
sizet_data,
(level, ip, jp, fidx + 1, elem),
)
data_idx3 = Topologies.linear_ind(
sizet_data,
(level, ip, jp, fidx + 2, elem),
)

(idx11, idx12, idx13, idx21, idx22, idx23, idx31, idx32, idx33) =
Topologies._get_idx_metric_3d(
sizet_metric,
(level, ip, jp, elem),
)

# Covariant to physical transformation
pperimeter_data[level, p, fidx, elem] =
(
p∂ξ∂x[idx11] * pdata[data_idx1] +
p∂ξ∂x[idx12] * pdata[data_idx2] +
p∂ξ∂x[idx13] * pdata[data_idx3]
) * weight
pperimeter_data[level, p, fidx + 1, elem] =
(
p∂ξ∂x[idx21] * pdata[data_idx1] +
p∂ξ∂x[idx22] * pdata[data_idx2] +
p∂ξ∂x[idx23] * pdata[data_idx3]
) * weight
pperimeter_data[level, p, fidx + 2, elem] =
(
p∂ξ∂x[idx31] * pdata[data_idx1] +
p∂ξ∂x[idx32] * pdata[data_idx2] +
p∂ξ∂x[idx33] * pdata[data_idx3]
) * weight
end

for fidx in contravariant123fidx
data_idx1 =
Topologies.linear_ind(sizet_data, (level, ip, jp, fidx, elem))
data_idx2 = Topologies.linear_ind(
sizet_data,
(level, ip, jp, fidx + 1, elem),
)
data_idx3 = Topologies.linear_ind(
sizet_data,
(level, ip, jp, fidx + 2, elem),
)
(idx11, idx12, idx13, idx21, idx22, idx23, idx31, idx32, idx33) =
Topologies._get_idx_metric_3d(
sizet_metric,
(level, ip, jp, elem),
)
# Contravariant to physical transformation
pperimeter_data[level, p, fidx, elem] =
(
p∂x∂ξ[idx11] * pdata[data_idx1] +
p∂x∂ξ[idx21] * pdata[data_idx2] +
p∂x∂ξ[idx31] * pdata[data_idx3]
) * weight
pperimeter_data[level, p, fidx + 1, elem] =
(
p∂x∂ξ[idx12] * pdata[data_idx1] +
p∂x∂ξ[idx22] * pdata[data_idx2] +
p∂x∂ξ[idx32] * pdata[data_idx3]
) * weight
pperimeter_data[level, p, fidx + 2, elem] =
(
p∂x∂ξ[idx13] * pdata[data_idx1] +
p∂x∂ξ[idx23] * pdata[data_idx2] +
p∂x∂ξ[idx33] * pdata[data_idx3]
) * weight
end
end
return nothing
end
Expand All @@ -302,6 +383,8 @@ function Topologies.dss_untransform!(
scalarfidx::AbstractVector{Int},
covariant12fidx::AbstractVector{Int},
contravariant12fidx::AbstractVector{Int},
covariant123fidx::AbstractVector{Int},
contravariant123fidx::AbstractVector{Int},
localelems::AbstractVector{Int},
) where {Nq}
nlocalelems = length(localelems)
Expand All @@ -324,6 +407,8 @@ function Topologies.dss_untransform!(
scalarfidx,
covariant12fidx,
contravariant12fidx,
covariant123fidx,
contravariant123fidx,
localelems,
)
auto_launch!(
Expand All @@ -347,6 +432,8 @@ function dss_untransform_kernel!(
scalarfidx::AbstractVector{Int},
covariant12fidx::AbstractVector{Int},
contravariant12fidx::AbstractVector{Int},
covariant123fidx::AbstractVector{Int},
contravariant123fidx::AbstractVector{Int},
localelems::AbstractVector{Int},
) where {FT <: AbstractFloat, Nq}
gidx = threadIdx().x + (blockIdx().x - 1) * blockDim().x
Expand Down Expand Up @@ -389,6 +476,50 @@ function dss_untransform_kernel!(
p∂ξ∂x[idx12] * pperimeter_data[level, p, fidx, elem] +
p∂ξ∂x[idx22] * pperimeter_data[level, p, fidx + 1, elem]
end
for fidx in covariant123fidx
data_idx1 = linear_ind(sizet_data, (level, ip, jp, fidx, elem))
data_idx2 = linear_ind(sizet_data, (level, ip, jp, fidx + 1, elem))
data_idx3 = linear_ind(sizet_data, (level, ip, jp, fidx + 2, elem))
(idx11, idx12, idx13, idx21, idx22, idx23, idx31, idx32, idx33) =
Topologies._get_idx_metric_3d(
sizet_metric,
(level, ip, jp, elem),
)
pdata[data_idx1] =
p∂x∂ξ[idx11] * pperimeter_data[level, p, fidx, elem] +
p∂x∂ξ[idx12] * pperimeter_data[level, p, fidx + 1, elem] +
p∂x∂ξ[idx13] * pperimeter_data[level, p, fidx + 2, elem]
pdata[data_idx2] =
p∂x∂ξ[idx21] * pperimeter_data[level, p, fidx, elem] +
p∂x∂ξ[idx22] * pperimeter_data[level, p, fidx + 1, elem] +
p∂x∂ξ[idx23] * pperimeter_data[level, p, fidx + 2, elem]
pdata[data_idx3] =
p∂x∂ξ[idx31] * pperimeter_data[level, p, fidx, elem] +
p∂x∂ξ[idx32] * pperimeter_data[level, p, fidx + 1, elem] +
p∂x∂ξ[idx33] * pperimeter_data[level, p, fidx + 2, elem]
end
for fidx in contravariant123fidx
data_idx1 = linear_ind(sizet_data, (level, ip, jp, fidx, elem))
data_idx2 = linear_ind(sizet_data, (level, ip, jp, fidx + 1, elem))
data_idx3 = linear_ind(sizet_data, (level, ip, jp, fidx + 2, elem))
(idx11, idx12, idx13, idx21, idx22, idx23, idx31, idx32, idx33) =
Topologies._get_idx_metric_3d(
sizet_metric,
(level, ip, jp, elem),
)
pdata[data_idx1] =
p∂ξ∂x[idx11] * pperimeter_data[level, p, fidx, elem] +
p∂ξ∂x[idx21] * pperimeter_data[level, p, fidx + 1, elem] +
p∂ξ∂x[idx31] * pperimeter_data[level, p, fidx + 2, elem]
pdata[data_idx2] =
p∂ξ∂x[idx12] * pperimeter_data[level, p, fidx, elem] +
p∂ξ∂x[idx22] * pperimeter_data[level, p, fidx + 1, elem]
p∂ξ∂x[idx32] * pperimeter_data[level, p, fidx + 2, elem]
pdata[data_idx3] =
p∂ξ∂x[idx13] * pperimeter_data[level, p, fidx, elem] +
p∂ξ∂x[idx23] * pperimeter_data[level, p, fidx + 1, elem] +
p∂ξ∂x[idx33] * pperimeter_data[level, p, fidx + 2, elem]
end
end
return nothing
end
Expand Down
2 changes: 0 additions & 2 deletions src/Hypsography/Hypsography.jl
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,6 @@ function _ExtrudedFiniteDifferenceGrid(
f = Spaces.create_dss_buffer(face_∇Z_field),
)

Spaces.weighted_dss!(center_∇Z_field => buffer.c, face_∇Z_field => buffer.f)

# construct full local geometry
center_local_geometry =
Geometry.product_geometry.(
Expand Down
Loading

0 comments on commit c38d9f8

Please sign in to comment.