Merge remote-tracking branch 'upstream/develop' into valgrind

This commit is contained in:
Sterling Harper 2019-12-04 18:48:18 -05:00
commit eabf3e2a86
241 changed files with 28672 additions and 11069 deletions

View file

@ -110,6 +110,7 @@ extern "C" {
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_get_type(int32_t index, int32_t* type);
int openmc_tally_get_writable(int32_t index, bool* writable);
int openmc_tally_reset(int32_t index);
int openmc_tally_results(int32_t index, double** ptr, size_t shape_[3]);
int openmc_tally_set_active(int32_t index, bool active);
@ -119,6 +120,7 @@ extern "C" {
int openmc_tally_set_nuclides(int32_t index, int n, const char** nuclides);
int openmc_tally_set_scores(int32_t index, int n, const char** scores);
int openmc_tally_set_type(int32_t index, const char* type);
int openmc_tally_set_writable(int32_t index, bool writable);
int openmc_zernike_filter_get_order(int32_t index, int* order);
int openmc_zernike_filter_get_params(int32_t index, double* x, double* y, double* r);
int openmc_zernike_filter_set_order(int32_t index, int order);

View file

@ -179,10 +179,10 @@ public:
//! \brief Rotational tranfsormation of the filled universe.
//
//! The vector is empty if there is no rotation. Otherwise, the first three
//! values are the rotation angles respectively about the x-, y-, and z-, axes
//! in degrees. The next 9 values give the rotation matrix in row-major
//! order.
//! The vector is empty if there is no rotation. Otherwise, the first 9 values
//! give the rotation matrix in row-major order. When the user specifies
//! rotation angles about the x-, y- and z- axes in degrees, these values are
//! also present at the end of the vector, making it of length 12.
std::vector<double> rotation_;
std::vector<int32_t> offset_; //!< Distribcell offset table

View file

@ -20,7 +20,7 @@ using double_4dvec = std::vector<std::vector<std::vector<std::vector<double>>>>;
// OpenMC major, minor, and release numbers
constexpr int VERSION_MAJOR {0};
constexpr int VERSION_MINOR {11};
constexpr int VERSION_MINOR {12};
constexpr int VERSION_RELEASE {0};
constexpr bool VERSION_DEV {true};
constexpr std::array<int, 3> VERSION {VERSION_MAJOR, VERSION_MINOR, VERSION_RELEASE};

View file

@ -37,6 +37,24 @@ private:
UPtrDist z_; //!< Distribution of z coordinates
};
//==============================================================================
//! Distribution of points specified by spherical coordinates r,theta,phi
//==============================================================================
class SphericalIndependent : public SpatialDistribution {
public:
explicit SphericalIndependent(pugi::xml_node node);
//! Sample a position from the distribution
//! \return Sampled position
Position sample() const;
private:
UPtrDist r_; //!< Distribution of r coordinates
UPtrDist theta_; //!< Distribution of theta coordinates
UPtrDist phi_; //!< Distribution of phi coordinates
Position origin_; //!< Cartesian coordinates of the sphere center
};
//==============================================================================
//! Uniform distribution of points over a box
//==============================================================================

View file

@ -7,9 +7,15 @@
#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>
namespace openmc {
namespace model {
extern std::unordered_map<int32_t, std::unordered_map<int32_t, int32_t>> universe_cell_counts;
extern std::unordered_map<int32_t, int32_t> universe_level_counts;
} // namespace model
void read_geometry_xml();
//==============================================================================

View file

@ -345,7 +345,7 @@ read_dataset(hid_t obj_id, const char* name, Position& r, bool indep=false)
}
template <typename T, std::size_t N>
void read_dataset_as_shape(hid_t obj_id, const char* name,
inline void read_dataset_as_shape(hid_t obj_id, const char* name,
xt::xtensor<T, N>& arr, bool indep=false)
{
hid_t dset = open_dataset(obj_id, name);
@ -367,7 +367,7 @@ void read_dataset_as_shape(hid_t obj_id, const char* name,
template <typename T, std::size_t N>
void read_nd_vector(hid_t obj_id, const char* name, xt::xtensor<T, N>& result,
inline void read_nd_vector(hid_t obj_id, const char* name, xt::xtensor<T, N>& result,
bool must_have=false)
{
if (object_exists(obj_id, name)) {

View file

@ -11,6 +11,7 @@
#include "openmc/constants.h"
#include "openmc/hdf5_interface.h"
#include "openmc/particle.h"
#include "openmc/xsdata.h"
@ -110,7 +111,10 @@ class Mgxs {
//!
//! @param xs_id HDF5 group id for the cross section data.
//! @param temperature Temperatures to read.
Mgxs(hid_t xs_id, const std::vector<double>& temperature);
//! @param num_group number of energy groups
//! @param num_delay number of delayed groups
Mgxs(hid_t xs_id, const std::vector<double>& temperature,
int num_group, int num_delay);
//! \brief Constructor that initializes and populates all data to build a
//! macroscopic cross section from microscopic cross section.
@ -119,8 +123,11 @@ class Mgxs {
//! @param mat_kTs temperatures (in units of eV) that data is needed.
//! @param micros Microscopic objects to combine.
//! @param atom_densities Atom densities of those microscopic quantities.
//! @param num_group number of energy groups
//! @param num_delay number of delayed groups
Mgxs(const std::string& in_name, const std::vector<double>& mat_kTs,
const std::vector<Mgxs*>& micros, const std::vector<double>& atom_densities);
const std::vector<Mgxs*>& micros, const std::vector<double>& atom_densities,
int num_group, int num_delay);
//! \brief Provides a cross section value given certain parameters
//!
@ -137,6 +144,11 @@ class Mgxs {
get_xs(int xstype, int gin, const int* gout, const double* mu,
const int* dg);
inline double
get_xs(int xstype, int gin)
{return get_xs(xstype, gin, nullptr, nullptr, nullptr);}
//! \brief Samples the fission neutron energy and if prompt or delayed.
//!
//! @param gin Incoming energy group.
@ -156,15 +168,9 @@ class Mgxs {
//! \brief Calculates cross section quantities needed for tracking.
//!
//! @param gin Incoming energy group.
//! @param sqrtkT Temperature of the material.
//! @param u Incoming particle direction.
//! @param total_xs Resultant total cross section.
//! @param abs_xs Resultant absorption cross section.
//! @param nu_fiss_xs Resultant nu-fission cross section.
//! @param p The particle whose attributes set which MGXS to get.
void
calculate_xs(int gin, double sqrtkT, Direction u,
double& total_xs, double& abs_xs, double& nu_fiss_xs);
calculate_xs(Particle& p);
//! \brief Sets the temperature index in cache given a temperature
//!

View file

@ -12,70 +12,71 @@
namespace openmc {
//==============================================================================
// Global variables
// Global MGXS data container structure
//==============================================================================
class MgxsInterface {
public:
MgxsInterface() = default;
// Construct from path to cross sections file, as well as a list
// of XS to read and the corresponding temperatures for each XS
MgxsInterface(const std::string& path_cross_sections,
const std::vector<std::string> xs_to_read,
const std::vector<std::vector<double>> xs_temps);
// Does things to construct after the nuclides and temperatures to
// read have been specified.
void init();
// Set which nuclides and temperatures are to be read
void set_nuclides_and_temperatures(std::vector<std::string> xs_to_read,
std::vector<std::vector<double>> xs_temps);
// Add an Mgxs object to be managed
void add_mgxs(hid_t file_id, const std::string& name,
const std::vector<double>& temperature);
// Reads just the header of the cross sections file, to find
// min & max energies as well as the available XS
void read_header(const std::string& path_cross_sections);
// Calculate microscopic cross sections from nuclide macro XS
void create_macro_xs();
// Get the kT values which are used in the OpenMC model
std::vector<std::vector<double>> get_mat_kTs();
int num_energy_groups_;
int num_delayed_groups_;
std::vector<std::string> xs_names_; // available names in HDF5 file
std::vector<std::string> xs_to_read_; // XS which appear in materials
std::vector<std::vector<double>> xs_temps_to_read_; // temperatures used
std::string cross_sections_path_; // path to MGXS h5 file
std::vector<Mgxs> nuclides_;
std::vector<Mgxs> macro_xs_;
std::vector<double> energy_bins_;
std::vector<double> energy_bin_avg_;
std::vector<double> rev_energy_bins_;
std::vector<std::vector<double>> nuc_temps_; // all available temperatures
};
namespace data {
extern MgxsInterface mg;
}
extern std::vector<Mgxs> nuclides_MG;
extern std::vector<Mgxs> macro_xs;
extern int num_energy_groups;
extern int num_delayed_groups;
extern std::vector<double> energy_bins;
extern std::vector<double> energy_bin_avg;
extern std::vector<double> rev_energy_bins;
// Puts available XS in MGXS file to globals so that when
// materials are read, the MGXS specified in a material can
// be ensured to be present in the available data.
void put_mgxs_header_data_to_globals();
} // namespace data
// Set which nuclides and temperatures are to be read on
// mg through global data
void set_mg_interface_nuclides_and_temps();
//==============================================================================
// Mgxs data loading interface methods
//==============================================================================
void read_mgxs();
void
add_mgxs(hid_t file_id, const std::string& name,
const std::vector<double>& temperature);
void create_macro_xs();
std::vector<std::vector<double>> get_mat_kTs();
void read_mg_cross_sections_header();
//==============================================================================
// Mgxs tracking/transport/tallying interface methods
//==============================================================================
extern "C" void
calculate_xs_c(int i_mat, int gin, double sqrtkT, Direction u,
double& total_xs, double& abs_xs, double& nu_fiss_xs);
double
get_nuclide_xs(int index, int xstype, int gin, const int* gout,
const double* mu, const int* dg);
inline double
get_nuclide_xs(int index, int xstype, int gin)
{return get_nuclide_xs(index, xstype, gin, nullptr, nullptr, nullptr);}
double
get_macro_xs(int index, int xstype, int gin, const int* gout,
const double* mu, const int* dg);
inline double
get_macro_xs(int index, int xstype, int gin)
{return get_macro_xs(index, xstype, gin, nullptr, nullptr, nullptr);}
//==============================================================================
// General Mgxs methods
//==============================================================================
extern "C" void
get_name_c(int index, int name_len, char* name);
extern "C" double
get_awr_c(int index);
// After macro XS have been read, materials can be marked as fissionable
void mark_fissionable_mgxs_materials();
} // namespace openmc
#endif // OPENMC_MGXS_INTERFACE_H

View file

@ -31,7 +31,7 @@ extern "C" bool cmfd_run; //!< is a CMFD run?
extern "C" bool dagmc; //!< indicator of DAGMC geometry
extern "C" bool entropy_on; //!< calculate Shannon entropy?
extern bool legendre_to_tabular; //!< convert Legendre distributions to tabular?
extern bool output_summary; //!< write summary.h5?
extern "C" bool output_summary; //!< write summary.h5?
extern bool output_tallies; //!< write tallies.out?
extern bool particle_restart_run; //!< particle restart run?
extern "C" bool photon_transport; //!< photon transport turned on?

View file

@ -37,6 +37,8 @@ public:
void set_active(bool active) { active_ = active; }
void set_writable(bool writable) { writable_ = writable; }
void set_scores(pugi::xml_node node);
void set_scores(const std::vector<std::string>& scores);
@ -55,6 +57,8 @@ public:
int32_t n_filter_bins() const {return n_filter_bins_;}
bool writable() const { return writable_;}
//----------------------------------------------------------------------------
// Other methods.
@ -98,6 +102,9 @@ public:
//! (e.g. specific cell, specific energy group, etc.)
xt::xtensor<double, 3> results_;
//! True if this tally should be written to statepoint files
bool writable_ {true};
//----------------------------------------------------------------------------
// Miscellaneous public members.

View file

@ -2,12 +2,14 @@
#define OPENMC_VOLUME_CALC_H
#include "openmc/position.h"
#include "openmc/tallies/trigger.h"
#include "pugixml.hpp"
#include "xtensor/xtensor.hpp"
#include <string>
#include <vector>
#include <gsl/gsl>
namespace openmc {
@ -16,6 +18,7 @@ namespace openmc {
//==============================================================================
class VolumeCalculation {
public:
// Aliases, types
struct Result {
@ -23,6 +26,7 @@ public:
std::vector<int> nuclides; //!< Index of nuclides
std::vector<double> atoms; //!< Number of atoms for each nuclide
std::vector<double> uncertainty; //!< Uncertainty on number of atoms
int iterations; //!< Number of iterations needed to obtain the results
}; // Results for a single domain
// Constructors
@ -44,7 +48,9 @@ public:
// Data members
int domain_type_; //!< Type of domain (cell, material, etc.)
int n_samples_; //!< Number of samples to use
size_t n_samples_; //!< Number of samples to use
double threshold_ {-1.0}; //!< Error threshold for domain volumes
TriggerMetric trigger_type_ {TriggerMetric::not_active}; //!< Trigger metric for the volume calculation
Position lower_left_; //!< Lower-left position of bounding box
Position upper_right_; //!< Upper-right position of bounding box
std::vector<int> domain_ids_; //!< IDs of domains to find volumes of

View file

@ -22,6 +22,7 @@ namespace openmc {
class XsData {
private:
//! \brief Reads scattering data from the HDF5 file
void
scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang,
@ -61,6 +62,9 @@ class XsData {
void
fission_matrix_no_delayed_from_hdf5(hid_t xsdata_grp, size_t n_ang);
//! Number of energy and delayed neutron groups
size_t n_g_, n_dg_;
public:
// The following quantities have the following dimensions:
@ -98,7 +102,10 @@ class XsData {
//! @param scatter_format The scattering representation of the file.
//! @param n_pol Number of polar angles.
//! @param n_azi Number of azimuthal angles.
XsData(bool fissionable, int scatter_format, int n_pol, int n_azi);
//! @param n_groups Number of energy groups.
//! @param n_d_groups Number of delayed neutron groups.
XsData(bool fissionable, int scatter_format, int n_pol, int n_azi,
size_t n_groups, size_t n_d_groups);
//! \brief Loads the XsData object from the HDF5 file
//!