mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Merge pull request #1154 from paulromano/cpp-output
Translate most output functions to C++
This commit is contained in:
commit
e86761814b
36 changed files with 977 additions and 1613 deletions
|
|
@ -100,7 +100,7 @@ extern "C" {
|
|||
int openmc_sphharm_filter_get_cosine(int32_t index, char cosine[]);
|
||||
int openmc_sphharm_filter_set_order(int32_t index, int order);
|
||||
int openmc_sphharm_filter_set_cosine(int32_t index, const char cosine[]);
|
||||
int openmc_statepoint_write(const char filename[], bool* write_source);
|
||||
int openmc_statepoint_write(const char* filename, bool* write_source);
|
||||
int openmc_tally_allocate(int32_t index, const char* type);
|
||||
int openmc_tally_get_active(int32_t index, bool* active);
|
||||
int openmc_tally_get_estimator(int32_t index, int32_t* estimator);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ constexpr std::array<int, 3> VERSION {VERSION_MAJOR, VERSION_MINOR, VERSION_RELE
|
|||
constexpr int HDF5_VERSION[] {2, 0};
|
||||
|
||||
// Version numbers for binary files
|
||||
constexpr std::array<int, 2> VERSION_STATEPOINT {17, 0};
|
||||
constexpr std::array<int, 2> VERSION_PARTICLE_RESTART {2, 0};
|
||||
constexpr std::array<int, 2> VERSION_TRACK {2, 0};
|
||||
constexpr std::array<int, 2> VERSION_SUMMARY {6, 0};
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <hdf5.h>
|
||||
|
||||
#include "openmc/particle.h"
|
||||
|
||||
|
|
@ -78,6 +79,14 @@ void ufs_count_sites();
|
|||
//! Get UFS weight corresponding to particle's location
|
||||
extern "C" double ufs_get_weight(const Particle* p);
|
||||
|
||||
//! Write data related to k-eigenvalue to statepoint
|
||||
//! \param[in] group HDF5 group
|
||||
void write_eigenvalue_hdf5(hid_t group);
|
||||
|
||||
//! Read data related to k-eigenvalue from statepoint
|
||||
//! \param[in] group HDF5 group
|
||||
void read_eigenvalue_hdf5(hid_t group);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_EIGENVALUE_H
|
||||
|
|
|
|||
|
|
@ -9,11 +9,6 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
extern "C" void fatal_error_from_c(const char* message, int message_len);
|
||||
extern "C" void warning_from_c(const char* message, int message_len);
|
||||
extern "C" void write_message_from_c(const char* message, int message_len,
|
||||
int level);
|
||||
|
||||
inline void
|
||||
set_errmsg(const char* message)
|
||||
{
|
||||
|
|
@ -32,17 +27,7 @@ set_errmsg(const std::stringstream& message)
|
|||
std::strcpy(openmc_err_msg, message.str().c_str());
|
||||
}
|
||||
|
||||
inline
|
||||
void fatal_error(const char* message)
|
||||
{
|
||||
fatal_error_from_c(message, std::strlen(message));
|
||||
}
|
||||
|
||||
inline
|
||||
void fatal_error(const std::string& message)
|
||||
{
|
||||
fatal_error_from_c(message.c_str(), message.length());
|
||||
}
|
||||
[[noreturn]] void fatal_error(const std::string& message, int err=-1);
|
||||
|
||||
inline
|
||||
void fatal_error(const std::stringstream& message)
|
||||
|
|
@ -51,28 +36,20 @@ void fatal_error(const std::stringstream& message)
|
|||
}
|
||||
|
||||
inline
|
||||
void warning(const std::string& message)
|
||||
void fatal_error(const char* message)
|
||||
{
|
||||
warning_from_c(message.c_str(), message.length());
|
||||
fatal_error({message, std::strlen(message)});
|
||||
}
|
||||
|
||||
void warning(const std::string& message);
|
||||
|
||||
inline
|
||||
void warning(const std::stringstream& message)
|
||||
{
|
||||
warning(message.str());
|
||||
}
|
||||
|
||||
inline
|
||||
void write_message(const char* message, int level)
|
||||
{
|
||||
write_message_from_c(message, std::strlen(message), level);
|
||||
}
|
||||
|
||||
inline
|
||||
void write_message(const std::string& message, int level)
|
||||
{
|
||||
write_message_from_c(message.c_str(), message.length(), level);
|
||||
}
|
||||
void write_message(const std::string& message, int level);
|
||||
|
||||
inline
|
||||
void write_message(const std::stringstream& message, int level)
|
||||
|
|
|
|||
|
|
@ -229,6 +229,19 @@ void read_dataset(hid_t obj_id, const char* name, T& buffer, bool indep=false)
|
|||
read_dataset(obj_id, name, H5TypeMap<T>::type_id, &buffer, indep);
|
||||
}
|
||||
|
||||
// overload for std::string
|
||||
inline void
|
||||
read_dataset(hid_t obj_id, const char* name, std::string& str, bool indep=false)
|
||||
{
|
||||
// Create buffer to read data into
|
||||
auto n = attribute_typesize(obj_id, name);
|
||||
char buffer[n];
|
||||
|
||||
// Read attribute and set string
|
||||
read_string(obj_id, name, n, buffer, indep);
|
||||
str = std::string{buffer, n};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void read_dataset(hid_t dset, std::vector<T>& vec, bool indep=false)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ extern "C" double normal_percentile(double p);
|
|||
//! \return The requested percentile
|
||||
//==============================================================================
|
||||
|
||||
extern "C" double t_percentile_c(double p, int df);
|
||||
extern "C" double t_percentile(double p, int df);
|
||||
|
||||
//==============================================================================
|
||||
//! Calculate the n-th order Legendre polynomials at the value of x.
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ extern "C" void read_meshes(pugi::xml_node* root);
|
|||
|
||||
//! Write mesh data to an HDF5 group
|
||||
//! \param[in] group HDF5 group
|
||||
extern "C" void meshes_to_hdf5(hid_t group);
|
||||
void meshes_to_hdf5(hid_t group);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
|
|
|
|||
|
|
@ -10,42 +10,51 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
//! \brief Display the main title banner as well as information about the
|
||||
//! program developers, version, and date/time which the problem was run.
|
||||
void title();
|
||||
|
||||
//! Display a header block.
|
||||
//!
|
||||
//
|
||||
//! \param msg The main text of the header
|
||||
//! \param level The lowest verbosity level at which this header is printed
|
||||
//==============================================================================
|
||||
|
||||
void header(const char* msg, int level);
|
||||
|
||||
//==============================================================================
|
||||
//! Retrieve a time stamp.
|
||||
//!
|
||||
//
|
||||
//! \return current time stamp (format: "yyyy-mm-dd hh:mm:ss")
|
||||
//==============================================================================
|
||||
|
||||
std::string time_stamp();
|
||||
|
||||
//==============================================================================
|
||||
//! Display the attributes of a particle.
|
||||
//==============================================================================
|
||||
|
||||
extern "C" void print_particle(Particle* p);
|
||||
|
||||
//==============================================================================
|
||||
//! Display plot information.
|
||||
//==============================================================================
|
||||
|
||||
void print_plot();
|
||||
|
||||
//==============================================================================
|
||||
//! Display information regarding cell overlap checking.
|
||||
//==============================================================================
|
||||
|
||||
void print_overlap_check();
|
||||
|
||||
extern "C" void title();
|
||||
//! Display information about command line usage of OpenMC
|
||||
void print_usage();
|
||||
|
||||
//! Display current version and copright/license information
|
||||
void print_version();
|
||||
|
||||
//! Display header listing what physical values will displayed
|
||||
void print_columns();
|
||||
|
||||
//! Display information about a generation of neutrons
|
||||
void print_generation();
|
||||
|
||||
//! \brief Display last batch's tallied value of the neutron multiplication
|
||||
//! factor as well as the average value if we're in active batches
|
||||
void print_batch_keff();
|
||||
|
||||
//! Display time elapsed for various stages of a run
|
||||
void print_runtime();
|
||||
|
||||
//! Display results for global tallies including k-effective estimators
|
||||
void print_results();
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_OUTPUT_H
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ namespace settings {
|
|||
// Boolean flags
|
||||
extern "C" bool assume_separate; //!< assume tallies are spatially separate?
|
||||
extern "C" bool check_overlaps; //!< check overlaps in geometry?
|
||||
extern "C" bool cmfd_run; //!< use CMFD?
|
||||
extern "C" bool confidence_intervals; //!< use confidence intervals for results?
|
||||
extern "C" bool create_fission_neutrons; //!< create fission neutrons (fixed source)?
|
||||
extern "C" bool dagmc; //!< indicator of DAGMC geometry
|
||||
extern "C" bool entropy_on; //!< calculate Shannon entropy?
|
||||
extern "C" bool legendre_to_tabular; //!< convert Legendre distributions to tabular?
|
||||
extern "C" bool output_summary; //!< write summary.h5?
|
||||
extern bool output_summary; //!< write summary.h5?
|
||||
extern "C" bool output_tallies; //!< write tallies.out?
|
||||
extern "C" bool particle_restart_run; //!< particle restart run?
|
||||
extern "C" bool photon_transport; //!< photon transport turned on?
|
||||
|
|
@ -49,7 +49,6 @@ extern bool ufs_on; //!< uniform fission site method on?
|
|||
extern bool urr_ptables_on; //!< use unresolved resonance prob. tables?
|
||||
extern "C" bool write_all_tracks; //!< write track files for every particle?
|
||||
extern "C" bool write_initial_source; //!< write out initial source file?
|
||||
extern "C" bool dagmc; //!< indicator of DAGMC geometry
|
||||
|
||||
// Paths to various files
|
||||
extern std::string path_cross_sections; //!< path to cross_sections.xml
|
||||
|
|
|
|||
|
|
@ -9,11 +9,12 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
void load_state_point();
|
||||
void write_source_point(const char* filename);
|
||||
extern "C" void write_source_bank(hid_t group_id);
|
||||
extern "C" void read_source_bank(hid_t group_id);
|
||||
extern "C" void write_tally_results_nr(hid_t file_id);
|
||||
extern "C" void restart_set_keff();
|
||||
void write_source_bank(hid_t group_id);
|
||||
void read_source_bank(hid_t group_id);
|
||||
void write_tally_results_nr(hid_t file_id);
|
||||
void restart_set_keff();
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_STATE_POINT_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue