Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Seems StaticArrays and tuples not supported #31

Closed
PharmCat opened this issue Feb 5, 2024 · 1 comment · Fixed by #33
Closed

Seems StaticArrays and tuples not supported #31

PharmCat opened this issue Feb 5, 2024 · 1 comment · Fixed by #33

Comments

@PharmCat
Copy link

PharmCat commented Feb 5, 2024

Hello!

I used concept-code:

   using SPHKernels, StaticArrays
    sphk     = WendlandC6(Float64, 3)
    r     = 0.5
    h     = 1.0
    h_inv = 1.0 / h
    u     = r * h_inv
    Δx    = SVector((0.1,0.1,0.1))
    ∇𝒲(sphk, r, h⁻¹, Δx)

Seems StaticArrays and tuples not supported.

ERROR: MethodError: no method matching ∇𝒲 (::WendlandC6{Float64}, ::Float64, ::Float64, ::SVector{3, Float64})
Closest candidates are:
  ∇𝒲(::AbstractSPHKernel, ::Real, ::Real,  ::Union{Real, Vector{<:Real}}) at .julia\packages\SPHKernels\SDriS\src\sph_functions\gradient.jl:87
  ∇𝒲(::AbstractSPHKernel, ::Real, ::Union{Real, Vector{<:Real}},  ::Union{Real, Vector{<:Real}}) at .julia\packages\SPHKernels\SDriS\src\sph_functions\gradient.jl:74
Stacktrace:

So maybe make method definition:

∇𝒲(::AbstractSPHKernel, ::Real, ::Real,  ::Union{Real, AbstrcatVector{<:Real}, Tuple{Real, Real}, Tuple{Real, Real, Real} })

So I see 3 functions:

function kernel_gradient( k::AbstractSPHKernel, h_inv::Real,  xᵢ::Vector{<:Real},  xⱼ::Vector{<:Real} ) # f1
function kernel_gradient( k::AbstractSPHKernel, r::Real, h_inv::Real,  Δx::Union{Real, Vector{<:Real}}) # f2
function kernel_gradient( k::AbstractSPHKernel, h_inv::Real,  xᵢ::Real,  xⱼ::Real ) # f3

Seems f2 will never run for kernel_gradient( k::AbstractSPHKernel, r::Real, h_inv::Real, Δx::Real) because it should call f3

Seems function f1 and function f2 have same code inside.

May be better to make:

function kernel_gradient( k::AbstractSPHKernel, h_inv,  xᵢ,  xⱼ ) # f1
function kernel_gradient( k::AbstractSPHKernel, h_inv,  r, Δx::Union{AbstractVector{<:Real}, NTuple{N, Real}}) where N # f2

then just

∇𝒲 = kernel_gradient
@LudwigBoess
Copy link
Owner

Hey, I'm really sorry I just saw these issues!
Can you please check the branch rc2.3.0 if this solution works for you?

@LudwigBoess LudwigBoess mentioned this issue Oct 9, 2024
1 task
@LudwigBoess LudwigBoess linked a pull request Oct 9, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants