diff --git a/include/openmc/bank.h b/include/openmc/bank.h index 1eae1774b..3dc09608b 100644 --- a/include/openmc/bank.h +++ b/include/openmc/bank.h @@ -2,11 +2,11 @@ #define OPENMC_BANK_H #include -#include -#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 source_bank; +extern vector source_bank; extern SharedArray surf_source_bank; extern SharedArray fission_bank; -extern std::vector progeny_per_particle; +extern vector progeny_per_particle; } // namespace simulation diff --git a/include/openmc/cell.h b/include/openmc/cell.h index 5cd819c26..6ecece120 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -4,10 +4,8 @@ #include #include // for hash #include -#include // for unique_ptr #include #include -#include #include #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 cell_map; - extern std::vector> cells; + extern vector> cells; extern std::unordered_map universe_map; - extern std::vector> universes; + extern vector> universes; } // namespace model //============================================================================== @@ -64,7 +64,7 @@ class Universe { public: int32_t id_; //!< Unique ID - std::vector cells_; //!< Cells within this universe + vector 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 partitioner_; + unique_ptr 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> - get_contained_cells() const; + std::unordered_map> get_contained_cells() const; protected: - void - get_contained_cells_inner(std::unordered_map>& contained_cells, - std::vector& parent_cells) const; + void get_contained_cells_inner( + std::unordered_map>& contained_cells, + vector& parent_cells) const; public: //---------------------------------------------------------------------------- @@ -176,18 +175,18 @@ public: //! \brief Material(s) within this cell. //! //! May be multiple materials for distribcell. - std::vector material_; + vector 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 sqrtkT_; + vector sqrtkT_; //! Definition of spatial region as Boolean expression of half-spaces - std::vector region_; + vector region_; //! Reverse Polish notation for region expression - std::vector rpn_; + vector 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 rotation_; + vector rotation_; - std::vector offset_; //!< Distribcell offset table + vector 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 rpn); + static BoundingBox bounding_box_complex(vector 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::iterator start, - std::vector::iterator stop); + static void apply_demorgan( + vector::iterator start, vector::iterator stop); //! Removes complement operators from the RPN //! \param rpn The rpn to remove complement operators from. - static void remove_complement_ops(std::vector& rpn); + static void remove_complement_ops(vector& 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::iterator - find_left_parenthesis(std::vector::iterator start, - const std::vector& rpn); - + static vector::iterator find_left_parenthesis( + vector::iterator start, const vector& 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& get_cells(Position r, Direction u) const; + const vector& get_cells(Position r, Direction u) const; private: //! A sorted vector of indices to surfaces that partition the universe - std::vector surfs_; + vector 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> partitions_; + vector> partitions_; }; diff --git a/include/openmc/constants.h b/include/openmc/constants.h index 60aa4544d..7b98085d1 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -4,18 +4,18 @@ #ifndef OPENMC_CONSTANTS_H #define OPENMC_CONSTANTS_H -#include #include #include -#include +#include "openmc/array.h" +#include "openmc/vector.h" #include "openmc/version.h" namespace openmc { -using double_2dvec = std::vector>; -using double_3dvec = std::vector>>; -using double_4dvec = std::vector>>>; +using double_2dvec = vector>; +using double_3dvec = vector>>; +using double_4dvec = vector>>>; // ============================================================================ // VERSIONING NUMBERS @@ -24,13 +24,13 @@ using double_4dvec = std::vector>>>; constexpr int HDF5_VERSION[] {3, 0}; // Version numbers for binary files -constexpr std::array VERSION_STATEPOINT {17, 0}; -constexpr std::array VERSION_PARTICLE_RESTART {2, 0}; -constexpr std::array VERSION_TRACK {2, 0}; -constexpr std::array VERSION_SUMMARY {6, 0}; -constexpr std::array VERSION_VOLUME {1, 0}; -constexpr std::array VERSION_VOXEL {2, 0}; -constexpr std::array VERSION_MGXS_LIBRARY {1, 0}; +constexpr array VERSION_STATEPOINT {17, 0}; +constexpr array VERSION_PARTICLE_RESTART {2, 0}; +constexpr array VERSION_TRACK {2, 0}; +constexpr array VERSION_SUMMARY {6, 0}; +constexpr array VERSION_VOLUME {1, 0}; +constexpr array VERSION_VOXEL {2, 0}; +constexpr array 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 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 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 DEPLETION_RX {N_GAMMA, N_P, N_A, N_2N, N_3N, N_4N}; +constexpr array DEPLETION_RX {N_GAMMA, N_P, N_A, N_2N, N_3N, N_4N}; enum class URRTableParam { CUM_PROB, diff --git a/include/openmc/cross_sections.h b/include/openmc/cross_sections.h index aa1ba3661..a9a160f2f 100644 --- a/include/openmc/cross_sections.h +++ b/include/openmc/cross_sections.h @@ -5,7 +5,8 @@ #include #include -#include + +#include "openmc/vector.h" namespace openmc { @@ -31,7 +32,7 @@ public: // Data members Type type_; //!< Type of data library - std::vector materials_; //!< Materials contained in library + vector materials_; //!< Materials contained in library std::string path_; //!< File path to library }; @@ -47,7 +48,7 @@ namespace data { extern std::map library_map; //!< Data libraries -extern std::vector libraries; +extern vector 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>& nuc_temps, - const std::vector>& thermal_temps); +void read_ce_cross_sections(const vector>& nuc_temps, + const vector>& thermal_temps); //! Read cross_sections.xml and populate data libraries void read_ce_cross_sections_xml(); diff --git a/include/openmc/distribution.h b/include/openmc/distribution.h index 026b3d723..888fab7d8 100644 --- a/include/openmc/distribution.h +++ b/include/openmc/distribution.h @@ -5,12 +5,12 @@ #define OPENMC_DISTRIBUTION_H #include // for size_t -#include // for unique_ptr -#include // 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& x() const { return x_; } - const std::vector& p() const { return p_; } + const vector& x() const { return x_; } + const vector& p() const { return p_; } + private: - std::vector x_; //!< Possible outcomes - std::vector p_; //!< Probability of each outcome + vector x_; //!< Possible outcomes + vector 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& x() { return x_; } - const std::vector& x() const { return x_; } - const std::vector& p() const { return p_; } + vector& x() { return x_; } + const vector& x() const { return x_; } + const vector& p() const { return p_; } Interpolation interp() const { return interp_; } private: - std::vector x_; //!< tabulated independent variable - std::vector p_; //!< tabulated probability density - std::vector c_; //!< cumulative distribution at tabulated values + vector x_; //!< tabulated independent variable + vector p_; //!< tabulated probability density + vector 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& x() const { return x_; } + const vector& x() const { return x_; } + private: - std::vector x_; //! Possible outcomes + vector x_; //! Possible outcomes }; - -using UPtrDist = std::unique_ptr; +using UPtrDist = unique_ptr; //! Return univariate probability distribution specified in XML file //! \param[in] node XML node representing distribution diff --git a/include/openmc/distribution_angle.h b/include/openmc/distribution_angle.h index b5b663caf..efd4e5842 100644 --- a/include/openmc/distribution_angle.h +++ b/include/openmc/distribution_angle.h @@ -4,11 +4,10 @@ #ifndef OPENMC_DISTRIBUTION_ANGLE_H #define OPENMC_DISTRIBUTION_ANGLE_H -#include // 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 energy_; - std::vector> distribution_; + vector energy_; + vector> distribution_; }; } // namespace openmc diff --git a/include/openmc/distribution_energy.h b/include/openmc/distribution_energy.h index 7b739ba94..9c7438f33 100644 --- a/include/openmc/distribution_energy.h +++ b/include/openmc/distribution_energy.h @@ -4,13 +4,12 @@ #ifndef OPENMC_DISTRIBUTION_ENERGY_H #define OPENMC_DISTRIBUTION_ENERGY_H -#include - #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 breakpoints_; //!< Breakpoints between regions - std::vector interpolation_; //!< Interpolation laws - std::vector energy_; //!< Incident energy in [eV] - std::vector distribution_; //!< Distributions for each incident energy + vector breakpoints_; //!< Breakpoints between regions + vector interpolation_; //!< Interpolation laws + vector energy_; //!< Incident energy in [eV] + vector distribution_; //!< Distributions for each incident energy }; //=============================================================================== diff --git a/include/openmc/distribution_multi.h b/include/openmc/distribution_multi.h index ae7768ac3..1e245e5ed 100644 --- a/include/openmc/distribution_multi.h +++ b/include/openmc/distribution_multi.h @@ -1,7 +1,7 @@ #ifndef DISTRIBUTION_MULTI_H #define DISTRIBUTION_MULTI_H -#include +#include "openmc/memory.h" #include "pugixml.hpp" @@ -82,7 +82,7 @@ public: Direction sample(uint64_t* seed) const; }; -using UPtrAngle = std::unique_ptr; +using UPtrAngle = unique_ptr; } // namespace openmc diff --git a/include/openmc/distribution_spatial.h b/include/openmc/distribution_spatial.h index fb0c0fe73..a56ff2dcf 100644 --- a/include/openmc/distribution_spatial.h +++ b/include/openmc/distribution_spatial.h @@ -135,7 +135,7 @@ private: Position r_; //!< Single position at which sites are generated }; -using UPtrSpace = std::unique_ptr; +using UPtrSpace = unique_ptr; } // namespace openmc diff --git a/include/openmc/eigenvalue.h b/include/openmc/eigenvalue.h index 8f430f548..b456fee21 100644 --- a/include/openmc/eigenvalue.h +++ b/include/openmc/eigenvalue.h @@ -4,14 +4,14 @@ #ifndef OPENMC_EIGENVALUE_H #define OPENMC_EIGENVALUE_H -#include #include // for int64_t -#include #include "xtensor/xtensor.hpp" #include +#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 k_sum; //!< Used to reduce sum and sum_sq -extern std::vector entropy; //!< Shannon entropy at each generation +extern array k_sum; //!< Used to reduce sum and sum_sq +extern vector entropy; //!< Shannon entropy at each generation extern xt::xtensor source_frac; //!< Source fraction for UFS } // namespace simulation diff --git a/include/openmc/endf.h b/include/openmc/endf.h index 27958db5c..40e1cef83 100644 --- a/include/openmc/endf.h +++ b/include/openmc/endf.h @@ -4,12 +4,11 @@ #ifndef OPENMC_ENDF_H #define OPENMC_ENDF_H -#include -#include - #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 coef_; //!< Polynomial coefficients + vector coef_; //!< Polynomial coefficients }; //============================================================================== @@ -80,15 +79,16 @@ public: double operator()(double x) const override; // Accessors - const std::vector& x() const { return x_; } - const std::vector& y() const { return y_; } + const vector& x() const { return x_; } + const vector& y() const { return y_; } + private: std::size_t n_regions_ {0}; //!< number of interpolation regions - std::vector nbt_; //!< values separating interpolation regions - std::vector int_; //!< interpolation schemes + vector nbt_; //!< values separating interpolation regions + vector int_; //!< interpolation schemes std::size_t n_pairs_; //!< number of (x,y) pairs - std::vector x_; //!< values of abscissa - std::vector y_; //!< values of ordinate + vector x_; //!< values of abscissa + vector y_; //!< values of ordinate }; //============================================================================== @@ -101,11 +101,12 @@ public: double operator()(double E) const override; - const std::vector& bragg_edges() const { return bragg_edges_; } - const std::vector& factors() const { return factors_; } + const vector& bragg_edges() const { return bragg_edges_; } + const vector& factors() const { return factors_; } + private: - std::vector bragg_edges_; //!< Bragg edges in [eV] - std::vector factors_; //!< Partial sums of structure factors [eV-b] + vector bragg_edges_; //!< Bragg edges in [eV] + vector 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 read_function(hid_t group, const char* name); +unique_ptr read_function(hid_t group, const char* name); } // namespace openmc diff --git a/include/openmc/event.h b/include/openmc/event.h index f45b2a18a..981fa9b17 100644 --- a/include/openmc/event.h +++ b/include/openmc/event.h @@ -65,7 +65,7 @@ extern SharedArray surface_crossing_queue; extern SharedArray collision_queue; // Particle buffer -extern std::vector particles; +extern vector particles; } // namespace simulation diff --git a/include/openmc/geometry.h b/include/openmc/geometry.h index 9ca0a9e9e..0ba29ef48 100644 --- a/include/openmc/geometry.h +++ b/include/openmc/geometry.h @@ -1,12 +1,12 @@ #ifndef OPENMC_GEOMETRY_H #define OPENMC_GEOMETRY_H -#include #include #include -#include +#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 overlap_check_count; +extern vector overlap_check_count; } // namespace model diff --git a/include/openmc/geometry_aux.h b/include/openmc/geometry_aux.h index 43e4e71cd..ff01779a4 100644 --- a/include/openmc/geometry_aux.h +++ b/include/openmc/geometry_aux.h @@ -6,9 +6,10 @@ #include #include -#include #include +#include "openmc/vector.h" + namespace openmc { namespace model { @@ -41,8 +42,8 @@ void assign_temperatures(); //! table //============================================================================== -void get_temperatures(std::vector>& nuc_temps, - std::vector>& thermal_temps); +void get_temperatures(vector>& nuc_temps, + vector>& thermal_temps); //============================================================================== //! \brief Perform final setup for geometry diff --git a/include/openmc/hdf5_interface.h b/include/openmc/hdf5_interface.h index 88a73415a..f60167304 100644 --- a/include/openmc/hdf5_interface.h +++ b/include/openmc/hdf5_interface.h @@ -2,22 +2,22 @@ #define OPENMC_HDF5_INTERFACE_H #include // for min -#include #include #include #include // for strlen #include #include #include -#include #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 attribute_shape(hid_t obj_id, const char* name); -std::vector dataset_names(hid_t group_id); +vector attribute_shape(hid_t obj_id, const char* name); +vector dataset_names(hid_t group_id); void ensure_exists(hid_t obj_id, const char* name, bool attribute=false); -std::vector group_names(hid_t group_id); -std::vector object_shape(hid_t obj_id); +vector group_names(hid_t group_id); +vector 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 inline void -read_attribute(hid_t obj_id, const char* name, std::array& buffer) +template +inline void read_attribute(hid_t obj_id, const char* name, array& buffer) { read_attr(obj_id, name, H5TypeMap::type_id, buffer.data()); } // vector version template -void read_attribute(hid_t obj_id, const char* name, std::vector& vec) +void read_attribute(hid_t obj_id, const char* name, vector& 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& arr) std::size_t size = 1; for (const auto x : shape) size *= x; - std::vector buffer(size); + vector buffer(size); // Read data from attribute read_attr(obj_id, name, H5TypeMap::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 -inline void -read_attribute(hid_t obj_id, const char* name, std::vector& vec) +// overload for vector +inline void read_attribute( + hid_t obj_id, const char* name, vector& 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 inline void -read_dataset(hid_t dset, const char* name, std::array& buffer, - bool indep=false) +template +inline void read_dataset( + hid_t dset, const char* name, array& buffer, bool indep = false) { read_dataset_lowlevel(dset, name, H5TypeMap::type_id, H5S_ALL, indep, buffer.data()); } // vector version -template -void read_dataset(hid_t dset, std::vector& vec, bool indep=false) +template +void read_dataset(hid_t dset, vector& vec, bool indep = false) { // Get shape of dataset - std::vector shape = object_shape(dset); + vector 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& vec, bool indep=false) vec.data()); } -template -void read_dataset(hid_t obj_id, const char* name, std::vector& vec, - bool indep=false) +template +void read_dataset( + hid_t obj_id, const char* name, vector& vec, bool indep = false) { hid_t dset = open_dataset(obj_id, name); read_dataset(dset, vec, indep); @@ -290,7 +290,7 @@ template void read_dataset(hid_t dset, xt::xarray& arr, bool indep=false) { // Get shape of dataset - std::vector shape = object_shape(dset); + vector 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& arr, hid_t dset = open_dataset(obj_id, name); // Get shape of dataset - std::vector hsize_t_shape = object_shape(dset); + vector hsize_t_shape = object_shape(dset); close_dataset(dset); // cast from hsize_t to size_t - std::vector shape(hsize_t_shape.size()); + vector shape(hsize_t_shape.size()); for (int i = 0; i < shape.size(); i++) { shape[i] = static_cast(hsize_t_shape[i]); } @@ -349,7 +349,7 @@ void read_dataset(hid_t obj_id, const char* name, xt::xtensor& arr, inline void read_dataset(hid_t obj_id, const char* name, Position& r, bool indep=false) { - std::array x; + array 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 buffer(size); + vector buffer(size); // Read data from attribute read_dataset_lowlevel(dset, nullptr, H5TypeMap::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 inline void -write_attribute(hid_t obj_id, const char* name, const std::array& buffer) +template +inline void write_attribute( + hid_t obj_id, const char* name, const array& buffer) { hsize_t dims[] {N}; write_attr(obj_id, 1, dims, name, H5TypeMap::type_id, buffer.data()); } -template inline void -write_attribute(hid_t obj_id, const char* name, const std::vector& buffer) +template +inline void write_attribute( + hid_t obj_id, const char* name, const vector& buffer) { hsize_t dims[] {buffer.size()}; write_attr(obj_id, 1, dims, name, H5TypeMap::type_id, buffer.data()); @@ -429,7 +431,7 @@ write_attribute(hid_t obj_id, const char* name, const std::vector& buffer) inline void write_attribute(hid_t obj_id, const char* name, Position r) { - std::array buffer {r.x, r.y, r.z}; + array 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 inline void -write_dataset(hid_t obj_id, const char* name, const std::array& buffer) +template +inline void write_dataset( + hid_t obj_id, const char* name, const array& buffer) { hsize_t dims[] {N}; write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap::type_id, H5S_ALL, false, buffer.data()); } -inline void -write_dataset(hid_t obj_id, const char* name, - const std::vector& buffer) +inline void write_dataset( + hid_t obj_id, const char* name, const vector& 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 inline void -write_dataset(hid_t obj_id, const char* name, const std::vector& buffer) +template +inline void write_dataset( + hid_t obj_id, const char* name, const vector& buffer) { hsize_t dims[] {buffer.size()}; write_dataset_lowlevel(obj_id, 1, dims, name, H5TypeMap::type_id, @@ -503,7 +506,7 @@ write_dataset(hid_t obj_id, const char* name, const xt::xcontainer& arr) { using T = typename D::value_type; auto s = arr.shape(); - std::vector dims {s.cbegin(), s.cend()}; + vector dims {s.cbegin(), s.cend()}; write_dataset_lowlevel(obj_id, dims.size(), dims.data(), name, H5TypeMap::type_id, H5S_ALL, false, arr.data()); } @@ -511,7 +514,7 @@ write_dataset(hid_t obj_id, const char* name, const xt::xcontainer& arr) inline void write_dataset(hid_t obj_id, const char* name, Position r) { - std::array buffer {r.x, r.y, r.z}; + array buffer {r.x, r.y, r.z}; write_dataset(obj_id, name, buffer); } diff --git a/include/openmc/lattice.h b/include/openmc/lattice.h index 64936ca0a..a5844c506 100644 --- a/include/openmc/lattice.h +++ b/include/openmc/lattice.h @@ -3,17 +3,16 @@ #include #include -#include // for unique_ptr #include #include -#include #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 lattice_map; - extern std::vector> lattices; + extern vector> lattices; } // namespace model //============================================================================== @@ -53,9 +52,9 @@ public: int32_t id_; //!< Universe ID number std::string name_; //!< User-defined name LatticeType type_; - std::vector universes_; //!< Universes filling each lattice tile + vector universes_; //!< Universes filling each lattice tile int32_t outer_ {NO_OUTER_UNIVERSE}; //!< Universe tiled outside the lattice - std::vector offsets_; //!< Distribcell offset table + vector 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> - distance(Position r, Direction u, const std::array& i_xyz) const - = 0; + virtual std::pair> distance( + Position r, Direction u, const array& 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> - distance(Position r, Direction u, const std::array& i_xyz) const; + std::pair> distance( + Position r, Direction u, const array& i_xyz) const; std::array get_indices(Position r, Direction u) const; @@ -234,7 +232,7 @@ public: void to_hdf5_inner(hid_t group_id) const; private: - std::array n_cells_; //!< Number of cells along each axis + array 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 const& i_xyz) const; - std::pair> - distance(Position r, Direction u, const std::array& i_xyz) const; + std::pair> distance( + Position r, Direction u, const array& i_xyz) const; std::array 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& univ_words); + void fill_lattice_y(const vector& univ_words); //! Fill universes_ vector for 'x' orientation - void fill_lattice_x(const std::vector& univ_words); + void fill_lattice_x(const vector& 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 pitch_; //!< Lattice tile width and height + array pitch_; //!< Lattice tile width and height }; //============================================================================== diff --git a/include/openmc/material.h b/include/openmc/material.h index 9adb9ff97..185efcd58 100644 --- a/include/openmc/material.h +++ b/include/openmc/material.h @@ -1,19 +1,19 @@ #ifndef OPENMC_MATERIAL_H #define OPENMC_MATERIAL_H -#include // for unique_ptr #include #include -#include #include #include #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 material_map; -extern std::vector> materials; +extern vector> 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& name, - const std::vector& density); + void set_densities( + const vector& name, const vector& density); //---------------------------------------------------------------------------- // Accessors @@ -139,26 +139,27 @@ public: // Data int32_t id_ {C_NONE}; //!< Unique ID std::string name_; //!< Name of material - std::vector nuclide_; //!< Indices in nuclides vector - std::vector element_; //!< Indices in elements vector + vector nuclide_; //!< Indices in nuclides vector + vector element_; //!< Indices in elements vector xt::xtensor 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 p0_; //!< Indicate which nuclides are to be treated with iso-in-lab scattering + vector 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 mat_nuclide_index_; + vector mat_nuclide_index_; // Thermal scattering tables - std::vector thermal_tables_; + vector thermal_tables_; - std::unique_ptr ttb_; + unique_ptr ttb_; private: //---------------------------------------------------------------------------- @@ -191,14 +192,14 @@ private: //============================================================================== //! Calculate Sternheimer adjustment factor -double sternheimer_adjustment(const std::vector& f, const - std::vector& e_b_sq, double e_p_sq, double n_conduction, double - log_I, double tol, int max_iter); +double sternheimer_adjustment(const vector& f, + const vector& 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& f, const std::vector& - e_b_sq, double e_p_sq, double n_conduction, double rho, double E, double tol, - int max_iter); +double density_effect(const vector& f, + const std::vector& 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(); diff --git a/include/openmc/memory.h b/include/openmc/memory.h new file mode 100644 index 000000000..99666da7d --- /dev/null +++ b/include/openmc/memory.h @@ -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 + +namespace openmc { +using std::make_unique; +using std::unique_ptr; +} // namespace openmc + +#endif // OPENMC_MEMORY_H diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 5904abb6e..d1d49a6c1 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -4,16 +4,16 @@ #ifndef OPENMC_MESH_H #define OPENMC_MESH_H -#include // for unique_ptr -#include #include #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 mesh_map; -extern std::vector> meshes; +extern vector> meshes; } // namespace model #ifdef LIBMESH namespace settings { // used when creating new libMesh::Mesh instances -extern std::unique_ptr libmesh_init; +extern unique_ptr 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& bins, - std::vector& lengths) const = 0; + vector& bins, + vector& 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& bins) const = 0; + vector& 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> - plot(Position plot_ll, Position plot_ur) const = 0; + virtual std::pair, std::vector> 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& bins, - std::vector& lengths) const override; + vector& bins, + vector& 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& bins) const override; + vector& 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> - plot(Position plot_ll, Position plot_ur) const override; + std::pair, std::vector> 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& bins) const override; + vector& 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> - plot(Position plot_ll, Position plot_ur) const override; + std::pair, std::vector> plot( + Position plot_ll, Position plot_ur) const override; void to_hdf5(hid_t group) const override; - std::vector> grid_; + vector> 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& values, - const std::vector& std_dev) = 0; + const vector& values, const vector& std_dev) = 0; //! Write the unstructured mesh to file // @@ -342,7 +341,7 @@ public: void surface_bins_crossed(Position r0, Position r1, - std::vector& bins) const; + vector& 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& bins, - std::vector& lengths) const override; + vector& bins, + vector& lengths) const override; void surface_bins_crossed(Position r0, @@ -383,8 +382,8 @@ public: int n_surface_bins() const override; - std::pair, std::vector> - plot(Position plot_ll, Position plot_ur) const override; + std::pair, std::vector> 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& values, - const std::vector& std_dev) override; + void set_score_data(const std::string& score, const vector& values, + const vector& 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& hits) const; + void intersect_track(const moab::CartVect& start, const moab::CartVect& dir, + double track_len, vector& 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 mbi_; //!< MOAB instance - std::unique_ptr kdtree_; //!< MOAB KDTree instance - std::vector baryc_data_; //!< Barycentric data for tetrahedra - std::vector tag_names_; //!< Names of score tags added to the mesh + unique_ptr mbi_; //!< MOAB instance + unique_ptr kdtree_; //!< MOAB KDTree instance + vector baryc_data_; //!< Barycentric data for tetrahedra + vector 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& bins, - std::vector& lengths) const override; + vector& bins, + vector& lengths) const override; void surface_bins_crossed(Position r0, @@ -539,16 +534,15 @@ public: int n_surface_bins() const override; - std::pair, std::vector> - plot(Position plot_ll, Position plot_ur) const override; + std::pair, std::vector> 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& values, - const std::vector& std_dev) override; + void set_score_data(const std::string& var_name, const vector& values, + const vector& 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 m_; //!< pointer to the libMesh mesh instance - std::vector> pl_; //!< per-thread point locators - std::unique_ptr equation_systems_; //!< pointer to the equation systems of the mesh + unique_ptr m_; //!< pointer to the libMesh mesh instance + vector> + pl_; //!< per-thread point locators + unique_ptr + 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 variable_map_; //!< mapping of variable names (tally scores) to libMesh variable numbers libMesh::BoundingBox bbox_; //!< bounding box of the mesh diff --git a/include/openmc/mgxs.h b/include/openmc/mgxs.h index ae7a54ad3..4447b47cb 100644 --- a/include/openmc/mgxs.h +++ b/include/openmc/mgxs.h @@ -5,16 +5,15 @@ #define OPENMC_MGXS_H #include -#include #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 xs; // Cross section data + vector 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 polar; - std::vector azimuthal; + vector polar; + vector 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& in_kTs, - bool in_fissionable, AngleDistributionType in_scatter_format, bool in_is_isotropic, - const std::vector& in_polar, const std::vector& in_azimuthal); + void init(const std::string& in_name, double in_awr, + const vector& in_kTs, bool in_fissionable, + AngleDistributionType in_scatter_format, bool in_is_isotropic, + const vector& in_polar, const std::vector& 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& temperature, - std::vector& temps_to_read, int& order_dim); + void metadata_from_hdf5(hid_t xs_id, const vector& temperature, + vector& 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& micros, const std::vector& scalars, - const std::vector& micro_ts, int this_t); + void combine(const vector& micros, + const std::vector& scalars, const vector& 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 cache; // index and data cache + vector 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& temperature, - int num_group, int num_delay); + Mgxs(hid_t xs_id, const vector& 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& mat_kTs, - const std::vector& micros, const std::vector& atom_densities, - int num_group, int num_delay); + Mgxs(const std::string& in_name, const vector& mat_kTs, + const vector& micros, const std::vector& 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& get_xsdata() const { return xs; } + const vector& get_xsdata() const { return xs; } }; } // namespace openmc diff --git a/include/openmc/mgxs_interface.h b/include/openmc/mgxs_interface.h index 6beda5778..01b865b97 100644 --- a/include/openmc/mgxs_interface.h +++ b/include/openmc/mgxs_interface.h @@ -4,10 +4,9 @@ #ifndef OPENMC_MGXS_INTERFACE_H #define OPENMC_MGXS_INTERFACE_H -#include "hdf5_interface.h" -#include "mgxs.h" - -#include +#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 xs_to_read, - const std::vector> xs_temps); + const vector xs_to_read, + const vector> 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 xs_to_read, - std::vector> xs_temps); + void set_nuclides_and_temperatures( + vector xs_to_read, vector> xs_temps); // Add an Mgxs object to be managed - void add_mgxs(hid_t file_id, const std::string& name, - const std::vector& temperature); + void add_mgxs( + hid_t file_id, const std::string& name, const vector& 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> get_mat_kTs(); + vector> get_mat_kTs(); int num_energy_groups_; int num_delayed_groups_; - std::vector xs_names_; // available names in HDF5 file - std::vector xs_to_read_; // XS which appear in materials - std::vector> xs_temps_to_read_; // temperatures used + vector xs_names_; // available names in HDF5 file + vector xs_to_read_; // XS which appear in materials + vector> xs_temps_to_read_; // temperatures used std::string cross_sections_path_; // path to MGXS h5 file - std::vector nuclides_; - std::vector macro_xs_; - std::vector energy_bins_; - std::vector energy_bin_avg_; - std::vector rev_energy_bins_; - std::vector> nuc_temps_; // all available temperatures + vector nuclides_; + vector macro_xs_; + vector energy_bins_; + vector energy_bin_avg_; + vector rev_energy_bins_; + vector> nuc_temps_; // all available temperatures }; namespace data { diff --git a/include/openmc/nuclide.h b/include/openmc/nuclide.h index 69bb50cc8..6067c53a0 100644 --- a/include/openmc/nuclide.h +++ b/include/openmc/nuclide.h @@ -4,21 +4,21 @@ #ifndef OPENMC_NUCLIDE_H #define OPENMC_NUCLIDE_H -#include -#include // for unique_ptr #include #include // for pair -#include #include #include +#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 grid_index; - std::vector energy; + vector grid_index; + vector energy; }; // Constructors/destructors - Nuclide(hid_t group, const std::vector& temperature); + Nuclide(hid_t group, const vector& 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 kTs_; //!< temperatures in eV (k*T) - std::vector grid_; //!< Energy grid at each temperature - std::vector> xs_; //!< Cross sections at each temperature + vector kTs_; //!< temperatures in eV (k*T) + vector grid_; //!< Energy grid at each temperature + vector> xs_; //!< Cross sections at each temperature // Multipole data - std::unique_ptr multipole_; + unique_ptr multipole_; // Fission data bool fissionable_ {false}; //!< Whether nuclide is fissionable bool has_partial_fission_ {false}; //!< has partial fission reactions? - std::vector fission_rx_; //!< Fission reactions + vector fission_rx_; //!< Fission reactions int n_precursor_ {0}; //!< Number of delayed neutron precursors - std::unique_ptr total_nu_; //!< Total neutron yield - std::unique_ptr fission_q_prompt_; //!< Prompt fission energy release - std::unique_ptr fission_q_recov_; //!< Recoverable fission energy release - std::unique_ptr prompt_photons_; //!< Prompt photon energy release - std::unique_ptr delayed_photons_; //!< Delayed photon energy release - std::unique_ptr fragments_; //!< Fission fragment energy release - std::unique_ptr betas_; //!< Delayed beta energy release + unique_ptr total_nu_; //!< Total neutron yield + unique_ptr fission_q_prompt_; //!< Prompt fission energy release + unique_ptr + fission_q_recov_; //!< Recoverable fission energy release + unique_ptr prompt_photons_; //!< Prompt photon energy release + unique_ptr delayed_photons_; //!< Delayed photon energy release + unique_ptr fragments_; //!< Fission fragment energy release + unique_ptr betas_; //!< Delayed beta energy release // Resonance scattering information bool resonant_ {false}; - std::vector energy_0K_; - std::vector elastic_0K_; - std::vector xs_cdf_; + vector energy_0K_; + vector elastic_0K_; + vector xs_cdf_; // Unresolved resonance range information bool urr_present_ {false}; int urr_inelastic_ {C_NONE}; - std::vector urr_data_; + vector urr_data_; - std::vector> reactions_; //!< Reactions - std::array reaction_index_; //!< Index of each reaction - std::vector index_inelastic_scatter_; + vector> reactions_; //!< Reactions + array reaction_index_; //!< Index of each reaction + vector 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 energy_min; -extern std::array energy_max; +extern array energy_min; +extern array 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 nuclide_map; -extern std::vector> nuclides; +extern vector> nuclides; } // namespace data diff --git a/include/openmc/particle.h b/include/openmc/particle.h index 77dec18b6..526c1a9ff 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -5,16 +5,16 @@ //! \brief Particle type #include -#include // for unique_ptr #include #include -#include #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" diff --git a/include/openmc/particle_data.h b/include/openmc/particle_data.h index 8da54dde4..7485552f5 100644 --- a/include/openmc/particle_data.h +++ b/include/openmc/particle_data.h @@ -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 +#include "openmc/vector.h" namespace openmc { @@ -56,7 +57,7 @@ struct NuBank { class LocalCoord { public: - void rotate(const std::vector& rotation); + void rotate(const vector& 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 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 + array lattice_translation {}; //!< which way lattice indices will change }; @@ -171,9 +170,8 @@ private: // Data members (accessor methods are below) // Cross section caches - std::vector - neutron_xs_; //!< Microscopic neutron cross sections - std::vector photon_xs_; //!< Microscopic photon cross sections + vector neutron_xs_; //!< Microscopic neutron cross sections + vector 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 coord_; //!< coordinates for all levels + vector coord_; //!< coordinates for all levels // Particle coordinates before crossing a surface int n_coord_last_ {1}; //!< number of current coordinates - std::vector cell_last_; //!< coordinates for all levels + vector 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 secondary_bank_; + vector secondary_bank_; int64_t current_work_; // current work index - std::vector flux_derivs_; // for derivatives for this particle + vector flux_derivs_; // for derivatives for this particle - std::vector filter_matches_; // tally filter matches + vector filter_matches_; // tally filter matches - std::vector> tracks_; // tracks for outputting to file + vector> tracks_; // tracks for outputting to file - std::vector nu_bank_; // bank of most recently fissioned particles + vector nu_bank_; // bank of most recently fissioned particles // Global tally accumulators double keff_tally_absorption_ {0.0}; diff --git a/include/openmc/photon.h b/include/openmc/photon.h index 43a37a9e3..ca8f75474 100644 --- a/include/openmc/photon.h +++ b/include/openmc/photon.h @@ -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 #include #include "xtensor/xtensor.hpp" -#include // for unique_ptr #include #include #include // for pair -#include namespace openmc { @@ -81,7 +81,7 @@ public: // Photoionization and atomic relaxation data std::unordered_map shell_map_; //!< Given a shell designator, e.g. 3, this //!< dictionary gives an index in shells_ - std::vector shells_; + vector shells_; // Compton profile data xt::xtensor profile_pdf_; @@ -121,7 +121,7 @@ extern xt::xtensor compton_profile_pz; //! Compton profile momentum g //! Photon interaction data for each element extern std::unordered_map element_map; -extern std::vector> elements; +extern vector> elements; } // namespace data diff --git a/include/openmc/physics.h b/include/openmc/physics.h index efafa9550..5c9218956 100644 --- a/include/openmc/physics.h +++ b/include/openmc/physics.h @@ -6,8 +6,7 @@ #include "openmc/particle.h" #include "openmc/position.h" #include "openmc/reaction.h" - -#include +#include "openmc/vector.h" namespace openmc { diff --git a/include/openmc/physics_mg.h b/include/openmc/physics_mg.h index c73bd2eb5..66dad7550 100644 --- a/include/openmc/physics_mg.h +++ b/include/openmc/physics_mg.h @@ -5,10 +5,9 @@ #define OPENMC_PHYSICS_MG_H #include "openmc/capi.h" -#include "openmc/particle.h" #include "openmc/nuclide.h" - -#include +#include "openmc/particle.h" +#include "openmc/vector.h" namespace openmc { diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 44da79e99..0e9ceea78 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -28,7 +28,7 @@ class Plot; namespace model { extern std::unordered_map plot_map; //!< map of plot ids to index -extern std::vector plots; //!< Plot instance container +extern vector 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 &v) { + RGBColor(const vector& 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 pixels_; //!< Plot size in pixels + array 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 colors_; //!< Plot colors + vector colors_; //!< Plot colors std::string path_plot_; //!< Plot output filename }; diff --git a/include/openmc/position.h b/include/openmc/position.h index 26cd6bb3f..ff258d0de 100644 --- a/include/openmc/position.h +++ b/include/openmc/position.h @@ -1,11 +1,12 @@ #ifndef OPENMC_POSITION_H #define OPENMC_POSITION_H -#include #include // for sqrt #include #include // for out_of_range -#include + +#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& xyz) : x{xyz[0]}, y{xyz[1]}, z{xyz[2]} { }; - Position(const std::array& xyz) : x{xyz[0]}, y{xyz[1]}, z{xyz[2]} { }; + Position(const vector& xyz) : x {xyz[0]}, y {xyz[1]}, z {xyz[2]} {}; + Position(const array& 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& rotation) const; + Position rotate(const vector& rotation) const; // Data members double x = 0.; diff --git a/include/openmc/reaction.h b/include/openmc/reaction.h index d1e3d6f82..a597e6237 100644 --- a/include/openmc/reaction.h +++ b/include/openmc/reaction.h @@ -5,12 +5,12 @@ #define OPENMC_REACTION_H #include -#include #include #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& temperatures); + explicit Reaction(hid_t group, const vector& 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 energy, - gsl::span flux, const std::vector& grid) const; + gsl::span flux, const vector& grid) const; //! Cross section at a single temperature struct TemperatureXS { int threshold; - std::vector value; + vector 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 xs_; //!< Cross section at each temperature - std::vector products_; //!< Reaction products + vector xs_; //!< Cross section at each temperature + vector products_; //!< Reaction products }; //============================================================================== diff --git a/include/openmc/reaction_product.h b/include/openmc/reaction_product.h index b072ae485..2c0a703dc 100644 --- a/include/openmc/reaction_product.h +++ b/include/openmc/reaction_product.h @@ -4,14 +4,13 @@ #ifndef OPENMC_REACTION_PRODUCT_H #define OPENMC_REACTION_PRODUCT_H -#include // for unique_ptr -#include // 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; + using Secondary = unique_ptr; //! 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 yield_; //!< Yield as a function of energy - std::vector applicability_; //!< Applicability of distribution - std::vector distribution_; //!< Secondary angle-energy distribution + unique_ptr yield_; //!< Yield as a function of energy + vector applicability_; //!< Applicability of distribution + vector distribution_; //!< Secondary angle-energy distribution }; } // namespace opemc diff --git a/include/openmc/scattdata.h b/include/openmc/scattdata.h index aa91d5688..bc1700319 100644 --- a/include/openmc/scattdata.h +++ b/include/openmc/scattdata.h @@ -4,11 +4,10 @@ #ifndef OPENMC_SCATTDATA_H #define OPENMC_SCATTDATA_H -#include - #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& those_scatts, - const std::vector& scalars, xt::xtensor& in_gmin, - xt::xtensor& in_gmax, double_2dvec& sparse_mult, - double_3dvec& sparse_scatter); + void base_combine(size_t max_order, size_t order_dim, + const vector& those_scatts, const vector& scalars, + xt::xtensor& in_gmin, xt::xtensor& 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& those_scatts, - const std::vector& scalars) = 0; + virtual void combine(const vector& those_scatts, + const vector& scalars) = 0; //! \brief Getter for the dimensionality of the scattering order. //! @@ -151,9 +147,8 @@ class ScattDataLegendre: public ScattData { init(const xt::xtensor& in_gmin, const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs); - void - combine(const std::vector& those_scatts, - const std::vector& scalars); + void combine( + const vector& those_scatts, const vector& 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& in_gmin, const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs); - void - combine(const std::vector& those_scatts, - const std::vector& scalars); + void combine( + const vector& those_scatts, const vector& scalars); double calc_f(int gin, int gout, double mu); @@ -233,9 +227,8 @@ class ScattDataTabular: public ScattData { init(const xt::xtensor& in_gmin, const xt::xtensor& in_gmax, const double_2dvec& in_mult, const double_3dvec& coeffs); - void - combine(const std::vector& those_scatts, - const std::vector& scalars); + void combine( + const vector& those_scatts, const vector& scalars); double calc_f(int gin, int gout, double mu); diff --git a/include/openmc/secondary_correlated.h b/include/openmc/secondary_correlated.h index ac568f689..46910c507 100644 --- a/include/openmc/secondary_correlated.h +++ b/include/openmc/secondary_correlated.h @@ -4,14 +4,13 @@ #ifndef OPENMC_SECONDARY_CORRELATED_H #define OPENMC_SECONDARY_CORRELATED_H -#include - #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 e_out; //!< Outgoing energies [eV] xt::xtensor p; //!< Probability density xt::xtensor c; //!< Cumulative distribution - std::vector> angle; //!< Angle distribution + vector> angle; //!< Angle distribution }; explicit CorrelatedAngleEnergy(hid_t group); @@ -43,19 +42,20 @@ public: uint64_t* seed) const override; // energy property - std::vector& energy() { return energy_; } - const std::vector& energy() const { return energy_; } + vector& energy() { return energy_; } + const vector& energy() const { return energy_; } // distribution property - std::vector& distribution() { return distribution_; } - const std::vector& distribution() const { return distribution_; } + vector& distribution() { return distribution_; } + const vector& distribution() const { return distribution_; } + private: int n_region_; //!< Number of interpolation regions - std::vector breakpoints_; //!< Breakpoints between regions - std::vector interpolation_; //!< Interpolation laws - std::vector energy_; //!< Energies [eV] at which distributions - //!< are tabulated - std::vector distribution_; //!< Distribution at each energy + vector breakpoints_; //!< Breakpoints between regions + vector interpolation_; //!< Interpolation laws + vector energy_; //!< Energies [eV] at which distributions + //!< are tabulated + vector distribution_; //!< Distribution at each energy }; } // namespace openmc diff --git a/include/openmc/secondary_kalbach.h b/include/openmc/secondary_kalbach.h index 0864367c0..ea9b8199a 100644 --- a/include/openmc/secondary_kalbach.h +++ b/include/openmc/secondary_kalbach.h @@ -4,14 +4,13 @@ #ifndef OPENMC_SECONDARY_KALBACH_H #define OPENMC_SECONDARY_KALBACH_H -#include - #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 breakpoints_; //!< Breakpoints between regions - std::vector interpolation_; //!< Interpolation laws - std::vector energy_; //!< Energies [eV] at which distributions - //!< are tabulated - std::vector distribution_; //!< Distribution at each energy + vector breakpoints_; //!< Breakpoints between regions + vector interpolation_; //!< Interpolation laws + vector energy_; //!< Energies [eV] at which distributions + //!< are tabulated + vector distribution_; //!< Distribution at each energy }; } // namespace openmc diff --git a/include/openmc/secondary_thermal.h b/include/openmc/secondary_thermal.h index 6e1768f46..9848c37fe 100644 --- a/include/openmc/secondary_thermal.h +++ b/include/openmc/secondary_thermal.h @@ -7,12 +7,11 @@ #include "openmc/angle_energy.h" #include "openmc/endf.h" #include "openmc/secondary_correlated.h" +#include "openmc/vector.h" #include #include "xtensor/xtensor.hpp" -#include - 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& energy); + explicit IncoherentElasticAEDiscrete( + hid_t group, const vector& 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& energy_; //!< Energies at which cosines are tabulated + const vector& energy_; //!< Energies at which cosines are tabulated xt::xtensor 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& energy); + explicit IncoherentInelasticAEDiscrete( + hid_t group, const vector& 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& energy_; //!< Incident energies + const vector& energy_; //!< Incident energies xt::xtensor energy_out_; //!< Outgoing energies for each incident energy xt::xtensor mu_out_; //!< Outgoing cosines for each incident/outgoing energy bool skewed_; //!< Whether outgoing energy distribution is skewed @@ -138,9 +139,9 @@ private: xt::xtensor mu; //!< Equiprobable angles at each outgoing energy }; - std::vector energy_; //!< Incident energies - std::vector distribution_; //!< Secondary angle-energy at - //!< each incident energy + vector energy_; //!< Incident energies + vector distribution_; //!< Secondary angle-energy at + //!< each incident energy }; diff --git a/include/openmc/secondary_uncorrelated.h b/include/openmc/secondary_uncorrelated.h index 79b8b5031..f3e05fbed 100644 --- a/include/openmc/secondary_uncorrelated.h +++ b/include/openmc/secondary_uncorrelated.h @@ -4,14 +4,13 @@ #ifndef OPENMC_SECONDARY_UNCORRELATED_H #define OPENMC_SECONDARY_UNCORRELATED_H -#include -#include - #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 energy_; //!< Energy distribution + unique_ptr energy_; //!< Energy distribution bool fission_ {false}; //!< Whether distribution is use for fission }; diff --git a/include/openmc/settings.h b/include/openmc/settings.h index 85468a733..384f629b0 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -4,15 +4,15 @@ //! \file settings.h //! \brief Settings for OpenMC -#include #include #include #include -#include #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 energy_cutoff; //!< Energy cutoff in [eV] for each particle type +extern array + 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 res_scat_nuclides; //!< Nuclides using res. upscattering treatment +extern vector + res_scat_nuclides; //!< Nuclides using res. upscattering treatment extern RunMode run_mode; //!< Run mode (eigenvalue, fixed src, etc.) extern std::unordered_set sourcepoint_batch; //!< Batches when source should be written extern std::unordered_set 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 temperature_range; //!< Min/max T in [K] over which to load xs +extern array + 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> track_identifiers; //!< Particle numbers for writing tracks +extern vector> + 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 diff --git a/include/openmc/shared_array.h b/include/openmc/shared_array.h index bdce58fab..588b8812b 100644 --- a/include/openmc/shared_array.h +++ b/include/openmc/shared_array.h @@ -4,8 +4,7 @@ //! \file shared_array.h //! \brief Shared array data structure -#include - +#include "openmc/memory.h" namespace openmc { @@ -38,7 +37,7 @@ public: //! space for SharedArray(int64_t capacity) : capacity_(capacity) { - data_ = std::make_unique(capacity); + data_ = make_unique(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(capacity); + data_ = make_unique(capacity); capacity_ = capacity; } @@ -120,7 +119,7 @@ private: //========================================================================== // Data members - std::unique_ptr data_; //!< An RAII handle to the elements + unique_ptr 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 diff --git a/include/openmc/simulation.h b/include/openmc/simulation.h index cd604dcb6..e7f8eb758 100644 --- a/include/openmc/simulation.h +++ b/include/openmc/simulation.h @@ -6,9 +6,9 @@ #include "openmc/mesh.h" #include "openmc/particle.h" +#include "openmc/vector.h" #include -#include 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 k_generation; -extern std::vector work_index; +extern vector k_generation; +extern vector work_index; } // namespace simulation diff --git a/include/openmc/source.h b/include/openmc/source.h index 24c5332e5..773a5859c 100644 --- a/include/openmc/source.h +++ b/include/openmc/source.h @@ -4,14 +4,13 @@ #ifndef OPENMC_SOURCE_H #define OPENMC_SOURCE_H -#include -#include - #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> external_sources; +extern vector> external_sources; } // namespace model @@ -87,7 +86,7 @@ public: ParticleBank sample(uint64_t* seed) const override; private: - std::vector sites_; //!< Source sites from a file + vector 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 custom_source_; + unique_ptr custom_source_; }; -typedef std::unique_ptr create_custom_source_t(std::string parameters); +typedef unique_ptr create_custom_source_t(std::string parameters); //============================================================================== // Functions diff --git a/include/openmc/state_point.h b/include/openmc/state_point.h index 7256192d4..0d2fa12c2 100644 --- a/include/openmc/state_point.h +++ b/include/openmc/state_point.h @@ -2,21 +2,21 @@ #define OPENMC_STATE_POINT_H #include -#include #include "hdf5.h" #include "openmc/capi.h" #include "openmc/particle.h" +#include "openmc/vector.h" namespace openmc { void load_state_point(); -std::vector calculate_surf_source_size(); +vector 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& sites, bool distribute); + hid_t group_id, vector& sites, bool distribute); void write_tally_results_nr(hid_t file_id); void restart_set_keff(); void write_unstructured_mesh_results(); diff --git a/include/openmc/string_utils.h b/include/openmc/string_utils.h index a60fd06a8..6b4c69d48 100644 --- a/include/openmc/string_utils.h +++ b/include/openmc/string_utils.h @@ -2,7 +2,8 @@ #define OPENMC_STRING_UTILS_H #include -#include + +#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 split(const std::string& in); +vector split(const std::string& in); bool ends_with(const std::string& value, const std::string& ending); diff --git a/include/openmc/surface.h b/include/openmc/surface.h index def7cb1eb..5a8a88aa4 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -1,20 +1,20 @@ #ifndef OPENMC_SURFACE_H #define OPENMC_SURFACE_H -#include // for unique_ptr #include // For numeric_limits #include #include -#include #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 surface_map; - extern std::vector> surfaces; + extern vector> surfaces; } // namespace model //============================================================================== diff --git a/include/openmc/tallies/derivative.h b/include/openmc/tallies/derivative.h index 53e6925ba..d3a7b8b20 100644 --- a/include/openmc/tallies/derivative.h +++ b/include/openmc/tallies/derivative.h @@ -2,9 +2,9 @@ #define OPENMC_TALLIES_DERIVATIVE_H #include "openmc/particle.h" +#include "openmc/vector.h" #include -#include #include "pugixml.hpp" @@ -71,7 +71,7 @@ namespace openmc { namespace model { extern std::unordered_map tally_deriv_map; -extern std::vector tally_derivs; +extern vector tally_derivs; } // namespace model } // namespace openmc diff --git a/include/openmc/tallies/filter.h b/include/openmc/tallies/filter.h index cde55fa7b..9620632a3 100644 --- a/include/openmc/tallies/filter.h +++ b/include/openmc/tallies/filter.h @@ -2,19 +2,18 @@ #define OPENMC_TALLIES_FILTER_H #include -#include #include #include -#include +#include "pugixml.hpp" #include #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 filter_map; - extern std::vector> tally_filters; + extern vector> tally_filters; } //============================================================================== diff --git a/include/openmc/tallies/filter_azimuthal.h b/include/openmc/tallies/filter_azimuthal.h index 7259f0f00..d1c468233 100644 --- a/include/openmc/tallies/filter_azimuthal.h +++ b/include/openmc/tallies/filter_azimuthal.h @@ -1,8 +1,8 @@ #ifndef OPENMC_TALLIES_FILTER_AZIMUTHAL_H #define OPENMC_TALLIES_FILTER_AZIMUTHAL_H +#include "openmc/vector.h" #include -#include #include @@ -45,7 +45,7 @@ private: //---------------------------------------------------------------------------- // Data members - std::vector bins_; + vector bins_; }; } // namespace openmc diff --git a/include/openmc/tallies/filter_cell.h b/include/openmc/tallies/filter_cell.h index 83114ea12..e4180148f 100644 --- a/include/openmc/tallies/filter_cell.h +++ b/include/openmc/tallies/filter_cell.h @@ -3,11 +3,11 @@ #include #include -#include #include #include "openmc/tallies/filter.h" +#include "openmc/vector.h" namespace openmc { @@ -40,7 +40,7 @@ public: //---------------------------------------------------------------------------- // Accessors - const std::vector& cells() const { return cells_; } + const vector& cells() const { return cells_; } void set_cells(gsl::span cells); @@ -49,7 +49,7 @@ protected: // Data members //! The indices of the cells binned by this filter. - std::vector cells_; + vector cells_; //! A map from cell indices to filter bin indices. std::unordered_map map_; diff --git a/include/openmc/tallies/filter_cell_instance.h b/include/openmc/tallies/filter_cell_instance.h index a406e73d7..dee9b8bea 100644 --- a/include/openmc/tallies/filter_cell_instance.h +++ b/include/openmc/tallies/filter_cell_instance.h @@ -3,13 +3,12 @@ #include #include -#include #include #include "openmc/cell.h" #include "openmc/tallies/filter.h" - +#include "openmc/vector.h" namespace openmc { @@ -43,7 +42,7 @@ public: //---------------------------------------------------------------------------- // Accessors - const std::vector& cell_instances() const { return cell_instances_; } + const vector& cell_instances() const { return cell_instances_; } void set_cell_instances(gsl::span instances); @@ -52,7 +51,7 @@ private: // Data members //! The indices of the cells binned by this filter. - std::vector cell_instances_; + vector cell_instances_; //! A map from cell/instance indices to filter bin indices. std::unordered_map map_; diff --git a/include/openmc/tallies/filter_collision.h b/include/openmc/tallies/filter_collision.h index 45e6d9405..1b23bd440 100644 --- a/include/openmc/tallies/filter_collision.h +++ b/include/openmc/tallies/filter_collision.h @@ -1,11 +1,11 @@ #ifndef OPENMC_TALLIES_FILTER_COLLISIONS_H #define OPENMC_TALLIES_FILTER_COLLISIONS_H -#include #include #include #include "openmc/tallies/filter.h" +#include "openmc/vector.h" namespace openmc { @@ -37,14 +37,14 @@ public: //---------------------------------------------------------------------------- // Accessors - const std::vector& bins() const { return bins_; } + const vector& bins() const { return bins_; } void set_bins(gsl::span bins); protected: //---------------------------------------------------------------------------- // Data members - std::vector bins_; + vector bins_; std::unordered_map map_; diff --git a/include/openmc/tallies/filter_delayedgroup.h b/include/openmc/tallies/filter_delayedgroup.h index 64bdd3398..63987e339 100644 --- a/include/openmc/tallies/filter_delayedgroup.h +++ b/include/openmc/tallies/filter_delayedgroup.h @@ -1,11 +1,10 @@ #ifndef OPENMC_TALLIES_FILTER_DELAYEDGROUP_H #define OPENMC_TALLIES_FILTER_DELAYEDGROUP_H -#include - #include #include "openmc/tallies/filter.h" +#include "openmc/vector.h" namespace openmc { @@ -41,7 +40,7 @@ public: //---------------------------------------------------------------------------- // Accessors - const std::vector& groups() const { return groups_; } + const vector& groups() const { return groups_; } void set_groups(gsl::span groups); @@ -49,7 +48,7 @@ private: //---------------------------------------------------------------------------- // Data members - std::vector groups_; + vector groups_; }; } // namespace openmc diff --git a/include/openmc/tallies/filter_energy.h b/include/openmc/tallies/filter_energy.h index 3eac0a9c1..2db0231e2 100644 --- a/include/openmc/tallies/filter_energy.h +++ b/include/openmc/tallies/filter_energy.h @@ -1,11 +1,10 @@ #ifndef OPENMC_TALLIES_FILTER_ENERGY_H #define OPENMC_TALLIES_FILTER_ENERGY_H -#include - #include #include "openmc/tallies/filter.h" +#include "openmc/vector.h" namespace openmc { @@ -38,7 +37,7 @@ public: //---------------------------------------------------------------------------- // Accessors - const std::vector& bins() const { return bins_; } + const vector& bins() const { return bins_; } void set_bins(gsl::span bins); bool matches_transport_groups() const { return matches_transport_groups_; } @@ -47,7 +46,7 @@ protected: //---------------------------------------------------------------------------- // Data members - std::vector bins_; + vector bins_; //! True if transport group number can be used directly to get bin number bool matches_transport_groups_ {false}; diff --git a/include/openmc/tallies/filter_energyfunc.h b/include/openmc/tallies/filter_energyfunc.h index 562d7f36d..5c131ba69 100644 --- a/include/openmc/tallies/filter_energyfunc.h +++ b/include/openmc/tallies/filter_energyfunc.h @@ -1,9 +1,8 @@ #ifndef OPENMC_TALLIES_FILTER_ENERGYFUNC_H #define OPENMC_TALLIES_FILTER_ENERGYFUNC_H -#include - #include "openmc/tallies/filter.h" +#include "openmc/vector.h" namespace openmc { @@ -43,8 +42,8 @@ public: //---------------------------------------------------------------------------- // Accessors - const std::vector& energy() const { return energy_; } - const std::vector& y() const { return y_; } + const vector& energy() const { return energy_; } + const vector& y() const { return y_; } void set_data(gsl::span energy, gsl::span y); private: @@ -52,10 +51,10 @@ private: // Data members //! Incident neutron energy interpolation grid. - std::vector energy_; + vector energy_; //! Interpolant values. - std::vector y_; + vector y_; }; } // namespace openmc diff --git a/include/openmc/tallies/filter_match.h b/include/openmc/tallies/filter_match.h index a4ab2e407..b07656f17 100644 --- a/include/openmc/tallies/filter_match.h +++ b/include/openmc/tallies/filter_match.h @@ -11,8 +11,8 @@ namespace openmc { class FilterMatch { public: - std::vector bins_; - std::vector weights_; + vector bins_; + vector weights_; int i_bin_; bool bins_present_ {false}; }; diff --git a/include/openmc/tallies/filter_material.h b/include/openmc/tallies/filter_material.h index 71396cf2b..65bfce04e 100644 --- a/include/openmc/tallies/filter_material.h +++ b/include/openmc/tallies/filter_material.h @@ -3,11 +3,11 @@ #include #include -#include #include #include "openmc/tallies/filter.h" +#include "openmc/vector.h" namespace openmc { @@ -40,9 +40,9 @@ public: //---------------------------------------------------------------------------- // Accessors - std::vector& materials() { return materials_; } + vector& materials() { return materials_; } - const std::vector& materials() const { return materials_; } + const vector& materials() const { return materials_; } void set_materials(gsl::span materials); @@ -51,7 +51,7 @@ private: // Data members //! The indices of the materials binned by this filter. - std::vector materials_; + vector materials_; //! A map from material indices to filter bin indices. std::unordered_map map_; diff --git a/include/openmc/tallies/filter_mu.h b/include/openmc/tallies/filter_mu.h index 7f6f29e5f..cad5bad1f 100644 --- a/include/openmc/tallies/filter_mu.h +++ b/include/openmc/tallies/filter_mu.h @@ -1,11 +1,10 @@ #ifndef OPENMC_TALLIES_FILTER_MU_H #define OPENMC_TALLIES_FILTER_MU_H -#include - #include #include "openmc/tallies/filter.h" +#include "openmc/vector.h" namespace openmc { @@ -45,7 +44,7 @@ private: //---------------------------------------------------------------------------- // Data members - std::vector bins_; + vector bins_; }; } // namespace openmc diff --git a/include/openmc/tallies/filter_particle.h b/include/openmc/tallies/filter_particle.h index e41ff3846..da022b81e 100644 --- a/include/openmc/tallies/filter_particle.h +++ b/include/openmc/tallies/filter_particle.h @@ -1,10 +1,9 @@ #ifndef OPENMC_TALLIES_FILTER_PARTICLE_H #define OPENMC_TALLIES_FILTER_PARTICLE_H -#include - #include "openmc/particle.h" #include "openmc/tallies/filter.h" +#include "openmc/vector.h" namespace openmc { @@ -37,7 +36,7 @@ public: //---------------------------------------------------------------------------- // Accessors - const std::vector& particles() const { return particles_; } + const vector& particles() const { return particles_; } void set_particles(gsl::span particles); @@ -45,7 +44,7 @@ private: //---------------------------------------------------------------------------- // Data members - std::vector particles_; + vector particles_; }; } // namespace openmc diff --git a/include/openmc/tallies/filter_polar.h b/include/openmc/tallies/filter_polar.h index fd800e2ed..ecfbc6f9c 100644 --- a/include/openmc/tallies/filter_polar.h +++ b/include/openmc/tallies/filter_polar.h @@ -2,11 +2,11 @@ #define OPENMC_TALLIES_FILTER_POLAR_H #include -#include #include #include "openmc/tallies/filter.h" +#include "openmc/vector.h" namespace openmc { @@ -45,7 +45,7 @@ private: //---------------------------------------------------------------------------- // Data members - std::vector bins_; + vector bins_; }; } // namespace openmc diff --git a/include/openmc/tallies/filter_surface.h b/include/openmc/tallies/filter_surface.h index cf27024c5..28b510534 100644 --- a/include/openmc/tallies/filter_surface.h +++ b/include/openmc/tallies/filter_surface.h @@ -3,11 +3,11 @@ #include #include -#include #include #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 surfaces_; + vector surfaces_; //! A map from surface indices to filter bin indices. std::unordered_map map_; diff --git a/include/openmc/tallies/filter_universe.h b/include/openmc/tallies/filter_universe.h index 1dabf9671..dfdbb8cf9 100644 --- a/include/openmc/tallies/filter_universe.h +++ b/include/openmc/tallies/filter_universe.h @@ -3,11 +3,11 @@ #include #include -#include #include #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 universes_; + vector universes_; //! A map from universe indices to filter bin indices. std::unordered_map map_; diff --git a/include/openmc/tallies/tally.h b/include/openmc/tallies/tally.h index 1de372f3c..aaaff0e70 100644 --- a/include/openmc/tallies/tally.h +++ b/include/openmc/tallies/tally.h @@ -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 #include "pugixml.hpp" #include "xtensor/xfixed.hpp" #include "xtensor/xtensor.hpp" -#include // for unique_ptr -#include #include -#include +#include namespace openmc { @@ -41,13 +41,13 @@ public: void set_scores(pugi::xml_node node); - void set_scores(const std::vector& scores); + void set_scores(const vector& scores); void set_nuclides(pugi::xml_node node); - void set_nuclides(const std::vector& nuclides); + void set_nuclides(const vector& nuclides); - const std::vector& filters() const {return filters_;} + const vector& 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 scores_; //!< Filter integrands (e.g. flux, fission) + vector scores_; //!< Filter integrands (e.g. flux, fission) //! Index of each nuclide to be tallied. -1 indicates total material. - std::vector nuclides_ {-1}; + vector 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 triggers_; + vector triggers_; int deriv_ {C_NONE}; //!< Index of a TallyDerivative object for diff tallies. @@ -130,10 +130,10 @@ private: //---------------------------------------------------------------------------- // Private data. - std::vector filters_; //!< Filter indices in global filters array + vector filters_; //!< Filter indices in global filters array //! Index strides assigned to each filter to support 1D indexing. - std::vector strides_; + vector strides_; int32_t n_filter_bins_ {0}; @@ -146,13 +146,13 @@ private: namespace model { extern std::unordered_map tally_map; - extern std::vector> tallies; - extern std::vector active_tallies; - extern std::vector active_analog_tallies; - extern std::vector active_tracklength_tallies; - extern std::vector active_collision_tallies; - extern std::vector active_meshsurf_tallies; - extern std::vector active_surface_tallies; + extern vector> tallies; + extern vector active_tallies; + extern vector active_analog_tallies; + extern vector active_tracklength_tallies; + extern vector active_collision_tallies; + extern vector active_meshsurf_tallies; + extern vector active_surface_tallies; } namespace simulation { diff --git a/include/openmc/tallies/tally_scoring.h b/include/openmc/tallies/tally_scoring.h index 20329e0c7..4510f725f 100644 --- a/include/openmc/tallies/tally_scoring.h +++ b/include/openmc/tallies/tally_scoring.h @@ -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* particle_filter_matches); + FilterBinIter( + const Tally& tally, bool end, vector* 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& filter_matches_; + vector& 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& tallies); +void score_surface_tally(Particle& p, const vector& tallies); } // namespace openmc diff --git a/include/openmc/thermal.h b/include/openmc/thermal.h index a18658fe3..d2db789e2 100644 --- a/include/openmc/thermal.h +++ b/include/openmc/thermal.h @@ -2,17 +2,17 @@ #define OPENMC_THERMAL_H #include -#include #include #include -#include #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 thermal_scatt_map; -extern std::vector> thermal_scatt; +extern vector> thermal_scatt; } //============================================================================== @@ -58,8 +58,9 @@ private: Reaction() { } // Data members - std::unique_ptr xs; //!< Cross section - std::unique_ptr distribution; //!< Secondary angle-energy distribution + unique_ptr xs; //!< Cross section + unique_ptr + distribution; //!< Secondary angle-energy distribution }; // Inelastic scattering data @@ -77,7 +78,7 @@ private: class ThermalScattering { public: - ThermalScattering(hid_t group, const std::vector& temperature); + ThermalScattering(hid_t group, const vector& 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 kTs_; //!< temperatures in [eV] (k*T) - std::vector nuclides_; //!< Valid nuclides + vector kTs_; //!< temperatures in [eV] (k*T) + vector nuclides_; //!< Valid nuclides //! cross sections and distributions at each temperature - std::vector data_; + vector data_; }; void free_memory_thermal(); diff --git a/include/openmc/vector.h b/include/openmc/vector.h new file mode 100644 index 000000000..a67eccc46 --- /dev/null +++ b/include/openmc/vector.h @@ -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 + +namespace openmc { +using std::vector; +} + +#endif // OPENMC_VECTOR_H diff --git a/include/openmc/version.h.in b/include/openmc/version.h.in index a7cf51d04..995f20c3b 100644 --- a/include/openmc/version.h.in +++ b/include/openmc/version.h.in @@ -1,4 +1,4 @@ -#include +#include "openmc/array.h" namespace openmc { diff --git a/include/openmc/volume_calc.h b/include/openmc/volume_calc.h index 3258be9d6..2071411f8 100644 --- a/include/openmc/volume_calc.h +++ b/include/openmc/volume_calc.h @@ -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 #include -#include #include namespace openmc { @@ -23,10 +23,10 @@ class VolumeCalculation { public: // Aliases, types struct Result { - std::array volume; //!< Mean/standard deviation of volume - std::vector nuclides; //!< Index of nuclides - std::vector atoms; //!< Number of atoms for each nuclide - std::vector uncertainty; //!< Uncertainty on number of atoms + array volume; //!< Mean/standard deviation of volume + vector nuclides; //!< Index of nuclides + vector atoms; //!< Number of atoms for each nuclide + vector 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 execute() const; + vector 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& results) const; + void to_hdf5( + const std::string& filename, const vector& 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 domain_ids_; //!< IDs of domains to find volumes of + vector 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& indices, - std::vector& hits) const; - + void check_hit(int i_material, vector& indices, vector& hits) const; }; //============================================================================== @@ -80,7 +79,7 @@ private: //============================================================================== namespace model { - extern std::vector volume_calcs; +extern vector volume_calcs; } //============================================================================== diff --git a/include/openmc/wmp.h b/include/openmc/wmp.h index 014ee7fe7..5b3104afc 100644 --- a/include/openmc/wmp.h +++ b/include/openmc/wmp.h @@ -4,11 +4,13 @@ #include "hdf5.h" #include "xtensor/xtensor.hpp" -#include #include #include #include +#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 WMP_VERSION {1, 1}; +constexpr array 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 window_info_; // Information about a window + vector window_info_; // Information about a window xt::xtensor curvefit_; // Curve fit coefficients (window, poly order, reaction) xt::xtensor, 2> data_; //!< Poles and residues diff --git a/include/openmc/xml_interface.h b/include/openmc/xml_interface.h index 6ab8c148c..ddd92ad7e 100644 --- a/include/openmc/xml_interface.h +++ b/include/openmc/xml_interface.h @@ -4,12 +4,13 @@ #include // for size_t #include // for stringstream #include -#include #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 -std::vector get_node_array(pugi::xml_node node, const char* name, - bool lowercase=false) +template +vector 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 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 values; + vector values; while (iss >> value) values.push_back(value); @@ -44,8 +45,8 @@ template xt::xarray get_node_xarray(pugi::xml_node node, const char* name, bool lowercase=false) { - std::vector v = get_node_array(node, name, lowercase); - std::vector shape = {v.size()}; + vector v = get_node_array(node, name, lowercase); + vector shape = {v.size()}; return xt::adapt(v, shape); } diff --git a/include/openmc/xsdata.h b/include/openmc/xsdata.h index 64d0c01cf..d8610d5b6 100644 --- a/include/openmc/xsdata.h +++ b/include/openmc/xsdata.h @@ -4,14 +4,12 @@ #ifndef OPENMC_XSDATA_H #define OPENMC_XSDATA_H -#include -#include - #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 chi_delayed; // scatter has the following dimensions: [angle] - std::vector> scatter; + vector> 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& those_xs, const std::vector& scalars); + void combine( + const vector& those_xs, const std::vector& scalars); //! \brief Checks to see if this and that are able to be combined //! diff --git a/src/bank.cpp b/src/bank.cpp index 9b77133a1..a14020784 100644 --- a/src/bank.cpp +++ b/src/bank.cpp @@ -1,8 +1,9 @@ #include "openmc/bank.h" #include "openmc/capi.h" #include "openmc/error.h" -#include "openmc/simulation.h" #include "openmc/message_passing.h" +#include "openmc/simulation.h" +#include "openmc/vector.h" #include @@ -15,7 +16,7 @@ namespace openmc { namespace simulation { -std::vector source_bank; +vector source_bank; SharedArray surf_source_bank; @@ -28,7 +29,7 @@ SharedArray fission_bank; // Each entry in this vector corresponds to the number of progeny produced // this generation for the particle located at that index. This vector is // used to efficiently sort the fission bank after each iteration. -std::vector progeny_per_particle; +vector progeny_per_particle; } // namespace simulation @@ -80,7 +81,7 @@ void sort_fission_bank() // sorted order easy. Under normal usage conditions, the fission bank is // over provisioned, so we can use that as scratch space. ParticleBank* sorted_bank; - std::vector sorted_bank_holder; + vector sorted_bank_holder; // If there is not enough space, allocate a temporary vector and point to it if (simulation::fission_bank.size() > simulation::fission_bank.capacity() / 2) { diff --git a/src/bremsstrahlung.cpp b/src/bremsstrahlung.cpp index 8fe8ea713..099e0ca0c 100644 --- a/src/bremsstrahlung.cpp +++ b/src/bremsstrahlung.cpp @@ -18,7 +18,7 @@ namespace data { xt::xtensor ttb_e_grid; xt::xtensor ttb_k_grid; -std::vector ttb; +vector ttb; } // namespace data diff --git a/src/cell.cpp b/src/cell.cpp index 4b18319b6..53c3b7a49 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -33,10 +33,10 @@ namespace openmc { namespace model { std::unordered_map cell_map; - std::vector> cells; + vector> cells; std::unordered_map universe_map; - std::vector> universes; + vector> universes; } // namespace model //============================================================================== @@ -46,10 +46,10 @@ namespace model { //! operators. //============================================================================== -std::vector -tokenize(const std::string region_spec) { +vector tokenize(const std::string region_spec) +{ // Check for an empty region_spec first. - std::vector tokens; + vector tokens; if (region_spec.empty()) { return tokens; } @@ -113,11 +113,10 @@ tokenize(const std::string region_spec) { //! This function uses the shunting-yard algorithm. //============================================================================== -std::vector -generate_rpn(int32_t cell_id, std::vector infix) +vector generate_rpn(int32_t cell_id, vector infix) { - std::vector rpn; - std::vector stack; + vector rpn; + vector stack; for (int32_t token : infix) { if (token < OP_UNION) { @@ -197,7 +196,7 @@ Universe::to_hdf5(hid_t universes_group) const // Write the contained cells. if (cells_.size() > 0) { - std::vector cell_ids; + vector cell_ids; for (auto i_cell : cells_) cell_ids.push_back(model::cells[i_cell]->id_); write_dataset(group, "cells", cell_ids); } @@ -333,8 +332,8 @@ CSGCell::CSGCell(pugi::xml_node cell_node) // universe), more than one material (distribmats), and some materials may // be "void". if (material_present) { - std::vector mats - {get_node_array(cell_node, "material", true)}; + vector mats { + get_node_array(cell_node, "material", true)}; if (mats.size() > 0) { material_.reserve(mats.size()); for (std::string mat : mats) { @@ -563,7 +562,7 @@ CSGCell::to_hdf5(hid_t cell_group) const // Write fill information. if (type_ == Fill::MATERIAL) { write_dataset(group, "fill_type", "material"); - std::vector mat_ids; + vector mat_ids; for (auto i_mat : material_) { if (i_mat != MATERIAL_VOID) { mat_ids.push_back(model::materials[i_mat]->id_); @@ -577,7 +576,7 @@ CSGCell::to_hdf5(hid_t cell_group) const write_dataset(group, "material", mat_ids); } - std::vector temps; + vector temps; for (auto sqrtkT_val : sqrtkT_) temps.push_back(sqrtkT_val * sqrtkT_val / K_BOLTZMANN); write_dataset(group, "temperature", temps); @@ -590,7 +589,7 @@ CSGCell::to_hdf5(hid_t cell_group) const } if (!rotation_.empty()) { if (rotation_.size() == 12) { - std::array rot {rotation_[9], rotation_[10], rotation_[11]}; + array rot {rotation_[9], rotation_[10], rotation_[11]}; write_dataset(group, "rotation", rot); } else { write_dataset(group, "rotation", rotation_); @@ -613,8 +612,8 @@ BoundingBox CSGCell::bounding_box_simple() const { return bbox; } -void CSGCell::apply_demorgan(std::vector::iterator start, - std::vector::iterator stop) +void CSGCell::apply_demorgan( + vector::iterator start, vector::iterator stop) { while (start < stop) { if (*start < OP_UNION) { *start *= -1; } @@ -624,9 +623,9 @@ void CSGCell::apply_demorgan(std::vector::iterator start, } } -std::vector::iterator -CSGCell::find_left_parenthesis(std::vector::iterator start, - const std::vector& rpn) { +vector::iterator CSGCell::find_left_parenthesis( + vector::iterator start, const vector& rpn) +{ // start search at zero int parenthesis_level = 0; auto it = start; @@ -657,12 +656,13 @@ CSGCell::find_left_parenthesis(std::vector::iterator start, return it; } -void CSGCell::remove_complement_ops(std::vector& rpn) { +void CSGCell::remove_complement_ops(vector& rpn) +{ auto it = std::find(rpn.begin(), rpn.end(), OP_COMPLEMENT); while (it != rpn.end()) { // find the opening parenthesis (if any) auto left = find_left_parenthesis(it, rpn); - std::vector tmp(left, it+1); + vector tmp(left, it + 1); // apply DeMorgan's law to any surfaces/operators between these // positions in the RPN @@ -674,11 +674,12 @@ void CSGCell::remove_complement_ops(std::vector& rpn) { } } -BoundingBox CSGCell::bounding_box_complex(std::vector rpn) { +BoundingBox CSGCell::bounding_box_complex(vector rpn) +{ // remove complements by adjusting surface signs and operators remove_complement_ops(rpn); - std::vector stack(rpn.size()); + vector stack(rpn.size()); int i_stack = -1; for (auto& token : rpn) { @@ -731,7 +732,7 @@ CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const { // Make a stack of booleans. We don't know how big it needs to be, but we do // know that rpn.size() is an upper-bound. - std::vector stack(rpn_.size()); + vector stack(rpn_.size()); int i_stack = -1; for (int32_t token : rpn_) { @@ -945,8 +946,8 @@ UniversePartitioner::UniversePartitioner(const Universe& univ) } } -const std::vector& -UniversePartitioner::get_cells(Position r, Direction u) const +const vector& UniversePartitioner::get_cells( + Position r, Direction u) const { // Perform a binary search for the partition containing the given coordinates. int left = 0; @@ -1175,11 +1176,10 @@ openmc_cell_set_name(int32_t index, const char* name) { return 0; } - -std::unordered_map> -Cell::get_contained_cells() const { - std::unordered_map> contained_cells; - std::vector parent_cells; +std::unordered_map> Cell::get_contained_cells() const +{ + std::unordered_map> contained_cells; + vector parent_cells; // if this cell is filled w/ a material, it contains no other cells if (type_ != Fill::MATERIAL) { @@ -1190,9 +1190,9 @@ Cell::get_contained_cells() const { } //! Get all cells within this cell -void -Cell::get_contained_cells_inner(std::unordered_map>& contained_cells, - std::vector& parent_cells) const +void Cell::get_contained_cells_inner( + std::unordered_map>& contained_cells, + vector& parent_cells) const { // filled by material, determine instance based on parent cells diff --git a/src/cmfd_solver.cpp b/src/cmfd_solver.cpp index ab6283662..4efc515ad 100644 --- a/src/cmfd_solver.cpp +++ b/src/cmfd_solver.cpp @@ -1,6 +1,5 @@ #include "openmc/cmfd_solver.h" -#include #include #ifdef _OPENMP @@ -9,14 +8,15 @@ #include "xtensor/xtensor.hpp" #include "openmc/bank.h" -#include "openmc/error.h" -#include "openmc/constants.h" #include "openmc/capi.h" +#include "openmc/constants.h" +#include "openmc/error.h" #include "openmc/mesh.h" #include "openmc/message_passing.h" #include "openmc/tallies/filter_energy.h" #include "openmc/tallies/filter_mesh.h" #include "openmc/tallies/tally.h" +#include "openmc/vector.h" namespace openmc { @@ -26,9 +26,9 @@ namespace cmfd { // Global variables //============================================================================== -std::vector indptr; +vector indptr; -std::vector indices; +vector indices; int dim; @@ -42,7 +42,7 @@ int use_all_threads; StructuredMesh* mesh; -std::vector egrid; +vector egrid; double norm; @@ -83,7 +83,7 @@ xt::xtensor count_bank_sites(xt::xtensor& bins, bool* outside { // Determine shape of array for counts std::size_t cnt_size = cmfd::nx * cmfd::ny * cmfd::nz * cmfd::ng; - std::vector cnt_shape = {cnt_size}; + vector cnt_shape = {cnt_size}; // Create array of zeros xt::xarray cnt {cnt_shape, 0.0}; @@ -299,7 +299,7 @@ int cmfd_linsolver_1g(const double* A_data, const double* b, double* x, double err = 0.0; // Copy over x vector - std::vector tmpx {x, x+cmfd::dim}; + vector tmpx {x, x + cmfd::dim}; // Perform red/black Gauss-Seidel iterations for (int irb = 0; irb < 2; irb++) { @@ -366,7 +366,7 @@ int cmfd_linsolver_2g(const double* A_data, const double* b, double* x, double err = 0.0; // Copy over x vector - std::vector tmpx {x, x+cmfd::dim}; + vector tmpx {x, x + cmfd::dim}; // Perform red/black Gauss-Seidel iterations for (int irb = 0; irb < 2; irb++) { @@ -458,7 +458,7 @@ int cmfd_linsolver_ng(const double* A_data, const double* b, double* x, double err = 0.0; // Copy over x vector - std::vector tmpx {x, x+cmfd::dim}; + vector tmpx {x, x + cmfd::dim}; // Loop around matrix rows for (int irow = 0; irow < cmfd::dim; irow++) { @@ -554,7 +554,7 @@ int openmc_run_linsolver(const double* A_data, const double* b, double* x, void free_memory_cmfd() { - // Clear std::vectors + // Clear vectors cmfd::indptr.clear(); cmfd::indices.clear(); cmfd::egrid.clear(); diff --git a/src/cross_sections.cpp b/src/cross_sections.cpp index dc071cbac..53cb0a0da 100644 --- a/src/cross_sections.cpp +++ b/src/cross_sections.cpp @@ -37,8 +37,7 @@ namespace openmc { namespace data { std::map library_map; -std::vector libraries; - +vector libraries; } //============================================================================== @@ -182,16 +181,15 @@ void read_cross_sections_xml() } } -void -read_ce_cross_sections(const std::vector>& nuc_temps, - const std::vector>& thermal_temps) +void read_ce_cross_sections(const vector>& nuc_temps, + const vector>& thermal_temps) { std::unordered_set already_read; // Construct a vector of nuclide names because we haven't loaded nuclide data // yet, but we need to know the name of the i-th nuclide - std::vector nuclide_names(data::nuclide_map.size()); - std::vector thermal_names(data::thermal_scatt_map.size()); + vector nuclide_names(data::nuclide_map.size()); + vector thermal_names(data::thermal_scatt_map.size()); for (const auto& kv : data::nuclide_map) { nuclide_names[kv.second] = kv.first; } diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 5939f3f40..74d5a56bd 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -183,7 +183,7 @@ void load_dagmc_geometry() dagmcMetaData DMD(model::DAG, false, false); DMD.load_property_data(); - std::vector keywords {"temp"}; + vector keywords {"temp"}; std::map dum; std::string delimiters = ":/"; rval = model::DAG->parse_properties(keywords, dum, delimiters.c_str()); diff --git a/src/distribution_angle.cpp b/src/distribution_angle.cpp index 970ea9040..13e8c480f 100644 --- a/src/distribution_angle.cpp +++ b/src/distribution_angle.cpp @@ -1,7 +1,6 @@ #include "openmc/distribution_angle.h" #include // for abs, copysign -#include // for vector #include "xtensor/xarray.hpp" #include "xtensor/xview.hpp" @@ -10,6 +9,7 @@ #include "openmc/hdf5_interface.h" #include "openmc/random_lcg.h" #include "openmc/search.h" +#include "openmc/vector.h" // for vector namespace openmc { @@ -24,8 +24,8 @@ AngleDistribution::AngleDistribution(hid_t group) int n_energy = energy_.size(); // Get outgoing energy distribution data - std::vector offsets; - std::vector interp; + vector offsets; + vector interp; hid_t dset = open_dataset(group, "mu"); read_attribute(dset, "offsets", offsets); read_attribute(dset, "interpolation", interp); @@ -47,9 +47,9 @@ AngleDistribution::AngleDistribution(hid_t group) auto xs = xt::view(temp, 0, xt::range(j, j+n)); auto ps = xt::view(temp, 1, xt::range(j, j+n)); auto cs = xt::view(temp, 2, xt::range(j, j+n)); - std::vector x {xs.begin(), xs.end()}; - std::vector p {ps.begin(), ps.end()}; - std::vector c {cs.begin(), cs.end()}; + vector x {xs.begin(), xs.end()}; + vector p {ps.begin(), ps.end()}; + vector c {cs.begin(), cs.end()}; // To get answers that match ACE data, for now we still use the tabulated // CDF values that were passed through to the HDF5 library. At a later diff --git a/src/distribution_energy.cpp b/src/distribution_energy.cpp index 7b32e9e4f..425a681bd 100644 --- a/src/distribution_energy.cpp +++ b/src/distribution_energy.cpp @@ -77,9 +77,9 @@ ContinuousTabular::ContinuousTabular(hid_t group) // Get outgoing energy distribution data dset = open_dataset(group, "distribution"); - std::vector offsets; - std::vector interp; - std::vector n_discrete; + vector offsets; + vector interp; + vector n_discrete; read_attribute(dset, "offsets", offsets); read_attribute(dset, "interpolation", interp); read_attribute(dset, "n_discrete_lines", n_discrete); diff --git a/src/eigenvalue.cpp b/src/eigenvalue.cpp index fd1f9bf43..fbd3eceb9 100644 --- a/src/eigenvalue.cpp +++ b/src/eigenvalue.cpp @@ -5,6 +5,7 @@ #include "xtensor/xtensor.hpp" #include "xtensor/xview.hpp" +#include "openmc/array.h" #include "openmc/bank.h" #include "openmc/capi.h" #include "openmc/constants.h" @@ -17,11 +18,10 @@ #include "openmc/search.h" #include "openmc/settings.h" #include "openmc/simulation.h" -#include "openmc/timer.h" #include "openmc/tallies/tally.h" +#include "openmc/timer.h" #include // for min -#include #include // for sqrt, abs, pow #include // for back_inserter #include @@ -36,8 +36,8 @@ namespace openmc { namespace simulation { double keff_generation; -std::array k_sum; -std::vector entropy; +array k_sum; +vector entropy; xt::xtensor source_frac; } // namespace simulation @@ -137,7 +137,7 @@ void synchronize_bank() // Allocate temporary source bank -- we don't really know how many fission // sites were created, so overallocate by a factor of 3 int64_t index_temp = 0; - std::vector temp_sites(3 * simulation::work_per_rank); + vector temp_sites(3 * simulation::work_per_rank); for (int64_t i = 0; i < simulation::fission_bank.size(); i++ ) { const auto& site = simulation::fission_bank[i]; @@ -214,7 +214,7 @@ void synchronize_bank() // SEND BANK SITES TO NEIGHBORS int64_t index_local = 0; - std::vector requests; + vector requests; if (start < settings::n_particles) { // Determine the index of the processor which has the first part of the @@ -372,7 +372,7 @@ int openmc_get_keff(double* k_combined) // Copy estimates of k-effective and its variance (not variance of the mean) const auto& gt = simulation::global_tallies; - std::array kv {}; + array kv {}; xt::xtensor cov = xt::zeros({3, 3}); kv[0] = gt(GlobalTally::K_COLLISION, TallyResult::SUM) / n; kv[1] = gt(GlobalTally::K_ABSORPTION, TallyResult::SUM) / n; @@ -427,7 +427,7 @@ int openmc_get_keff(double* k_combined) // Initialize variables double g = 0.0; - std::array S {}; + array S {}; for (int l = 0; l < 3; ++l) { // Permutations of estimates @@ -601,7 +601,7 @@ void write_eigenvalue_hdf5(hid_t group) write_dataset(group, "k_col_abs", simulation::k_col_abs); write_dataset(group, "k_col_tra", simulation::k_col_tra); write_dataset(group, "k_abs_tra", simulation::k_abs_tra); - std::array k_combined; + array k_combined; openmc_get_keff(k_combined.data()); write_dataset(group, "k_combined", k_combined); } diff --git a/src/endf.cpp b/src/endf.cpp index 99afe39fc..53df401c9 100644 --- a/src/endf.cpp +++ b/src/endf.cpp @@ -1,7 +1,6 @@ #include "openmc/endf.h" #include // for copy -#include #include // for log, exp #include // for back_inserter #include // for runtime_error @@ -9,6 +8,7 @@ #include "xtensor/xarray.hpp" #include "xtensor/xview.hpp" +#include "openmc/array.h" #include "openmc/constants.h" #include "openmc/hdf5_interface.h" #include "openmc/search.h" @@ -77,13 +77,12 @@ bool is_inelastic_scatter(int mt) } } -std::unique_ptr -read_function(hid_t group, const char* name) +unique_ptr read_function(hid_t group, const char* name) { hid_t dset = open_dataset(group, name); std::string func_type; read_attribute(dset, "type", func_type); - std::unique_ptr func; + unique_ptr func; if (func_type == "Tabulated1D") { func = std::make_unique(dset); } else if (func_type == "Polynomial") { @@ -133,7 +132,7 @@ Tabulated1D::Tabulated1D(hid_t dset) // Change 1-indexing to 0-indexing for (auto& b : nbt_) --b; - std::vector int_temp; + vector int_temp; read_attribute(dset, "interpolation", int_temp); // Convert vector of ints into Interpolation @@ -245,7 +244,7 @@ double CoherentElasticXS::operator()(double E) const IncoherentElasticXS::IncoherentElasticXS(hid_t dset) { - std::array tmp; + array tmp; read_dataset(dset, nullptr, tmp); bound_xs_ = tmp[0]; debye_waller_ = tmp[1]; diff --git a/src/event.cpp b/src/event.cpp index 6072a7712..895b1d62e 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -17,7 +17,7 @@ SharedArray advance_particle_queue; SharedArray surface_crossing_queue; SharedArray collision_queue; -std::vector particles; +vector particles; } // namespace simulation diff --git a/src/geometry.cpp b/src/geometry.cpp index 7103b0a5f..496c510d3 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -1,10 +1,9 @@ #include "openmc/geometry.h" -#include - #include #include +#include "openmc/array.h" #include "openmc/cell.h" #include "openmc/constants.h" #include "openmc/error.h" @@ -27,7 +26,7 @@ namespace model { int root_universe {-1}; int n_coord_levels; -std::vector overlap_check_count; +vector overlap_check_count; } // namespace model @@ -371,7 +370,7 @@ BoundaryInfo distance_to_boundary(Particle& p) double d_lat = INFINITY; double d_surf = INFINITY; int32_t level_surf_cross; - std::array level_lat_trans {}; + array level_lat_trans {}; // Loop over each coordinate level. for (int i = 0; i < p.n_coord(); i++) { @@ -391,7 +390,7 @@ BoundaryInfo distance_to_boundary(Particle& p) std::array i_xyz {coord.lattice_x, coord.lattice_y, coord.lattice_z}; //TODO: refactor so both lattice use the same position argument (which //also means the lat.type attribute can be removed) - std::pair> lattice_distance; + std::pair> lattice_distance; switch (lat.type_) { case LatticeType::rect: lattice_distance = lat.distance(r, u, i_xyz); diff --git a/src/geometry_aux.cpp b/src/geometry_aux.cpp index e2b079ba7..c3170922f 100644 --- a/src/geometry_aux.cpp +++ b/src/geometry_aux.cpp @@ -191,9 +191,8 @@ assign_temperatures() //============================================================================== -void -get_temperatures(std::vector>& nuc_temps, - std::vector>& thermal_temps) +void get_temperatures(vector>& nuc_temps, + vector>& thermal_temps) { for (const auto& cell : model::cells) { // Skip non-material cells. @@ -205,7 +204,7 @@ get_temperatures(std::vector>& nuc_temps, if (i_material == MATERIAL_VOID) continue; // Get temperature(s) of cell (rounding to nearest integer) - std::vector cell_temps; + vector cell_temps; if (cell->sqrtkT_.size() == 1) { double sqrtkT = cell->sqrtkT_[0]; cell_temps.push_back(sqrtkT*sqrtkT / K_BOLTZMANN); @@ -351,7 +350,7 @@ prepare_distribcell() // Search through universes for material cells and assign each one a // unique distribcell array index. int distribcell_index = 0; - std::vector target_univ_ids; + vector target_univ_ids; for (const auto& u : model::universes) { for (auto idx : u->cells_) { if (distribcells.find(idx) != distribcells.end()) { @@ -495,8 +494,8 @@ distribcell_path_inner(int32_t target_cell, int32_t map, int32_t target_offset, // The target must be further down the geometry tree and contained in a fill // cell or lattice cell in this universe. Find which cell contains the // target. - std::vector::const_reverse_iterator cell_it - {search_univ.cells_.crbegin()}; + vector::const_reverse_iterator cell_it { + search_univ.cells_.crbegin()}; for (; cell_it != search_univ.cells_.crend(); ++cell_it) { Cell& c = *model::cells[*cell_it]; diff --git a/src/hdf5_interface.cpp b/src/hdf5_interface.cpp index 1fcc97f3c..0f8db2dc5 100644 --- a/src/hdf5_interface.cpp +++ b/src/hdf5_interface.cpp @@ -1,6 +1,5 @@ #include "openmc/hdf5_interface.h" -#include #include #include #include @@ -16,6 +15,7 @@ #include "openmc/message_passing.h" #endif +#include "openmc/array.h" namespace openmc { @@ -56,16 +56,15 @@ get_shape(hid_t obj_id, hsize_t* dims) H5Sclose(dspace); } - -std::vector attribute_shape(hid_t obj_id, const char* name) +vector attribute_shape(hid_t obj_id, const char* name) { hid_t attr = H5Aopen(obj_id, name, H5P_DEFAULT); - std::vector shape = object_shape(attr); + vector shape = object_shape(attr); H5Aclose(attr); return shape; } -std::vector object_shape(hid_t obj_id) +vector object_shape(hid_t obj_id) { // Get number of dimensions auto type = H5Iget_type(obj_id); @@ -81,7 +80,7 @@ std::vector object_shape(hid_t obj_id) int n = H5Sget_simple_extent_ndims(dspace); // Get shape of array - std::vector shape(n); + vector shape(n); H5Sget_simple_extent_dims(dspace, shape.data(), nullptr); // Free resources and return @@ -337,8 +336,7 @@ get_groups(hid_t group_id, char* name[]) } } -std::vector -member_names(hid_t group_id, H5O_type_t type) +vector member_names(hid_t group_id, H5O_type_t type) { // Determine number of links in the group H5G_info_t info; @@ -347,7 +345,7 @@ member_names(hid_t group_id, H5O_type_t type) // Iterate over links to get names H5O_info_t oinfo; size_t size; - std::vector names; + vector names; for (hsize_t i = 0; i < info.nlinks; ++i) { // Determine type of object (and skip non-group) H5Oget_info_by_idx(group_id, ".", H5_INDEX_NAME, H5_ITER_INC, i, &oinfo, @@ -368,14 +366,12 @@ member_names(hid_t group_id, H5O_type_t type) return names; } -std::vector -group_names(hid_t group_id) +vector group_names(hid_t group_id) { return member_names(group_id, H5O_TYPE_GROUP); } -std::vector -dataset_names(hid_t group_id) +vector dataset_names(hid_t group_id) { return member_names(group_id, H5O_TYPE_DATASET); } @@ -492,13 +488,13 @@ template<> void read_dataset(hid_t dset, xt::xarray>& arr, bool indep) { // Get shape of dataset - std::vector shape = object_shape(dset); + vector shape = object_shape(dset); // Allocate new array to read data into std::size_t size = 1; for (const auto x : shape) size *= x; - std::vector> buffer(size); + vector> buffer(size); // Read data from attribute read_complex(dset, nullptr, buffer.data(), indep); diff --git a/src/initialize.cpp b/src/initialize.cpp index 1a1e7b2ab..239834c4e 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -3,9 +3,7 @@ #include #include // for getenv #include -#include #include -#include #ifdef _OPENMP #include @@ -19,6 +17,7 @@ #include "openmc/geometry_aux.h" #include "openmc/hdf5_interface.h" #include "openmc/material.h" +#include "openmc/memory.h" #include "openmc/message_passing.h" #include "openmc/mgxs_interface.h" #include "openmc/nuclide.h" @@ -32,6 +31,7 @@ #include "openmc/tallies/tally.h" #include "openmc/thermal.h" #include "openmc/timer.h" +#include "openmc/vector.h" #ifdef LIBMESH #include "libmesh/libmesh.h" diff --git a/src/lattice.cpp b/src/lattice.cpp index 5301f3d14..37d69b3e9 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -2,7 +2,6 @@ #include #include -#include #include @@ -12,9 +11,9 @@ #include "openmc/geometry_aux.h" #include "openmc/hdf5_interface.h" #include "openmc/string_utils.h" +#include "openmc/vector.h" #include "openmc/xml_interface.h" - namespace openmc { //============================================================================== @@ -23,7 +22,7 @@ namespace openmc { namespace model { std::unordered_map lattice_map; - std::vector> lattices; + vector> lattices; } //============================================================================== @@ -142,7 +141,7 @@ RectLattice::RectLattice(pugi::xml_node lat_node) // Read the number of lattice cells in each dimension. std::string dimension_str {get_node_value(lat_node, "dimension")}; - std::vector dimension_words {split(dimension_str)}; + vector dimension_words {split(dimension_str)}; if (dimension_words.size() == 2) { n_cells_[0] = std::stoi(dimension_words[0]); n_cells_[1] = std::stoi(dimension_words[1]); @@ -159,7 +158,7 @@ RectLattice::RectLattice(pugi::xml_node lat_node) // Read the lattice lower-left location. std::string ll_str {get_node_value(lat_node, "lower_left")}; - std::vector ll_words {split(ll_str)}; + vector ll_words {split(ll_str)}; if (ll_words.size() != dimension_words.size()) { fatal_error("Number of entries on must be the same as the " "number of entries on ."); @@ -170,7 +169,7 @@ RectLattice::RectLattice(pugi::xml_node lat_node) // Read the lattice pitches. std::string pitch_str {get_node_value(lat_node, "pitch")}; - std::vector pitch_words {split(pitch_str)}; + vector pitch_words {split(pitch_str)}; if (pitch_words.size() != dimension_words.size()) { fatal_error("Number of entries on must be the same as the " "number of entries on ."); @@ -181,8 +180,8 @@ RectLattice::RectLattice(pugi::xml_node lat_node) // Read the universes and make sure the correct number was specified. std::string univ_str {get_node_value(lat_node, "universes")}; - std::vector univ_words {split(univ_str)}; - if (univ_words.size() != nx*ny*nz) { + vector univ_words {split(univ_str)}; + if (univ_words.size() != n_cells_[0] * n_cells_[1] * n_cells_[2]) { fatal_error(fmt::format( "Expected {} universes for a rectangular lattice of size {}x{}x{} but {} " "were specified.", nx*ny*nz, nx, ny, nz, univ_words.size())); @@ -222,9 +221,8 @@ RectLattice::are_valid_indices(const int i_xyz[3]) const //============================================================================== -std::pair> -RectLattice::distance(Position r, Direction u, const std::array& i_xyz) -const +std::pair> RectLattice::distance( + Position r, Direction u, const array& i_xyz) const { // Get short aliases to the coordinates. double x = r.x; @@ -237,7 +235,7 @@ const // Left and right sides double d {INFTY}; - std::array lattice_trans; + array lattice_trans; if ((std::abs(x - x0) > FP_PRECISION) && u.x != 0) { d = (x0 - x) / u.x; if (u.x > 0) { @@ -378,11 +376,11 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const write_dataset(lat_group, "lower_left", lower_left_); write_dataset(lat_group, "dimension", n_cells_); } else { - std::array pitch_short {{pitch_[0], pitch_[1]}}; + array pitch_short {{pitch_[0], pitch_[1]}}; write_dataset(lat_group, "pitch", pitch_short); - std::array ll_short {{lower_left_[0], lower_left_[1]}}; + array ll_short {{lower_left_[0], lower_left_[1]}}; write_dataset(lat_group, "lower_left", ll_short); - std::array nc_short {{n_cells_[0], n_cells_[1]}}; + array nc_short {{n_cells_[0], n_cells_[1]}}; write_dataset(lat_group, "dimension", nc_short); } @@ -392,7 +390,7 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const hsize_t nx {static_cast(n_cells_[0])}; hsize_t ny {static_cast(n_cells_[1])}; hsize_t nz {static_cast(n_cells_[2])}; - std::vector out(nx*ny*nz); + vector out(nx * ny * nz); for (int m = 0; m < nz; m++) { for (int k = 0; k < ny; k++) { @@ -410,7 +408,7 @@ RectLattice::to_hdf5_inner(hid_t lat_group) const } else { hsize_t nx {static_cast(n_cells_[0])}; hsize_t ny {static_cast(n_cells_[1])}; - std::vector out(nx*ny); + vector out(nx * ny); for (int k = 0; k < ny; k++) { for (int j = 0; j < nx; j++) { @@ -461,7 +459,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node) // Read the lattice center. std::string center_str {get_node_value(lat_node, "center")}; - std::vector center_words {split(center_str)}; + vector center_words {split(center_str)}; if (is_3d_ && (center_words.size() != 3)) { fatal_error("A hexagonal lattice with must have
" "specified by 3 numbers."); @@ -475,7 +473,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node) // Read the lattice pitches. std::string pitch_str {get_node_value(lat_node, "pitch")}; - std::vector pitch_words {split(pitch_str)}; + vector pitch_words {split(pitch_str)}; if (is_3d_ && (pitch_words.size() != 2)) { fatal_error("A hexagonal lattice with must have " "specified by 2 numbers."); @@ -489,7 +487,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node) // Read the universes and make sure the correct number was specified. int n_univ = (3*n_rings_*n_rings_ - 3*n_rings_ + 1) * n_axial_; std::string univ_str {get_node_value(lat_node, "universes")}; - std::vector univ_words {split(univ_str)}; + vector univ_words {split(univ_str)}; if (univ_words.size() != n_univ) { fatal_error(fmt::format( "Expected {} universes for a hexagonal lattice with {} rings and {} " @@ -516,8 +514,7 @@ HexLattice::HexLattice(pugi::xml_node lat_node) //============================================================================== -void -HexLattice::fill_lattice_x(const std::vector& univ_words) +void HexLattice::fill_lattice_x(const vector& univ_words) { int input_index = 0; for (int m = 0; m < n_axial_; m++) { @@ -569,8 +566,7 @@ HexLattice::fill_lattice_x(const std::vector& univ_words) //============================================================================== -void -HexLattice::fill_lattice_y(const std::vector& univ_words) +void HexLattice::fill_lattice_y(const vector& univ_words) { int input_index = 0; for (int m = 0; m < n_axial_; m++) { @@ -689,9 +685,8 @@ HexLattice::are_valid_indices(const int i_xyz[3]) const //============================================================================== -std::pair> -HexLattice::distance(Position r, Direction u, const std::array& i_xyz) -const +std::pair> HexLattice::distance( + Position r, Direction u, const array& i_xyz) const { // Short description of the direction vectors used here. The beta, gamma, and // delta vectors point towards the flat sides of each hexagonal tile. @@ -729,14 +724,14 @@ const // beta direction double d {INFTY}; - std::array lattice_trans; + array lattice_trans; double edge = -copysign(0.5*pitch_[0], beta_dir); // Oncoming edge Position r_t; if (beta_dir > 0) { - const std::array i_xyz_t {i_xyz[0]+1, i_xyz[1], i_xyz[2]}; + const array i_xyz_t {i_xyz[0] + 1, i_xyz[1], i_xyz[2]}; r_t = get_local_position(r, i_xyz_t); } else { - const std::array i_xyz_t {i_xyz[0]-1, i_xyz[1], i_xyz[2]}; + const array i_xyz_t {i_xyz[0] - 1, i_xyz[1], i_xyz[2]}; r_t = get_local_position(r, i_xyz_t); } double beta; @@ -757,10 +752,10 @@ const // gamma direction edge = -copysign(0.5*pitch_[0], gamma_dir); if (gamma_dir > 0) { - const std::array i_xyz_t {i_xyz[0]+1, i_xyz[1]-1, i_xyz[2]}; + const array i_xyz_t {i_xyz[0] + 1, i_xyz[1] - 1, i_xyz[2]}; r_t = get_local_position(r, i_xyz_t); } else { - const std::array i_xyz_t {i_xyz[0]-1, i_xyz[1]+1, i_xyz[2]}; + const array i_xyz_t {i_xyz[0] - 1, i_xyz[1] + 1, i_xyz[2]}; r_t = get_local_position(r, i_xyz_t); } double gamma; @@ -784,10 +779,10 @@ const // delta direction edge = -copysign(0.5*pitch_[0], delta_dir); if (delta_dir > 0) { - const std::array i_xyz_t {i_xyz[0], i_xyz[1]+1, i_xyz[2]}; + const array i_xyz_t {i_xyz[0], i_xyz[1] + 1, i_xyz[2]}; r_t = get_local_position(r, i_xyz_t); } else { - const std::array i_xyz_t {i_xyz[0], i_xyz[1]-1, i_xyz[2]}; + const array i_xyz_t {i_xyz[0], i_xyz[1] - 1, i_xyz[2]}; r_t = get_local_position(r, i_xyz_t); } double delta; @@ -1028,9 +1023,9 @@ HexLattice::to_hdf5_inner(hid_t lat_group) const write_dataset(lat_group, "pitch", pitch_); write_dataset(lat_group, "center", center_); } else { - std::array pitch_short {{pitch_[0]}}; + array pitch_short {{pitch_[0]}}; write_dataset(lat_group, "pitch", pitch_short); - std::array center_short {{center_[0], center_[1]}}; + array center_short {{center_[0], center_[1]}}; write_dataset(lat_group, "center", center_short); } @@ -1038,7 +1033,7 @@ HexLattice::to_hdf5_inner(hid_t lat_group) const hsize_t nx {static_cast(2*n_rings_ - 1)}; hsize_t ny {static_cast(2*n_rings_ - 1)}; hsize_t nz {static_cast(n_axial_)}; - std::vector out(nx*ny*nz); + vector out(nx * ny * nz); for (int m = 0; m < nz; m++) { for (int k = 0; k < ny; k++) { diff --git a/src/material.cpp b/src/material.cpp index 89103e4c2..80c6de3c1 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -39,7 +39,7 @@ namespace openmc { namespace model { std::unordered_map material_map; -std::vector> materials; +vector> materials; } // namespace model @@ -127,8 +127,8 @@ Material::Material(pugi::xml_node node) auto node_macros = node.children("macroscopic"); int num_macros = std::distance(node_macros.begin(), node_macros.end()); - std::vector names; - std::vector densities; + vector names; + vector densities; if (settings::run_CE && num_macros > 0) { fatal_error("Macroscopic can not be used in continuous-energy mode."); } else if (num_macros > 1) { @@ -194,7 +194,7 @@ Material::Material(pugi::xml_node node) // ======================================================================= // READ AND PARSE element - std::vector iso_lab; + vector iso_lab; if (check_for_node(node, "isotropic")) { iso_lab = get_node_array(node, "isotropic"); } @@ -295,7 +295,7 @@ Material::Material(pugi::xml_node node) if (settings::run_CE) { // Loop over elements - std::vector sab_names; + vector sab_names; for (auto node_sab : node.children("sab")) { // Determine name of thermal scattering table if (!check_for_node(node_sab, "name")) { @@ -413,7 +413,7 @@ void Material::normalize_density() void Material::init_thermal() { - std::vector tables; + vector tables; std::unordered_set already_checked; for (const auto& table : thermal_tables_) { @@ -481,8 +481,8 @@ void Material::collision_stopping_power(double* s_col, bool positron) // Oscillator strength and square of the binding energy for each oscillator // in material - std::vector f; - std::vector e_b_sq; + vector f; + vector e_b_sq; for (int i = 0; i < element_.size(); ++i) { const auto& elm = *data::elements[element_[i]]; @@ -936,8 +936,8 @@ void Material::set_density(double density, gsl::cstring_span units) } } -void Material::set_densities(const std::vector& name, - const std::vector& density) +void Material::set_densities( + const vector& name, const vector& density) { auto n = name.size(); Expects(n > 0); @@ -1010,9 +1010,9 @@ void Material::to_hdf5(hid_t group) const write_dataset(material_group, "atom_density", density_); // Copy nuclide/macro name for each nuclide to vector - std::vector nuc_names; - std::vector macro_names; - std::vector nuc_densities; + vector nuc_names; + vector macro_names; + vector nuc_densities; if (settings::run_CE) { for (int i = 0; i < nuclide_.size(); ++i) { int i_nuc = nuclide_[i]; @@ -1043,7 +1043,7 @@ void Material::to_hdf5(hid_t group) const } if (!thermal_tables_.empty()) { - std::vector sab_names; + vector sab_names; for (const auto& table : thermal_tables_) { sab_names.push_back(data::thermal_scatt[table.index_table]->name_); } @@ -1099,9 +1099,9 @@ void Material::add_nuclide(const std::string& name, double density) // Non-method functions //============================================================================== -double sternheimer_adjustment(const std::vector& f, const - std::vector& e_b_sq, double e_p_sq, double n_conduction, double - log_I, double tol, int max_iter) +double sternheimer_adjustment(const vector& f, + const vector& e_b_sq, double e_p_sq, double n_conduction, + double log_I, double tol, int max_iter) { // Get the total number of oscillators int n = f.size(); @@ -1144,9 +1144,9 @@ double sternheimer_adjustment(const std::vector& f, const return rho; } -double density_effect(const std::vector& f, const std::vector& - e_b_sq, double e_p_sq, double n_conduction, double rho, double E, double tol, - int max_iter) +double density_effect(const vector& f, + const std::vector& e_b_sq, double e_p_sq, double n_conduction, + double rho, double E, double tol, int max_iter) { // Get the total number of oscillators int n = f.size(); diff --git a/src/math_functions.cpp b/src/math_functions.cpp index ac60c6ce0..bff3fd0f9 100644 --- a/src/math_functions.cpp +++ b/src/math_functions.cpp @@ -537,8 +537,8 @@ void calc_zn(int n, double rho, double phi, double zn[]) { double sin_phi = std::sin(phi); double cos_phi = std::cos(phi); - std::vector sin_phi_vec(n + 1); // Sin[n * phi] - std::vector cos_phi_vec(n + 1); // Cos[n * phi] + vector sin_phi_vec(n + 1); // Sin[n * phi] + vector cos_phi_vec(n + 1); // Cos[n * phi] sin_phi_vec[0] = 1.0; cos_phi_vec[0] = 1.0; sin_phi_vec[1] = 2.0 * cos_phi; @@ -556,7 +556,7 @@ void calc_zn(int n, double rho, double phi, double zn[]) { // =========================================================================== // Calculate R_pq(rho) // Matrix forms of the coefficients which are easier to work with - std::vector> zn_mat(n + 1, std::vector(n + 1)); + vector> zn_mat(n + 1, std::vector(n + 1)); // Fill the main diagonal first (Eq 3.9 in Chong) for (int p = 0; p <= n; p++) { @@ -720,7 +720,7 @@ double watt_spectrum(double a, double b, uint64_t* seed) { void spline(int n, const double x[], const double y[], double z[]) { - std::vector c_new(n-1); + vector c_new(n - 1); // Set natural boundary conditions c_new[0] = 0.0; diff --git a/src/mesh.cpp b/src/mesh.cpp index d6cadf12f..a179dfcea 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -2,7 +2,6 @@ #include // for copy, equal, min, min_element #include // for size_t #include // for ceil -#include // for allocator #include #include @@ -25,11 +24,12 @@ #include "openmc/error.h" #include "openmc/file_utils.h" #include "openmc/hdf5_interface.h" +#include "openmc/memory.h" #include "openmc/message_passing.h" #include "openmc/search.h" #include "openmc/settings.h" -#include "openmc/tallies/tally.h" #include "openmc/tallies/filter.h" +#include "openmc/tallies/tally.h" #include "openmc/xml_interface.h" #ifdef LIBMESH @@ -53,13 +53,13 @@ const bool LIBMESH_ENABLED = false; namespace model { std::unordered_map mesh_map; -std::vector> meshes; +vector> meshes; } // namespace model #ifdef LIBMESH namespace settings { -std::unique_ptr libmesh_init; +unique_ptr libmesh_init; const libMesh::Parallel::Communicator* libmesh_comm {nullptr}; } #endif @@ -143,7 +143,7 @@ Mesh::set_id(int32_t id) { std::string StructuredMesh::bin_label(int bin) const { - std::vector ijk(n_dimension_); + vector ijk(n_dimension_); get_indices_from_bin(bin, ijk.data()); if (n_dimension_ > 2) { @@ -192,7 +192,7 @@ UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) { void UnstructuredMesh::surface_bins_crossed(Position r0, Position r1, - std::vector& bins) const { + vector& bins) const { fatal_error("Unstructured mesh surface tallies are not implemented."); } @@ -210,7 +210,7 @@ UnstructuredMesh::to_hdf5(hid_t group) const write_dataset(mesh_group, "filename", filename_); write_dataset(mesh_group, "library", this->library()); // write volume of each element - std::vector tet_vols; + vector tet_vols; xt::xtensor centroids({static_cast(this->n_bins()), 3}); for (int i = 0; i < this->n_bins(); i++) { tet_vols.emplace_back(this->volume(i)); @@ -264,7 +264,7 @@ void StructuredMesh::get_indices_from_bin(int bin, int* ijk) const int StructuredMesh::get_bin(Position r) const { // Determine indices - std::vector ijk(n_dimension_); + vector ijk(n_dimension_); bool in_mesh; get_indices(r, ijk.data(), &in_mesh); if (!in_mesh) return -1; @@ -288,7 +288,7 @@ xt::xtensor StructuredMesh::count_sites( { // Determine shape of array for counts std::size_t m = this->n_bins(); - std::vector shape = {m}; + vector shape = {m}; // Create array of zeros xt::xarray cnt {shape, 0.0}; @@ -583,8 +583,8 @@ bool StructuredMesh::intersects_3d(Position& r0, Position r1, int* ijk) const void StructuredMesh::bins_crossed(Position r0, Position r1, const Direction& u, - std::vector& bins, - std::vector& lengths) const + vector& bins, + vector& lengths) const { // ======================================================================== // Determine where the track intersects the mesh and if it intersects at all. @@ -600,7 +600,7 @@ void StructuredMesh::bins_crossed(Position r0, Position r = r1 - TINY_BIT*u; // Determine the mesh indices for the starting and ending coords. Here, we - // use arrays for ijk0 and ijk1 instead of std::vector because we obtain a + // use arrays for ijk0 and ijk1 instead of vector because we obtain a // small performance improvement by forcing this data to live on the stack, // rather than on the heap. We know the maximum length is 3, and by // ensuring that all loops are only indexed up to n_dimension, we will not @@ -798,11 +798,11 @@ void RegularMesh::surface_bins_crossed(Position r0, Position r1, const Direction& u, - std::vector& bins) const + vector& bins) const { // Determine indices for starting and ending location. int n = n_dimension_; - std::vector ijk0(n), ijk1(n); + vector ijk0(n), ijk1(n); bool start_in_mesh; get_indices(r0, ijk0.data(), &start_in_mesh); bool end_in_mesh; @@ -811,7 +811,7 @@ RegularMesh::surface_bins_crossed(Position r0, // Check if the track intersects any part of the mesh. if (!start_in_mesh) { Position r0_copy = r0; - std::vector ijk0_copy(ijk0); + vector ijk0_copy(ijk0); if (!intersects(r0_copy, r1, ijk0_copy.data())) return; } @@ -938,11 +938,11 @@ RegularMesh::surface_bins_crossed(Position r0, } } -std::pair, std::vector> -RegularMesh::plot(Position plot_ll, Position plot_ur) const +std::pair, std::vector> RegularMesh::plot( + Position plot_ll, Position plot_ur) const { // Figure out which axes lie in the plane of the plot. - std::array axes {-1, -1}; + array axes {-1, -1}; if (plot_ur.z == plot_ll.z) { axes[0] = 0; if (n_dimension_ > 1) axes[1] = 1; @@ -957,7 +957,7 @@ RegularMesh::plot(Position plot_ll, Position plot_ur) const } // Get the coordinates of the mesh lines along both of the axes. - std::array, 2> axis_lines; + array, 2> axis_lines; for (int i_ax = 0; i_ax < 2; ++i_ax) { int axis = axes[i_ax]; if (axis == -1) continue; @@ -992,7 +992,7 @@ xt::xtensor RegularMesh::count_sites( { // Determine shape of array for counts std::size_t m = this->n_bins(); - std::vector shape = {m}; + vector shape = {m}; // Create array of zeros xt::xarray cnt {shape, 0.0}; @@ -1100,7 +1100,7 @@ int RectilinearMesh::set_grid() void RectilinearMesh::surface_bins_crossed(Position r0, Position r1, const Direction& u, - std::vector& bins) const + vector& bins) const { // Determine indices for starting and ending location. int ijk0[3], ijk1[3]; @@ -1264,11 +1264,11 @@ int RectilinearMesh::get_index_in_direction(double r, int i) const return lower_bound_index(grid_[i].begin(), grid_[i].end(), r) + 1; } -std::pair, std::vector> -RectilinearMesh::plot(Position plot_ll, Position plot_ur) const +std::pair, std::vector> RectilinearMesh::plot( + Position plot_ll, Position plot_ur) const { // Figure out which axes lie in the plane of the plot. - std::array axes {-1, -1}; + array axes {-1, -1}; if (plot_ur.z == plot_ll.z) { axes = {0, 1}; } else if (plot_ur.y == plot_ll.y) { @@ -1280,10 +1280,10 @@ RectilinearMesh::plot(Position plot_ll, Position plot_ur) const } // Get the coordinates of the mesh lines along both of the axes. - std::array, 2> axis_lines; + array, 2> axis_lines; for (int i_ax = 0; i_ax < 2; ++i_ax) { int axis = axes[i_ax]; - std::vector& lines {axis_lines[i_ax]}; + vector& lines {axis_lines[i_ax]}; for (auto coord : grid_[axis]) { if (coord >= plot_ll[axis] && coord <= plot_ur[axis]) @@ -1466,7 +1466,7 @@ openmc_regular_mesh_set_dimension(int32_t index, int n, const int* dims) RegularMesh* mesh = dynamic_cast(model::meshes[index].get()); // Copy dimension - std::vector shape = {static_cast(n)}; + vector shape = {static_cast(n)}; mesh->shape_ = xt::adapt(dims, n, xt::no_ownership(), shape); mesh->n_dimension_ = mesh->shape_.size(); return 0; @@ -1500,7 +1500,7 @@ openmc_regular_mesh_set_params(int32_t index, int n, const double* ll, if (int err = check_mesh_type(index)) return err; RegularMesh* m = dynamic_cast(model::meshes[index].get()); - std::vector shape = {static_cast(n)}; + vector shape = {static_cast(n)}; if (ll && ur) { m->lower_left_ = xt::adapt(ll, n, xt::no_ownership(), shape); m->upper_right_ = xt::adapt(ur, n, xt::no_ownership(), shape); @@ -1653,15 +1653,13 @@ MOABMesh::build_kdtree(const moab::Range& all_tets) } } -void -MOABMesh::intersect_track(const moab::CartVect& start, - const moab::CartVect& dir, - double track_len, - std::vector& hits) const { +void MOABMesh::intersect_track(const moab::CartVect& start, + const moab::CartVect& dir, double track_len, vector& hits) const +{ hits.clear(); moab::ErrorCode rval; - std::vector tris; + vector tris; // get all intersections with triangles in the tet mesh // (distances are relative to the start point, not the previous intersection) rval = kdtree_->ray_intersect_triangles(kdtree_root_, @@ -1681,15 +1679,14 @@ MOABMesh::intersect_track(const moab::CartVect& start, // sorts by first component of std::pair by default std::sort(hits.begin(), hits.end()); - } void MOABMesh::bins_crossed(Position r0, Position r1, const Direction& u, - std::vector& bins, - std::vector& lengths) const + vector& bins, + vector& lengths) const { moab::CartVect start(r0.x, r0.y, r0.z); moab::CartVect end(r1.x, r1.y, r1.z); @@ -1702,7 +1699,7 @@ MOABMesh::bins_crossed(Position r0, start -= TINY_BIT * dir; end += TINY_BIT * dir; - std::vector hits; + vector hits; intersect_track(start, dir, track_len, hits); bins.clear(); @@ -1801,7 +1798,7 @@ std::string MOABMesh::library() const double MOABMesh::tet_volume(moab::EntityHandle tet) const { - std::vector conn; + vector conn; moab::ErrorCode rval = mbi_->get_connectivity(&tet, 1, conn); if (rval != moab::MB_SUCCESS) { fatal_error("Failed to get tet connectivity"); @@ -1846,7 +1843,7 @@ MOABMesh::compute_barycentric_data(const moab::Range& tets) { // compute the barycentric data for each tet element // and store it as a 3x3 matrix for (auto& tet : tets) { - std::vector verts; + vector verts; rval = mbi_->get_connectivity(&tet, 1, verts); if (rval != moab::MB_SUCCESS) { fatal_error("Failed to get connectivity of tet on umesh: " + filename_); @@ -1874,7 +1871,7 @@ MOABMesh::point_in_tet(const moab::CartVect& r, moab::ErrorCode rval; // get tet vertices - std::vector verts; + vector verts; rval = mbi_->get_connectivity(&tet, 1, verts); if (rval != moab::MB_SUCCESS) { warning("Failed to get vertices of tet in umesh: " + filename_); @@ -1926,8 +1923,8 @@ int MOABMesh::get_index_from_bin(int bin) const return bin; } -std::pair, std::vector> -MOABMesh::plot(Position plot_ll, Position plot_ur) const +std::pair, std::vector> MOABMesh::plot( + Position plot_ll, Position plot_ur) const { // TODO: Implement mesh lines return {}; @@ -1978,7 +1975,7 @@ MOABMesh::centroid(int bin) const auto tet = this->get_ent_handle_from_bin(bin); // look up the tet connectivity - std::vector conn; + vector conn; rval = mbi_->get_connectivity(&tet, 1, conn); if (rval != moab::MB_SUCCESS) { warning("Failed to get connectivity of a mesh element."); @@ -1986,7 +1983,7 @@ MOABMesh::centroid(int bin) const } // get the coordinates - std::vector coords(conn.size()); + vector coords(conn.size()); rval = mbi_->get_coords(conn.data(), conn.size(), coords[0].array()); if (rval != moab::MB_SUCCESS) { warning("Failed to get the coordinates of a mesh element."); @@ -2085,10 +2082,8 @@ void MOABMesh::remove_scores() tag_names_.clear(); } -void -MOABMesh::set_score_data(const std::string& score, - const std::vector& values, - const std::vector& std_dev) +void MOABMesh::set_score_data(const std::string& score, + const vector& values, const vector& std_dev) { auto score_tags = this->get_score_tags(score); @@ -2259,10 +2254,8 @@ LibMesh::remove_scores() variable_map_.clear(); } -void -LibMesh::set_score_data(const std::string& var_name, - const std::vector& values, - const std::vector& std_dev) +void LibMesh::set_score_data(const std::string& var_name, + const vector& values, const vector& std_dev) { auto& eqn_sys = equation_systems_->get_system(eq_system_name_); @@ -2281,13 +2274,13 @@ LibMesh::set_score_data(const std::string& var_name, auto bin = get_bin_from_element(*it); // set value - std::vector value_dof_indices; + vector value_dof_indices; dof_map.dof_indices(*it, value_dof_indices, value_num); Ensures(value_dof_indices.size() == 1); eqn_sys.solution->set(value_dof_indices[0], values.at(bin)); // set std dev - std::vector std_dev_dof_indices; + vector std_dev_dof_indices; dof_map.dof_indices(*it, std_dev_dof_indices, std_dev_num); Ensures(std_dev_dof_indices.size() == 1); eqn_sys.solution->set(std_dev_dof_indices[0], std_dev.at(bin)); @@ -2306,8 +2299,8 @@ void LibMesh::bins_crossed(Position r0, Position r1, const Direction& u, - std::vector& bins, - std::vector& lengths) const + vector& bins, + vector& lengths) const { // TODO: Implement triangle crossings here fatal_error("Tracklength tallies on libMesh instances are not implemented."); @@ -2344,8 +2337,8 @@ LibMesh::get_bin_from_element(const libMesh::Elem* elem) const return bin; } -std::pair, std::vector> -LibMesh::plot(Position plot_ll, Position plot_ur) const +std::pair, std::vector> LibMesh::plot( + Position plot_ll, Position plot_ur) const { return {}; } @@ -2416,7 +2409,7 @@ void meshes_to_hdf5(hid_t group) if (n_meshes > 0) { // Write IDs of meshes - std::vector ids; + vector ids; for (const auto& m : model::meshes) { m->to_hdf5(meshes_group); ids.push_back(m->id_); diff --git a/src/mgxs.cpp b/src/mgxs.cpp index 02d27f960..21c6b4b3c 100644 --- a/src/mgxs.cpp +++ b/src/mgxs.cpp @@ -29,11 +29,10 @@ namespace openmc { // Mgxs base-class methods //============================================================================== -void -Mgxs::init(const std::string& in_name, double in_awr, - const std::vector& in_kTs, bool in_fissionable, - AngleDistributionType in_scatter_format, bool in_is_isotropic, - const std::vector& in_polar, const std::vector& in_azimuthal) +void Mgxs::init(const std::string& in_name, double in_awr, + const vector& in_kTs, bool in_fissionable, + AngleDistributionType in_scatter_format, bool in_is_isotropic, + const vector& in_polar, const std::vector& in_azimuthal) { // Set the metadata name = in_name; @@ -56,14 +55,13 @@ Mgxs::init(const std::string& in_name, double in_awr, int n_threads = 1; #endif cache.resize(n_threads); - // std::vector.resize() will value-initialize the members of cache[:] + // vector.resize() will value-initialize the members of cache[:] } //============================================================================== -void -Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector& temperature, - std::vector& temps_to_read, int& order_dim) +void Mgxs::metadata_from_hdf5(hid_t xs_id, const vector& temperature, + vector& temps_to_read, int& order_dim) { // get name char char_name[MAX_WORD_LEN]; @@ -88,7 +86,7 @@ Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector& temperature, dset_names[i] = new char[151]; } get_datasets(kT_group, dset_names); - std::vector shape = {num_temps}; + vector shape = {num_temps}; xt::xarray available_temps(shape); for (int i = 0; i < num_temps; i++) { read_double(kT_group, dset_names[i], &available_temps[i], true); @@ -160,7 +158,7 @@ Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector& temperature, // Get the library's temperatures int n_temperature = temps_to_read.size(); - std::vector in_kTs(n_temperature); + vector in_kTs(n_temperature); for (int i = 0; i < n_temperature; i++) { std::string temp_str(std::to_string(temps_to_read[i]) + "K"); @@ -254,12 +252,12 @@ Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector& temperature, } // Set the angular bins to use equally-spaced bins - std::vector in_polar(in_n_pol); + vector in_polar(in_n_pol); double dangle = PI / in_n_pol; for (int p = 0; p < in_n_pol; p++) { in_polar[p] = (p + 0.5) * dangle; } - std::vector in_azimuthal(in_n_azi); + vector in_azimuthal(in_n_azi); dangle = 2. * PI / in_n_azi; for (int a = 0; a < in_n_azi; a++) { in_azimuthal[a] = (a + 0.5) * dangle - PI; @@ -273,14 +271,13 @@ Mgxs::metadata_from_hdf5(hid_t xs_id, const std::vector& temperature, //============================================================================== -Mgxs::Mgxs(hid_t xs_id, const std::vector& temperature, - int num_group, int num_delay) : - num_groups(num_group), - num_delayed_groups(num_delay) +Mgxs::Mgxs( + hid_t xs_id, const vector& temperature, int num_group, int num_delay) + : num_groups(num_group), num_delayed_groups(num_delay) { // Call generic data gathering routine (will populate the metadata) int order_data; - std::vector temps_to_read; + vector temps_to_read; metadata_from_hdf5(xs_id, temperature, temps_to_read, order_data); // Set number of energy and delayed groups @@ -309,11 +306,10 @@ Mgxs::Mgxs(hid_t xs_id, const std::vector& temperature, //============================================================================== -Mgxs::Mgxs(const std::string& in_name, const std::vector& mat_kTs, - const std::vector& micros, const std::vector& atom_densities, - int num_group, int num_delay) : - num_groups(num_group), - num_delayed_groups(num_delay) +Mgxs::Mgxs(const std::string& in_name, const vector& mat_kTs, + const vector& micros, const std::vector& atom_densities, + int num_group, int num_delay) + : num_groups(num_group), num_delayed_groups(num_delay) { // Get the minimum data needed to initialize: // Dont need awr, but lets just initialize it anyways @@ -328,8 +324,8 @@ Mgxs::Mgxs(const std::string& in_name, const std::vector& mat_kTs, // to be true later AngleDistributionType in_scatter_format = micros[0]->scatter_format; bool in_is_isotropic = micros[0]->is_isotropic; - std::vector in_polar = micros[0]->polar; - std::vector in_azimuthal = micros[0]->azimuthal; + vector in_polar = micros[0]->polar; + vector in_azimuthal = micros[0]->azimuthal; init(in_name, in_awr, mat_kTs, in_fissionable, in_scatter_format, in_is_isotropic, in_polar, in_azimuthal); @@ -344,8 +340,8 @@ Mgxs::Mgxs(const std::string& in_name, const std::vector& mat_kTs, // Create the list of temperature indices and interpolation factors for // each microscopic data at the material temperature - std::vector micro_t(micros.size(), 0); - std::vector micro_t_interp(micros.size(), 0.); + vector micro_t(micros.size(), 0); + vector micro_t_interp(micros.size(), 0.); for (int m = 0; m < micros.size(); m++) { switch(settings::temperature_method) { case TemperatureMethod::NEAREST: @@ -383,9 +379,9 @@ Mgxs::Mgxs(const std::string& in_name, const std::vector& mat_kTs, // a different nuclide. Mathematically this just means the temperature // interpolant is included in the number density. // These interpolants are contained within interpolant. - std::vector interpolant; // the interpolant for the Mgxs - std::vector temp_indices; // the temperature index for each Mgxs - std::vector mgxs_to_combine; // The Mgxs to combine + vector interpolant; // the interpolant for the Mgxs + vector temp_indices; // the temperature index for each Mgxs + vector mgxs_to_combine; // The Mgxs to combine // Now go through and build the above vectors so that we can use them to // combine the data. We will step through each microscopic data and // add in its lower and upper temperature points @@ -419,12 +415,11 @@ Mgxs::Mgxs(const std::string& in_name, const std::vector& mat_kTs, //============================================================================== -void -Mgxs::combine(const std::vector& micros, const std::vector& scalars, - const std::vector& micro_ts, int this_t) +void Mgxs::combine(const vector& micros, + const std::vector& scalars, const vector& micro_ts, int this_t) { // Build the vector of pointers to the xs objects within micros - std::vector those_xs(micros.size()); + vector those_xs(micros.size()); for (int i = 0; i < micros.size(); i++) { those_xs[i] = &(micros[i]->xs[micro_ts[i]]); } diff --git a/src/mgxs_interface.cpp b/src/mgxs_interface.cpp index 3f2454a73..c64ab4631 100644 --- a/src/mgxs_interface.cpp +++ b/src/mgxs_interface.cpp @@ -29,8 +29,8 @@ namespace data { } MgxsInterface::MgxsInterface(const std::string& path_cross_sections, - const std::vector xs_to_read, - const std::vector> xs_temps) + const vector xs_to_read, + const vector> xs_temps) { read_header(path_cross_sections); set_nuclides_and_temperatures(xs_to_read, xs_temps); @@ -38,8 +38,7 @@ MgxsInterface::MgxsInterface(const std::string& path_cross_sections, } void MgxsInterface::set_nuclides_and_temperatures( - std::vector xs_to_read, - std::vector> xs_temps) + vector xs_to_read, vector> xs_temps) { // Check to remove all duplicates xs_to_read_ = xs_to_read; @@ -76,7 +75,7 @@ void MgxsInterface::init() // Read revision number for the MGXS Library file and make sure it matches // with the current version - std::array array; + array array; read_attribute(file_id, "version", array); if (array != VERSION_MGXS_LIBRARY) { fatal_error("MGXS Library file version does not match current version " @@ -95,9 +94,8 @@ void MgxsInterface::init() //============================================================================== -void -MgxsInterface::add_mgxs(hid_t file_id, const std::string& name, - const std::vector& temperature) +void MgxsInterface::add_mgxs( + hid_t file_id, const std::string& name, const vector& temperature) { write_message(5, "Loading {} data...", name); @@ -129,12 +127,12 @@ void MgxsInterface::create_macro_xs() if (kTs[i].size() > 0) { // Convert atom_densities to a vector auto& mat {model::materials[i]}; - std::vector atom_densities(mat->atom_density_.begin(), - mat->atom_density_.end()); + vector atom_densities( + mat->atom_density_.begin(), mat->atom_density_.end()); // Build array of pointers to nuclides's Mgxs objects needed for this // material - std::vector mgxs_ptr; + vector mgxs_ptr; for (int i_nuclide : mat->nuclide_) { mgxs_ptr.push_back(&nuclides_[i_nuclide]); } @@ -150,9 +148,9 @@ void MgxsInterface::create_macro_xs() //============================================================================== -std::vector> MgxsInterface::get_mat_kTs() +vector> MgxsInterface::get_mat_kTs() { - std::vector> kTs(model::materials.size()); + vector> kTs(model::materials.size()); for (const auto& cell : model::cells) { // Skip non-material cells @@ -248,12 +246,12 @@ void put_mgxs_header_data_to_globals() void set_mg_interface_nuclides_and_temps() { // Get temperatures from global data - std::vector> nuc_temps(data::nuclide_map.size()); - std::vector> dummy; + vector> nuc_temps(data::nuclide_map.size()); + vector> dummy; get_temperatures(nuc_temps, dummy); // Build vector of nuclide names which are to be read - std::vector nuclide_names(data::nuclide_map.size()); + vector nuclide_names(data::nuclide_map.size()); for (const auto& kv : data::nuclide_map) { nuclide_names[kv.second] = kv.first; } diff --git a/src/nuclide.cpp b/src/nuclide.cpp index 1f4eb9c81..4e5c0f3bf 100644 --- a/src/nuclide.cpp +++ b/src/nuclide.cpp @@ -30,12 +30,12 @@ namespace openmc { //============================================================================== namespace data { -std::array energy_min {0.0, 0.0}; -std::array energy_max {INFTY, INFTY}; +array energy_min {0.0, 0.0}; +array energy_max {INFTY, INFTY}; double temperature_min {INFTY}; double temperature_max {0.0}; std::unordered_map nuclide_map; -std::vector> nuclides; +vector> nuclides; } // namespace data //============================================================================== @@ -48,7 +48,7 @@ int Nuclide::XS_FISSION {2}; int Nuclide::XS_NU_FISSION {3}; int Nuclide::XS_PHOTON_PROD {4}; -Nuclide::Nuclide(hid_t group, const std::vector& temperature) +Nuclide::Nuclide(hid_t group, const vector& temperature) { // Set index of nuclide in global vector index_ = data::nuclides.size(); @@ -65,7 +65,7 @@ Nuclide::Nuclide(hid_t group, const std::vector& temperature) // Determine temperatures available hid_t kT_group = open_group(group, "kTs"); auto dset_names = dataset_names(kT_group); - std::vector temps_available; + vector temps_available; for (const auto& name : dset_names) { double T; read_dataset(kT_group, name.c_str(), T); @@ -86,7 +86,7 @@ Nuclide::Nuclide(hid_t group, const std::vector& temperature) // temperature range was given (indicated by T_max > 0), in which case all // temperatures in the range are loaded irrespective of what temperatures // actually appear in the model - std::vector temps_to_read; + vector temps_to_read; int n = temperature.size(); double T_min = n > 0 ? settings::temperature_range[0] : 0.0; double T_max = n > 0 ? settings::temperature_range[1] : INFTY; @@ -310,7 +310,7 @@ void Nuclide::create_derived(const Function1D* prompt_photons, const Function1D* { for (const auto& grid : grid_) { // Allocate and initialize cross section - std::array shape {grid.energy.size(), 5}; + array shape {grid.energy.size(), 5}; xs_.emplace_back(shape, 0.0); } @@ -999,7 +999,7 @@ double Nuclide::collapse_rate(int MT, double temperature, gsl::span version; + vector version; read_attribute(file_id, "version", version); if (version[0] != HDF5_VERSION[0]) { fatal_error("HDF5 data format uses version " + std::to_string(version[0]) @@ -1046,7 +1046,7 @@ extern "C" int openmc_load_nuclide(const char* name, const double* temps, int n) // Read nuclide data from HDF5 hid_t group = open_group(file_id, name); - std::vector temperature{temps, temps + n}; + vector temperature {temps, temps + n}; data::nuclides.push_back(std::make_unique(group, temperature)); close_group(group); diff --git a/src/output.cpp b/src/output.cpp index ecc720421..8f81d9881 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -269,17 +269,16 @@ void print_overlap_check() { #ifdef OPENMC_MPI - std::vector temp(model::overlap_check_count); - MPI_Reduce(temp.data(), model::overlap_check_count.data(), - model::overlap_check_count.size(), MPI_INT64_T, - MPI_SUM, 0, mpi::intracomm); - #endif + vector temp(model::overlap_check_count); + MPI_Reduce(temp.data(), model::overlap_check_count.data(), + model::overlap_check_count.size(), MPI_INT64_T, MPI_SUM, 0, mpi::intracomm); +#endif if (mpi::master) { header("cell overlap check summary", 1); fmt::print(" Cell ID No. Overlap Checks\n"); - std::vector sparse_cell_ids; + vector sparse_cell_ids; for (int i = 0; i < model::cells.size(); i++) { fmt::print(" {:8} {:17}\n", model::cells[i]->id_, model::overlap_check_count[i]); if (model::overlap_check_count[i] < 10) { @@ -606,7 +605,7 @@ write_tallies() } // Initialize Filter Matches Object - std::vector filter_matches; + vector filter_matches; // Allocate space for tally filter matches filter_matches.resize(model::tally_filters.size()); diff --git a/src/particle.cpp b/src/particle.cpp index bb0a843ea..ebdd3b080 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -35,8 +35,7 @@ namespace openmc { // LocalCoord implementation //============================================================================== -void -LocalCoord::rotate(const std::vector& rotation) +void LocalCoord::rotate(const vector& rotation) { r = r.rotate(rotation); u = u.rotate(rotation); diff --git a/src/particle_restart.cpp b/src/particle_restart.cpp index 32b64154a..7150bc6da 100644 --- a/src/particle_restart.cpp +++ b/src/particle_restart.cpp @@ -1,5 +1,6 @@ #include "openmc/particle_restart.h" +#include "openmc/array.h" #include "openmc/constants.h" #include "openmc/hdf5_interface.h" #include "openmc/mgxs_interface.h" @@ -15,7 +16,6 @@ #include "openmc/track_output.h" #include // for copy -#include #include #include diff --git a/src/photon.cpp b/src/photon.cpp index e1d262302..a1efbbb7a 100644 --- a/src/photon.cpp +++ b/src/photon.cpp @@ -1,5 +1,6 @@ #include "openmc/photon.h" +#include "openmc/array.h" #include "openmc/bremsstrahlung.h" #include "openmc/constants.h" #include "openmc/hdf5_interface.h" @@ -13,7 +14,6 @@ #include "xtensor/xoperation.hpp" #include "xtensor/xview.hpp" -#include #include #include // for tie @@ -28,7 +28,7 @@ namespace data { xt::xtensor compton_profile_pz; std::unordered_map element_map; -std::vector> elements; +vector> elements; } // namespace data @@ -110,7 +110,7 @@ PhotonInteraction::PhotonInteraction(hid_t group) // Read subshell photoionization cross section and atomic relaxation data rgroup = open_group(group, "subshells"); - std::vector designators; + vector designators; read_attribute(rgroup, "designators", designators); auto n_shell = designators.size(); if (n_shell == 0) { diff --git a/src/plot.cpp b/src/plot.cpp index 9333a6fd3..615701341 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -88,7 +88,7 @@ void PropertyData::set_overlap(size_t y, size_t x) { namespace model { std::unordered_map plot_map; -std::vector plots; +vector plots; uint64_t plotter_seed = 1; } // namespace model @@ -244,7 +244,7 @@ Plot::set_output_path(pugi::xml_node plot_node) path_plot_ = filename; // Copy plot pixel size - std::vector pxls = get_node_array(plot_node, "pixels"); + vector pxls = get_node_array(plot_node, "pixels"); if (PlotType::slice == type_) { if (pxls.size() == 2) { pixels_[0] = pxls[0]; @@ -268,7 +268,7 @@ Plot::set_bg_color(pugi::xml_node plot_node) { // Copy plot background color if (check_for_node(plot_node, "background")) { - std::vector bg_rgb = get_node_array(plot_node, "background"); + vector bg_rgb = get_node_array(plot_node, "background"); if (PlotType::voxel == type_) { if (mpi::master) { warning(fmt::format("Background color ignored in voxel plot {}", id_)); @@ -320,7 +320,7 @@ void Plot::set_width(pugi::xml_node plot_node) { // Copy plotting width - std::vector pl_width = get_node_array(plot_node, "width"); + vector pl_width = get_node_array(plot_node, "width"); if (PlotType::slice == type_) { if (pl_width.size() == 2) { width_.x = pl_width[0]; @@ -391,7 +391,7 @@ Plot::set_user_colors(pugi::xml_node plot_node) for (auto cn : plot_node.children("color")) { // Make sure 3 values are specified for RGB - std::vector user_rgb = get_node_array(cn, "rgb"); + vector user_rgb = get_node_array(cn, "rgb"); if (user_rgb.size() != 3) { fatal_error(fmt::format("Bad RGB in plot {}", id_)); } @@ -461,7 +461,7 @@ Plot::set_meshlines(pugi::xml_node plot_node) // Check for color if (check_for_node(meshlines_node, "color")) { // Check and make sure 3 values are specified for RGB - std::vector ml_rgb = get_node_array(meshlines_node, "color"); + vector ml_rgb = get_node_array(meshlines_node, "color"); if (ml_rgb.size() != 3) { fatal_error(fmt::format("Bad RGB for meshlines color in plot {}", id_)); } @@ -544,7 +544,7 @@ Plot::set_mask(pugi::xml_node plot_node) pugi::xml_node mask_node = mask_nodes[0].node(); // Determine how many components there are and allocate - std::vector iarray = get_node_array(mask_node, "components"); + vector iarray = get_node_array(mask_node, "components"); if (iarray.size() == 0) { fatal_error(fmt::format("Missing in mask of plot {}", id_)); } @@ -575,7 +575,7 @@ Plot::set_mask(pugi::xml_node plot_node) for (int j = 0; j < colors_.size(); j++) { if (std::find(iarray.begin(), iarray.end(), j) == iarray.end()) { if (check_for_node(mask_node, "background")) { - std::vector bg_rgb = get_node_array(mask_node, "background"); + vector bg_rgb = get_node_array(mask_node, "background"); colors_[j] = bg_rgb; } else { colors_[j] = WHITE; @@ -599,7 +599,7 @@ void Plot::set_overlap_color(pugi::xml_node plot_node) { warning(fmt::format( "Overlap color specified in plot {} but overlaps won't be shown.", id_)); } - std::vector olap_clr = get_node_array(plot_node, "overlap_color"); + vector olap_clr = get_node_array(plot_node, "overlap_color"); if (olap_clr.size() == 3) { overlap_color_ = olap_clr; } else { @@ -778,7 +778,7 @@ void draw_mesh_lines(Plot const& pl, ImageData& data) void create_voxel(Plot const& pl) { // compute voxel widths in each direction - std::array vox; + array vox; vox[0] = pl.width_[0]/(double)pl.pixels_[0]; vox[1] = pl.width_[1]/(double)pl.pixels_[1]; vox[2] = pl.width_[2]/(double)pl.pixels_[2]; @@ -803,7 +803,7 @@ void create_voxel(Plot const& pl) // Write current date and time write_attribute(file_id, "date_and_time", time_stamp().c_str()); - std::array pixels; + array pixels; std::copy(pl.pixels_.begin(), pl.pixels_.end(), pixels.begin()); write_attribute(file_id, "num_voxels", pixels); write_attribute(file_id, "voxel_width", vox); diff --git a/src/position.cpp b/src/position.cpp index d29e8d81c..46611df99 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -84,8 +84,7 @@ Position::operator-() const return {-x, -y, -z}; } -Position -Position::rotate(const std::vector& rotation) const +Position Position::rotate(const vector& rotation) const { return { x*rotation[0] + y*rotation[1] + z*rotation[2], diff --git a/src/reaction.cpp b/src/reaction.cpp index 0d5a80004..e5f91052c 100644 --- a/src/reaction.cpp +++ b/src/reaction.cpp @@ -19,7 +19,7 @@ namespace openmc { // Reaction implementation //============================================================================== -Reaction::Reaction(hid_t group, const std::vector& temperatures) +Reaction::Reaction(hid_t group, const vector& temperatures) { read_attribute(group, "Q_value", q_value_); read_attribute(group, "mt", mt_); @@ -84,9 +84,9 @@ Reaction::Reaction(hid_t group, const std::vector& temperatures) // <<<<<<<<<<<<<<<<<<<<<<<<<<<< REMOVE THIS <<<<<<<<<<<<<<<<<<<<<<<<< } -double -Reaction::collapse_rate(gsl::index i_temp, gsl::span energy, - gsl::span flux, const std::vector& grid) const +double Reaction::collapse_rate(gsl::index i_temp, + gsl::span energy, gsl::span flux, + const vector& grid) const { // Find index corresponding to first energy const auto& xs = xs_[i_temp].value; diff --git a/src/reaction_product.cpp b/src/reaction_product.cpp index 5d80fb7ba..b3c137fe7 100644 --- a/src/reaction_product.cpp +++ b/src/reaction_product.cpp @@ -1,6 +1,5 @@ #include "openmc/reaction_product.h" -#include // for unique_ptr #include // for string #include @@ -8,6 +7,7 @@ #include "openmc/endf.h" #include "openmc/error.h" #include "openmc/hdf5_interface.h" +#include "openmc/memory.h" #include "openmc/particle.h" #include "openmc/random_lcg.h" #include "openmc/secondary_correlated.h" diff --git a/src/scattdata.cpp b/src/scattdata.cpp index 6c20b8e37..a0341b153 100644 --- a/src/scattdata.cpp +++ b/src/scattdata.cpp @@ -70,12 +70,10 @@ ScattData::base_init(int order, const xt::xtensor& in_gmin, //============================================================================== -void -ScattData::base_combine(size_t max_order, size_t order_dim, - const std::vector& those_scatts, - const std::vector& scalars, xt::xtensor& in_gmin, - xt::xtensor& in_gmax, double_2dvec& sparse_mult, - double_3dvec& sparse_scatter) +void ScattData::base_combine(size_t max_order, size_t order_dim, + const vector& those_scatts, const vector& scalars, + xt::xtensor& in_gmin, xt::xtensor& in_gmax, + double_2dvec& sparse_mult, double_3dvec& sparse_scatter) { size_t groups = those_scatts[0] -> energy.size(); @@ -378,9 +376,8 @@ ScattDataLegendre::sample(int gin, int& gout, double& mu, double& wgt, //============================================================================== -void -ScattDataLegendre::combine(const std::vector& those_scatts, - const std::vector& scalars) +void ScattDataLegendre::combine( + const vector& those_scatts, const vector& scalars) { // Find the max order in the data set and make sure we can combine the sets size_t max_order = 0; @@ -595,9 +592,8 @@ ScattDataHistogram::get_matrix(size_t max_order) //============================================================================== -void -ScattDataHistogram::combine(const std::vector& those_scatts, - const std::vector& scalars) +void ScattDataHistogram::combine( + const vector& those_scatts, const vector& scalars) { // Find the max order in the data set and make sure we can combine the sets size_t max_order = those_scatts[0]->get_order(); @@ -814,9 +810,8 @@ ScattDataTabular::get_matrix(size_t max_order) //============================================================================== -void -ScattDataTabular::combine(const std::vector& those_scatts, - const std::vector& scalars) +void ScattDataTabular::combine( + const vector& those_scatts, const vector& scalars) { // Find the max order in the data set and make sure we can combine the sets size_t max_order = those_scatts[0]->get_order(); diff --git a/src/secondary_correlated.cpp b/src/secondary_correlated.cpp index 4a1ccad6e..e759d6b18 100644 --- a/src/secondary_correlated.cpp +++ b/src/secondary_correlated.cpp @@ -43,9 +43,9 @@ CorrelatedAngleEnergy::CorrelatedAngleEnergy(hid_t group) // Get outgoing energy distribution data dset = open_dataset(group, "energy_out"); - std::vector offsets; - std::vector interp; - std::vector n_discrete; + vector offsets; + vector interp; + vector n_discrete; read_attribute(dset, "offsets", offsets); read_attribute(dset, "interpolation", interp); read_attribute(dset, "n_discrete_lines", n_discrete); @@ -136,9 +136,9 @@ CorrelatedAngleEnergy::CorrelatedAngleEnergy(hid_t group) auto ps = xt::view(mu, 1, xt::range(offset_mu, offset_mu + m)); auto cs = xt::view(mu, 2, xt::range(offset_mu, offset_mu + m)); - std::vector x {xs.begin(), xs.end()}; - std::vector p {ps.begin(), ps.end()}; - std::vector c {cs.begin(), cs.end()}; + vector x {xs.begin(), xs.end()}; + vector p {ps.begin(), ps.end()}; + vector c {cs.begin(), cs.end()}; // To get answers that match ACE data, for now we still use the tabulated // CDF values that were passed through to the HDF5 library. At a later diff --git a/src/secondary_kalbach.cpp b/src/secondary_kalbach.cpp index 6a31a4376..322924c8d 100644 --- a/src/secondary_kalbach.cpp +++ b/src/secondary_kalbach.cpp @@ -4,7 +4,6 @@ #include // for log, sqrt, sinh #include // for size_t #include // for back_inserter -#include #include "xtensor/xarray.hpp" #include "xtensor/xview.hpp" @@ -12,6 +11,7 @@ #include "openmc/hdf5_interface.h" #include "openmc/random_lcg.h" #include "openmc/search.h" +#include "openmc/vector.h" namespace openmc { @@ -43,9 +43,9 @@ KalbachMann::KalbachMann(hid_t group) // Get outgoing energy distribution data dset = open_dataset(group, "distribution"); - std::vector offsets; - std::vector interp; - std::vector n_discrete; + vector offsets; + vector interp; + vector n_discrete; read_attribute(dset, "offsets", offsets); read_attribute(dset, "interpolation", interp); read_attribute(dset, "n_discrete_lines", n_discrete); diff --git a/src/secondary_thermal.cpp b/src/secondary_thermal.cpp index f61922a82..dd86c0d07 100644 --- a/src/secondary_thermal.cpp +++ b/src/secondary_thermal.cpp @@ -11,8 +11,8 @@ namespace openmc { // Helper function to get index on incident energy grid -void -get_energy_index(const std::vector& energies, double E, int& i, double& f) +void get_energy_index( + const vector& energies, double E, int& i, double& f) { // Get index and interpolation factor for elastic grid i = 0; @@ -81,9 +81,9 @@ IncoherentElasticAE::sample(double E_in, double& E_out, double& mu, // IncoherentElasticAEDiscrete implementation //============================================================================== -IncoherentElasticAEDiscrete::IncoherentElasticAEDiscrete(hid_t group, - const std::vector& energy) - : energy_{energy} +IncoherentElasticAEDiscrete::IncoherentElasticAEDiscrete( + hid_t group, const vector& energy) + : energy_ {energy} { read_dataset(group, "mu_out", mu_out_); } @@ -135,9 +135,9 @@ IncoherentElasticAEDiscrete::sample(double E_in, double& E_out, double& mu, // IncoherentInelasticAEDiscrete implementation //============================================================================== -IncoherentInelasticAEDiscrete::IncoherentInelasticAEDiscrete(hid_t group, - const std::vector& energy) - : energy_{energy} +IncoherentInelasticAEDiscrete::IncoherentInelasticAEDiscrete( + hid_t group, const vector& energy) + : energy_ {energy} { read_dataset(group, "energy_out", energy_out_); read_dataset(group, "mu_out", mu_out_); diff --git a/src/secondary_uncorrelated.cpp b/src/secondary_uncorrelated.cpp index a1aa8ca0b..a73c7053b 100644 --- a/src/secondary_uncorrelated.cpp +++ b/src/secondary_uncorrelated.cpp @@ -29,7 +29,7 @@ UncorrelatedAngleEnergy::UncorrelatedAngleEnergy(hid_t group) std::string type; read_attribute(energy_group, "type", type); - using UPtrEDist = std::unique_ptr; + using UPtrEDist = unique_ptr; if (type == "discrete_photon") { energy_ = UPtrEDist{new DiscretePhoton{energy_group}}; } else if (type == "level") { diff --git a/src/settings.cpp b/src/settings.cpp index 41b18942c..426f512f1 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -87,7 +87,7 @@ int64_t n_particles {-1}; int64_t max_particles_in_flight {100000}; ElectronTreatment electron_treatment {ElectronTreatment::TTB}; -std::array energy_cutoff {0.0, 1000.0, 0.0, 0.0}; +array energy_cutoff {0.0, 1000.0, 0.0, 0.0}; int legendre_to_tabular_points {C_NONE}; int max_order {0}; int n_log_bins {8000}; @@ -96,7 +96,7 @@ int n_max_batches; ResScatMethod res_scat_method {ResScatMethod::rvs}; double res_scat_energy_min {0.01}; double res_scat_energy_max {1000.0}; -std::vector res_scat_nuclides; +vector res_scat_nuclides; RunMode run_mode {RunMode::UNSET}; std::unordered_set sourcepoint_batch; std::unordered_set statepoint_batch; @@ -105,11 +105,11 @@ int64_t max_surface_particles; TemperatureMethod temperature_method {TemperatureMethod::NEAREST}; double temperature_tolerance {10.0}; double temperature_default {293.6}; -std::array temperature_range {0.0, 0.0}; +array temperature_range {0.0, 0.0}; int trace_batch; int trace_gen; int64_t trace_particle; -std::vector> track_identifiers; +vector> track_identifiers; int trigger_batch_interval {1}; int verbosity {7}; double weight_cutoff {0.25}; diff --git a/src/simulation.cpp b/src/simulation.cpp index 5b9fc1c4d..e6de68b7e 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -267,9 +267,8 @@ int64_t work_per_rank; const RegularMesh* entropy_mesh {nullptr}; const RegularMesh* ufs_mesh {nullptr}; -std::vector k_generation; -std::vector work_index; - +vector k_generation; +vector work_index; } // namespace simulation diff --git a/src/source.cpp b/src/source.cpp index 89131f359..e0b45a183 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -5,7 +5,6 @@ #endif #include // for move -#include // for unique_ptr #ifdef HAS_DYNAMIC_LINKING #include // for dlopen, dlsym, dlclose, dlerror @@ -15,15 +14,16 @@ #include "xtensor/xadapt.hpp" #include "openmc/bank.h" +#include "openmc/capi.h" #include "openmc/cell.h" #include "openmc/error.h" #include "openmc/file_utils.h" #include "openmc/hdf5_interface.h" #include "openmc/material.h" +#include "openmc/memory.h" #include "openmc/message_passing.h" #include "openmc/mgxs_interface.h" #include "openmc/nuclide.h" -#include "openmc/capi.h" #include "openmc/random_lcg.h" #include "openmc/search.h" #include "openmc/settings.h" @@ -39,8 +39,7 @@ namespace openmc { namespace model { -std::vector> external_sources; - +vector> external_sources; } //============================================================================== diff --git a/src/state_point.cpp b/src/state_point.cpp index 1db9fa38b..6d30dc70b 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -3,7 +3,6 @@ #include #include // for int64_t #include -#include #include #include "xtensor/xbuilder.hpp" // for empty_like @@ -27,6 +26,7 @@ #include "openmc/tallies/filter_mesh.h" #include "openmc/tallies/tally.h" #include "openmc/timer.h" +#include "openmc/vector.h" namespace openmc { @@ -141,7 +141,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) write_attribute(filters_group, "n_filters", model::tally_filters.size()); if (!model::tally_filters.empty()) { // Write filter IDs - std::vector filter_ids; + vector filter_ids; filter_ids.reserve(model::tally_filters.size()); for (const auto& filt : model::tally_filters) filter_ids.push_back(filt->id()); @@ -161,7 +161,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) write_attribute(tallies_group, "n_tallies", model::tallies.size()); if (!model::tallies.empty()) { // Write tally IDs - std::vector tally_ids; + vector tally_ids; tally_ids.reserve(model::tallies.size()); for (const auto& tally : model::tallies) tally_ids.push_back(tally->id_); @@ -195,7 +195,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) // Write the ID of each filter attached to this tally write_dataset(tally_group, "n_filters", tally->filters().size()); if (!tally->filters().empty()) { - std::vector filter_ids; + vector filter_ids; filter_ids.reserve(tally->filters().size()); for (auto i_filt : tally->filters()) filter_ids.push_back(model::tally_filters[i_filt]->id()); @@ -203,7 +203,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) } // Write the nuclides this tally scores - std::vector nuclides; + vector nuclides; for (auto i_nuclide : tally->nuclides_) { if (i_nuclide == -1) { nuclides.push_back("total"); @@ -221,7 +221,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) model::tally_derivs[tally->deriv_].id); // Write the tally score bins - std::vector scores; + vector scores; for (auto sc : tally->scores_) scores.push_back(reaction_name(sc)); write_dataset(tally_group, "n_score_bins", scores.size()); write_dataset(tally_group, "score_bins", scores); @@ -351,7 +351,7 @@ void load_state_point() // Read revision number for state point file and make sure it matches with // current version - std::array array; + array array; read_attribute(file_id, "version", array); if (array != VERSION_STATEPOINT) { fatal_error("State point version does not match current version in OpenMC."); @@ -528,14 +528,14 @@ hid_t h5banktype() { return banktype; } -std::vector calculate_surf_source_size() +vector calculate_surf_source_size() { - std::vector surf_source_index; + vector surf_source_index; surf_source_index.reserve(mpi::n_procs + 1); #ifdef OPENMC_MPI surf_source_index.resize(mpi::n_procs); - std::vector bank_size(mpi::n_procs); + vector bank_size(mpi::n_procs); // Populate the surf_source_index with cumulative sum of the number of // surface source banks per process @@ -597,10 +597,10 @@ write_source_bank(hid_t group_id, bool surf_source_bank) int64_t count_size = simulation::work_per_rank; // Set vectors for source bank and starting bank index of each process - std::vector* bank_index = &simulation::work_index; - std::vector* source_bank = &simulation::source_bank; - std::vector surf_source_index_vector; - std::vector surf_source_bank_vector; + vector* bank_index = &simulation::work_index; + vector* source_bank = &simulation::source_bank; + vector surf_source_index_vector; + vector surf_source_bank_vector; // Reset dataspace sizes and vectors for surface source bank if (surf_source_bank) { @@ -656,8 +656,7 @@ write_source_bank(hid_t group_id, bool surf_source_bank) // Save source bank sites since the array is overwritten below #ifdef OPENMC_MPI - std::vector temp_source { - source_bank->begin(), source_bank->end()}; + vector temp_source {source_bank->begin(), source_bank->end()}; #endif for (int i = 0; i < mpi::n_procs; ++i) { @@ -715,7 +714,7 @@ std::string dtype_member_names(hid_t dtype_id) } void read_source_bank( - hid_t group_id, std::vector& sites, bool distribute) + hid_t group_id, vector& sites, bool distribute) { hid_t banktype = h5banktype(); @@ -779,7 +778,7 @@ void write_unstructured_mesh_results() { for (auto& tally : model::tallies) { - std::vector tally_scores; + vector tally_scores; for (auto filter_idx : tally->filters()) { auto& filter = model::tally_filters[filter_idx]; if (filter->type() != "mesh") continue; @@ -829,8 +828,8 @@ void write_unstructured_mesh_results() { int nuc_score_idx = score_idx + nuc_idx*tally->scores_.size(); // construct result vectors - std::vector mean_vec(umesh->n_bins()), - std_dev_vec(umesh->n_bins()); + vector mean_vec(umesh->n_bins()), + std_dev_vec(umesh->n_bins()); for (int j = 0; j < tally->results_.shape()[0]; j++) { // get the volume for this bin double volume = umesh->volume(j); diff --git a/src/string_utils.cpp b/src/string_utils.cpp index 614e38767..5ad977aab 100644 --- a/src/string_utils.cpp +++ b/src/string_utils.cpp @@ -46,9 +46,9 @@ int word_count(std::string const& str) return count; } -std::vector split(const std::string& in) +vector split(const std::string& in) { - std::vector out; + vector out; for (int i = 0; i < in.size(); ) { // Increment i until we find a non-whitespace character. diff --git a/src/summary.cpp b/src/summary.cpp index 1f5f7a097..3d2c6816b 100644 --- a/src/summary.cpp +++ b/src/summary.cpp @@ -47,9 +47,9 @@ void write_nuclides(hid_t file) { // Build vectors of nuclide names and awrs while only sorting nuclides from // macroscopics - std::vector nuc_names; - std::vector macro_names; - std::vector awrs; + vector nuc_names; + vector macro_names; + vector awrs; for (int i = 0; i < data::nuclides.size(); ++i) { if (settings::run_CE) { diff --git a/src/surface.cpp b/src/surface.cpp index 1f542e64e..ff3a009fc 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -1,6 +1,5 @@ #include "openmc/surface.h" -#include #include #include #include @@ -8,15 +7,16 @@ #include #include +#include "openmc/array.h" #include "openmc/container_util.h" -#include "openmc/error.h" #include "openmc/dagmc.h" +#include "openmc/error.h" #include "openmc/hdf5_interface.h" +#include "openmc/math_functions.h" +#include "openmc/random_lcg.h" #include "openmc/settings.h" #include "openmc/string_utils.h" #include "openmc/xml_interface.h" -#include "openmc/random_lcg.h" -#include "openmc/math_functions.h" namespace openmc { @@ -26,7 +26,7 @@ namespace openmc { namespace model { std::unordered_map surface_map; - std::vector> surfaces; + vector> surfaces; } // namespace model //============================================================================== @@ -322,7 +322,7 @@ Direction SurfaceXPlane::normal(Position r) const void SurfaceXPlane::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "x-plane", false); - std::array coeffs {{x0_}}; + array coeffs {{x0_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -364,7 +364,7 @@ Direction SurfaceYPlane::normal(Position r) const void SurfaceYPlane::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "y-plane", false); - std::array coeffs {{y0_}}; + array coeffs {{y0_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -406,7 +406,7 @@ Direction SurfaceZPlane::normal(Position r) const void SurfaceZPlane::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "z-plane", false); - std::array coeffs {{z0_}}; + array coeffs {{z0_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -459,7 +459,7 @@ SurfacePlane::normal(Position r) const void SurfacePlane::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "plane", false); - std::array coeffs {{A_, B_, C_, D_}}; + array coeffs {{A_, B_, C_, D_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -567,7 +567,7 @@ Direction SurfaceXCylinder::normal(Position r) const void SurfaceXCylinder::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "x-cylinder", false); - std::array coeffs {{y0_, z0_, radius_}}; + array coeffs {{y0_, z0_, radius_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -607,7 +607,7 @@ Direction SurfaceYCylinder::normal(Position r) const void SurfaceYCylinder::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "y-cylinder", false); - std::array coeffs {{x0_, z0_, radius_}}; + array coeffs {{x0_, z0_, radius_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -648,7 +648,7 @@ Direction SurfaceZCylinder::normal(Position r) const void SurfaceZCylinder::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "z-cylinder", false); - std::array coeffs {{x0_, y0_, radius_}}; + array coeffs {{x0_, y0_, radius_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -725,7 +725,7 @@ Direction SurfaceSphere::normal(Position r) const void SurfaceSphere::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "sphere", false); - std::array coeffs {{x0_, y0_, z0_, radius_}}; + array coeffs {{x0_, y0_, z0_, radius_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -854,7 +854,7 @@ Direction SurfaceXCone::normal(Position r) const void SurfaceXCone::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "x-cone", false); - std::array coeffs {{x0_, y0_, z0_, radius_sq_}}; + array coeffs {{x0_, y0_, z0_, radius_sq_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -887,7 +887,7 @@ Direction SurfaceYCone::normal(Position r) const void SurfaceYCone::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "y-cone", false); - std::array coeffs {{x0_, y0_, z0_, radius_sq_}}; + array coeffs {{x0_, y0_, z0_, radius_sq_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -920,7 +920,7 @@ Direction SurfaceZCone::normal(Position r) const void SurfaceZCone::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "z-cone", false); - std::array coeffs {{x0_, y0_, z0_, radius_sq_}}; + array coeffs {{x0_, y0_, z0_, radius_sq_}}; write_dataset(group_id, "coefficients", coeffs); } @@ -1025,7 +1025,7 @@ SurfaceQuadric::normal(Position r) const void SurfaceQuadric::to_hdf5_inner(hid_t group_id) const { write_string(group_id, "type", "quadric", false); - std::array coeffs {{A_, B_, C_, D_, E_, F_, G_, H_, J_, K_}}; + array coeffs {{A_, B_, C_, D_, E_, F_, G_, H_, J_, K_}}; write_dataset(group_id, "coefficients", coeffs); } diff --git a/src/tallies/derivative.cpp b/src/tallies/derivative.cpp index 00e2d7db1..41ea57370 100644 --- a/src/tallies/derivative.cpp +++ b/src/tallies/derivative.cpp @@ -9,7 +9,7 @@ #include -template class std::vector; +template class openmc::vector; namespace openmc { @@ -19,7 +19,7 @@ namespace openmc { namespace model { std::unordered_map tally_deriv_map; - std::vector tally_derivs; + vector tally_derivs; } //============================================================================== diff --git a/src/tallies/filter.cpp b/src/tallies/filter.cpp index 31f572e4b..c6dc1342f 100644 --- a/src/tallies/filter.cpp +++ b/src/tallies/filter.cpp @@ -34,7 +34,7 @@ #include "openmc/tallies/filter_zernike.h" // explicit template instantiation definition -template class std::vector; +template class openmc::vector; namespace openmc { @@ -44,7 +44,7 @@ namespace openmc { namespace model { std::unordered_map filter_map; - std::vector> tally_filters; + vector> tally_filters; } //============================================================================== diff --git a/src/tallies/filter_cell.cpp b/src/tallies/filter_cell.cpp index 861a11aa4..10fa0040e 100644 --- a/src/tallies/filter_cell.cpp +++ b/src/tallies/filter_cell.cpp @@ -62,7 +62,7 @@ void CellFilter::to_statepoint(hid_t filter_group) const { Filter::to_statepoint(filter_group); - std::vector cell_ids; + vector cell_ids; for (auto c : cells_) cell_ids.push_back(model::cells[c]->id_); write_dataset(filter_group, "bins", cell_ids); } diff --git a/src/tallies/filter_cell_instance.cpp b/src/tallies/filter_cell_instance.cpp index 82af5bb9f..c41077631 100644 --- a/src/tallies/filter_cell_instance.cpp +++ b/src/tallies/filter_cell_instance.cpp @@ -24,7 +24,7 @@ CellInstanceFilter::from_xml(pugi::xml_node node) Expects(cells.size() % 2 == 0); // Convert into vector of CellInstance - std::vector instances; + vector instances; for (gsl::index i = 0; i < cells.size() / 2; ++i) { int32_t cell_id = cells[2*i]; gsl::index instance = cells[2*i + 1]; diff --git a/src/tallies/filter_legendre.cpp b/src/tallies/filter_legendre.cpp index 314f98a29..6626f5ea1 100644 --- a/src/tallies/filter_legendre.cpp +++ b/src/tallies/filter_legendre.cpp @@ -27,7 +27,7 @@ void LegendreFilter::get_all_bins(const Particle& p, TallyEstimator estimator, FilterMatch& match) const { - std::vector wgt(n_bins_); + vector wgt(n_bins_); calc_pn_c(order_, p.mu(), wgt.data()); for (int i = 0; i < n_bins_; i++) { match.bins_.push_back(i); diff --git a/src/tallies/filter_material.cpp b/src/tallies/filter_material.cpp index 0dec223c5..e9247457f 100644 --- a/src/tallies/filter_material.cpp +++ b/src/tallies/filter_material.cpp @@ -59,7 +59,7 @@ void MaterialFilter::to_statepoint(hid_t filter_group) const { Filter::to_statepoint(filter_group); - std::vector material_ids; + vector material_ids; for (auto c : materials_) material_ids.push_back(model::materials[c]->id_); write_dataset(filter_group, "bins", material_ids); } diff --git a/src/tallies/filter_particle.cpp b/src/tallies/filter_particle.cpp index b5f0660f6..a9669661e 100644 --- a/src/tallies/filter_particle.cpp +++ b/src/tallies/filter_particle.cpp @@ -12,7 +12,7 @@ ParticleFilter::from_xml(pugi::xml_node node) auto particles = get_node_array(node, "bins"); // Convert to vector of ParticleType - std::vector types; + vector types; for (auto& p : particles) { types.push_back(str_to_particle_type(p)); } @@ -48,7 +48,7 @@ void ParticleFilter::to_statepoint(hid_t filter_group) const { Filter::to_statepoint(filter_group); - std::vector particles; + vector particles; for (auto p : particles_) { particles.push_back(particle_type_to_str(p)); } diff --git a/src/tallies/filter_sph_harm.cpp b/src/tallies/filter_sph_harm.cpp index 0dbc1e59b..e8f8eed21 100644 --- a/src/tallies/filter_sph_harm.cpp +++ b/src/tallies/filter_sph_harm.cpp @@ -49,7 +49,7 @@ SphericalHarmonicsFilter::get_all_bins(const Particle& p, TallyEstimator estimat FilterMatch& match) const { // Determine cosine term for scatter expansion if necessary - std::vector wgt(order_ + 1); + vector wgt(order_ + 1); if (cosine_ == SphericalHarmonicsCosine::scatter) { calc_pn_c(order_, p.mu(), wgt.data()); } else { @@ -59,7 +59,7 @@ SphericalHarmonicsFilter::get_all_bins(const Particle& p, TallyEstimator estimat } // Find the Rn,m values - std::vector rn(n_bins_); + vector rn(n_bins_); calc_rn(order_, p.u_last(), rn.data()); int j = 0; diff --git a/src/tallies/filter_sptl_legendre.cpp b/src/tallies/filter_sptl_legendre.cpp index c32cc49d6..c835f1dd9 100644 --- a/src/tallies/filter_sptl_legendre.cpp +++ b/src/tallies/filter_sptl_legendre.cpp @@ -81,7 +81,7 @@ SpatialLegendreFilter::get_all_bins(const Particle& p, TallyEstimator estimator, double x_norm = 2.0*(x - min_) / (max_ - min_) - 1.0; // Compute and return the Legendre weights. - std::vector wgt(order_ + 1); + vector wgt(order_ + 1); calc_pn_c(order_, x_norm, wgt.data()); for (int i = 0; i < order_ + 1; i++) { match.bins_.push_back(i); diff --git a/src/tallies/filter_surface.cpp b/src/tallies/filter_surface.cpp index d65530d6f..53bbf4045 100644 --- a/src/tallies/filter_surface.cpp +++ b/src/tallies/filter_surface.cpp @@ -65,7 +65,7 @@ void SurfaceFilter::to_statepoint(hid_t filter_group) const { Filter::to_statepoint(filter_group); - std::vector surface_ids; + vector surface_ids; for (auto c : surfaces_) surface_ids.push_back(model::surfaces[c]->id_); write_dataset(filter_group, "bins", surface_ids); } diff --git a/src/tallies/filter_universe.cpp b/src/tallies/filter_universe.cpp index bcd20d795..8dbfa6462 100644 --- a/src/tallies/filter_universe.cpp +++ b/src/tallies/filter_universe.cpp @@ -61,7 +61,7 @@ void UniverseFilter::to_statepoint(hid_t filter_group) const { Filter::to_statepoint(filter_group); - std::vector universe_ids; + vector universe_ids; for (auto u : universes_) universe_ids.push_back(model::universes[u]->id_); write_dataset(filter_group, "bins", universe_ids); } diff --git a/src/tallies/filter_zernike.cpp b/src/tallies/filter_zernike.cpp index f57a0be7c..d86298c45 100644 --- a/src/tallies/filter_zernike.cpp +++ b/src/tallies/filter_zernike.cpp @@ -39,7 +39,7 @@ ZernikeFilter::get_all_bins(const Particle& p, TallyEstimator estimator, if (r <= 1.0) { // Compute and return the Zernike weights. - std::vector zn(n_bins_); + vector zn(n_bins_); calc_zn(order_, r, theta, zn.data()); for (int i = 0; i < n_bins_; i++) { match.bins_.push_back(i); @@ -98,7 +98,7 @@ ZernikeRadialFilter::get_all_bins(const Particle& p, TallyEstimator estimator, if (r <= 1.0) { // Compute and return the Zernike weights. - std::vector zn(n_bins_); + vector zn(n_bins_); calc_zn_rad(order_, r, zn.data()); for (int i = 0; i < n_bins_; i++) { match.bins_.push_back(i); diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index a4dc835a9..e488d69b9 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -1,11 +1,12 @@ #include "openmc/tallies/tally.h" +#include "openmc/array.h" #include "openmc/capi.h" #include "openmc/constants.h" #include "openmc/error.h" #include "openmc/file_utils.h" -#include "openmc/message_passing.h" #include "openmc/mesh.h" +#include "openmc/message_passing.h" #include "openmc/mgxs_interface.h" #include "openmc/nuclide.h" #include "openmc/particle.h" @@ -18,9 +19,9 @@ #include "openmc/tallies/filter.h" #include "openmc/tallies/filter_cell.h" #include "openmc/tallies/filter_cellfrom.h" +#include "openmc/tallies/filter_collision.h" #include "openmc/tallies/filter_delayedgroup.h" #include "openmc/tallies/filter_energy.h" -#include "openmc/tallies/filter_collision.h" #include "openmc/tallies/filter_legendre.h" #include "openmc/tallies/filter_mesh.h" #include "openmc/tallies/filter_meshsurface.h" @@ -35,7 +36,6 @@ #include "xtensor/xview.hpp" #include // for max -#include #include // for size_t #include @@ -47,13 +47,13 @@ namespace openmc { namespace model { std::unordered_map tally_map; - std::vector> tallies; - std::vector active_tallies; - std::vector active_analog_tallies; - std::vector active_tracklength_tallies; - std::vector active_collision_tallies; - std::vector active_meshsurf_tallies; - std::vector active_surface_tallies; + vector> tallies; + vector active_tallies; + vector active_analog_tallies; + vector active_tracklength_tallies; + vector active_collision_tallies; + vector active_meshsurf_tallies; + vector active_surface_tallies; } namespace simulation { @@ -103,13 +103,13 @@ Tally::Tally(pugi::xml_node node) } // Determine number of filters - std::vector filter_ids; + vector filter_ids; if (check_for_node(node, "filters")) { filter_ids = get_node_array(node, "filters"); } // Allocate and store filter user ids - std::vector filters; + vector filters; for (int filter_id : filter_ids) { // Determine if filter ID is valid auto it = model::filter_map.find(filter_id); @@ -388,8 +388,7 @@ Tally::set_scores(pugi::xml_node node) set_scores(scores); } -void -Tally::set_scores(const std::vector& scores) +void Tally::set_scores(const vector& scores) { // Reset state and prepare for the new scores. scores_.clear(); @@ -541,8 +540,7 @@ Tally::set_nuclides(pugi::xml_node node) } } -void -Tally::set_nuclides(const std::vector& nuclides) +void Tally::set_nuclides(const vector& nuclides) { nuclides_.clear(); @@ -595,7 +593,7 @@ Tally::init_triggers(pugi::xml_node node) } // Read the trigger scores. - std::vector trigger_scores; + vector trigger_scores; if (check_for_node(trigger_node, "scores")) { trigger_scores = get_node_array(trigger_node, "scores"); } else { @@ -1108,7 +1106,7 @@ openmc_tally_set_scores(int32_t index, int n, const char** scores) return OPENMC_E_OUT_OF_BOUNDS; } - std::vector scores_str(scores, scores+n); + vector scores_str(scores, scores + n); try { model::tallies[index]->set_scores(scores_str); } catch (const std::invalid_argument& ex) { @@ -1143,8 +1141,8 @@ openmc_tally_set_nuclides(int32_t index, int n, const char** nuclides) return OPENMC_E_OUT_OF_BOUNDS; } - std::vector words(nuclides, nuclides+n); - std::vector nucs; + vector words(nuclides, nuclides + n); + vector nucs; for (auto word : words){ if (word == "total") { nucs.push_back(-1); @@ -1188,7 +1186,7 @@ openmc_tally_set_filters(int32_t index, size_t n, const int32_t* indices) // Set the filters. try { // Convert indices to filter pointers - std::vector filters; + vector filters; for (gsl::index i = 0; i < n; ++i) { int32_t i_filt = indices[i]; filters.push_back(model::tally_filters.at(i_filt).get()); diff --git a/src/tallies/tally_scoring.cpp b/src/tallies/tally_scoring.cpp index c2f51bb9d..5242db2e3 100644 --- a/src/tallies/tally_scoring.cpp +++ b/src/tallies/tally_scoring.cpp @@ -55,9 +55,9 @@ FilterBinIter::FilterBinIter(const Tally& tally, Particle& p) this->compute_index_weight(); } -FilterBinIter::FilterBinIter(const Tally& tally, bool end, - std::vector* particle_filter_matches) - : filter_matches_{*particle_filter_matches}, tally_{tally} +FilterBinIter::FilterBinIter( + const Tally& tally, bool end, vector* particle_filter_matches) + : filter_matches_ {*particle_filter_matches}, tally_ {tally} { // Handle the special case for an iterator that points to the end. if (end) { @@ -144,9 +144,8 @@ FilterBinIter::compute_index_weight() //! Helper function used to increment tallies with a delayed group filter. -void -score_fission_delayed_dg(int i_tally, int d_bin, double score, int score_index, - std::vector& filter_matches) +void score_fission_delayed_dg(int i_tally, int d_bin, double score, + int score_index, vector& filter_matches) { // Save the original delayed group bin auto& tally {*model::tallies[i_tally]}; @@ -2420,8 +2419,7 @@ void score_collision_tally(Particle& p) match.bins_present_ = false; } -void -score_surface_tally(Particle& p, const std::vector& tallies) +void score_surface_tally(Particle& p, const vector& tallies) { // No collision, so no weight change when survival biasing double flux = p.wgt(); diff --git a/src/thermal.cpp b/src/thermal.cpp index 4b1561428..4d67123a3 100644 --- a/src/thermal.cpp +++ b/src/thermal.cpp @@ -28,14 +28,15 @@ namespace openmc { namespace data { std::unordered_map thermal_scatt_map; -std::vector> thermal_scatt; +vector> thermal_scatt; } //============================================================================== // ThermalScattering implementation //============================================================================== -ThermalScattering::ThermalScattering(hid_t group, const std::vector& temperature) +ThermalScattering::ThermalScattering( + hid_t group, const vector& temperature) { // Get name of table from group name_ = object_name(group); @@ -65,7 +66,7 @@ ThermalScattering::ThermalScattering(hid_t group, const std::vector& tem // Determine actual temperatures to read -- start by checking whether a // temperature range was given, in which case all temperatures in the range // are loaded irrespective of what temperatures actually appear in the model - std::vector temps_to_read; + vector temps_to_read; if (settings::temperature_range[1] > 0.0) { for (const auto& T : temps_available) { if (settings::temperature_range[0] <= T && diff --git a/src/track_output.cpp b/src/track_output.cpp index 0a3e06f00..ed20b057b 100644 --- a/src/track_output.cpp +++ b/src/track_output.cpp @@ -5,13 +5,13 @@ #include "openmc/position.h" #include "openmc/settings.h" #include "openmc/simulation.h" +#include "openmc/vector.h" #include #include "xtensor/xtensor.hpp" #include // for size_t #include -#include namespace openmc { @@ -40,7 +40,7 @@ void finalize_particle_track(Particle& p) simulation::current_batch, simulation::current_gen, p.id()); // Determine number of coordinates for each particle - std::vector n_coords; + vector n_coords; for (auto& coords : p.tracks()) { n_coords.push_back(coords.size()); } diff --git a/src/volume_calc.cpp b/src/volume_calc.cpp index ecb610ec4..17528ca58 100644 --- a/src/volume_calc.cpp +++ b/src/volume_calc.cpp @@ -33,7 +33,7 @@ namespace openmc { //============================================================================== namespace model { - std::vector volume_calcs; +vector volume_calcs; } //============================================================================== @@ -94,12 +94,14 @@ VolumeCalculation::VolumeCalculation(pugi::xml_node node) } -std::vector VolumeCalculation::execute() const +vector VolumeCalculation::execute() const { // Shared data that is collected from all threads int n = domain_ids_.size(); - std::vector> master_indices(n); // List of material indices for each domain - std::vector> master_hits(n); // Number of hits for each material in each domain + vector> master_indices( + n); // List of material indices for each domain + vector> master_hits( + n); // Number of hits for each material in each domain int iterations = 0; // Divide work over MPI processes @@ -119,8 +121,8 @@ std::vector VolumeCalculation::execute() const #pragma omp parallel { // Variables that are private to each thread - std::vector> indices(n); - std::vector> hits(n); + vector> indices(n); + vector> hits(n); Particle p; // Sample locations and count hits @@ -224,7 +226,7 @@ std::vector VolumeCalculation::execute() const double trigger_val = -INFTY; // Set size for members of the Result struct - std::vector results(n); + vector results(n); for (int i_domain = 0; i_domain < n; ++i_domain) { // Get reference to result for this domain @@ -353,8 +355,8 @@ std::vector VolumeCalculation::execute() const } // end while } -void VolumeCalculation::to_hdf5(const std::string& filename, - const std::vector& results) const +void VolumeCalculation::to_hdf5( + const std::string& filename, const vector& results) const { // Create HDF5 file hid_t file_id = file_open(filename, 'w'); @@ -418,7 +420,7 @@ void VolumeCalculation::to_hdf5(const std::string& filename, // Create array of nuclide names from the vector auto n_nuc = result.nuclides.size(); - std::vector nucnames; + vector nucnames; for (int i_nuc : result.nuclides) { nucnames.push_back(data::nuclides[i_nuc]->name_); } @@ -438,8 +440,8 @@ void VolumeCalculation::to_hdf5(const std::string& filename, file_close(file_id); } -void VolumeCalculation::check_hit(int i_material, std::vector& indices, - std::vector& hits) const +void VolumeCalculation::check_hit( + int i_material, vector& indices, vector& hits) const { // Check if this material was previously hit and if so, increment count diff --git a/src/wmp.cpp b/src/wmp.cpp index 6a56ddd0f..235e82b17 100644 --- a/src/wmp.cpp +++ b/src/wmp.cpp @@ -105,7 +105,7 @@ WindowedMultipole::evaluate(double E, double sqrtkT) const if (sqrtkT > 0.0 && window.broaden_poly) { // Broaden the curvefit. double dopp = sqrt_awr_ / sqrtkT; - std::array broadened_polynomials; + array broadened_polynomials; broaden_wmp_polynomials(E, dopp, fit_order_ + 1, broadened_polynomials.data()); for (int i_poly = 0; i_poly < fit_order_ + 1; ++i_poly) { sig_s += curvefit_(i_window, i_poly, FIT_S) * broadened_polynomials[i_poly]; @@ -216,7 +216,7 @@ WindowedMultipole::evaluate_deriv(double E, double sqrtkT) const void check_wmp_version(hid_t file) { if (attribute_exists(file, "version")) { - std::array version; + array version; read_attribute(file, "version", version); if (version[0] != WMP_VERSION[0]) { fatal_error(fmt::format( diff --git a/src/xsdata.cpp b/src/xsdata.cpp index ff360c052..4cfc0b85a 100644 --- a/src/xsdata.cpp +++ b/src/xsdata.cpp @@ -37,7 +37,7 @@ XsData::XsData(bool fissionable, AngleDistributionType scatter_format, int n_pol fatal_error("Invalid scatter_format!"); } // allocate all [temperature][angle][in group] quantities - std::vector shape {n_ang, n_g_}; + vector shape {n_ang, n_g_}; total = xt::zeros(shape); absorption = xt::zeros(shape); inverse_velocity = xt::zeros(shape); @@ -509,9 +509,8 @@ XsData::scatter_from_hdf5(hid_t xsdata_grp, size_t n_ang, AngleDistributionType //============================================================================== -void -XsData::combine(const std::vector& those_xs, - const std::vector& scalars) +void XsData::combine( + const vector& those_xs, const vector& scalars) { // Combine the non-scattering data for (size_t i = 0; i < those_xs.size(); i++) { @@ -551,7 +550,7 @@ XsData::combine(const std::vector& those_xs, // Allow the ScattData object to combine itself for (size_t a = 0; a < total.shape()[0]; a++) { // Build vector of the scattering objects to incorporate - std::vector those_scatts(those_xs.size()); + vector those_scatts(those_xs.size()); for (size_t i = 0; i < those_xs.size(); i++) { those_scatts[i] = those_xs[i]->scatter[a].get(); }