diff --git a/include/openmc/shared_array.h b/include/openmc/shared_array.h index 676481296c..7e9ef28c58 100644 --- a/include/openmc/shared_array.h +++ b/include/openmc/shared_array.h @@ -107,6 +107,9 @@ public: //! \param size The new size of the container void resize(int64_t size) { size_ = size; } + //! Return whether the array is full + bool full() const { return size_ == capacity_; } + //! Return the number of elements that the container has currently allocated //! space for. int64_t capacity() { return capacity_; } diff --git a/src/particle.cpp b/src/particle.cpp index 8dd4a12e5b..200bcc6d6d 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -468,7 +468,8 @@ void Particle::cross_surface() write_message(1, " Crossing surface {}", surf->id_); } - if (surf->surf_source_ && simulation::current_batch == settings::n_batches) { + if (surf->surf_source_ && simulation::current_batch > settings::n_inactive && + !simulation::surf_source_bank.full()) { SourceSite site; site.r = r(); site.u = u(); diff --git a/tests/regression_tests/surface_source/surface_source_true.h5 b/tests/regression_tests/surface_source/surface_source_true.h5 index 9090c9fac4..f2055d09dc 100644 Binary files a/tests/regression_tests/surface_source/surface_source_true.h5 and b/tests/regression_tests/surface_source/surface_source_true.h5 differ diff --git a/tests/regression_tests/surface_source/test.py b/tests/regression_tests/surface_source/test.py index 1647266f6c..a25b40064d 100644 --- a/tests/regression_tests/surface_source/test.py +++ b/tests/regression_tests/surface_source/test.py @@ -7,6 +7,7 @@ import pytest import openmc from tests.testing_harness import PyAPITestHarness +from tests.regression_tests import config @pytest.fixture @@ -118,10 +119,14 @@ class SurfaceSourceTestHarness(PyAPITestHarness): @pytest.mark.surf_source_op('write') def test_surface_source_write(model): + # Test result is based on 1 MPI process + np = config['mpi_np'] + config['mpi_np'] = '1' harness = SurfaceSourceTestHarness('statepoint.10.h5', model, 'inputs_true_write.dat') harness.main() + config['mpi_np'] = np @pytest.mark.surf_source_op('read')