Skip to content

Commit c5f5511

Browse files
paulromanomarquezj
andauthored
Bank surface source particles in all active cycles (#2592)
Co-authored-by: Jose Ignacio Marquez Damian <22483345+marquezj@users.noreply.github.com>
1 parent 0666e3a commit c5f5511

4 files changed

Lines changed: 10 additions & 1 deletion

File tree

‎include/openmc/shared_array.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ class SharedArray {
107107
//! \param size The new size of the container
108108
void resize(int64_t size) { size_ = size; }
109109

110+
//! Return whether the array is full
111+
bool full() const { return size_ == capacity_; }
112+
110113
//! Return the number of elements that the container has currently allocated
111114
//! space for.
112115
int64_t capacity() { return capacity_; }

‎src/particle.cpp‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,8 @@ void Particle::cross_surface()
468468
write_message(1, " Crossing surface {}", surf->id_);
469469
}
470470

471-
if (surf->surf_source_ && simulation::current_batch == settings::n_batches) {
471+
if (surf->surf_source_ && simulation::current_batch > settings::n_inactive &&
472+
!simulation::surf_source_bank.full()) {
472473
SourceSite site;
473474
site.r = r();
474475
site.u = u();
0 Bytes
Binary file not shown.

‎tests/regression_tests/surface_source/test.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import openmc
88

99
from tests.testing_harness import PyAPITestHarness
10+
from tests.regression_tests import config
1011

1112

1213
@pytest.fixture
@@ -118,10 +119,14 @@ def _cleanup(self):
118119

119120
@pytest.mark.surf_source_op('write')
120121
def test_surface_source_write(model):
122+
# Test result is based on 1 MPI process
123+
np = config['mpi_np']
124+
config['mpi_np'] = '1'
121125
harness = SurfaceSourceTestHarness('statepoint.10.h5',
122126
model,
123127
'inputs_true_write.dat')
124128
harness.main()
129+
config['mpi_np'] = np
125130

126131

127132
@pytest.mark.surf_source_op('read')

0 commit comments

Comments
 (0)