Skip to content

Commit

Permalink
silence empty source/target warning
Browse files Browse the repository at this point in the history
  • Loading branch information
rymanderson committed May 18, 2024
1 parent 97b8bbc commit c486d54
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/fmm.jl
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,10 @@ function fmm!(tree::Tree, systems;
)
end

const WARNING_FLAG_EMPTY_SOURCE = Array{Bool,0}(undef)
WARNING_FLAG_EMPTY_SOURCE[] = false
const WARNING_FLAG_EMPTY_TARGET = Array{Bool,0}(undef)
WARNING_FLAG_EMPTY_TARGET[] = false

"""
fmm!(target_tree, target_systems, source_tree, source_systems; kwargs...)
Expand Down Expand Up @@ -729,11 +733,17 @@ function fmm!(target_tree::Tree, target_systems, source_tree::Tree, source_syste
end

else
n_sources == 0 && (@warn "fmm! called but the source system is empty; foregoing calculation")
n_targets == 0 && (@warn "fmm! called but the target system is empty; foregoing calculation")
if n_sources == 0 && !WARNING_FLAG_EMPTY_SOURCE[]
@warn "fmm! called but the source system is empty; foregoing calculation"
WARNING_FLAG_EMPTY_SOURCE[] = true
end
if n_targets == 0 && !WARNING_FLAG_EMPTY_TARGET[]
@warn "fmm! called but the target system is empty; foregoing calculation"
WARNING_FLAG_EMPTY_TARGET[] = true
end
end

# unsort bodies
# unsort bodies
n_sources > 0 && unsort_source_bodies && unsort!(source_systems, source_tree)
n_targets > 0 && unsort_target_bodies && unsort!(target_systems, target_tree)

Expand Down

0 comments on commit c486d54

Please sign in to comment.