openmc.capi.run_in_memory

openmc.capi.run_in_memory(intracomm=None)[source]

Provides context manager for calling OpenMC shared library functions.

This function is intended to be used in a ‘with’ statement and ensures that OpenMC is properly initialized/finalized. At the completion of the ‘with’ block, all memory that was allocated during the block is freed. For example:

with openmc.capi.run_in_memory():
    for i in range(n_iters):
        openmc.capi.reset()
        do_stuff()
        openmc.capi.run()
Parameters:intracomm (mpi4py.MPI.Intracomm or None) – MPI intracommunicator