mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Move variable definitions from simulation_header.F90 to simulation.cpp
This commit is contained in:
parent
d3b9d65fc7
commit
3ba886cd6d
3 changed files with 52 additions and 22 deletions
|
|
@ -26,12 +26,13 @@ extern "C" double k_abs_tra; //!< sum over batches of k_absorption * k_track
|
|||
extern "C" double log_spacing; //!< lethargy spacing for energy grid searches
|
||||
extern "C" int n_lost_particles; //!< cumulative number of lost particles
|
||||
extern "C" bool need_depletion_rx; //!< need to calculate depletion rx?
|
||||
extern "C" bool restart_batch; //!< batch at which a restart job resumed
|
||||
extern "C" int restart_batch; //!< batch at which a restart job resumed
|
||||
extern "C" bool satisfy_triggers; //!< have tally triggers been satisfied?
|
||||
extern "C" bool simulation_initialized; //!< has simulation been initialized?
|
||||
extern "C" int total_gen; //!< total number of generations simulated
|
||||
extern "C" int64_t work; //!< number of particles per process
|
||||
|
||||
extern std::vector<double> k_generation;
|
||||
extern std::vector<int64_t> work_index;
|
||||
|
||||
// Threadprivate variables
|
||||
|
|
@ -52,6 +53,9 @@ extern "C" int thread_id; //!< ID of a given thread
|
|||
//! Initialize simulation
|
||||
extern "C" void openmc_simulation_init_c();
|
||||
|
||||
//! Determine overall generation number
|
||||
extern "C" int overall_generation();
|
||||
|
||||
//! Determine number of particles to transport per process
|
||||
void calculate_work();
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,33 @@ namespace openmc {
|
|||
|
||||
namespace simulation {
|
||||
|
||||
int current_batch;
|
||||
int current_gen;
|
||||
int64_t current_work;
|
||||
double keff {1.0};
|
||||
double keff_std;
|
||||
double k_col_abs {0.0};
|
||||
double k_col_tra {0.0};
|
||||
double k_abs_tra {0.0};
|
||||
double log_spacing;
|
||||
int n_lost_particles {0};
|
||||
bool need_depletion_rx {false};
|
||||
int restart_batch;
|
||||
bool satisfy_triggers {false};
|
||||
bool simulation_initialized {false};
|
||||
int total_gen {0};
|
||||
int64_t work;
|
||||
|
||||
std::vector<double> k_generation;
|
||||
std::vector<int64_t> work_index;
|
||||
|
||||
// Threadprivate variables
|
||||
bool trace; //!< flag to show debug information
|
||||
#ifdef _OPENMP
|
||||
int n_threads {-1}; //!< number of OpenMP threads
|
||||
int thread_id; //!< ID of a given thread
|
||||
#endif
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -43,6 +68,12 @@ void openmc_simulation_init_c()
|
|||
calculate_work();
|
||||
}
|
||||
|
||||
int overall_generation()
|
||||
{
|
||||
using namespace simulation;
|
||||
return settings::gen_per_batch*(current_batch - 1) + current_gen;
|
||||
}
|
||||
|
||||
void calculate_work()
|
||||
{
|
||||
// Determine minimum amount of particles to simulate on each processor
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ module simulation_header
|
|||
! GEOMETRY-RELATED VARIABLES
|
||||
|
||||
! Number of lost particles
|
||||
integer(C_INT), bind(C) :: n_lost_particles = 0
|
||||
integer(C_INT), bind(C) :: n_lost_particles
|
||||
|
||||
real(C_DOUBLE), bind(C) :: log_spacing ! spacing on logarithmic grid
|
||||
|
||||
|
|
@ -22,14 +22,14 @@ module simulation_header
|
|||
|
||||
integer(C_INT), bind(C) :: current_batch ! current batch
|
||||
integer(C_INT), bind(C) :: current_gen ! current generation within a batch
|
||||
integer(C_INT), bind(C) :: total_gen = 0 ! total number of generations simulated
|
||||
logical(C_BOOL), bind(C) :: simulation_initialized = .false.
|
||||
integer(C_INT), bind(C) :: total_gen ! total number of generations simulated
|
||||
logical(C_BOOL), bind(C) :: simulation_initialized
|
||||
logical(C_BOOL), bind(C) :: need_depletion_rx ! need to calculate depletion reaction rx?
|
||||
|
||||
! ============================================================================
|
||||
! TALLY PRECISION TRIGGER VARIABLES
|
||||
|
||||
logical(C_BOOL), bind(C) :: satisfy_triggers = .false. ! whether triggers are satisfied
|
||||
logical(C_BOOL), bind(C) :: satisfy_triggers ! whether triggers are satisfied
|
||||
|
||||
integer(C_INT64_T), bind(C) :: work ! number of particles per processor
|
||||
integer(C_INT64_T), allocatable :: work_index(:) ! starting index in source bank for each process
|
||||
|
|
@ -40,18 +40,18 @@ module simulation_header
|
|||
|
||||
! Temporary k-effective values
|
||||
type(VectorReal) :: k_generation ! single-generation estimates of k
|
||||
real(C_DOUBLE), bind(C) :: keff = ONE ! average k over active batches
|
||||
real(C_DOUBLE), bind(C) :: keff_std ! standard deviation of average k
|
||||
real(C_DOUBLE), bind(C) :: k_col_abs = ZERO ! sum over batches of k_collision * k_absorption
|
||||
real(C_DOUBLE), bind(C) :: k_col_tra = ZERO ! sum over batches of k_collision * k_tracklength
|
||||
real(C_DOUBLE), bind(C) :: k_abs_tra = ZERO ! sum over batches of k_absorption * k_tracklength
|
||||
real(C_DOUBLE), bind(C) :: keff ! average k over active batches
|
||||
real(C_DOUBLE), bind(C) :: keff_std ! standard deviation of average k
|
||||
real(C_DOUBLE), bind(C) :: k_col_abs ! sum over batches of k_collision * k_absorption
|
||||
real(C_DOUBLE), bind(C) :: k_col_tra ! sum over batches of k_collision * k_tracklength
|
||||
real(C_DOUBLE), bind(C) :: k_abs_tra ! sum over batches of k_absorption * k_tracklength
|
||||
|
||||
! ============================================================================
|
||||
! PARALLEL PROCESSING VARIABLES
|
||||
|
||||
#ifdef _OPENMP
|
||||
integer(C_INT), bind(C) :: n_threads = NONE ! number of OpenMP threads
|
||||
integer(C_INT), bind(C) :: thread_id ! ID of a given thread
|
||||
integer(C_INT), bind(C) :: n_threads ! number of OpenMP threads
|
||||
integer(C_INT), bind(C) :: thread_id ! ID of a given thread
|
||||
#endif
|
||||
|
||||
! ============================================================================
|
||||
|
|
@ -66,20 +66,15 @@ module simulation_header
|
|||
interface
|
||||
subroutine entropy_clear() bind(C)
|
||||
end subroutine
|
||||
|
||||
pure function overall_generation() result(gen) bind(C)
|
||||
import C_INT
|
||||
integer(C_INT) :: gen
|
||||
end function overall_generation
|
||||
end interface
|
||||
|
||||
|
||||
contains
|
||||
|
||||
!===============================================================================
|
||||
! OVERALL_GENERATION determines the overall generation number
|
||||
!===============================================================================
|
||||
|
||||
pure function overall_generation() result(gen) bind(C)
|
||||
integer(C_INT) :: gen
|
||||
gen = gen_per_batch*(current_batch - 1) + current_gen
|
||||
end function overall_generation
|
||||
|
||||
!===============================================================================
|
||||
! FREE_MEMORY_SIMULATION deallocates global arrays defined in this module
|
||||
!===============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue