Skip to content

Commit

Permalink
Particle Container: local=False for non-MPI (#224)
Browse files Browse the repository at this point in the history
Avoid requiring `mpi4py` and causing crashes for non-MPI runs that
use `pc.to_df(local=False)`.
  • Loading branch information
ax3l authored Nov 20, 2023
1 parent d90e390 commit 1c24a85
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/amrex/ParticleContainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def pc_to_df(self, local=True, comm=None, root_rank=0):
self : amrex.ParticleContainer_*
A ParticleContainer class in pyAMReX
local : bool
MPI-local particles
MPI rank-local particles only
comm : MPI Communicator
if local is False, this defaults to mpi4py.MPI.COMM_WORLD
root_rank : MPI root rank to gather to
Expand All @@ -31,6 +31,14 @@ def pc_to_df(self, local=True, comm=None, root_rank=0):
"""
import pandas as pd

# silently ignore local=False for non-MPI runs
if local is False:
from inspect import getmodule

amr = getmodule(self)
if not amr.Config.have_mpi:
local = True

# create a DataFrame per particle box and append it to the list of
# local DataFrame(s)
dfs_local = []
Expand Down

0 comments on commit 1c24a85

Please sign in to comment.