Skip to content

Commit

Permalink
Bank surface source particles in all active cycles (#2592)
Browse files Browse the repository at this point in the history
Co-authored-by: Jose Ignacio Marquez Damian <[email protected]>
  • Loading branch information
paulromano and marquezj authored Jul 14, 2023
1 parent 0666e3a commit c5f5511
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions include/openmc/shared_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class SharedArray {
//! \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_; }
Expand Down
3 changes: 2 additions & 1 deletion src/particle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Binary file modified tests/regression_tests/surface_source/surface_source_true.h5
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/regression_tests/surface_source/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import openmc

from tests.testing_harness import PyAPITestHarness
from tests.regression_tests import config


@pytest.fixture
Expand Down Expand Up @@ -118,10 +119,14 @@ def _cleanup(self):

@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')
Expand Down

0 comments on commit c5f5511

Please sign in to comment.