LudwigBoess / SPHKernels.jl

Julia implementation of some common SPH kernels
MIT License
10 stars 0 forks source link

Non normalize methods #32

Open PharmCat opened 7 months ago

PharmCat commented 7 months ago

Hi! I try to apply SPHKernels.jl for GPU kernel but for performance purpose it important to get only result of kernel function, and make multiplication kernel.norm * h_inv after summation.

function kernel_value(kernel::WendlandC2_1D{T}, u::Real, h_inv::Real) where {T}

    if u < 1
        n = kernel.norm * h_inv
        t1 = 1 - u
        t3 = t1 * t1 * t1
        return (t3 * (1 + 3u)) * n |> T
    else
        return 0 |> T
    end

end

is it possible to make method like that?:

function kernel_value(kernel::WendlandC2_1D{T}, u::Real, h_inv::Real, norm::Bool = true) where {T}
    if u < 1
        t1 = 1 - u
        t3 = t1 * t1 * t1
        val = t3 * (1 + 3u)
        ifelse(norm, return val  * kernel.norm * h_inv, return val) |> T  # `|> T`   this is potential issue for ForwardDiff and have few sense 
    end
    return zero(T)
end

so actually need method to get normalization constant for each function.