Skip to content

Commit 1c24a85

Browse files
authored
Particle Container: local=False for non-MPI (#224)
Avoid requiring `mpi4py` and causing crashes for non-MPI runs that use `pc.to_df(local=False)`.
1 parent d90e390 commit 1c24a85

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/amrex/ParticleContainer.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def pc_to_df(self, local=True, comm=None, root_rank=0):
1616
self : amrex.ParticleContainer_*
1717
A ParticleContainer class in pyAMReX
1818
local : bool
19-
MPI-local particles
19+
MPI rank-local particles only
2020
comm : MPI Communicator
2121
if local is False, this defaults to mpi4py.MPI.COMM_WORLD
2222
root_rank : MPI root rank to gather to
@@ -31,6 +31,14 @@ def pc_to_df(self, local=True, comm=None, root_rank=0):
3131
"""
3232
import pandas as pd
3333

34+
# silently ignore local=False for non-MPI runs
35+
if local is False:
36+
from inspect import getmodule
37+
38+
amr = getmodule(self)
39+
if not amr.Config.have_mpi:
40+
local = True
41+
3442
# create a DataFrame per particle box and append it to the list of
3543
# local DataFrame(s)
3644
dfs_local = []

0 commit comments

Comments
 (0)