Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
cefc77b
Optimize kernels and kernel gradients
efaulhaber Mar 24, 2026
97ef7b0
Enable quartic spline kernel test on GPUs
efaulhaber Mar 25, 2026
f1cede8
Fix corrections
efaulhaber Mar 25, 2026
93f106a
Implement copilot suggestions
efaulhaber Mar 25, 2026
b662efd
Fix tests
efaulhaber Mar 25, 2026
52daa61
Fix docs tutorial
efaulhaber Mar 25, 2026
134de11
Merge branch 'main' into optimize-kernels
efaulhaber Mar 25, 2026
69b0cb1
Fix docs tutorial
efaulhaber Apr 1, 2026
2ba2d0d
Add 1D kernel tests
efaulhaber Apr 2, 2026
8ea6e52
Remove unused function
efaulhaber Apr 2, 2026
7900854
Merge branch 'main' into optimize-kernels
efaulhaber Apr 2, 2026
bd83177
Remove zero distance check for density diffusion
efaulhaber Apr 2, 2026
6faa918
Fix Laguerre kernel
efaulhaber Apr 2, 2026
ac3016e
Fix
efaulhaber Apr 7, 2026
b1bff6e
Merge branch 'main' into optimize-kernels
efaulhaber Apr 7, 2026
cf85299
Fix division by zero in density diffusion by adding checks in all int…
efaulhaber Apr 7, 2026
099b255
Fix tests
efaulhaber Apr 7, 2026
7eb5a4f
Reformat
efaulhaber Apr 7, 2026
0a7d190
Fix tests
efaulhaber Apr 7, 2026
183bdad
Fix comment
efaulhaber Apr 7, 2026
4d0a097
Fix GPU tests
efaulhaber Apr 7, 2026
015faf3
Add more comments
efaulhaber Apr 7, 2026
bcbf8c9
Fix
efaulhaber Apr 7, 2026
47c4007
Remove `@muladd` and dependency
efaulhaber Apr 9, 2026
8dfaa3e
Add docs
efaulhaber Apr 10, 2026
6bf3c57
Merge remote-tracking branch 'origin/main' into optimize-kernels
efaulhaber Apr 10, 2026
2ae1f15
Fix merge
efaulhaber Apr 10, 2026
26d0109
Merge branch 'main' into optimize-kernels
efaulhaber Apr 13, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/TrixiParticles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ using Reexport: @reexport

using Accessors: @set
using Adapt: Adapt
using Base: @propagate_inbounds
using Base: @propagate_inbounds, FastMath.div_fast
using CSV: CSV
using Dates
using DataFrames: DataFrames, DataFrame
Expand Down
26 changes: 23 additions & 3 deletions src/general/abstract_system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,30 @@ end
return kernel(smoothing_kernel, distance, smoothing_length(system, particle))
end

@inline function skip_zero_distance(system, distance, almostzero)
return skip_zero_distance(system_correction(system), system, distance, almostzero)
end

# Robust/safe version of the function below. In performance-critical code, manually check
# the kernel support, call `skip_zero_distance` and then `smoothing_kernel_grad_unsafe`.
@inline function smoothing_kernel_grad(system, pos_diff, distance, particle)
return corrected_kernel_grad(system_smoothing_kernel(system), pos_diff,
distance, smoothing_length(system, particle),
system_correction(system), system, particle)
h = smoothing_length(system, particle)
compact_support_ = compact_support(kernel, h)

# Note that `sqrt(eps(h^2)) != eps(h)`
if distance > compact_support_ || skip_zero_distance(system, distance, sqrt(eps(h^2)))
return zero(pos_diff)
end

return smoothing_kernel_grad_unsafe(system, pos_diff, distance, particle)
end

# Skip the zero distance and compact support checks for maximum performance.
# Only call this when you are sure that `0 < distance < compact_support`.
@inline function smoothing_kernel_grad_unsafe(system, pos_diff, distance, particle)
return corrected_kernel_grad_unsafe(system_smoothing_kernel(system), pos_diff,
distance, smoothing_length(system, particle),
system_correction(system), system, particle)
end

# System updates do nothing by default, but can be dispatched if needed
Expand Down
Loading
Loading