mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Add C API function for resetting tally individually
This commit is contained in:
parent
4bfd2fbcc9
commit
6ea533a61f
2 changed files with 20 additions and 0 deletions
|
|
@ -97,6 +97,7 @@ extern "C" {
|
|||
int openmc_tally_get_n_realizations(int32_t index, int32_t* n);
|
||||
int openmc_tally_get_nuclides(int32_t index, int** nuclides, int* n);
|
||||
int openmc_tally_get_scores(int32_t index, int** scores, int* n);
|
||||
int openmc_tally_reset(int32_t index);
|
||||
int openmc_tally_results(int32_t index, double** ptr, int shape_[3]);
|
||||
int openmc_tally_set_active(int32_t index, bool active);
|
||||
int openmc_tally_set_filters(int32_t index, int n, const int32_t* indices);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ module tally_header
|
|||
public :: openmc_tally_get_n_realizations
|
||||
public :: openmc_tally_get_nuclides
|
||||
public :: openmc_tally_get_scores
|
||||
public :: openmc_tally_reset
|
||||
public :: openmc_tally_results
|
||||
public :: openmc_tally_set_active
|
||||
public :: openmc_tally_set_filters
|
||||
|
|
@ -608,6 +609,24 @@ contains
|
|||
end function openmc_tally_get_scores
|
||||
|
||||
|
||||
function openmc_tally_reset(index) result(err) bind(C)
|
||||
! Reset tally results and number of realizations
|
||||
integer(C_INT32_T), intent(in), value :: index
|
||||
integer(C_INT) :: err
|
||||
|
||||
if (index >= 1 .and. index <= size(tallies)) then
|
||||
associate (t => tallies(index) % obj)
|
||||
t % n_realizations = 0
|
||||
if (allocated(t % results)) t % results(:, :, :) = ZERO
|
||||
err = 0
|
||||
end associate
|
||||
else
|
||||
err = E_OUT_OF_BOUNDS
|
||||
call set_errmsg('Index in tallies array is out of bounds.')
|
||||
end if
|
||||
end function openmc_tally_reset
|
||||
|
||||
|
||||
function openmc_tally_results(index, ptr, shape_) result(err) bind(C)
|
||||
! Returns a pointer to a tally results array along with its shape. This
|
||||
! allows a user to obtain in-memory tally results from Python directly.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue