Core
SmoothedParticles.apply!
— Methodapply!(sys::ParticleSystem, action!::Function; self::Bool = false)
Calls either apply_unary!
or apply_binary!
according to the signature of action!
. If self == true
, then particle self-interaction for binary operator is allowed.
SmoothedParticles.apply_binary!
— Methodapply_binary!(sys::ParticleSystem, action!::Function)
Apply a binary operator action!(p::T, q::T, r::Float64)
between any two neighbouring particles p
, q
in sys::ParticleSystem{T}
. Value r
is their mutual distance. This excludes particle pairs with distance greater than sys.h
. This has linear complexity in number of particles and runs in parallel.
Modifying second particle q
within action!
can lead to race condition, so do not do this. Also, make sure that result will not depend on the order of particle evaluation, which is implementation-specific.
SmoothedParticles.apply_unary!
— Methodapply_unary!(sys::ParticleSystem, action!::Function)
Apply a unary operator action!(p::T)
on every particle p
in sys::ParticleSystem{T}
. This has linear complexity in number of particles and runs in parallel.
SmoothedParticles.assemble_matrix
— Methodassemble_matrix(sys::ParticleSystem, func::Function)::SparseMatrixCSC{Float64}
For given function func(p::T, q::T)::Float64
where T <: AbstractParticle
, assemble a sparse matrix $\mathbb{A}$, such that
\[ A_{ij} = \text{func}(p_i, p_j, r_{ij}),\]
where $p_i$, $p_j$ are respectively the i-th and j-th particle in sys::ParticleSystem{T}
and $r_{ij}$ is their mutual distance. This assumes that $A_{ij} = 0$ for $r_{ij} > h$.
SmoothedParticles.assemble_vector
— Methodassemble_vector(sys::ParticleSystem, func::Function)::Vector{Float64}
For given function func(q::T)::Float64 where T <: AbstractParticle
, assemble a vector $\mathbf{v}$, such that
\[ v_i = \text{func}(p_i),\]
where $p_i$ is the i-th particle in sys::ParticleSystem{T}
.
SmoothedParticles.create_cell_list!
— Methodcreate_cell_list!(sys::ParticleSystem)
Create the cell list for given particle system sys
. This function should be always called after updating positions. Without updated cell list, applying binary particle operators or assembling matrices will lead to incorrect results.
SmoothedParticles.dist
— Methoddist(p::AbstractParticle, q::AbstractParticle)::Float64
Computes the distance between any two particles.
SmoothedParticles.sum
— Methodsum(sys::ParticleSystem, func::Function, x::RealVector)::Float64
For given function func(p::T, q::T, r::Float64)::Float64 where T <: AbstractParticle
and particle p
it returns the sum
\[ \sum_{q \in \text{sys.particles}} \text{func}(p, q, r).\]
SmoothedParticles.sum
— Methodsum(sys::ParticleSystem, func::Function, x::RealVector)::Float64
For given function func(p::T, r::Float64)::Float64 where T <: AbstractParticle
it returns the sum
\[ \sum_{p \in \text{sys.particles}} \text{func}(p, \sqrt{(p.x - x)^2 + (p.y - y)^2}).\]
This can be useful if one needs to compute SPH interpolation at a point which is not occupied by a particle.