mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Use unittest.Mock for MPI when collecting proc_time
This commit is contained in:
parent
8deda73647
commit
544cbd0c39
2 changed files with 5 additions and 4 deletions
|
|
@ -5,16 +5,17 @@ openmc.deplete
|
|||
A depletion front-end tool.
|
||||
"""
|
||||
|
||||
from unittest import Mock
|
||||
|
||||
from .dummy_comm import DummyCommunicator
|
||||
try:
|
||||
from mpi4py import MPI
|
||||
comm = MPI.COMM_WORLD
|
||||
have_mpi = True
|
||||
mpi_sum = MPI.SUM
|
||||
except ImportError:
|
||||
comm = DummyCommunicator()
|
||||
have_mpi = False
|
||||
mpi_sum = lambda x: x
|
||||
MPI = Mock()
|
||||
|
||||
from .nuclide import *
|
||||
from .chain import *
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ from warnings import warn
|
|||
import numpy as np
|
||||
import h5py
|
||||
|
||||
from . import comm, have_mpi, mpi_sum
|
||||
from . import comm, have_mpi, MPI
|
||||
from .reaction_rates import ReactionRates
|
||||
|
||||
_VERSION_RESULTS = (1, 0)
|
||||
|
|
@ -452,7 +452,7 @@ class Results(object):
|
|||
results.power = power
|
||||
results.proc_time = proc_time
|
||||
if results.proc_time is not None:
|
||||
results.proc_time = comm.reduce(proc_time, op=mpi_sum)
|
||||
results.proc_time = comm.reduce(proc_time, op=MPI.SUM)
|
||||
|
||||
results.export_to_hdf5("depletion_results.h5", step_ind)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue