diff --git a/include/openmc/distribution.h b/include/openmc/distribution.h index b8ebcabf4..6db3c1618 100644 --- a/include/openmc/distribution.h +++ b/include/openmc/distribution.h @@ -37,6 +37,7 @@ public: //! \return Sampled value double sample() const; + // Properties const std::vector& x() const { return x_; } const std::vector& p() const { return p_; } private: diff --git a/include/openmc/distribution_spatial.h b/include/openmc/distribution_spatial.h index e94005f0f..248f03588 100644 --- a/include/openmc/distribution_spatial.h +++ b/include/openmc/distribution_spatial.h @@ -48,6 +48,8 @@ public: //! Sample a position from the distribution //! \return Sampled position Position sample() const; + + // Properties bool only_fissionable() const { return only_fissionable_; } private: Position lower_left_; //!< Lower-left coordinates of box diff --git a/include/openmc/file_utils.h b/include/openmc/file_utils.h index 0a24cb547..f9c23468d 100644 --- a/include/openmc/file_utils.h +++ b/include/openmc/file_utils.h @@ -6,12 +6,15 @@ namespace openmc { +//! Determine if a file exists +//! \param[in] filename Path to file +//! \return Whether file exists inline bool file_exists(const std::string& filename) { std::ifstream s {filename}; return s.good(); } -} +} // namespace openmc -#endif // OPENMC_FILE_UTILS_H \ No newline at end of file +#endif // OPENMC_FILE_UTILS_H diff --git a/include/openmc/nuclide.h b/include/openmc/nuclide.h index 8a19791ba..e3d43450d 100644 --- a/include/openmc/nuclide.h +++ b/include/openmc/nuclide.h @@ -1,3 +1,6 @@ +//! \file nuclide.h +//! \brief Nuclide type and other associated types/data + #ifndef OPENMC_NUCLIDE_H #define OPENMC_NUCLIDE_H @@ -7,6 +10,12 @@ namespace openmc { +//============================================================================== +// Global variables +//============================================================================== + +// Minimum/maximum transport energy for each particle type. Order corresponds to +// that of the ParticleType enum extern std::array energy_min; extern std::array energy_max; diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index a1350c936..daf7393fb 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -1,3 +1,6 @@ +//! \file simulation.h +//! \brief Variables/functions related to a running simulation + #ifndef OPENMC_SIMULATION_H #define OPENMC_SIMULATION_H @@ -6,6 +9,10 @@ namespace openmc { +//============================================================================== +// Global variables +//============================================================================== + extern "C" int openmc_current_batch; extern "C" int openmc_current_gen; extern "C" int64_t openmc_current_work; @@ -16,7 +23,14 @@ extern std::vector work_index; #pragma omp threadprivate(openmc_current_work) +//============================================================================== +// Functions +//============================================================================== + +//! Initialize simulation extern "C" void openmc_simulation_init_c(); + +//! Determine number of particles to transport per process void calculate_work(); } // namespace openmc diff --git a/include/openmc/source.h b/include/openmc/source.h index ac5f69a2f..2e8c9491a 100644 --- a/include/openmc/source.h +++ b/include/openmc/source.h @@ -1,3 +1,6 @@ +//! \file source.h +//! \brief External source distributions + #ifndef OPENMC_SOURCE_H #define OPENMC_SOURCE_H @@ -19,17 +22,22 @@ namespace openmc { class SourceDistribution { public: + // Constructors SourceDistribution(UPtrSpace space, UPtrAngle angle, UPtrDist energy); explicit SourceDistribution(pugi::xml_node node); + //! Sample from the external source distribution + //! \return Sampled site Bank sample() const; + + // Properties double strength() const { return strength_; } private: - ParticleType particle_ {ParticleType::neutron}; - double strength_ {1.0}; - UPtrSpace space_; - UPtrAngle angle_; - UPtrDist energy_; + ParticleType particle_ {ParticleType::neutron}; //!< Type of particle emitted + double strength_ {1.0}; //!< Source strength + UPtrSpace space_; //!< Spatial distribution + UPtrAngle angle_; //!< Angular distribution + UPtrDist energy_; //!< Energy distribution }; //============================================================================== @@ -47,6 +55,7 @@ extern "C" void initialize_source(); //! Sample a site from all external source distributions in proportion to their //! source strength +//! \return Sampled source site extern "C" Bank sample_external_source(); } // namespace openmc diff --git a/src/nuclide.cpp b/src/nuclide.cpp index f7f5399ba..79e2289ae 100644 --- a/src/nuclide.cpp +++ b/src/nuclide.cpp @@ -2,10 +2,17 @@ namespace openmc { -// Order corresponds to ParticleType enum +//============================================================================== +// Global variables +//============================================================================== + std::array energy_min {0.0, 0.0}; std::array energy_max {INFTY, INFTY}; +//============================================================================== +// Fortran compatibility functions +//============================================================================== + extern "C" void set_particle_energy_bounds(int particle, double E_min, double E_max) { diff --git a/src/simulation.cpp b/src/simulation.cpp index 19cc78d19..3514f4a47 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -22,8 +22,22 @@ int openmc_run() { namespace openmc { +//============================================================================== +// Global variables +//============================================================================== + std::vector work_index; +//============================================================================== +// Functions +//============================================================================== + +void openmc_simulation_init_c() +{ + // Determine how much work each process should do + calculate_work(); +} + void calculate_work() { // Determine minimum amount of particles to simulate on each processor @@ -48,10 +62,4 @@ void calculate_work() } } -void openmc_simulation_init_c() -{ - // Determine how much work each process should do - calculate_work(); -} - } // namespace openmc