remove std:: from vector,unique_ptr,make_unique,array

This commit is contained in:
Gavin Ridley 2021-04-22 16:46:23 -04:00
parent 2af4c9cd92
commit ad4e1c9f4a
129 changed files with 1013 additions and 1033 deletions

View file

@ -2,11 +2,11 @@
#define OPENMC_BANK_H
#include <cstdint>
#include <vector>
#include "openmc/shared_array.h"
#include "openmc/particle.h"
#include "openmc/position.h"
#include "openmc/shared_array.h"
#include "openmc/vector.h"
namespace openmc {
@ -16,13 +16,13 @@ namespace openmc {
namespace simulation {
extern std::vector<ParticleBank> source_bank;
extern vector<ParticleBank> source_bank;
extern SharedArray<ParticleBank> surf_source_bank;
extern SharedArray<ParticleBank> fission_bank;
extern std::vector<int64_t> progeny_per_particle;
extern vector<int64_t> progeny_per_particle;
} // namespace simulation

View file

@ -4,10 +4,8 @@
#include <cstdint>
#include <functional> // for hash
#include <limits>
#include <memory> // for unique_ptr
#include <string>
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include "hdf5.h"
@ -15,9 +13,11 @@
#include "dagmc.h"
#include "openmc/constants.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/neighbor_list.h"
#include "openmc/position.h"
#include "openmc/surface.h"
#include "openmc/vector.h"
namespace openmc {
@ -50,10 +50,10 @@ class UniversePartitioner;
namespace model {
extern std::unordered_map<int32_t, int32_t> cell_map;
extern std::vector<std::unique_ptr<Cell>> cells;
extern vector<unique_ptr<Cell>> cells;
extern std::unordered_map<int32_t, int32_t> universe_map;
extern std::vector<std::unique_ptr<Universe>> universes;
extern vector<unique_ptr<Universe>> universes;
} // namespace model
//==============================================================================
@ -64,7 +64,7 @@ class Universe
{
public:
int32_t id_; //!< Unique ID
std::vector<int32_t> cells_; //!< Cells within this universe
vector<int32_t> cells_; //!< Cells within this universe
//! \brief Write universe information to an HDF5 group.
//! \param group_id An HDF5 group id.
@ -72,7 +72,7 @@ public:
BoundingBox bounding_box() const;
std::unique_ptr<UniversePartitioner> partitioner_;
unique_ptr<UniversePartitioner> partitioner_;
};
//==============================================================================
@ -151,13 +151,12 @@ public:
//! Get all cell instances contained by this cell
//! \return Map with cell indexes as keys and instances as values
std::unordered_map<int32_t, std::vector<int32_t>>
get_contained_cells() const;
std::unordered_map<int32_t, vector<int32_t>> get_contained_cells() const;
protected:
void
get_contained_cells_inner(std::unordered_map<int32_t, std::vector<int32_t>>& contained_cells,
std::vector<ParentCell>& parent_cells) const;
void get_contained_cells_inner(
std::unordered_map<int32_t, vector<int32_t>>& contained_cells,
vector<ParentCell>& parent_cells) const;
public:
//----------------------------------------------------------------------------
@ -176,18 +175,18 @@ public:
//! \brief Material(s) within this cell.
//!
//! May be multiple materials for distribcell.
std::vector<int32_t> material_;
vector<int32_t> material_;
//! \brief Temperature(s) within this cell.
//!
//! The stored values are actually sqrt(k_Boltzmann * T) for each temperature
//! T. The units are sqrt(eV).
std::vector<double> sqrtkT_;
vector<double> sqrtkT_;
//! Definition of spatial region as Boolean expression of half-spaces
std::vector<std::int32_t> region_;
vector<std::int32_t> region_;
//! Reverse Polish notation for region expression
std::vector<std::int32_t> rpn_;
vector<std::int32_t> rpn_;
bool simple_; //!< Does the region contain only intersections?
//! \brief Neighboring cells in the same universe.
@ -201,9 +200,9 @@ public:
//! 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_;
vector<double> rotation_;
std::vector<int32_t> offset_; //!< Distribcell offset table
vector<int32_t> offset_; //!< Distribcell offset table
};
struct CellInstanceItem {
@ -234,27 +233,25 @@ protected:
bool contains_simple(Position r, Direction u, int32_t on_surface) const;
bool contains_complex(Position r, Direction u, int32_t on_surface) const;
BoundingBox bounding_box_simple() const;
static BoundingBox bounding_box_complex(std::vector<int32_t> rpn);
static BoundingBox bounding_box_complex(vector<int32_t> rpn);
//! Applies DeMorgan's laws to a section of the RPN
//! \param start Starting point for token modification
//! \param stop Stopping point for token modification
static void apply_demorgan(std::vector<int32_t>::iterator start,
std::vector<int32_t>::iterator stop);
static void apply_demorgan(
vector<int32_t>::iterator start, vector<int32_t>::iterator stop);
//! Removes complement operators from the RPN
//! \param rpn The rpn to remove complement operators from.
static void remove_complement_ops(std::vector<int32_t>& rpn);
static void remove_complement_ops(vector<int32_t>& rpn);
//! Returns the beginning position of a parenthesis block (immediately before
//! two surface tokens) in the RPN given a starting position at the end of
//! that block (immediately after two surface tokens)
//! \param start Starting position of the search
//! \param rpn The rpn being searched
static std::vector<int32_t>::iterator
find_left_parenthesis(std::vector<int32_t>::iterator start,
const std::vector<int32_t>& rpn);
static vector<int32_t>::iterator find_left_parenthesis(
vector<int32_t>::iterator start, const vector<int32_t>& rpn);
};
//==============================================================================
@ -293,11 +290,11 @@ public:
explicit UniversePartitioner(const Universe& univ);
//! Return the list of cells that could contain the given coordinates.
const std::vector<int32_t>& get_cells(Position r, Direction u) const;
const vector<int32_t>& get_cells(Position r, Direction u) const;
private:
//! A sorted vector of indices to surfaces that partition the universe
std::vector<int32_t> surfs_;
vector<int32_t> surfs_;
//! Vectors listing the indices of the cells that lie within each partition
//
@ -306,7 +303,7 @@ private:
//! `partitions_.back()` gives the cells that lie on the positive side of
//! `surfs_.back()`. Otherwise, `partitions_[i]` gives cells sandwiched
//! between `surfs_[i-1]` and `surfs_[i]`.
std::vector<std::vector<int32_t>> partitions_;
vector<std::vector<int32_t>> partitions_;
};

View file

@ -4,18 +4,18 @@
#ifndef OPENMC_CONSTANTS_H
#define OPENMC_CONSTANTS_H
#include <array>
#include <cmath>
#include <limits>
#include <vector>
#include "openmc/array.h"
#include "openmc/vector.h"
#include "openmc/version.h"
namespace openmc {
using double_2dvec = std::vector<std::vector<double>>;
using double_3dvec = std::vector<std::vector<std::vector<double>>>;
using double_4dvec = std::vector<std::vector<std::vector<std::vector<double>>>>;
using double_2dvec = vector<std::vector<double>>;
using double_3dvec = vector<std::vector<std::vector<double>>>;
using double_4dvec = vector<std::vector<std::vector<std::vector<double>>>>;
// ============================================================================
// VERSIONING NUMBERS
@ -24,13 +24,13 @@ using double_4dvec = std::vector<std::vector<std::vector<std::vector<double>>>>;
constexpr int HDF5_VERSION[] {3, 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};
constexpr std::array<int, 2> VERSION_VOLUME {1, 0};
constexpr std::array<int, 2> VERSION_VOXEL {2, 0};
constexpr std::array<int, 2> VERSION_MGXS_LIBRARY {1, 0};
constexpr array<int, 2> VERSION_STATEPOINT {17, 0};
constexpr array<int, 2> VERSION_PARTICLE_RESTART {2, 0};
constexpr array<int, 2> VERSION_TRACK {2, 0};
constexpr array<int, 2> VERSION_SUMMARY {6, 0};
constexpr array<int, 2> VERSION_VOLUME {1, 0};
constexpr array<int, 2> VERSION_VOXEL {2, 0};
constexpr array<int, 2> VERSION_MGXS_LIBRARY {1, 0};
// ============================================================================
// ADJUSTABLE PARAMETERS
@ -92,13 +92,10 @@ constexpr double N_AVOGADRO {0.6022140857}; // Avogadro's number in 10^24/
constexpr double K_BOLTZMANN {8.6173303e-5}; // Boltzmann constant in eV/K
// Electron subshell labels
constexpr std::array<const char*, 39> SUBSHELLS = {
"K", "L1", "L2", "L3", "M1", "M2", "M3", "M4", "M5",
"N1", "N2", "N3", "N4", "N5", "N6", "N7", "O1", "O2",
"O3", "O4", "O5", "O6", "O7", "O8", "O9", "P1", "P2",
"P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10", "P11",
"Q1", "Q2", "Q3"
};
constexpr array<const char*, 39> SUBSHELLS = {"K", "L1", "L2", "L3", "M1", "M2",
"M3", "M4", "M5", "N1", "N2", "N3", "N4", "N5", "N6", "N7", "O1", "O2", "O3",
"O4", "O5", "O6", "O7", "O8", "O9", "P1", "P2", "P3", "P4", "P5", "P6", "P7",
"P8", "P9", "P10", "P11", "Q1", "Q2", "Q3"};
// Void material and nuclide
// TODO: refactor and remove
@ -243,7 +240,7 @@ enum ReactionType {
HEATING_LOCAL = 901
};
constexpr std::array<int, 6> DEPLETION_RX {N_GAMMA, N_P, N_A, N_2N, N_3N, N_4N};
constexpr array<int, 6> DEPLETION_RX {N_GAMMA, N_P, N_A, N_2N, N_3N, N_4N};
enum class URRTableParam {
CUM_PROB,

View file

@ -5,7 +5,8 @@
#include <string>
#include <map>
#include <vector>
#include "openmc/vector.h"
namespace openmc {
@ -31,7 +32,7 @@ public:
// Data members
Type type_; //!< Type of data library
std::vector<std::string> materials_; //!< Materials contained in library
vector<std::string> materials_; //!< Materials contained in library
std::string path_; //!< File path to library
};
@ -47,7 +48,7 @@ namespace data {
extern std::map<LibraryKey, std::size_t> library_map;
//!< Data libraries
extern std::vector<Library> libraries;
extern vector<Library> libraries;
} // namespace data
@ -64,8 +65,8 @@ void read_cross_sections_xml();
//
//! \param[in] nuc_temps Temperatures for each nuclide in [K]
//! \param[in] thermal_temps Temperatures for each thermal scattering table in [K]
void read_ce_cross_sections(const std::vector<std::vector<double>>& nuc_temps,
const std::vector<std::vector<double>>& thermal_temps);
void read_ce_cross_sections(const vector<std::vector<double>>& nuc_temps,
const vector<std::vector<double>>& thermal_temps);
//! Read cross_sections.xml and populate data libraries
void read_ce_cross_sections_xml();

View file

@ -5,12 +5,12 @@
#define OPENMC_DISTRIBUTION_H
#include <cstddef> // for size_t
#include <memory> // for unique_ptr
#include <vector> // for vector
#include "pugixml.hpp"
#include "openmc/constants.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/vector.h" // for vector
namespace openmc {
@ -39,11 +39,12 @@ public:
double sample(uint64_t* seed) const;
// Properties
const std::vector<double>& x() const { return x_; }
const std::vector<double>& p() const { return p_; }
const vector<double>& x() const { return x_; }
const vector<double>& p() const { return p_; }
private:
std::vector<double> x_; //!< Possible outcomes
std::vector<double> p_; //!< Probability of each outcome
vector<double> x_; //!< Possible outcomes
vector<double> p_; //!< Probability of each outcome
//! Normalize distribution so that probabilities sum to unity
void normalize();
@ -174,14 +175,14 @@ public:
double sample(uint64_t* seed) const;
// x property
std::vector<double>& x() { return x_; }
const std::vector<double>& x() const { return x_; }
const std::vector<double>& p() const { return p_; }
vector<double>& x() { return x_; }
const vector<double>& x() const { return x_; }
const vector<double>& p() const { return p_; }
Interpolation interp() const { return interp_; }
private:
std::vector<double> x_; //!< tabulated independent variable
std::vector<double> p_; //!< tabulated probability density
std::vector<double> c_; //!< cumulative distribution at tabulated values
vector<double> x_; //!< tabulated independent variable
vector<double> p_; //!< tabulated probability density
vector<double> c_; //!< cumulative distribution at tabulated values
Interpolation interp_; //!< interpolation rule
//! Initialize tabulated probability density function
@ -206,13 +207,13 @@ public:
//! \return Sampled value
double sample(uint64_t* seed) const;
const std::vector<double>& x() const { return x_; }
const vector<double>& x() const { return x_; }
private:
std::vector<double> x_; //! Possible outcomes
vector<double> x_; //! Possible outcomes
};
using UPtrDist = std::unique_ptr<Distribution>;
using UPtrDist = unique_ptr<Distribution>;
//! Return univariate probability distribution specified in XML file
//! \param[in] node XML node representing distribution

View file

@ -4,11 +4,10 @@
#ifndef OPENMC_DISTRIBUTION_ANGLE_H
#define OPENMC_DISTRIBUTION_ANGLE_H
#include <vector> // for vector
#include "hdf5.h"
#include "openmc/distribution.h"
#include "openmc/vector.h"
namespace openmc {
@ -32,8 +31,8 @@ public:
bool empty() const { return energy_.empty(); }
private:
std::vector<double> energy_;
std::vector<std::unique_ptr<Tabular>> distribution_;
vector<double> energy_;
vector<unique_ptr<Tabular>> distribution_;
};
} // namespace openmc

View file

@ -4,13 +4,12 @@
#ifndef OPENMC_DISTRIBUTION_ENERGY_H
#define OPENMC_DISTRIBUTION_ENERGY_H
#include <vector>
#include "xtensor/xtensor.hpp"
#include "hdf5.h"
#include "openmc/constants.h"
#include "openmc/endf.h"
#include "openmc/vector.h"
namespace openmc {
@ -90,10 +89,10 @@ private:
};
int n_region_; //!< Number of inteprolation regions
std::vector<int> breakpoints_; //!< Breakpoints between regions
std::vector<Interpolation> interpolation_; //!< Interpolation laws
std::vector<double> energy_; //!< Incident energy in [eV]
std::vector<CTTable> distribution_; //!< Distributions for each incident energy
vector<int> breakpoints_; //!< Breakpoints between regions
vector<Interpolation> interpolation_; //!< Interpolation laws
vector<double> energy_; //!< Incident energy in [eV]
vector<CTTable> distribution_; //!< Distributions for each incident energy
};
//===============================================================================

View file

@ -1,7 +1,7 @@
#ifndef DISTRIBUTION_MULTI_H
#define DISTRIBUTION_MULTI_H
#include <memory>
#include "openmc/memory.h"
#include "pugixml.hpp"
@ -82,7 +82,7 @@ public:
Direction sample(uint64_t* seed) const;
};
using UPtrAngle = std::unique_ptr<UnitSphereDistribution>;
using UPtrAngle = unique_ptr<UnitSphereDistribution>;
} // namespace openmc

