Skip to content

Commit

Permalink
Fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
luraess committed Mar 5, 2024
1 parent 9a9694c commit 739c201
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/LevelSets/LevelSets.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module LevelSets

export compute_level_set_from_dem!
export volfrac_field, compute_volume_fractions_from_level_set!
export volfrac_field, compute_volfrac_from_level_set!

# using Chmy
using Chmy.Architectures
using Chmy.Grids
using Chmy.Fields
Expand Down
5 changes: 3 additions & 2 deletions src/LevelSets/compute_level_sets.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Initialize level sets.
"""
@kernel function init_level_set!::Field, dem::Field, dem_grid::UniformGrid, Ψ_grid::UniformGrid, cutoff, R)
@kernel inbounds = true function init_level_set!::Field, dem::Field, dem_grid::UniformGrid, Ψ_grid::UniformGrid, cutoff, R)
I = @index(Global, NTuple)
x, y, z = coord(Ψ_grid, location(Ψ), I...)

Check warning on line 8 in src/LevelSets/compute_level_sets.jl

View check run for this annotation

Codecov / codecov/patch

src/LevelSets/compute_level_sets.jl#L6-L8

Added lines #L6 - L8 were not covered by tests
P = R * Point3(x, y, z)
Expand All @@ -16,7 +16,8 @@ end
Compute level sets from dem.
"""
function compute_level_set_from_dem!(backend, Ψ::Field, dem::Field, dem_grid::UniformGrid, Ψ_grid::UniformGrid, R=LinearAlgebra.I)
function compute_level_set_from_dem!(arch::Architecture, Ψ::Field, dem::Field, dem_grid::UniformGrid, Ψ_grid::UniformGrid, R=LinearAlgebra.I)
backend = Architectures.get_backend(arch)
kernel = init_level_set!(backend, 256, size(Ψ))
cutoff = 4maximum(spacing(Ψ_grid, Center()))

Check warning on line 22 in src/LevelSets/compute_level_sets.jl

View check run for this annotation

Codecov / codecov/patch

src/LevelSets/compute_level_sets.jl#L19-L22

Added lines #L19 - L22 were not covered by tests
kernel(Ψ, dem, dem_grid, Ψ_grid, cutoff, R)
Expand Down
10 changes: 8 additions & 2 deletions src/LevelSets/compute_volume_fractions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,14 @@ end

include("volume_fractions_kernels.jl")

function compute_volume_fractions_from_level_set!(backend::Backend, wt, Ψ, grid::UniformGrid)
kernel = kernel_compute_volume_fractions_from_level_set!(backend, 256, size(Ψ))
"""
compute_volfrac_from_level_set!(arch::Architecture, wt::Field, Ψ::Field, grid::UniformGrid)
Compute volume fractions from level sets.
"""
function compute_volfrac_from_level_set!(arch::Architecture, wt::Field, Ψ::Field, grid::UniformGrid)
backend = Architectures.get_backend(arch)
kernel = compute_volfrac_from_level_set!(backend, 256, size(Ψ))
kernel(wt, Ψ, grid)
return

Check warning on line 148 in src/LevelSets/compute_volume_fractions.jl

View check run for this annotation

Codecov / codecov/patch

src/LevelSets/compute_volume_fractions.jl#L144-L148

Added lines #L144 - L148 were not covered by tests
end
4 changes: 2 additions & 2 deletions src/LevelSets/volume_fractions_kernels.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Volume fraction kernel (2D)
@kernel inbounds = true function kernel_compute_volume_fractions_from_level_set!(wt, Ψ, grid::UniformGrid{2})
@kernel inbounds = true function compute_volfrac_from_level_set!(wt, Ψ, grid::UniformGrid{2})
ix, iy = @index(Global, NTuple)
dx, dy = spacing(grid, Center())
cell = Rect(Vec(0.0, 0.0), Vec(dx, dy))
Expand All @@ -22,7 +22,7 @@
end

# Volume fraction kernel (3D)
@kernel inbounds = true function kernel_compute_volume_fractions_from_level_set!(wt, Ψ, grid::UniformGrid{3})
@kernel inbounds = true function compute_volfrac_from_level_set!(wt, Ψ, grid::UniformGrid{3})
ix, iy, iz = @index(Global, NTuple)
dx, dy, dz = spacing(grid, Center())
cell = Rect(Vec(0.0, 0.0, 0.0), Vec(dx, dy, dz))
Expand Down

0 comments on commit 739c201

Please sign in to comment.