OpenMC/include/openmc/simulation.h

92 lines
3 KiB
C
Raw Normal View History

2018-08-23 21:38:23 -05:00
//! \file simulation.h
//! \brief Variables/functions related to a running simulation
#ifndef OPENMC_SIMULATION_H
#define OPENMC_SIMULATION_H
2018-10-17 06:34:12 -05:00
#include "openmc/particle.h"
#include <cstdint>
2018-07-17 06:43:35 -05:00
#include <vector>
namespace openmc {
2018-10-17 16:14:13 -05:00
constexpr int STATUS_EXIT_NORMAL {0};
constexpr int STATUS_EXIT_MAX_BATCH {1};
constexpr int STATUS_EXIT_ON_TRIGGER {2};
2018-08-23 21:38:23 -05:00
//==============================================================================
// Global variable declarations
2018-08-23 21:38:23 -05:00
//==============================================================================
namespace simulation {
extern "C" int current_batch; //!< current batch
extern "C" int current_gen; //!< current fission generation
extern "C" int64_t current_work; //!< index in source back of current particle
2018-10-16 20:28:00 -05:00
extern "C" bool initialized; //!< has simulation been initialized?
extern "C" double keff; //!< average k over batches
extern "C" double keff_std; //!< standard deviation of average k
extern "C" double k_col_abs; //!< sum over batches of k_collision * k_absorption
extern "C" double k_col_tra; //!< sum over batches of k_collision * k_tracklength
extern "C" double k_abs_tra; //!< sum over batches of k_absorption * k_tracklength
extern 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" int restart_batch; //!< batch at which a restart job resumed
extern "C" bool satisfy_triggers; //!< have tally triggers been satisfied?
extern "C" int total_gen; //!< total number of generations simulated
extern double total_weight; //!< Total source weight in a batch
2019-03-20 13:26:04 -05:00
extern int64_t work_per_rank; //!< number of particles per MPI rank
extern std::vector<double> k_generation;
extern std::vector<int64_t> work_index;
// Threadprivate variables
extern "C" bool trace; //!< flag to show debug information
#pragma omp threadprivate(current_work, trace)
} // namespace simulation
2018-08-23 21:38:23 -05:00
//==============================================================================
// Functions
//==============================================================================
2018-11-15 08:13:14 -06:00
//! Allocate space for source and fission banks
void allocate_banks();
//! Determine number of particles to transport per process
void calculate_work();
//! Initialize a batch
2018-10-17 16:14:13 -05:00
void initialize_batch();
//! Initialize a fission generation
2018-10-17 16:14:13 -05:00
void initialize_generation();
2018-10-17 16:14:13 -05:00
void initialize_history(Particle* p, int64_t index_source);
2018-10-17 06:34:12 -05:00
//! Finalize a batch
//!
//! Handles synchronization and accumulation of tallies, calculation of Shannon
//! entropy, getting single-batch estimate of keff, and turning on tallies when
//! appropriate
2018-10-17 16:14:13 -05:00
void finalize_batch();
2018-10-16 19:48:26 -05:00
//! Finalize a fission generation
2018-10-17 16:14:13 -05:00
void finalize_generation();
2018-10-16 19:48:26 -05:00
//! Determine overall generation number
extern "C" int overall_generation();
#ifdef OPENMC_MPI
2018-10-17 16:14:13 -05:00
void broadcast_results();
#endif
2018-07-17 06:43:35 -05:00
2019-02-21 08:32:32 -06:00
void free_memory_simulation();
2018-07-17 06:43:35 -05:00
} // namespace openmc
#endif // OPENMC_SIMULATION_H