View file

@ -135,7 +135,7 @@ private:
Position r_; //!< Single position at which sites are generated
};
using UPtrSpace = std::unique_ptr<SpatialDistribution>;
using UPtrSpace = unique_ptr<SpatialDistribution>;
} // namespace openmc

View file

@ -4,14 +4,14 @@
#ifndef OPENMC_EIGENVALUE_H
#define OPENMC_EIGENVALUE_H
#include <array>
#include <cstdint> // for int64_t
#include <vector>
#include "xtensor/xtensor.hpp"
#include <hdf5.h>
#include "openmc/array.h"
#include "openmc/particle.h"
#include "openmc/vector.h"
namespace openmc {
@ -22,8 +22,8 @@ namespace openmc {
namespace simulation {
extern double keff_generation; //!< Single-generation k on each processor
extern std::array<double, 2> k_sum; //!< Used to reduce sum and sum_sq
extern std::vector<double> entropy; //!< Shannon entropy at each generation
extern array<double, 2> k_sum; //!< Used to reduce sum and sum_sq
extern vector<double> entropy; //!< Shannon entropy at each generation
extern xt::xtensor<double, 1> source_frac; //!< Source fraction for UFS
} // namespace simulation

View file

@ -4,12 +4,11 @@
#ifndef OPENMC_ENDF_H
#define OPENMC_ENDF_H
#include <memory>
#include <vector>
#include "hdf5.h"
#include "openmc/constants.h"
#include "openmc/memory.h"
#include "openmc/vector.h"
namespace openmc {
@ -59,7 +58,7 @@ public:
//! \return Polynomial evaluated at x
double operator()(double x) const override;
private:
std::vector<double> coef_; //!< Polynomial coefficients
vector<double> coef_; //!< Polynomial coefficients
};
//==============================================================================
@ -80,15 +79,16 @@ public:
double operator()(double x) const override;
// Accessors
const std::vector<double>& x() const { return x_; }
const std::vector<double>& y() const { return y_; }
const vector<double>& x() const { return x_; }
const vector<double>& y() const { return y_; }
private:
std::size_t n_regions_ {0}; //!< number of interpolation regions
std::vector<int> nbt_; //!< values separating interpolation regions
std::vector<Interpolation> int_; //!< interpolation schemes
vector<int> nbt_; //!< values separating interpolation regions
vector<Interpolation> int_; //!< interpolation schemes
std::size_t n_pairs_; //!< number of (x,y) pairs
std::vector<double> x_; //!< values of abscissa
std::vector<double> y_; //!< values of ordinate
vector<double> x_; //!< values of abscissa
vector<double> y_; //!< values of ordinate
};
//==============================================================================
@ -101,11 +101,12 @@ public:
double operator()(double E) const override;
const std::vector<double>& bragg_edges() const { return bragg_edges_; }
const std::vector<double>& factors() const { return factors_; }
const vector<double>& bragg_edges() const { return bragg_edges_; }
const vector<double>& factors() const { return factors_; }
private:
std::vector<double> bragg_edges_; //!< Bragg edges in [eV]
std::vector<double> factors_; //!< Partial sums of structure factors [eV-b]
vector<double> bragg_edges_; //!< Bragg edges in [eV]
vector<double> factors_; //!< Partial sums of structure factors [eV-b]
};
//==============================================================================
@ -126,7 +127,7 @@ private:
//! \param[in] group HDF5 group containing dataset
//! \param[in] name Name of dataset
//! \return Unique pointer to 1D function
std::unique_ptr<Function1D> read_function(hid_t group, const char* name);
unique_ptr<Function1D> read_function(hid_t group, const char* name);
} // namespace openmc

View file

@ -65,7 +65,7 @@ extern SharedArray<EventQueueItem> surface_crossing_queue;
extern SharedArray<EventQueueItem> collision_queue;
// Particle buffer
extern std::vector<Particle> particles;
extern vector<Particle> particles;
} // namespace simulation

View file

