Skip to content

Commit

Permalink
add_line! function for ProbeSystem
Browse files Browse the repository at this point in the history
  • Loading branch information
rymanderson committed Apr 30, 2024
1 parent 57391b5 commit 7dca307
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/FastMultipole.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ for file in ["containers", "complex", "derivatives", "element", "tree", "direct"
include(file*".jl")
end

export fmm!, direct!, Tree, SortWrapper, ProbeSystem, reset!, DerivativesSwitch
export fmm!, direct!, Tree, SortWrapper, ProbeSystem, add_line!, reset!, DerivativesSwitch

end # module
30 changes: 30 additions & 0 deletions src/probe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,35 @@ end

reset!(::Nothing) = nothing

"""
add_line!(probes::ProbeSystem, x1, x2, n_probes, i_last)
Adds `n_probes` probes in a line between `x1` and `x2`. Specifically, they are added at the midpoint of equally partiti oned segments of the line.
# Arguments
* `probes::ProbeSystem`: the probe system whose `.position` field is to be updated
* `x1::Vector{Float64}`: the first point defining the line along which probes are to be added
* `x2::Vector{Float64}`: the second point defining the line along which probes are to be added
* `n_probes::Int`: number of probes to be added
* `i_last::Int`: index of the last probe in `probes`
# Output
* `i_last::Int`: updated index of the last probe in `probes`
"""
@inline function add_line!(probes::FastMultipole.ProbeSystem, x1, x2, n_probes, i_last)
dx = (x2 - x1) / n_probes
x = x1 + dx/2
for i in 1:n_probes
i_start += 1
probes.position[i_last + i] = x
x += dx
end
return i_last + n_probes
end

"""
reset!(probes)
Expand All @@ -122,3 +151,4 @@ function reset!(probes::ProbeSystem)
reset!(probes.velocity)
reset!(probes.velocity_gradient)
end

0 comments on commit 7dca307

Please sign in to comment.