@ -1,12 +1,12 @@
#ifndef OPENMC_GEOMETRY_H
#define OPENMC_GEOMETRY_H
#include <array>
#include <cmath>
#include <cstdint>
#include <vector>
#include "openmc/array.h"
#include "openmc/constants.h"
#include "openmc/vector.h"
namespace openmc {
@ -22,7 +22,7 @@ namespace model {
extern int root_universe; //!< Index of root universe
extern "C" int n_coord_levels; //!< Number of CSG coordinate levels
extern std::vector<int64_t> overlap_check_count;
extern vector<int64_t> overlap_check_count;
} // namespace model

View file

@ -6,9 +6,10 @@
#include <cstdint>
#include <string>
#include <vector>
#include <unordered_map>
#include "openmc/vector.h"
namespace openmc {
namespace model {
@ -41,8 +42,8 @@ void assign_temperatures();
//! table
//==============================================================================
void get_temperatures(std::vector<std::vector<double>>& nuc_temps,
std::vector<std::vector<double>>& thermal_temps);
void get_temperatures(vector<std::vector<double>>& nuc_temps,
vector<std::vector<double>>& thermal_temps);
//==============================================================================
//! \brief Perform final setup for geometry

View file

@ -2,22 +2,22 @@
#define OPENMC_HDF5_INTERFACE_H
#include <algorithm> // for min
#include <array>
#include <complex>
#include <cstddef>
#include <cstring> // for strlen
#include <string>
#include <sstream>
#include <type_traits>
#include <vector>
#include "hdf5.h"
#include "hdf5_hl.h"
#include "xtensor/xadapt.hpp"
#include "xtensor/xarray.hpp"
#include "openmc/position.h"
#include "openmc/array.h"
#include "openmc/error.h"
#include "openmc/position.h"
#include "openmc/vector.h"
namespace openmc {
@ -55,11 +55,11 @@ hid_t file_open(const std::string& filename, char mode, bool parallel=false);
void write_string(hid_t group_id, const char* name, const std::string& buffer,
bool indep);
std::vector<hsize_t> attribute_shape(hid_t obj_id, const char* name);
std::vector<std::string> dataset_names(hid_t group_id);
vector<hsize_t> attribute_shape(hid_t obj_id, const char* name);
vector<std::string> dataset_names(hid_t group_id);
void ensure_exists(hid_t obj_id, const char* name, bool attribute=false);
std::vector<std::string> group_names(hid_t group_id);
std::vector<hsize_t> object_shape(hid_t obj_id);
vector<std::string> group_names(hid_t group_id);
vector<hsize_t> object_shape(hid_t obj_id);
std::string object_name(hid_t obj_id);
//==============================================================================
@ -141,15 +141,15 @@ void read_attribute(hid_t obj_id, const char* name, T& buffer)
}
// array version
template<typename T, std::size_t N> inline void
read_attribute(hid_t obj_id, const char* name, std::array<T, N>& buffer)
template<typename T, std::size_t N>
inline void read_attribute(hid_t obj_id, const char* name, array<T, N>& buffer)
{
read_attr(obj_id, name, H5TypeMap<T>::type_id, buffer.data());
}
// vector version
template<typename T>
void read_attribute(hid_t obj_id, const char* name, std::vector<T>& vec)
void read_attribute(hid_t obj_id, const char* name, vector<T>& vec)
{
// Get shape of attribute array
auto shape = attribute_shape(obj_id, name);
@ -175,7 +175,7 @@ void read_attribute(hid_t obj_id, const char* name, xt::xarray<T>& arr)
std::size_t size = 1;
for (const auto x : shape)
size *= x;
std::vector<T> buffer(size);
vector<T> buffer(size);
// Read data from attribute
read_attr(obj_id, name, H5TypeMap<T>::type_id, buffer.data());
@ -198,9 +198,9 @@ read_attribute(hid_t obj_id, const char* name, std::string& str)
delete[] buffer;
}
// overload for std::vector<std::string>
inline void
read_attribute(hid_t obj_id, const char* name, std::vector<std::string>& vec)
// overload for vector<std::string>
inline void read_attribute(
hid_t obj_id, const char* name, vector<std::string>& vec)
{
auto dims = attribute_shape(obj_id, name);
auto m = dims[0];
@ -254,20 +254,20 @@ read_dataset(hid_t obj_id, const char* name, std::string& str, bool indep=false)
}
// array version
template<typename T, std::size_t N> inline void
read_dataset(hid_t dset, const char* name, std::array<T, N>& buffer,
bool indep=false)
template<typename T, std::size_t N>
inline void read_dataset(
hid_t dset, const char* name, array<T, N>& buffer, bool indep = false)
{
read_dataset_lowlevel(dset, name, H5TypeMap<T>::type_id, H5S_ALL, indep,
buffer.data());
}
// vector version
template <typename T>
void read_dataset(hid_t dset, std::vector<T>& vec, bool indep=false)
template<typename T>
void read_dataset(hid_t dset, vector<T>& vec, bool indep = false)
{
// Get shape of dataset
std::vector<hsize_t> shape = object_shape(dset);
vector<hsize_t> shape = object_shape(dset);
// Resize vector to appropriate size
vec.resize(shape[0]);
@ -277,9 +277,9 @@ void read_dataset(hid_t dset, std::vector<T>& vec, bool indep=false)
vec.data());
}
template <typename T>
void read_dataset(hid_t obj_id, const char* name, std::vector<T>& vec,
bool indep=false)
template<typename T>
void read_dataset(
hid_t obj_id, const char* name, vector<T>& vec, bool indep = false)
{
hid_t dset = open_dataset(obj_id, name);
read_dataset(dset, vec, indep);
@ -290,7 +290,7 @@ template <typename T>
void read_dataset(hid_t dset, xt::xarray<T>& arr, bool indep=false)
{
// Get shape of dataset
std::vector<hsize_t> shape = object_shape(dset);
vector<hsize_t> shape = object_shape(dset);
// Allocate space in the array to read data into
std::size_t size = 1;
@ -326,11 +326,11 @@ void read_dataset(hid_t obj_id, const char* name, xt::xtensor<T, N>& arr,
hid_t dset = open_dataset(obj_id, name);
// Get shape of dataset
std::vector<hsize_t> hsize_t_shape = object_shape(dset);
vector<hsize_t> hsize_t_shape = object_shape(dset);
close_dataset(dset);
// cast from hsize_t to size_t
std::vector<size_t> shape(hsize_t_shape.size());
vector<size_t> shape(hsize_t_shape.size());
for (int i = 0; i < shape.size(); i++) {
shape[i] = static_cast<size_t>(hsize_t_shape[i]);
}
@ -349,7 +349,7 @@ void read_dataset(hid_t obj_id, const char* name, xt::xtensor<T, N>& arr,
inline void
read_dataset(hid_t obj_id, const char* name, Position& r, bool indep=false)
{
std::array<double, 3> x;
array<double, 3> x;
read_dataset(obj_id, name, x, indep);
r.x = x[0];
r.y = x[1];
@ -366,7 +366,7 @@ inline void read_dataset_as_shape(hid_t obj_id, const char* name,
std::size_t size = 1;
for (const auto x : arr.shape())
size *= x;
std::vector<T> buffer(size);
vector<T> buffer(size);
// Read data from attribute
read_dataset_lowlevel(dset, nullptr, H5TypeMap<T>::type_id, H5S_ALL, indep,
@ -412,15 +412,17 @@ write_attribute(hid_t obj_id, const char* name, const std::string& buffer)
write_attr_string(obj_id, name, buffer.c_str());
}
template<typename T, std::size_t N> inline void
write_attribute(hid_t obj_id, const char* name, const std::array<T, N>& buffer)
template<typename T, std::size_t N>
inline void write_attribute(
hid_t obj_id, const char* name, const array<T, N>& buffer)
{
hsize_t dims[] {N};
write_attr(obj_id, 1, dims, name, H5TypeMap<T>::type_id, buffer.data());
}
template<typename T> inline void
write_attribute(hid_t obj_id, const char* name, const std::vector<T>& buffer)
template<typename T>
inline void write_attribute(
hid_t obj_id, const char* name, const vector<T>& buffer)
{
hsize_t dims[] {buffer.size()};
write_attr(obj_id, 1, dims, name, H5TypeMap<T>::type_id, buffer.data());
@ -429,7 +431,7 @@ write_attribute(hid_t obj_id, const char* name, const std::vector<T>& buffer)
inline void
write_attribute(hid_t obj_id, const char* name, Position r)
{
std::array<double, 3> buffer {r.x, r.y, r.z};
array<double, 3> buffer {r.x, r.y, r.z};
write_attribute(obj_id, name, buffer);
}
@ -454,17 +456,17 @@ write_dataset(hid_t obj_id, const char* name, const char* buffer)
write_string(obj_id, name, buffer, false);
}
template<typename T, std::size_t N> inline void
write_dataset(hid_t obj_id, const char* name, const std::array<T, N>& buffer)
template<typename T, std::size_t N>
inline void write_dataset(
hid_t obj_id, const char* name, const array<T, N>& buffer)
{
hsize_t dims[] {N};
write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap<T>::type_id,
H5S_ALL, false, buffer.data());
}
inline void
write_dataset(hid_t obj_id, const char* name,
const std::vector<std::string>& buffer)
inline void write_dataset(
hid_t obj_id, const char* name, const vector<std::string>& buffer)
{
auto n {buffer.size()};
hsize_t dims[] {n};
@ -489,8 +491,9 @@ write_dataset(hid_t obj_id, const char* name,
delete[] temp;
}
template<typename T> inline void
write_dataset(hid_t obj_id, const char* name, const std::vector<T>& buffer)
template<typename T>
inline void write_dataset(
hid_t obj_id, const char* name, const vector<T>& buffer)
{
hsize_t dims[] {buffer.size()};
write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap<T>::type_id,
@ -503,7 +506,7 @@ write_dataset(hid_t obj_id, const char* name, const xt::xcontainer<D>& arr)
{
using T = typename D::value_type;
auto s = arr.shape();
std::vector<hsize_t> dims {s.cbegin(), s.cend()};
vector<hsize_t> dims {s.cbegin(), s.cend()};
write_dataset_lowlevel(obj_id, dims.size(), dims.data(), name,
H5TypeMap<T>::type_id, H5S_ALL, false, arr.data());
}
@ -511,7 +514,7 @@ write_dataset(hid_t obj_id, const char* name, const xt::xcontainer<D>& arr)
inline void
write_dataset(hid_t obj_id, const char* name, Position r)
{
std::array<double, 3> buffer {r.x, r.y, r.z};
array<double, 3> buffer {r.x, r.y, r.z};
write_dataset(obj_id, name, buffer);
}

View file

@ -3,17 +3,16 @@
#include <array>
#include <cstdint>
#include <memory> // for unique_ptr
#include <string>
#include <unordered_map>
#include <vector>
#include "hdf5.h"
#include "pugixml.hpp"
#include "openmc/constants.h"
#include "openmc/memory.h"
#include "openmc/position.h"
#include "openmc/vector.h"
namespace openmc {
@ -36,7 +35,7 @@ class Lattice;
namespace model {
extern std::unordered_map<int32_t, int32_t> lattice_map;
extern std::vector<std::unique_ptr<Lattice>> lattices;
extern vector<unique_ptr<Lattice>> lattices;
} // namespace model
//==============================================================================
@ -53,9 +52,9 @@ public:
int32_t id_; //!< Universe ID number
std::string name_; //!< User-defined name
LatticeType type_;
std::vector<int32_t> universes_; //!< Universes filling each lattice tile
vector<int32_t> universes_; //!< Universes filling each lattice tile
int32_t outer_ {NO_OUTER_UNIVERSE}; //!< Universe tiled outside the lattice
std::vector<int32_t> offsets_; //!< Distribcell offset table
vector<int32_t> offsets_; //!< Distribcell offset table
explicit Lattice(pugi::xml_node lat_node);
@ -99,9 +98,8 @@ public:
//! \param i_xyz The indices for a lattice tile.
//! \return The distance to the next crossing and an array indicating how the
//! lattice indices would change after crossing that boundary.
virtual std::pair<double, std::array<int, 3>>
distance(Position r, Direction u, const std::array<int, 3>& i_xyz) const
= 0;
virtual std::pair<double, array<int, 3>> distance(
Position r, Direction u, const array<int, 3>& i_xyz) const = 0;
//! \brief Find the lattice tile indices for a given point.
//! \param r A 3D Cartesian coordinate.
@ -217,8 +215,8 @@ public:
bool are_valid_indices(const int i_xyz[3]) const;
std::pair<double, std::array<int, 3>>
distance(Position r, Direction u, const std::array<int, 3>& i_xyz) const;
std::pair<double, array<int, 3>> distance(
Position r, Direction u, const array<int, 3>& i_xyz) const;
std::array<int, 3> get_indices(Position r, Direction u) const;
@ -234,7 +232,7 @@ public:
void to_hdf5_inner(hid_t group_id) const;
private:
std::array<int, 3> n_cells_; //!< Number of cells along each axis
array<int, 3> n_cells_; //!< Number of cells along each axis
Position lower_left_; //!< Global lower-left corner of the lattice
Position pitch_; //!< Lattice tile width along each axis
@ -259,8 +257,8 @@ public:
bool are_valid_indices(array<int, 3> const& i_xyz) const;
std::pair<double, std::array<int, 3>>
distance(Position r, Direction u, const std::array<int, 3>& i_xyz) const;
std::pair<double, array<int, 3>> distance(
Position r, Direction u, const array<int, 3>& i_xyz) const;
std::array<int, 3> get_indices(Position r, Direction u) const;
@ -284,16 +282,16 @@ private:
};
//! Fill universes_ vector for 'y' orientation
void fill_lattice_y(const std::vector<std::string>& univ_words);
void fill_lattice_y(const vector<std::string>& univ_words);
//! Fill universes_ vector for 'x' orientation
void fill_lattice_x(const std::vector<std::string>& univ_words);
void fill_lattice_x(const vector<std::string>& univ_words);
int n_rings_; //!< Number of radial tile positions
int n_axial_; //!< Number of axial tile positions
Orientation orientation_; //!< Orientation of lattice
Position center_; //!< Global center of lattice
std::array<double, 2> pitch_; //!< Lattice tile width and height
array<double, 2> pitch_; //!< Lattice tile width and height
};
//==============================================================================

View file

@ -1,19 +1,19 @@
#ifndef OPENMC_MATERIAL_H
#define OPENMC_MATERIAL_H
#include <memory> // for unique_ptr
#include <string>
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include <hdf5.h>
#include "pugixml.hpp"
#include "xtensor/xtensor.hpp"
#include "openmc/constants.h"
#include "openmc/bremsstrahlung.h"
#include "openmc/constants.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/particle.h"
#include "openmc/vector.h"
namespace openmc {
@ -26,7 +26,7 @@ class Material;
namespace model {
extern std::unordered_map<int32_t, int32_t> material_map;
extern std::vector<std::unique_ptr<Material>> materials;
extern vector<unique_ptr<Material>> materials;
} // namespace model
@ -79,8 +79,8 @@ public:
//
//! \param[in] name Name of each nuclide
//! \param[in] density Density of each nuclide in [atom/b-cm]
void set_densities(const std::vector<std::string>& name,
const std::vector<double>& density);
void set_densities(
const vector<std::string>& name, const vector<double>& density);
//----------------------------------------------------------------------------
// Accessors
@ -139,26 +139,27 @@ public:
// Data
int32_t id_ {C_NONE}; //!< Unique ID
std::string name_; //!< Name of material
std::vector<int> nuclide_; //!< Indices in nuclides vector
std::vector<int> element_; //!< Indices in elements vector
vector<int> nuclide_; //!< Indices in nuclides vector
vector<int> element_; //!< Indices in elements vector
xt::xtensor<double, 1> atom_density_; //!< Nuclide atom density in [atom/b-cm]
double density_; //!< Total atom density in [atom/b-cm]
double density_gpcc_; //!< Total atom density in [g/cm^3]
double volume_ {-1.0}; //!< Volume in [cm^3]
bool fissionable_ {false}; //!< Does this material contain fissionable nuclides
bool depletable_ {false}; //!< Is the material depletable?
std::vector<bool> p0_; //!< Indicate which nuclides are to be treated with iso-in-lab scattering
vector<bool> p0_; //!< Indicate which nuclides are to be treated with
//!< iso-in-lab scattering
// To improve performance of tallying, we store an array (direct address
// table) that indicates for each nuclide in data::nuclides the index of the
// corresponding nuclide in the nuclide_ vector. If it is not present in the
// material, the entry is set to -1.
std::vector<int> mat_nuclide_index_;
vector<int> mat_nuclide_index_;
// Thermal scattering tables
std::vector<ThermalTable> thermal_tables_;
vector<ThermalTable> thermal_tables_;
std::unique_ptr<Bremsstrahlung> ttb_;
unique_ptr<Bremsstrahlung> ttb_;
private:
//----------------------------------------------------------------------------
@ -191,14 +192,14 @@ private:
//==============================================================================
//! Calculate Sternheimer adjustment factor
double sternheimer_adjustment(const std::vector<double>& f, const
std::vector<double>& e_b_sq, double e_p_sq, double n_conduction, double
log_I, double tol, int max_iter);
double sternheimer_adjustment(const vector<double>& f,
const vector<double>& e_b_sq, double e_p_sq, double n_conduction,
double log_I, double tol, int max_iter);
//! Calculate density effect correction
double density_effect(const std::vector<double>& f, const std::vector<double>&
e_b_sq, double e_p_sq, double n_conduction, double rho, double E, double tol,
int max_iter);
double density_effect(const vector<double>& f,
const std::vector<double>& e_b_sq, double e_p_sq, double n_conduction,
double rho, double E, double tol, int max_iter);
//! Read material data from materials.xml
void read_materials_xml();

19
include/openmc/memory.h Normal file
View file

@ -0,0 +1,19 @@
#ifndef OPENMC_MEMORY_H
#define OPENMC_MEMORY_H
/*
* See notes in include/openmc/vector.h
*
* In an implementation of OpenMC that uses an accelerator, we may remove the
* use of unique_ptr, etc. below and replace it with a custom
* implementation behaving as expected on the device.
*/
#include <memory>
namespace openmc {
using std::make_unique;
using std::unique_ptr;
} // namespace openmc
#endif // OPENMC_MEMORY_H

View file

@ -4,16 +4,16 @@
#ifndef OPENMC_MESH_H
#define OPENMC_MESH_H
#include <memory> // for unique_ptr
#include <vector>
#include <unordered_map>
#include "hdf5.h"
#include "pugixml.hpp"
#include "xtensor/xtensor.hpp"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/particle.h"
#include "openmc/position.h"
#include "openmc/vector.h"
#ifdef DAGMC
#include "moab/Core.hpp"
@ -47,14 +47,14 @@ class Mesh;
namespace model {
extern std::unordered_map<int32_t, int32_t> mesh_map;
extern std::vector<std::unique_ptr<Mesh>> meshes;
extern vector<unique_ptr<Mesh>> meshes;
} // namespace model
#ifdef LIBMESH
namespace settings {
// used when creating new libMesh::Mesh instances
extern std::unique_ptr<libMesh::LibMeshInit> libmesh_init;
extern unique_ptr<libMesh::LibMeshInit> libmesh_init;
extern const libMesh::Parallel::Communicator* libmesh_comm;
}
#endif
@ -79,8 +79,8 @@ public:
virtual void bins_crossed(Position r0,
Position r1,
const Direction& u,
std::vector<int>& bins,
std::vector<double>& lengths) const = 0;
vector<int>& bins,
vector<double>& lengths) const = 0;
//! Determine which surface bins were crossed by a particle
//
@ -92,7 +92,7 @@ public:
surface_bins_crossed(Position r0,
Position r1,
const Direction& u,
std::vector<int>& bins) const = 0;
vector<int>& bins) const = 0;
//! Get bin at a given position in space
//
@ -122,8 +122,8 @@ public:
//! of the plot's axes. For example an xy-slice plot will get back a vector
//! of x-coordinates and another of y-coordinates. These vectors may be
//! empty for low-dimensional meshes.
virtual std::pair<std::vector<double>, std::vector<double>>
plot(Position plot_ll, Position plot_ur) const = 0;
virtual std::pair<vector<double>, std::vector<double>> plot(
Position plot_ll, Position plot_ur) const = 0;
//! Return a string representation of the mesh bin
//
@ -150,8 +150,8 @@ public:
void bins_crossed(Position r0,
Position r1,
const Direction& u,
std::vector<int>& bins,
std::vector<double>& lengths) const override;
vector<int>& bins,
vector<double>& lengths) const override;
//! Count number of bank sites in each mesh bin / energy bin
//
@ -236,7 +236,7 @@ public:
surface_bins_crossed(Position r0,
Position r1,
const Direction& u,
std::vector<int>& bins) const override;
vector<int>& bins) const override;
int get_index_in_direction(double r, int i) const override;
@ -244,8 +244,8 @@ public:
double negative_grid_boundary(int* ijk, int i) const override;
std::pair<std::vector<double>, std::vector<double>>
plot(Position plot_ll, Position plot_ur) const override;
std::pair<vector<double>, std::vector<double>> plot(
Position plot_ll, Position plot_ur) const override;
void to_hdf5(hid_t group) const override;
@ -277,7 +277,7 @@ public:
surface_bins_crossed(Position r0,
Position r1,
const Direction& u,
std::vector<int>& bins) const override;
vector<int>& bins) const override;
int get_index_in_direction(double r, int i) const override;
@ -285,12 +285,12 @@ public:
double negative_grid_boundary(int* ijk, int i) const override;
std::pair<std::vector<double>, std::vector<double>>
plot(Position plot_ll, Position plot_ur) const override;
std::pair<vector<double>, std::vector<double>> plot(
Position plot_ll, Position plot_ur) const override;
void to_hdf5(hid_t group) const override;
std::vector<std::vector<double>> grid_;
vector<std::vector<double>> grid_;
int set_grid();
};
@ -315,8 +315,7 @@ public:
//! Set the value of a bin for a variable on the internal
// mesh instance
virtual void set_score_data(const std::string& var_name,
const std::vector<double>& values,
const std::vector<double>& std_dev) = 0;
const vector<double>& values, const vector<double>& std_dev) = 0;
//! Write the unstructured mesh to file
//
@ -342,7 +341,7 @@ public:
void surface_bins_crossed(Position r0,
Position r1,
std::vector<int>& bins) const;
vector<int>& bins) const;
void to_hdf5(hid_t group) const override;
@ -368,8 +367,8 @@ public:
void bins_crossed(Position r0,
Position r1,
const Direction& u,
std::vector<int>& bins,
std::vector<double>& lengths) const override;
vector<int>& bins,
vector<double>& lengths) const override;
void
surface_bins_crossed(Position r0,
@ -383,8 +382,8 @@ public:
int n_surface_bins() const override;
std::pair<std::vector<double>, std::vector<double>>
plot(Position plot_ll, Position plot_ur) const override;
std::pair<vector<double>, std::vector<double>> plot(
Position plot_ll, Position plot_ur) const override;
std::string library() const override;
@ -395,9 +394,8 @@ public:
void remove_scores() override;
//! Set data for a score
void set_score_data(const std::string& score,
const std::vector<double>& values,
const std::vector<double>& std_dev) override;
void set_score_data(const std::string& score, const vector<double>& values,
const vector<double>& std_dev) override;
//! Write the mesh with any current tally data
void write(const std::string& base_filename) const;
@ -416,11 +414,8 @@ private:
//! \param[in] dir Normalized particle direction
//! \param[in] track_len length of particle track
//! \param[out] Mesh intersections
void
intersect_track(const moab::CartVect& start,
const moab::CartVect& dir,
double track_len,
std::vector<double>& hits) const;
void intersect_track(const moab::CartVect& start, const moab::CartVect& dir,
double track_len, vector<double>& hits) const;
//! Calculate the volume for a given tetrahedron handle.
//
@ -504,10 +499,10 @@ private:
moab::Range ehs_; //!< Range of tetrahedra EntityHandle's in the mesh
moab::EntityHandle tetset_; //!< EntitySet containing all tetrahedra
moab::EntityHandle kdtree_root_; //!< Root of the MOAB KDTree
std::unique_ptr<moab::Interface> mbi_; //!< MOAB instance
std::unique_ptr<moab::AdaptiveKDTree> kdtree_; //!< MOAB KDTree instance
std::vector<moab::Matrix3> baryc_data_; //!< Barycentric data for tetrahedra
std::vector<std::string> tag_names_; //!< Names of score tags added to the mesh
unique_ptr<moab::Interface> mbi_; //!< MOAB instance
unique_ptr<moab::AdaptiveKDTree> kdtree_; //!< MOAB KDTree instance
vector<moab::Matrix3> baryc_data_; //!< Barycentric data for tetrahedra
vector<std::string> tag_names_; //!< Names of score tags added to the mesh
};
#endif
@ -524,8 +519,8 @@ public:
void bins_crossed(Position r0,
Position r1,
const Direction& u,
std::vector<int>& bins,
std::vector<double>& lengths) const override;
vector<int>& bins,
vector<double>& lengths) const override;
void
surface_bins_crossed(Position r0,
@ -539,16 +534,15 @@ public:
int n_surface_bins() const override;
std::pair<std::vector<double>, std::vector<double>>
plot(Position plot_ll, Position plot_ur) const override;
std::pair<vector<double>, std::vector<double>> plot(
Position plot_ll, Position plot_ur) const override;
void add_score(const std::string& var_name) override;
void remove_scores() override;
void set_score_data(const std::string& var_name,
const std::vector<double>& values,
const std::vector<double>& std_dev) override;
void set_score_data(const std::string& var_name, const vector<double>& values,
const vector<double>& std_dev) override;
void write(const std::string& base_filename) const override;
@ -569,9 +563,11 @@ private:
int get_bin_from_element(const libMesh::Elem* elem) const;
// Data members
std::unique_ptr<libMesh::Mesh> m_; //!< pointer to the libMesh mesh instance
std::vector<std::unique_ptr<libMesh::PointLocatorBase>> pl_; //!< per-thread point locators
std::unique_ptr<libMesh::EquationSystems> equation_systems_; //!< pointer to the equation systems of the mesh
unique_ptr<libMesh::Mesh> m_; //!< pointer to the libMesh mesh instance
vector<unique_ptr<libMesh::PointLocatorBase>>
pl_; //!< per-thread point locators
unique_ptr<libMesh::EquationSystems>
equation_systems_; //!< pointer to the equation systems of the mesh
std::string eq_system_name_; //!< name of the equation system holding OpenMC results
std::unordered_map<std::string, unsigned int> variable_map_; //!< mapping of variable names (tally scores) to libMesh variable numbers
libMesh::BoundingBox bbox_; //!< bounding box of the mesh

View file

@ -5,16 +5,15 @@
#define OPENMC_MGXS_H
#include <string>
#include <vector>
#include "xtensor/xtensor.hpp"
#include "openmc/constants.h"
#include "openmc/hdf5_interface.h"
#include "openmc/particle.h"
#include "openmc/vector.h"
#include "openmc/xsdata.h"
namespace openmc {
//==============================================================================
@ -42,13 +41,13 @@ class Mgxs {
AngleDistributionType scatter_format; // flag for if this is legendre, histogram, or tabular
int num_groups; // number of energy groups
int num_delayed_groups; // number of delayed neutron groups
std::vector<XsData> xs; // Cross section data
vector<XsData> xs; // Cross section data
// MGXS Incoming Flux Angular grid information
bool is_isotropic; // used to skip search for angle indices if isotropic
int n_pol;
int n_azi;
std::vector<double> polar;
std::vector<double> azimuthal;
vector<double> polar;
vector<double> azimuthal;
//! \brief Initializes the Mgxs object metadata
//!
@ -62,10 +61,10 @@ class Mgxs {
//! the incoming particle.
//! @param in_polar Polar angle grid.
//! @param in_azimuthal Azimuthal angle grid.
void
init(const std::string& in_name, double in_awr, const std::vector<double>& in_kTs,
bool in_fissionable, AngleDistributionType in_scatter_format, bool in_is_isotropic,
const std::vector<double>& in_polar, const std::vector<double>& in_azimuthal);
void init(const std::string& in_name, double in_awr,
const vector<double>& in_kTs, bool in_fissionable,
AngleDistributionType in_scatter_format, bool in_is_isotropic,
const vector<double>& in_polar, const std::vector<double>& in_azimuthal);
//! \brief Initializes the Mgxs object metadata from the HDF5 file
//!
@ -74,9 +73,8 @@ class Mgxs {
//! @param temps_to_read Resultant list of temperatures in the library
//! to read which correspond to the requested temperatures.
//! @param order_dim Resultant dimensionality of the scattering order.
void
metadata_from_hdf5(hid_t xs_id, const std::vector<double>& temperature,
std::vector<int>& temps_to_read, int& order_dim);
void metadata_from_hdf5(hid_t xs_id, const vector<double>& temperature,
vector<int>& temps_to_read, int& order_dim);
//! \brief Performs the actual act of combining the microscopic data for a
//! single temperature.
@ -86,9 +84,9 @@ class Mgxs {
//! @param micro_ts The temperature index of the microscopic objects that
//! corresponds to the temperature of interest.
//! @param this_t The temperature index of the macroscopic object.
void
combine(const std::vector<Mgxs*>& micros, const std::vector<double>& scalars,
const std::vector<int>& micro_ts, int this_t);
void combine(const vector<Mgxs*>& micros,
const std::vector<double>& scalars, const vector<int>& micro_ts,
int this_t);
//! \brief Checks to see if this and that are able to be combined
//!
@ -103,7 +101,7 @@ class Mgxs {
std::string name; // name of dataset, e.g., UO2
double awr; // atomic weight ratio
bool fissionable; // Is this fissionable
std::vector<CacheData> cache; // index and data cache
vector<CacheData> cache; // index and data cache
Mgxs() = default;
@ -113,8 +111,8 @@ class Mgxs {
//! @param temperature Temperatures to read.
//! @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);
Mgxs(hid_t xs_id, const 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 sections.
@ -125,9 +123,9 @@ class Mgxs {
//! @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,
int num_group, int num_delay);
Mgxs(const std::string& in_name, const vector<double>& mat_kTs,
const vector<Mgxs*>& micros, const std::vector<double>& atom_densities,
int num_group, int num_delay);
//! \brief Provides a cross section value given certain parameters
//!
@ -187,7 +185,7 @@ class Mgxs {
set_angle_index(Direction u);
//! \brief Provide const access to list of XsData held by this
const std::vector<XsData>& get_xsdata() const { return xs; }
const vector<XsData>& get_xsdata() const { return xs; }
};
} // namespace openmc

View file

@ -4,10 +4,9 @@
#ifndef OPENMC_MGXS_INTERFACE_H
#define OPENMC_MGXS_INTERFACE_H
#include "hdf5_interface.h"
#include "mgxs.h"
#include <vector>
#include "openmc/hdf5_interface.h"
#include "openmc/mgxs.h"
#include "openmc/vector.h"
namespace openmc {
@ -23,20 +22,20 @@ public:
// 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);
const vector<std::string> xs_to_read,
const 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);
void set_nuclides_and_temperatures(
vector<std::string> xs_to_read, 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);
void add_mgxs(
hid_t file_id, const std::string& name, const vector<double>& temperature);
// Reads just the header of the cross sections file, to find
// min & max energies as well as the available XS
@ -46,20 +45,20 @@ public:
void create_macro_xs();
// Get the kT values which are used in the OpenMC model
std::vector<std::vector<double>> get_mat_kTs();
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
vector<std::string> xs_names_; // available names in HDF5 file
vector<std::string> xs_to_read_; // XS which appear in materials
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
vector<Mgxs> nuclides_;
vector<Mgxs> macro_xs_;
vector<double> energy_bins_;
vector<double> energy_bin_avg_;
vector<double> rev_energy_bins_;
vector<std::vector<double>> nuc_temps_; // all available temperatures
};
namespace data {

View file

@ -4,21 +4,21 @@
#ifndef OPENMC_NUCLIDE_H
#define OPENMC_NUCLIDE_H
#include <array>
#include <memory> // for unique_ptr
#include <unordered_map>
#include <utility> // for pair
#include <vector>
#include <gsl/gsl>
#include <hdf5.h>
#include "openmc/array.h"
#include "openmc/constants.h"
#include "openmc/endf.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/particle.h"
#include "openmc/reaction.h"
#include "openmc/reaction_product.h"
#include "openmc/urr.h"
#include "openmc/vector.h"
#include "openmc/wmp.h"
namespace openmc {
@ -32,12 +32,12 @@ public:
// Types, aliases
using EmissionMode = ReactionProduct::EmissionMode;
struct EnergyGrid {
std::vector<int> grid_index;
std::vector<double> energy;
vector<int> grid_index;
vector<double> energy;
};
// Constructors/destructors
Nuclide(hid_t group, const std::vector<double>& temperature);
Nuclide(hid_t group, const vector<double>& temperature);
~Nuclide();
//! Initialize logarithmic grid for energy searches
@ -78,40 +78,41 @@ public:
gsl::index index_; //!< Index in the nuclides array
// Temperature dependent cross section data
std::vector<double> kTs_; //!< temperatures in eV (k*T)
std::vector<EnergyGrid> grid_; //!< Energy grid at each temperature
std::vector<xt::xtensor<double, 2>> xs_; //!< Cross sections at each temperature
vector<double> kTs_; //!< temperatures in eV (k*T)
vector<EnergyGrid> grid_; //!< Energy grid at each temperature
vector<xt::xtensor<double, 2>> xs_; //!< Cross sections at each temperature
// Multipole data
std::unique_ptr<WindowedMultipole> multipole_;
unique_ptr<WindowedMultipole> multipole_;
// Fission data
bool fissionable_ {false}; //!< Whether nuclide is fissionable
bool has_partial_fission_ {false}; //!< has partial fission reactions?
std::vector<Reaction*> fission_rx_; //!< Fission reactions
vector<Reaction*> fission_rx_; //!< Fission reactions
int n_precursor_ {0}; //!< Number of delayed neutron precursors
std::unique_ptr<Function1D> total_nu_; //!< Total neutron yield
std::unique_ptr<Function1D> fission_q_prompt_; //!< Prompt fission energy release
std::unique_ptr<Function1D> fission_q_recov_; //!< Recoverable fission energy release
std::unique_ptr<Function1D> prompt_photons_; //!< Prompt photon energy release
std::unique_ptr<Function1D> delayed_photons_; //!< Delayed photon energy release
std::unique_ptr<Function1D> fragments_; //!< Fission fragment energy release
std::unique_ptr<Function1D> betas_; //!< Delayed beta energy release
unique_ptr<Function1D> total_nu_; //!< Total neutron yield
unique_ptr<Function1D> fission_q_prompt_; //!< Prompt fission energy release
unique_ptr<Function1D>
fission_q_recov_; //!< Recoverable fission energy release
unique_ptr<Function1D> prompt_photons_; //!< Prompt photon energy release
unique_ptr<Function1D> delayed_photons_; //!< Delayed photon energy release
unique_ptr<Function1D> fragments_; //!< Fission fragment energy release
unique_ptr<Function1D> betas_; //!< Delayed beta energy release
// Resonance scattering information
bool resonant_ {false};
std::vector<double> energy_0K_;
std::vector<double> elastic_0K_;
std::vector<double> xs_cdf_;
vector<double> energy_0K_;
vector<double> elastic_0K_;
vector<double> xs_cdf_;
// Unresolved resonance range information
bool urr_present_ {false};
int urr_inelastic_ {C_NONE};
std::vector<UrrData> urr_data_;
vector<UrrData> urr_data_;
std::vector<std::unique_ptr<Reaction>> reactions_; //!< Reactions
std::array<size_t, 902> reaction_index_; //!< Index of each reaction
std::vector<int> index_inelastic_scatter_;
vector<unique_ptr<Reaction>> reactions_; //!< Reactions
array<size_t, 902> reaction_index_; //!< Index of each reaction
vector<int> index_inelastic_scatter_;
private:
void create_derived(const Function1D* prompt_photons, const Function1D* delayed_photons);
@ -146,8 +147,8 @@ namespace data {
// Minimum/maximum transport energy for each particle type. Order corresponds to
// that of the ParticleType enum
extern std::array<double, 2> energy_min;
extern std::array<double, 2> energy_max;
extern array<double, 2> energy_min;
extern array<double, 2> energy_max;
//! Minimum temperature in [K] that nuclide data is available at
extern double temperature_min;
@ -156,7 +157,7 @@ extern double temperature_min;
extern double temperature_max;
extern std::unordered_map<std::string, int> nuclide_map;
extern std::vector<std::unique_ptr<Nuclide>> nuclides;
extern vector<unique_ptr<Nuclide>> nuclides;
} // namespace data

View file

@ -5,16 +5,16 @@
//! \brief Particle type
#include <cstdint>
#include <memory> // for unique_ptr
#include <sstream>
#include <string>
#include <vector>
#include "openmc/constants.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/particle_data.h"
#include "openmc/position.h"
#include "openmc/random_lcg.h"
#include "openmc/tallies/filter_match.h"
#include "openmc/vector.h"
#ifdef DAGMC
#include "DagMC.hpp"

View file

@ -1,11 +1,12 @@
#ifndef OPENMC_PARTICLE_REPRESENTATION_H
#define OPENMC_PARTICLE_REPRESENTATION_H
#include "openmc/array.h"
#include "openmc/constants.h"
#include "openmc/position.h"
#include "openmc/random_lcg.h"
#include "openmc/tallies/filter_match.h"
#include <vector>
#include "openmc/vector.h"
namespace openmc {
@ -56,7 +57,7 @@ struct NuBank {
class LocalCoord {
public:
void rotate(const std::vector<double>& rotation);
void rotate(const vector<double>& rotation);
//! clear data from a single coordinate level
void reset();
@ -66,9 +67,7 @@ public:
int cell {-1};
int universe {-1};
int lattice {-1};
int lattice_x {-1};
int lattice_y {-1};
int lattice_z {-1};
array<int, 3> lattice_i {-1, -1, -1};
bool rotated {false}; //!< Is the level rotated?
};
@ -153,7 +152,7 @@ struct BoundaryInfo {
double distance {INFINITY}; //!< distance to nearest boundary
int surface_index {0}; //!< if boundary is surface, index in surfaces vector
int coord_level; //!< coordinate level after crossing boundary
std::array<int, 3>
array<int, 3>
lattice_translation {}; //!< which way lattice indices will change
};
@ -171,9 +170,8 @@ private:
// Data members (accessor methods are below)
// Cross section caches
std::vector<NuclideMicroXS>
neutron_xs_; //!< Microscopic neutron cross sections
std::vector<ElementMicroXS> photon_xs_; //!< Microscopic photon cross sections
vector<NuclideMicroXS> neutron_xs_; //!< Microscopic neutron cross sections
vector<ElementMicroXS> photon_xs_; //!< Microscopic photon cross sections
MacroXS macro_xs_; //!< Macroscopic cross sections
int64_t id_; //!< Unique ID
@ -181,11 +179,11 @@ private:
int n_coord_ {1}; //!< number of current coordinate levels
int cell_instance_; //!< offset for distributed properties
std::vector<LocalCoord> coord_; //!< coordinates for all levels
vector<LocalCoord> coord_; //!< coordinates for all levels
// Particle coordinates before crossing a surface
int n_coord_last_ {1}; //!< number of current coordinates
std::vector<int> cell_last_; //!< coordinates for all levels
vector<int> cell_last_; //!< coordinates for all levels
// Energy data
double E_; //!< post-collision energy in eV
@ -245,17 +243,17 @@ private:
int stream_; // current RNG stream
// Secondary particle bank
std::vector<ParticleBank> secondary_bank_;
vector<ParticleBank> secondary_bank_;
int64_t current_work_; // current work index
std::vector<double> flux_derivs_; // for derivatives for this particle
vector<double> flux_derivs_; // for derivatives for this particle
std::vector<FilterMatch> filter_matches_; // tally filter matches
vector<FilterMatch> filter_matches_; // tally filter matches
std::vector<std::vector<Position>> tracks_; // tracks for outputting to file
vector<std::vector<Position>> tracks_; // tracks for outputting to file
std::vector<NuBank> nu_bank_; // bank of most recently fissioned particles
vector<NuBank> nu_bank_; // bank of most recently fissioned particles
// Global tally accumulators
double keff_tally_absorption_ {0.0};

View file

@ -2,17 +2,17 @@
#define OPENMC_PHOTON_H
#include "openmc/endf.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/particle.h"
#include "openmc/vector.h"
#include <gsl/gsl>
#include <hdf5.h>
#include "xtensor/xtensor.hpp"
#include <memory> // for unique_ptr
#include <string>
#include <unordered_map>
#include <utility> // for pair
#include <vector>
namespace openmc {
@ -81,7 +81,7 @@ public:
// Photoionization and atomic relaxation data
std::unordered_map<int, int> shell_map_; //!< Given a shell designator, e.g. 3, this
//!< dictionary gives an index in shells_
std::vector<ElectronSubshell> shells_;
vector<ElectronSubshell> shells_;
// Compton profile data
xt::xtensor<double, 2> profile_pdf_;
@ -121,7 +121,7 @@ extern xt::xtensor<double, 1> compton_profile_pz; //! Compton profile momentum g
//! Photon interaction data for each element
extern std::unordered_map<std::string, int> element_map;
extern std::vector<std::unique_ptr<PhotonInteraction>> elements;
extern vector<unique_ptr<PhotonInteraction>> elements;
} // namespace data

View file

@ -6,8 +6,7 @@
#include "openmc/particle.h"
#include "openmc/position.h"
#include "openmc/reaction.h"
#include <vector>
#include "openmc/vector.h"
namespace openmc {

View file

@ -5,10 +5,9 @@
#define OPENMC_PHYSICS_MG_H
#include "openmc/capi.h"
#include "openmc/particle.h"
#include "openmc/nuclide.h"
#include <vector>
#include "openmc/particle.h"
#include "openmc/vector.h"
namespace openmc {

View file

@ -28,7 +28,7 @@ class Plot;
namespace model {
extern std::unordered_map<int, int> plot_map; //!< map of plot ids to index
extern std::vector<Plot> plots; //!< Plot instance container
extern vector<Plot> plots; //!< Plot instance container
extern uint64_t plotter_prn_seeds[N_STREAMS]; // Random number seeds used for plotter
extern int plotter_stream; // Stream index used by the plotter
@ -45,7 +45,8 @@ struct RGBColor {
RGBColor(const int v[3]) : red(v[0]), green(v[1]), blue(v[2]) { };
RGBColor(int r, int g, int b) : red(r), green(g), blue(b) { };
RGBColor(const std::vector<int> &v) {
RGBColor(const vector<int>& v)
{
if (v.size() != 3) {
throw std::out_of_range("Incorrect vector size for RGBColor.");
}
@ -121,7 +122,7 @@ public:
Position origin_; //!< Plot origin in geometry
Position width_; //!< Plot width in geometry
PlotBasis basis_; //!< Plot basis (XY/XZ/YZ)
std::array<size_t, 3> pixels_; //!< Plot size in pixels
array<size_t, 3> pixels_; //!< Plot size in pixels
bool color_overlaps_; //!< Show overlapping cells?
int level_; //!< Plot universe level
};
@ -230,7 +231,7 @@ public:
RGBColor meshlines_color_; //!< Color of meshlines on the plot
RGBColor not_found_ {WHITE}; //!< Plot background color
RGBColor overlap_color_ {RED}; //!< Plot overlap color
std::vector<RGBColor> colors_; //!< Plot colors
vector<RGBColor> colors_; //!< Plot colors
std::string path_plot_; //!< Plot output filename
};

View file

@ -1,11 +1,12 @@
#ifndef OPENMC_POSITION_H
#define OPENMC_POSITION_H
#include <array>
#include <cmath> // for sqrt
#include <iostream>
#include <stdexcept> // for out_of_range
#include <vector>
#include "openmc/array.h"
#include "openmc/vector.h"
namespace openmc {
@ -18,8 +19,8 @@ struct Position {
Position() = default;
Position(double x_, double y_, double z_) : x{x_}, y{y_}, z{z_} { };
Position(const double xyz[]) : x{xyz[0]}, y{xyz[1]}, z{xyz[2]} { };
Position(const std::vector<double>& xyz) : x{xyz[0]}, y{xyz[1]}, z{xyz[2]} { };
Position(const std::array<double, 3>& xyz) : x{xyz[0]}, y{xyz[1]}, z{xyz[2]} { };
Position(const vector<double>& xyz) : x {xyz[0]}, y {xyz[1]}, z {xyz[2]} {};
Position(const array<double, 3>& xyz) : x {xyz[0]}, y {xyz[1]}, z {xyz[2]} {};
// Unary operators
Position& operator+=(Position);
@ -81,7 +82,7 @@ struct Position {
Position reflect(Position n) const;
//! Rotate the position based on a rotation matrix
Position rotate(const std::vector<double>& rotation) const;
Position rotate(const vector<double>& rotation) const;
// Data members
double x = 0.;

View file

@ -5,12 +5,12 @@
#define OPENMC_REACTION_H
#include <string>
#include <vector>
#include <gsl/gsl>
#include "hdf5.h"
#include "openmc/reaction_product.h"
#include "openmc/vector.h"
namespace openmc {
@ -25,7 +25,7 @@ public:
//! Construct reaction from HDF5 data
//! \param[in] group HDF5 group containing reaction data
//! \param[in] temperatures Desired temperatures for cross sections
explicit Reaction(hid_t group, const std::vector<int>& temperatures);
explicit Reaction(hid_t group, const vector<int>& temperatures);
//! \brief Calculate reaction rate based on group-wise flux distribution
//
@ -35,20 +35,20 @@ public:
//! \param[in] grid Nuclide energy grid
//! \return Reaction rate
double collapse_rate(gsl::index i_temp, gsl::span<const double> energy,
gsl::span<const double> flux, const std::vector<double>& grid) const;
gsl::span<const double> flux, const vector<double>& grid) const;
//! Cross section at a single temperature
struct TemperatureXS {
int threshold;
std::vector<double> value;
vector<double> value;
};
int mt_; //!< ENDF MT value
double q_value_; //!< Reaction Q value in [eV]
bool scatter_in_cm_; //!< scattering system in center-of-mass?
bool redundant_; //!< redundant reaction?
std::vector<TemperatureXS> xs_; //!< Cross section at each temperature
std::vector<ReactionProduct> products_; //!< Reaction products
vector<TemperatureXS> xs_; //!< Cross section at each temperature
vector<ReactionProduct> products_; //!< Reaction products
};
//==============================================================================

View file

@ -4,14 +4,13 @@
#ifndef OPENMC_REACTION_PRODUCT_H
#define OPENMC_REACTION_PRODUCT_H
#include <memory> // for unique_ptr
#include <vector> // for vector
#include "hdf5.h"
#include "openmc/angle_energy.h"
#include "openmc/endf.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/particle.h"
#include "openmc/vector.h" // for vector
namespace openmc {
@ -32,7 +31,7 @@ public:
total // Delayed emission of secondary particle
};
using Secondary = std::unique_ptr<AngleEnergy>;
using Secondary = unique_ptr<AngleEnergy>;
//! Construct reaction product from HDF5 data
//! \param[in] group HDF5 group containing data
@ -48,9 +47,9 @@ public:
ParticleType particle_; //!< Particle type
EmissionMode emission_mode_; //!< Emission mode
double decay_rate_; //!< Decay rate (for delayed neutron precursors) in [1/s]
std::unique_ptr<Function1D> yield_; //!< Yield as a function of energy
std::vector<Tabulated1D> applicability_; //!< Applicability of distribution
std::vector<Secondary> distribution_; //!< Secondary angle-energy distribution
unique_ptr<Function1D> yield_; //!< Yield as a function of energy
vector<Tabulated1D> applicability_; //!< Applicability of distribution
vector<Secondary> distribution_; //!< Secondary angle-energy distribution
};
} // namespace opemc

View file

@ -4,11 +4,10 @@
#ifndef OPENMC_SCATTDATA_H
#define OPENMC_SCATTDATA_H
#include <vector>
#include "xtensor/xtensor.hpp"
#include "openmc/constants.h"
#include "openmc/vector.h"
namespace openmc {
@ -32,12 +31,10 @@ class ScattData {
const double_2dvec& in_mult);
//! \brief Combines microscopic ScattDatas into a macroscopic one.
void
base_combine(size_t max_order, size_t order_dim,
const std::vector<ScattData*>& those_scatts,
const std::vector<double>& scalars, xt::xtensor<int, 1>& in_gmin,
xt::xtensor<int, 1>& in_gmax, double_2dvec& sparse_mult,
double_3dvec& sparse_scatter);
void base_combine(size_t max_order, size_t order_dim,
const vector<ScattData*>& those_scatts, const vector<double>& scalars,
xt::xtensor<int, 1>& in_gmin, xt::xtensor<int, 1>& in_gmax,
double_2dvec& sparse_mult, double_3dvec& sparse_scatter);
public:
@ -85,9 +82,8 @@ class ScattData {
//!
//! @param those_scatts Microscopic objects to combine.
//! @param scalars Scalars to multiply the microscopic data by.
virtual void
combine(const std::vector<ScattData*>& those_scatts,
const std::vector<double>& scalars) = 0;
virtual void combine(const vector<ScattData*>& those_scatts,
const vector<double>& scalars) = 0;
//! \brief Getter for the dimensionality of the scattering order.
//!
@ -151,9 +147,8 @@ class ScattDataLegendre: public ScattData {
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
const double_2dvec& in_mult, const double_3dvec& coeffs);
void
combine(const std::vector<ScattData*>& those_scatts,
const std::vector<double>& scalars);
void combine(
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
//! \brief Find the maximal value of the angular distribution to use as a
// bounding box with rejection sampling.
@ -192,9 +187,8 @@ class ScattDataHistogram: public ScattData {
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
const double_2dvec& in_mult, const double_3dvec& coeffs);
void
combine(const std::vector<ScattData*>& those_scatts,
const std::vector<double>& scalars);
void combine(
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
double
calc_f(int gin, int gout, double mu);
@ -233,9 +227,8 @@ class ScattDataTabular: public ScattData {
init(const xt::xtensor<int, 1>& in_gmin, const xt::xtensor<int, 1>& in_gmax,
const double_2dvec& in_mult, const double_3dvec& coeffs);
void
combine(const std::vector<ScattData*>& those_scatts,
const std::vector<double>& scalars);
void combine(
const vector<ScattData*>& those_scatts, const vector<double>& scalars);
double
calc_f(int gin, int gout, double mu);

View file

@ -4,14 +4,13 @@
#ifndef OPENMC_SECONDARY_CORRELATED_H
#define OPENMC_SECONDARY_CORRELATED_H
#include <vector>
#include "hdf5.h"
#include "xtensor/xtensor.hpp"
#include "openmc/angle_energy.h"
#include "openmc/endf.h"
#include "openmc/distribution.h"
#include "openmc/endf.h"
#include "openmc/vector.h"
namespace openmc {
@ -29,7 +28,7 @@ public:
xt::xtensor<double, 1> e_out; //!< Outgoing energies [eV]
xt::xtensor<double, 1> p; //!< Probability density
xt::xtensor<double, 1> c; //!< Cumulative distribution
std::vector<std::unique_ptr<Tabular>> angle; //!< Angle distribution
vector<unique_ptr<Tabular>> angle; //!< Angle distribution
};
explicit CorrelatedAngleEnergy(hid_t group);
@ -43,19 +42,20 @@ public:
uint64_t* seed) const override;
// energy property
std::vector<double>& energy() { return energy_; }
const std::vector<double>& energy() const { return energy_; }
vector<double>& energy() { return energy_; }
const vector<double>& energy() const { return energy_; }
// distribution property
std::vector<CorrTable>& distribution() { return distribution_; }
const std::vector<CorrTable>& distribution() const { return distribution_; }
vector<CorrTable>& distribution() { return distribution_; }
const vector<CorrTable>& distribution() const { return distribution_; }
private:
int n_region_; //!< Number of interpolation regions
std::vector<int> breakpoints_; //!< Breakpoints between regions
std::vector<Interpolation> interpolation_; //!< Interpolation laws
std::vector<double> energy_; //!< Energies [eV] at which distributions
//!< are tabulated
std::vector<CorrTable> distribution_; //!< Distribution at each energy
vector<int> breakpoints_; //!< Breakpoints between regions
vector<Interpolation> interpolation_; //!< Interpolation laws
vector<double> energy_; //!< Energies [eV] at which distributions
//!< are tabulated
vector<CorrTable> distribution_; //!< Distribution at each energy
};
} // namespace openmc

View file

@ -4,14 +4,13 @@
#ifndef OPENMC_SECONDARY_KALBACH_H
#define OPENMC_SECONDARY_KALBACH_H
#include <vector>
#include "hdf5.h"
#include "xtensor/xtensor.hpp"
#include "openmc/angle_energy.h"
#include "openmc/constants.h"
#include "openmc/endf.h"
#include "openmc/vector.h"
namespace openmc {
@ -45,11 +44,11 @@ private:
};
int n_region_; //!< Number of interpolation regions
std::vector<int> breakpoints_; //!< Breakpoints between regions
std::vector<Interpolation> interpolation_; //!< Interpolation laws
std::vector<double> energy_; //!< Energies [eV] at which distributions
//!< are tabulated
std::vector<KMTable> distribution_; //!< Distribution at each energy
vector<int> breakpoints_; //!< Breakpoints between regions
vector<Interpolation> interpolation_; //!< Interpolation laws
vector<double> energy_; //!< Energies [eV] at which distributions
//!< are tabulated
vector<KMTable> distribution_; //!< Distribution at each energy
};
} // namespace openmc

View file

@ -7,12 +7,11 @@
#include "openmc/angle_energy.h"
#include "openmc/endf.h"
#include "openmc/secondary_correlated.h"
#include "openmc/vector.h"
#include <hdf5.h>
#include "xtensor/xtensor.hpp"
#include <vector>
namespace openmc {
//==============================================================================
@ -70,7 +69,8 @@ public:
//
//! \param[in] group HDF5 group
//! \param[in] energy Energies at which cosines are tabulated
explicit IncoherentElasticAEDiscrete(hid_t group, const std::vector<double>& energy);
explicit IncoherentElasticAEDiscrete(
hid_t group, const vector<double>& energy);
//! Sample distribution for an angle and energy
//! \param[in] E_in Incoming energy in [eV]
@ -80,7 +80,7 @@ public:
void sample(double E_in, double& E_out, double& mu,
uint64_t* seed) const override;
private:
const std::vector<double>& energy_; //!< Energies at which cosines are tabulated
const vector<double>& energy_; //!< Energies at which cosines are tabulated
xt::xtensor<double, 2> mu_out_; //!< Cosines for each incident energy
};
@ -94,7 +94,8 @@ public:
//
//! \param[in] group HDF5 group
//! \param[in] energy Incident energies at which distributions are tabulated
explicit IncoherentInelasticAEDiscrete(hid_t group, const std::vector<double>& energy);
explicit IncoherentInelasticAEDiscrete(
hid_t group, const vector<double>& energy);
//! Sample distribution for an angle and energy
//! \param[in] E_in Incoming energy in [eV]
@ -104,7 +105,7 @@ public:
void sample(double E_in, double& E_out, double& mu,
uint64_t* seed) const override;
private:
const std::vector<double>& energy_; //!< Incident energies
const vector<double>& energy_; //!< Incident energies
xt::xtensor<double, 2> energy_out_; //!< Outgoing energies for each incident energy
xt::xtensor<double, 3> mu_out_; //!< Outgoing cosines for each incident/outgoing energy
bool skewed_; //!< Whether outgoing energy distribution is skewed
@ -138,9 +139,9 @@ private:
xt::xtensor<double, 2> mu; //!< Equiprobable angles at each outgoing energy
};
std::vector<double> energy_; //!< Incident energies
std::vector<DistEnergySab> distribution_; //!< Secondary angle-energy at
//!< each incident energy
vector<double> energy_; //!< Incident energies
vector<DistEnergySab> distribution_; //!< Secondary angle-energy at
//!< each incident energy
};

View file

@ -4,14 +4,13 @@
#ifndef OPENMC_SECONDARY_UNCORRELATED_H
#define OPENMC_SECONDARY_UNCORRELATED_H
#include <memory>
#include <vector>
#include "hdf5.h"
#include "openmc/angle_energy.h"
#include "openmc/distribution_angle.h"
#include "openmc/distribution_energy.h"
#include "openmc/memory.h"
#include "openmc/vector.h"
namespace openmc {
@ -38,7 +37,7 @@ public:
bool& fission() { return fission_; }
private:
AngleDistribution angle_; //!< Angle distribution
std::unique_ptr<EnergyDistribution> energy_; //!< Energy distribution
unique_ptr<EnergyDistribution> energy_; //!< Energy distribution
bool fission_ {false}; //!< Whether distribution is use for fission
};

View file

@ -4,15 +4,15 @@
//! \file settings.h
//! \brief Settings for OpenMC
#include <array>
#include <cstdint>
#include <string>
#include <unordered_set>
#include <vector>
#include "pugixml.hpp"
#include "openmc/array.h"
#include "openmc/constants.h"
#include "openmc/vector.h"
namespace openmc {
@ -75,7 +75,8 @@ extern "C" int64_t n_particles; //!< number of particles per genera
extern int64_t max_particles_in_flight; //!< Max num. event-based particles in flight
extern ElectronTreatment electron_treatment; //!< how to treat secondary electrons
extern std::array<double, 4> energy_cutoff; //!< Energy cutoff in [eV] for each particle type
extern array<double, 4>
energy_cutoff; //!< Energy cutoff in [eV] for each particle type
extern int legendre_to_tabular_points; //!< number of points to convert Legendres
extern int max_order; //!< Maximum Legendre order for multigroup data
extern int n_log_bins; //!< number of bins for logarithmic energy grid
@ -84,7 +85,8 @@ extern int n_max_batches; //!< Maximum number of batches
extern ResScatMethod res_scat_method; //!< resonance upscattering method
extern double res_scat_energy_min; //!< Min energy in [eV] for res. upscattering
extern double res_scat_energy_max; //!< Max energy in [eV] for res. upscattering
extern std::vector<std::string> res_scat_nuclides; //!< Nuclides using res. upscattering treatment
extern vector<std::string>
res_scat_nuclides; //!< Nuclides using res. upscattering treatment
extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.)
extern std::unordered_set<int> sourcepoint_batch; //!< Batches when source should be written
extern std::unordered_set<int> statepoint_batch; //!< Batches when state should be written
@ -93,11 +95,13 @@ extern int64_t max_surface_particles; //!< maximum number of particles to be
extern TemperatureMethod temperature_method; //!< method for choosing temperatures
extern double temperature_tolerance; //!< Tolerance in [K] on choosing temperatures
extern double temperature_default; //!< Default T in [K]
extern std::array<double, 2> temperature_range; //!< Min/max T in [K] over which to load xs
extern array<double, 2>
temperature_range; //!< Min/max T in [K] over which to load xs
extern int trace_batch; //!< Batch to trace particle on
extern int trace_gen; //!< Generation to trace particle on
extern int64_t trace_particle; //!< Particle ID to enable trace on
extern std::vector<std::array<int, 3>> track_identifiers; //!< Particle numbers for writing tracks
extern vector<array<int, 3>>
track_identifiers; //!< Particle numbers for writing tracks
extern int trigger_batch_interval; //!< Batch interval for triggers
extern "C" int verbosity; //!< How verbose to make output
extern double weight_cutoff; //!< Weight cutoff for Russian roulette

View file

@ -4,8 +4,7 @@
//! \file shared_array.h
//! \brief Shared array data structure
#include <memory>
#include "openmc/memory.h"
namespace openmc {
@ -38,7 +37,7 @@ public:
//! space for
SharedArray(int64_t capacity) : capacity_(capacity)
{
data_ = std::make_unique<T[]>(capacity);
data_ = make_unique<T[]>(capacity);
}
//==========================================================================
@ -55,7 +54,7 @@ public:
//! \param capacity The number of elements to allocate in the container
void reserve(int64_t capacity)
{
data_ = std::make_unique<T[]>(capacity);
data_ = make_unique<T[]>(capacity);
capacity_ = capacity;
}
@ -120,7 +119,7 @@ private:
//==========================================================================
// Data members
std::unique_ptr<T[]> data_; //!< An RAII handle to the elements
unique_ptr<T[]> data_; //!< An RAII handle to the elements
int64_t size_ {0}; //!< The current number of elements
int64_t capacity_ {0}; //!< The total space allocated for elements

View file

@ -6,9 +6,9 @@
#include "openmc/mesh.h"
#include "openmc/particle.h"
#include "openmc/vector.h"
#include <cstdint>
#include <vector>
namespace openmc {
@ -42,8 +42,8 @@ extern int64_t work_per_rank; //!< number of particles per MPI rank
extern const RegularMesh* entropy_mesh;
extern const RegularMesh* ufs_mesh;
extern std::vector<double> k_generation;
extern std::vector<int64_t> work_index;
extern vector<double> k_generation;
extern vector<int64_t> work_index;
} // namespace simulation

View file

@ -4,14 +4,13 @@
#ifndef OPENMC_SOURCE_H
#define OPENMC_SOURCE_H
#include <memory>
#include <vector>
#include "pugixml.hpp"
#include "openmc/distribution_multi.h"
#include "openmc/distribution_spatial.h"
#include "openmc/memory.h"
#include "openmc/particle.h"
#include "openmc/vector.h"
namespace openmc {
@ -23,7 +22,7 @@ class Source;
namespace model {
extern std::vector<std::unique_ptr<Source>> external_sources;
extern vector<unique_ptr<Source>> external_sources;
} // namespace model
@ -87,7 +86,7 @@ public:
ParticleBank sample(uint64_t* seed) const override;
private:
std::vector<ParticleBank> sites_; //!< Source sites from a file
vector<ParticleBank> sites_; //!< Source sites from a file
};
//==============================================================================
@ -109,10 +108,10 @@ public:
double strength() const override { return custom_source_->strength(); }
private:
void* shared_library_; //!< library from dlopen
std::unique_ptr<Source> custom_source_;
unique_ptr<Source> custom_source_;
};
typedef std::unique_ptr<Source> create_custom_source_t(std::string parameters);
typedef unique_ptr<Source> create_custom_source_t(std::string parameters);
//==============================================================================
// Functions

View file

@ -2,21 +2,21 @@
#define OPENMC_STATE_POINT_H
#include <cstdint>
#include <vector>
#include "hdf5.h"
#include "openmc/capi.h"
#include "openmc/particle.h"
#include "openmc/vector.h"
namespace openmc {
void load_state_point();
std::vector<int64_t> calculate_surf_source_size();
vector<int64_t> calculate_surf_source_size();
void write_source_point(const char* filename, bool surf_source_bank = false);
void write_source_bank(hid_t group_id, bool surf_source_bank);
void read_source_bank(
hid_t group_id, std::vector<ParticleBank>& sites, bool distribute);
hid_t group_id, vector<ParticleBank>& sites, bool distribute);
void write_tally_results_nr(hid_t file_id);
void restart_set_keff();
void write_unstructured_mesh_results();

View file

@ -2,7 +2,8 @@
#define OPENMC_STRING_UTILS_H
#include <string>
#include <vector>
#include "openmc/vector.h"
namespace openmc {
@ -16,7 +17,7 @@ void to_lower(std::string& str);
int word_count(std::string const& str);
std::vector<std::string> split(const std::string& in);
vector<std::string> split(const std::string& in);
bool ends_with(const std::string& value, const std::string& ending);

View file

@ -1,20 +1,20 @@
#ifndef OPENMC_SURFACE_H
#define OPENMC_SURFACE_H
#include <memory> // for unique_ptr
#include <limits> // For numeric_limits
#include <string>
#include <unordered_map>
#include <vector>
#include "hdf5.h"
#include "pugixml.hpp"
#include "dagmc.h"
#include "openmc/boundary_condition.h"
#include "openmc/constants.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/particle.h"
#include "openmc/position.h"
#include "dagmc.h"
#include "openmc/vector.h"
namespace openmc {
@ -26,7 +26,7 @@ class Surface;
namespace model {
extern std::unordered_map<int, int> surface_map;
extern std::vector<std::unique_ptr<Surface>> surfaces;
extern vector<unique_ptr<Surface>> surfaces;
} // namespace model
//==============================================================================

View file

@ -2,9 +2,9 @@
#define OPENMC_TALLIES_DERIVATIVE_H
#include "openmc/particle.h"
#include "openmc/vector.h"
#include <unordered_map>
#include <vector>
#include "pugixml.hpp"
@ -71,7 +71,7 @@ namespace openmc {
namespace model {
extern std::unordered_map<int, int> tally_deriv_map;
extern std::vector<TallyDerivative> tally_derivs;
extern vector<TallyDerivative> tally_derivs;
} // namespace model
} // namespace openmc

View file

@ -2,19 +2,18 @@
#define OPENMC_TALLIES_FILTER_H
#include <cstdint>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "pugixml.hpp"
#include <gsl/gsl>
#include "openmc/constants.h"
#include "openmc/hdf5_interface.h"
#include "openmc/memory.h"
#include "openmc/particle.h"
#include "openmc/tallies/filter_match.h"
#include "pugixml.hpp"
#include "openmc/vector.h"
namespace openmc {
@ -120,7 +119,7 @@ private:
namespace model {
extern "C" int32_t n_filters;
extern std::unordered_map<int, int> filter_map;
extern std::vector<std::unique_ptr<Filter>> tally_filters;
extern vector<unique_ptr<Filter>> tally_filters;
}
//==============================================================================

View file

@ -1,8 +1,8 @@
#ifndef OPENMC_TALLIES_FILTER_AZIMUTHAL_H
#define OPENMC_TALLIES_FILTER_AZIMUTHAL_H
#include "openmc/vector.h"
#include <string>
#include <vector>
#include <gsl/gsl>
@ -45,7 +45,7 @@ private:
//----------------------------------------------------------------------------
// Data members
std::vector<double> bins_;
vector<double> bins_;
};
} // namespace openmc

View file

@ -3,11 +3,11 @@
#include <cstdint>
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -40,7 +40,7 @@ public:
//----------------------------------------------------------------------------
// Accessors
const std::vector<int32_t>& cells() const { return cells_; }
const vector<int32_t>& cells() const { return cells_; }
void set_cells(gsl::span<int32_t> cells);
@ -49,7 +49,7 @@ protected:
// Data members
//! The indices of the cells binned by this filter.
std::vector<int32_t> cells_;
vector<int32_t> cells_;
//! A map from cell indices to filter bin indices.
std::unordered_map<int32_t, int> map_;

View file

@ -3,13 +3,12 @@
#include <cstdint>
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include "openmc/cell.h"
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -43,7 +42,7 @@ public:
//----------------------------------------------------------------------------
// Accessors
const std::vector<CellInstance>& cell_instances() const { return cell_instances_; }
const vector<CellInstance>& cell_instances() const { return cell_instances_; }
void set_cell_instances(gsl::span<CellInstance> instances);
@ -52,7 +51,7 @@ private:
// Data members
//! The indices of the cells binned by this filter.
std::vector<CellInstance> cell_instances_;
vector<CellInstance> cell_instances_;
//! A map from cell/instance indices to filter bin indices.
std::unordered_map<CellInstance, gsl::index, CellInstanceHash> map_;

View file

@ -1,11 +1,11 @@
#ifndef OPENMC_TALLIES_FILTER_COLLISIONS_H
#define OPENMC_TALLIES_FILTER_COLLISIONS_H
#include <vector>
#include <unordered_map>
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -37,14 +37,14 @@ public:
//----------------------------------------------------------------------------
// Accessors
const std::vector<int>& bins() const { return bins_; }
const vector<int>& bins() const { return bins_; }
void set_bins(gsl::span<const int> bins);
protected:
//----------------------------------------------------------------------------
// Data members
std::vector<int> bins_;
vector<int> bins_;
std::unordered_map<int,int> map_;

View file

@ -1,11 +1,10 @@
#ifndef OPENMC_TALLIES_FILTER_DELAYEDGROUP_H
#define OPENMC_TALLIES_FILTER_DELAYEDGROUP_H
#include <vector>
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -41,7 +40,7 @@ public:
//----------------------------------------------------------------------------
// Accessors
const std::vector<int>& groups() const { return groups_; }
const vector<int>& groups() const { return groups_; }
void set_groups(gsl::span<int> groups);
@ -49,7 +48,7 @@ private:
//----------------------------------------------------------------------------
// Data members
std::vector<int> groups_;
vector<int> groups_;
};
} // namespace openmc

View file

@ -1,11 +1,10 @@
#ifndef OPENMC_TALLIES_FILTER_ENERGY_H
#define OPENMC_TALLIES_FILTER_ENERGY_H
#include <vector>
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -38,7 +37,7 @@ public:
//----------------------------------------------------------------------------
// Accessors
const std::vector<double>& bins() const { return bins_; }
const vector<double>& bins() const { return bins_; }
void set_bins(gsl::span<const double> bins);
bool matches_transport_groups() const { return matches_transport_groups_; }
@ -47,7 +46,7 @@ protected:
//----------------------------------------------------------------------------
// Data members
std::vector<double> bins_;
vector<double> bins_;
//! True if transport group number can be used directly to get bin number
bool matches_transport_groups_ {false};

View file

@ -1,9 +1,8 @@
#ifndef OPENMC_TALLIES_FILTER_ENERGYFUNC_H
#define OPENMC_TALLIES_FILTER_ENERGYFUNC_H
#include <vector>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -43,8 +42,8 @@ public:
//----------------------------------------------------------------------------
// Accessors
const std::vector<double>& energy() const { return energy_; }
const std::vector<double>& y() const { return y_; }
const vector<double>& energy() const { return energy_; }
const vector<double>& y() const { return y_; }
void set_data(gsl::span<const double> energy, gsl::span<const double> y);
private:
@ -52,10 +51,10 @@ private:
// Data members
//! Incident neutron energy interpolation grid.
std::vector<double> energy_;
vector<double> energy_;
//! Interpolant values.
std::vector<double> y_;
vector<double> y_;
};
} // namespace openmc

View file

@ -11,8 +11,8 @@ namespace openmc {
class FilterMatch
{
public:
std::vector<int> bins_;
std::vector<double> weights_;
vector<int> bins_;
vector<double> weights_;
int i_bin_;
bool bins_present_ {false};
};

View file

@ -3,11 +3,11 @@
#include <cstdint>
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -40,9 +40,9 @@ public:
//----------------------------------------------------------------------------
// Accessors
std::vector<int32_t>& materials() { return materials_; }
vector<int32_t>& materials() { return materials_; }
const std::vector<int32_t>& materials() const { return materials_; }
const vector<int32_t>& materials() const { return materials_; }
void set_materials(gsl::span<const int32_t> materials);
@ -51,7 +51,7 @@ private:
// Data members
//! The indices of the materials binned by this filter.
std::vector<int32_t> materials_;
vector<int32_t> materials_;
//! A map from material indices to filter bin indices.
std::unordered_map<int32_t, int> map_;

View file

@ -1,11 +1,10 @@
#ifndef OPENMC_TALLIES_FILTER_MU_H
#define OPENMC_TALLIES_FILTER_MU_H
#include <vector>
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -45,7 +44,7 @@ private:
//----------------------------------------------------------------------------
// Data members
std::vector<double> bins_;
vector<double> bins_;
};
} // namespace openmc

View file

@ -1,10 +1,9 @@
#ifndef OPENMC_TALLIES_FILTER_PARTICLE_H
#define OPENMC_TALLIES_FILTER_PARTICLE_H
#include <vector>
#include "openmc/particle.h"
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -37,7 +36,7 @@ public:
//----------------------------------------------------------------------------
// Accessors
const std::vector<ParticleType>& particles() const { return particles_; }
const vector<ParticleType>& particles() const { return particles_; }
void set_particles(gsl::span<ParticleType> particles);
@ -45,7 +44,7 @@ private:
//----------------------------------------------------------------------------
// Data members
std::vector<ParticleType> particles_;
vector<ParticleType> particles_;
};
} // namespace openmc

View file

@ -2,11 +2,11 @@
#define OPENMC_TALLIES_FILTER_POLAR_H
#include <cmath>
#include <vector>
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -45,7 +45,7 @@ private:
//----------------------------------------------------------------------------
// Data members
std::vector<double> bins_;
vector<double> bins_;
};
} // namespace openmc

View file

@ -3,11 +3,11 @@
#include <cstdint>
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -47,7 +47,7 @@ private:
// Data members
//! The indices of the surfaces binned by this filter.
std::vector<int32_t> surfaces_;
vector<int32_t> surfaces_;
//! A map from surface indices to filter bin indices.
std::unordered_map<int32_t, int> map_;

View file

@ -3,11 +3,11 @@
#include <cstdint>
#include <unordered_map>
#include <vector>
#include <gsl/gsl>
#include "openmc/tallies/filter.h"
#include "openmc/vector.h"
namespace openmc {
@ -47,7 +47,7 @@ private:
// Data members
//! The indices of the universes binned by this filter.
std::vector<int32_t> universes_;
vector<int32_t> universes_;
//! A map from universe indices to filter bin indices.
std::unordered_map<int32_t, int> map_;

View file

@ -2,18 +2,18 @@
#define OPENMC_TALLIES_TALLY_H
#include "openmc/constants.h"
#include "openmc/memory.h" // for unique_ptr
#include "openmc/tallies/filter.h"
#include "openmc/tallies/trigger.h"
#include "openmc/vector.h"
#include <gsl/gsl>
#include "pugixml.hpp"
#include "xtensor/xfixed.hpp"
#include "xtensor/xtensor.hpp"
#include <memory> // for unique_ptr
#include <unordered_map>
#include <string>
#include <vector>
#include <unordered_map>
namespace openmc {
@ -41,13 +41,13 @@ public:
void set_scores(pugi::xml_node node);
void set_scores(const std::vector<std::string>& scores);
void set_scores(const vector<std::string>& scores);
void set_nuclides(pugi::xml_node node);
void set_nuclides(const std::vector<std::string>& nuclides);
void set_nuclides(const vector<std::string>& nuclides);
const std::vector<int32_t>& filters() const {return filters_;}
const vector<int32_t>& filters() const { return filters_; }
int32_t filters(int i) const {return filters_[i];}
@ -96,10 +96,10 @@ public:
//! Number of realizations
int n_realizations_ {0};
std::vector<int> scores_; //!< Filter integrands (e.g. flux, fission)
vector<int> scores_; //!< Filter integrands (e.g. flux, fission)
//! Index of each nuclide to be tallied. -1 indicates total material.
std::vector<int> nuclides_ {-1};
vector<int> nuclides_ {-1};
//! True if this tally has a bin for every nuclide in the problem
bool all_nuclides_ {false};
@ -122,7 +122,7 @@ public:
int energyout_filter_ {C_NONE};
int delayedgroup_filter_ {C_NONE};
std::vector<Trigger> triggers_;
vector<Trigger> triggers_;
int deriv_ {C_NONE}; //!< Index of a TallyDerivative object for diff tallies.
@ -130,10 +130,10 @@ private:
//----------------------------------------------------------------------------
// Private data.
std::vector<int32_t> filters_; //!< Filter indices in global filters array
vector<int32_t> filters_; //!< Filter indices in global filters array
//! Index strides assigned to each filter to support 1D indexing.
std::vector<int32_t> strides_;
vector<int32_t> strides_;
int32_t n_filter_bins_ {0};
@ -146,13 +146,13 @@ private:
namespace model {
extern std::unordered_map<int, int> tally_map;
extern std::vector<std::unique_ptr<Tally>> tallies;
extern std::vector<int> active_tallies;
extern std::vector<int> active_analog_tallies;
extern std::vector<int> active_tracklength_tallies;
extern std::vector<int> active_collision_tallies;
extern std::vector<int> active_meshsurf_tallies;
extern std::vector<int> active_surface_tallies;
extern vector<unique_ptr<Tally>> tallies;
extern vector<int> active_tallies;
extern vector<int> active_analog_tallies;
extern vector<int> active_tracklength_tallies;
extern vector<int> active_collision_tallies;
extern vector<int> active_meshsurf_tallies;
extern vector<int> active_surface_tallies;
}
namespace simulation {

View file

@ -28,8 +28,8 @@ public:
//! Construct an iterator over all filter bin combinations.
//
//! \param end if true, the returned iterator indicates the end of a loop.
FilterBinIter(const Tally& tally, bool end,
std::vector<FilterMatch>* particle_filter_matches);
FilterBinIter(
const Tally& tally, bool end, vector<FilterMatch>* particle_filter_matches);
bool operator==(const FilterBinIter& other) const
{return index_ == other.index_;}
@ -42,7 +42,7 @@ public:
int index_ {1};
double weight_ {1.};
std::vector<FilterMatch>& filter_matches_;
vector<FilterMatch>& filter_matches_;
private:
void compute_index_weight();
@ -93,7 +93,7 @@ void score_tracklength_tally(Particle& p, double distance);
//
//! \param p The particle being tracked
//! \param tallies A vector of tallies to score to
void score_surface_tally(Particle& p, const std::vector<int>& tallies);
void score_surface_tally(Particle& p, const vector<int>& tallies);
} // namespace openmc

View file

@ -2,17 +2,17 @@
#define OPENMC_THERMAL_H
#include <cstddef>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "xtensor/xtensor.hpp"
#include "openmc/angle_energy.h"
#include "openmc/endf.h"
#include "openmc/hdf5_interface.h"
#include "openmc/memory.h"
#include "openmc/particle.h"
#include "openmc/vector.h"
namespace openmc {
@ -24,7 +24,7 @@ class ThermalScattering;
namespace data {
extern std::unordered_map<std::string, int> thermal_scatt_map;
extern std::vector<std::unique_ptr<ThermalScattering>> thermal_scatt;
extern vector<unique_ptr<ThermalScattering>> thermal_scatt;
}
//==============================================================================
@ -58,8 +58,9 @@ private:
Reaction() { }
// Data members
std::unique_ptr<Function1D> xs; //!< Cross section
std::unique_ptr<AngleEnergy> distribution; //!< Secondary angle-energy distribution
unique_ptr<Function1D> xs; //!< Cross section
unique_ptr<AngleEnergy>
distribution; //!< Secondary angle-energy distribution
};
// Inelastic scattering data
@ -77,7 +78,7 @@ private:
class ThermalScattering {
public:
ThermalScattering(hid_t group, const std::vector<double>& temperature);
ThermalScattering(hid_t group, const vector<double>& temperature);
//! Determine inelastic/elastic cross section at given energy
//!
@ -103,11 +104,11 @@ public:
std::string name_; //!< name of table, e.g. "c_H_in_H2O"
double awr_; //!< weight of nucleus in neutron masses
double energy_max_; //!< maximum energy for thermal scattering in [eV]
std::vector<double> kTs_; //!< temperatures in [eV] (k*T)
std::vector<std::string> nuclides_; //!< Valid nuclides
vector<double> kTs_; //!< temperatures in [eV] (k*T)
vector<std::string> nuclides_; //!< Valid nuclides
//! cross sections and distributions at each temperature
std::vector<ThermalData> data_;
vector<ThermalData> data_;
};
void free_memory_thermal();

23
include/openmc/vector.h Normal file
View file

@ -0,0 +1,23 @@
#ifndef OPENMC_VECTOR_H
#define OPENMC_VECTOR_H
/*
* In an implementation of OpenMC that offloads computations to an accelerator,
* we may need to provide replacements for standard library containers and
* algorithms that have no native implementations on the device of interest.
* Because some developers are currently in the process of creating such code,
* introducing the below typedef lessens the amount of rebase conflicts that
* happen as they rebase their code on OpenMC's develop branch.
*
* In an implementation of OpenMC that uses such an accelerator, we may remove
* the use of vector below and replace it with a custom implementation
* behaving as expected on the device.
*/
#include <vector>
namespace openmc {
using std::vector;
}
#endif // OPENMC_VECTOR_H

View file

@ -1,4 +1,4 @@
#include <array>
#include "openmc/array.h"
namespace openmc {

View file

@ -1,15 +1,15 @@
#ifndef OPENMC_VOLUME_CALC_H
#define OPENMC_VOLUME_CALC_H
#include "openmc/array.h"
#include "openmc/position.h"
#include "openmc/tallies/trigger.h"
#include "openmc/vector.h"
#include "pugixml.hpp"
#include "xtensor/xtensor.hpp"
#include <array>
#include <string>
#include <vector>
#include <gsl/gsl>
namespace openmc {
@ -23,10 +23,10 @@ class VolumeCalculation {
public:
// Aliases, types
struct Result {
std::array<double, 2> volume; //!< Mean/standard deviation of volume
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
array<double, 2> volume; //!< Mean/standard deviation of volume
vector<int> nuclides; //!< Index of nuclides
vector<double> atoms; //!< Number of atoms for each nuclide
vector<double> uncertainty; //!< Uncertainty on number of atoms
int iterations; //!< Number of iterations needed to obtain the results
}; // Results for a single domain
@ -39,13 +39,14 @@ public:
//! average number densities of nuclides within the domain
//
//! \return Vector of results for each user-specified domain
std::vector<Result> execute() const;
vector<Result> execute() const;
//! \brief Write volume calculation results to HDF5 file
//
//! \param[in] filename Path to HDF5 file to write
//! \param[in] results Vector of results for each domain
void to_hdf5(const std::string& filename, const std::vector<Result>& results) const;
void to_hdf5(
const std::string& filename, const vector<Result>& results) const;
// Tally filter and map types
enum class TallyDomain {
@ -61,7 +62,7 @@ public:
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
vector<int> domain_ids_; //!< IDs of domains to find volumes of
private:
//! \brief Check whether a material has already been hit for a given domain.
@ -70,9 +71,7 @@ private:
//! \param[in] i_material Index in global materials vector
//! \param[in,out] indices Vector of material indices
//! \param[in,out] hits Number of hits corresponding to each material
void check_hit(int i_material, std::vector<int>& indices,
std::vector<int>& hits) const;
void check_hit(int i_material, vector<int>& indices, vector<int>& hits) const;
};
//==============================================================================
@ -80,7 +79,7 @@ private:
//==============================================================================
namespace model {
extern std::vector<VolumeCalculation> volume_calcs;
extern vector<VolumeCalculation> volume_calcs;
}
//==============================================================================

View file

@ -4,11 +4,13 @@
#include "hdf5.h"
#include "xtensor/xtensor.hpp"
#include <array>
#include <complex>
#include <string>
#include <tuple>
#include "openmc/array.h"
#include "openmc/vector.h"
namespace openmc {
//========================================================================
@ -27,7 +29,7 @@ constexpr int FIT_A {1}; // Absorption
constexpr int FIT_F {2}; // Fission
// Multipole HDF5 file version
constexpr std::array<int, 2> WMP_VERSION {1, 1};
constexpr array<int, 2> WMP_VERSION {1, 1};
//========================================================================
// Windowed multipole data
@ -73,7 +75,7 @@ public:
double inv_spacing_; //!< 1 / spacing in sqrt(E) space
int fit_order_; //!< Order of the fit
bool fissionable_; //!< Is the nuclide fissionable?
std::vector<WindowInfo> window_info_; // Information about a window
vector<WindowInfo> window_info_; // Information about a window
xt::xtensor<double, 3> curvefit_; // Curve fit coefficients (window, poly order, reaction)
xt::xtensor<std::complex<double>, 2> data_; //!< Poles and residues

View file

@ -4,12 +4,13 @@
#include <cstddef> // for size_t
#include <sstream> // for stringstream
#include <string>
#include <vector>
#include "pugixml.hpp"
#include "xtensor/xarray.hpp"
#include "xtensor/xadapt.hpp"
#include "openmc/vector.h"
namespace openmc {
inline bool
@ -23,9 +24,9 @@ std::string get_node_value(pugi::xml_node node, const char* name,
bool get_node_value_bool(pugi::xml_node node, const char* name);
template <typename T>
std::vector<T> get_node_array(pugi::xml_node node, const char* name,
bool lowercase=false)
template<typename T>
vector<T> get_node_array(
pugi::xml_node node, const char* name, bool lowercase = false)
{
// Get value of node attribute/child
std::string s {get_node_value(node, name, lowercase)};
@ -33,7 +34,7 @@ std::vector<T> get_node_array(pugi::xml_node node, const char* name,
// Read values one by one into vector
std::stringstream iss {s};
T value;
std::vector<T> values;
vector<T> values;
while (iss >> value)
values.push_back(value);
@ -44,8 +45,8 @@ template <typename T>
xt::xarray<T> get_node_xarray(pugi::xml_node node, const char* name,
bool lowercase=false)
{
std::vector<T> v = get_node_array<T>(node, name, lowercase);
std::vector<std::size_t> shape = {v.size()};
vector<T> v = get_node_array<T>(node, name, lowercase);
vector<std::size_t> shape = {v.size()};
return xt::adapt(v, shape);
}

View file

@ -4,14 +4,12 @@
#ifndef OPENMC_XSDATA_H
#define OPENMC_XSDATA_H
#include <memory>
#include <vector>
#include "xtensor/xtensor.hpp"
#include "openmc/hdf5_interface.h"
#include "openmc/memory.h"
#include "openmc/scattdata.h"
#include "openmc/vector.h"
namespace openmc {
@ -99,7 +97,7 @@ class XsData {
// [angle][incoming group][outgoing group][delayed group]
xt::xtensor<double, 4> chi_delayed;
// scatter has the following dimensions: [angle]
std::vector<std::shared_ptr<ScattData>> scatter;
vector<std::shared_ptr<ScattData>> scatter;
XsData() = default;
@ -138,8 +136,8 @@ class XsData {
//!
//! @param micros Microscopic objects to combine.
//! @param scalars Scalars to multiply the microscopic data by.
void
combine(const std::vector<XsData*>& those_xs, const std::vector<double>& scalars);
void combine(
const vector<XsData*>& those_xs, const std::vector<double>& scalars);
//! \brief Checks to see if this and that are able to be combined
//!