mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-21 06:25:30 -04:00
remove gsl-lite dependency (#3225)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
bcc2a4c5f0
commit
aa4de82258
72 changed files with 458 additions and 247 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,9 +1,6 @@
|
|||
[submodule "vendor/pugixml"]
|
||||
path = vendor/pugixml
|
||||
url = https://github.com/zeux/pugixml.git
|
||||
[submodule "vendor/gsl-lite"]
|
||||
path = vendor/gsl-lite
|
||||
url = https://github.com/martinmoene/gsl-lite.git
|
||||
[submodule "vendor/xtensor"]
|
||||
path = vendor/xtensor
|
||||
url = https://github.com/xtensor-stack/xtensor.git
|
||||
|
|
|
|||
|
|
@ -293,19 +293,6 @@ if (NOT xtensor_FOUND)
|
|||
add_subdirectory(vendor/xtensor)
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
# GSL header-only library
|
||||
#===============================================================================
|
||||
|
||||
find_package_write_status(gsl-lite)
|
||||
if (NOT gsl-lite_FOUND)
|
||||
add_subdirectory(vendor/gsl-lite)
|
||||
|
||||
# Make sure contract violations throw exceptions
|
||||
target_compile_definitions(gsl-lite-v1 INTERFACE GSL_THROW_ON_CONTRACT_VIOLATION)
|
||||
target_compile_definitions(gsl-lite-v1 INTERFACE gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON=1)
|
||||
endif()
|
||||
|
||||
#===============================================================================
|
||||
# Catch2 library
|
||||
#===============================================================================
|
||||
|
|
@ -519,7 +506,7 @@ endif()
|
|||
# target_link_libraries treats any arguments starting with - but not -l as
|
||||
# linker flags. Thus, we can pass both linker flags and libraries together.
|
||||
target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}
|
||||
xtensor gsl::gsl-lite-v1 fmt::fmt ${CMAKE_DL_LIBS})
|
||||
xtensor fmt::fmt ${CMAKE_DL_LIBS})
|
||||
|
||||
if(TARGET pugixml::pugixml)
|
||||
target_link_libraries(libopenmc pugixml::pugixml)
|
||||
|
|
|
|||
|
|
@ -43,6 +43,5 @@ recursive-include vendor *.hh
|
|||
recursive-include vendor *.hpp
|
||||
recursive-include vendor *.pc.in
|
||||
recursive-include vendor *.natvis
|
||||
include vendor/gsl-lite/include/gsl/gsl
|
||||
prune docs/build
|
||||
prune docs/source/pythonapi/generated/
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
get_filename_component(OpenMC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
|
||||
|
||||
find_package(fmt REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../fmt)
|
||||
find_package(gsl-lite REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../gsl-lite)
|
||||
find_package(pugixml REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../pugixml)
|
||||
find_package(xtl REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtl)
|
||||
find_package(xtensor REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtensor)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@
|
|||
|
||||
#include "hdf5.h"
|
||||
#include "pugixml.hpp"
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/bounding_box.h"
|
||||
#include "openmc/constants.h"
|
||||
|
|
@ -128,7 +127,7 @@ private:
|
|||
void add_precedence();
|
||||
|
||||
//! Add parenthesis to enforce precedence
|
||||
gsl::index add_parentheses(gsl::index start);
|
||||
int64_t add_parentheses(int64_t start);
|
||||
|
||||
//! Remove complement operators from the expression
|
||||
void remove_complement_ops();
|
||||
|
|
@ -418,8 +417,8 @@ struct CellInstance {
|
|||
return index_cell == other.index_cell && instance == other.instance;
|
||||
}
|
||||
|
||||
gsl::index index_cell;
|
||||
gsl::index instance;
|
||||
int64_t index_cell;
|
||||
int64_t instance;
|
||||
};
|
||||
|
||||
//! Structure necessary for inserting CellInstance into hashed STL data
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@
|
|||
#include <cstddef> // for size_t
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/vector.h" // for vector
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -44,9 +44,9 @@ class DiscreteIndex {
|
|||
public:
|
||||
DiscreteIndex() {};
|
||||
DiscreteIndex(pugi::xml_node node);
|
||||
DiscreteIndex(gsl::span<const double> p);
|
||||
DiscreteIndex(span<const double> p);
|
||||
|
||||
void assign(gsl::span<const double> p);
|
||||
void assign(span<const double> p);
|
||||
|
||||
//! Sample a value from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "openmc/distribution.h"
|
||||
#include "openmc/mesh.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/span.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -104,7 +105,7 @@ private:
|
|||
class MeshSpatial : public SpatialDistribution {
|
||||
public:
|
||||
explicit MeshSpatial(pugi::xml_node node);
|
||||
explicit MeshSpatial(int32_t mesh_id, gsl::span<const double> strengths);
|
||||
explicit MeshSpatial(int32_t mesh_id, span<const double> strengths);
|
||||
|
||||
//! Sample a position from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
@ -144,7 +145,7 @@ class PointCloud : public SpatialDistribution {
|
|||
public:
|
||||
explicit PointCloud(pugi::xml_node node);
|
||||
explicit PointCloud(
|
||||
std::vector<Position> point_cloud, gsl::span<const double> strengths);
|
||||
std::vector<Position> point_cloud, span<const double> strengths);
|
||||
|
||||
//! Sample a position from the distribution
|
||||
//! \param seed Pseudorandom number seed pointer
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@
|
|||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/search.h"
|
||||
#include "openmc/span.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -36,8 +35,8 @@ inline double interpolate_log_log(
|
|||
return y0 * std::exp(f * std::log(y1 / y0));
|
||||
}
|
||||
|
||||
inline double interpolate_lagrangian(gsl::span<const double> xs,
|
||||
gsl::span<const double> ys, int idx, double x, int order)
|
||||
inline double interpolate_lagrangian(
|
||||
span<const double> xs, span<const double> ys, int idx, double x, int order)
|
||||
{
|
||||
double output {0.0};
|
||||
|
||||
|
|
@ -56,9 +55,8 @@ inline double interpolate_lagrangian(gsl::span<const double> xs,
|
|||
return output;
|
||||
}
|
||||
|
||||
inline double interpolate(gsl::span<const double> xs,
|
||||
gsl::span<const double> ys, double x,
|
||||
Interpolation i = Interpolation::lin_lin)
|
||||
inline double interpolate(span<const double> xs, span<const double> ys,
|
||||
double x, Interpolation i = Interpolation::lin_lin)
|
||||
{
|
||||
int idx = lower_bound_index(xs.begin(), xs.end(), x);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@
|
|||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <hdf5.h>
|
||||
|
||||
#include "openmc/bremsstrahlung.h"
|
||||
|
|
@ -118,21 +118,21 @@ public:
|
|||
//
|
||||
//! \param[in] density Density value
|
||||
//! \param[in] units Units of density
|
||||
void set_density(double density, gsl::cstring_span units);
|
||||
void set_density(double density, const std::string& units);
|
||||
|
||||
//! Set temperature of the material
|
||||
void set_temperature(double temperature) { temperature_ = temperature; };
|
||||
|
||||
//! Get nuclides in material
|
||||
//! \return Indices into the global nuclides vector
|
||||
gsl::span<const int> nuclides() const
|
||||
span<const int> nuclides() const
|
||||
{
|
||||
return {nuclide_.data(), nuclide_.size()};
|
||||
}
|
||||
|
||||
//! Get densities of each nuclide in material
|
||||
//! \return Densities in [atom/b-cm]
|
||||
gsl::span<const double> densities() const
|
||||
span<const double> densities() const
|
||||
{
|
||||
return {atom_density_.data(), atom_density_.size()};
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ private:
|
|||
|
||||
//----------------------------------------------------------------------------
|
||||
// Private data members
|
||||
gsl::index index_;
|
||||
int64_t index_;
|
||||
|
||||
bool depletable_ {false}; //!< Is the material depletable?
|
||||
bool fissionable_ {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@
|
|||
#define OPENMC_MCPL_INTERFACE_H
|
||||
|
||||
#include "openmc/particle_data.h"
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -30,13 +29,14 @@ vector<SourceSite> mcpl_source_sites(std::string path);
|
|||
//
|
||||
//! \param[in] filename Path to MCPL file
|
||||
//! \param[in] source_bank Vector of SourceSites to write to file for this
|
||||
//! MPI rank
|
||||
//! MPI rank. Note that this can't be const due to
|
||||
//! it being used as work space by MPI.
|
||||
//! \param[in] bank_indx Pointer to vector of site index ranges over all
|
||||
//! MPI ranks. This can be computed by calling
|
||||
//! calculate_parallel_index_vector on
|
||||
//! source_bank.size().
|
||||
void write_mcpl_source_point(const char* filename,
|
||||
gsl::span<SourceSite> source_bank, vector<int64_t> const& bank_index);
|
||||
void write_mcpl_source_point(const char* filename, span<SourceSite> source_bank,
|
||||
const vector<int64_t>& bank_index);
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_MCPL_INTERFACE_H
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@
|
|||
#include "hdf5.h"
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/bounding_box.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/position.h"
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/vector.h"
|
||||
#include "openmc/xml_interface.h"
|
||||
|
||||
|
|
@ -179,8 +179,8 @@ public:
|
|||
//! \param[out] Array of (material index, volume) for desired element
|
||||
//! \param[inout] seed Pseudorandom number seed
|
||||
//! \return Number of materials within element
|
||||
int material_volumes(int n_sample, int bin, gsl::span<MaterialVolume> volumes,
|
||||
uint64_t* seed) const;
|
||||
int material_volumes(
|
||||
int n_sample, int bin, span<MaterialVolume> volumes, uint64_t* seed) const;
|
||||
|
||||
//! Determine volume of materials within a single mesh elemenet
|
||||
//
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include <unordered_map>
|
||||
#include <utility> // for pair
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <hdf5.h>
|
||||
|
||||
#include "openmc/array.h"
|
||||
|
|
@ -17,6 +16,7 @@
|
|||
#include "openmc/particle.h"
|
||||
#include "openmc/reaction.h"
|
||||
#include "openmc/reaction_product.h"
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/urr.h"
|
||||
#include "openmc/vector.h"
|
||||
#include "openmc/wmp.h"
|
||||
|
|
@ -81,8 +81,8 @@ public:
|
|||
//! \param[in] energy Energy group boundaries in [eV]
|
||||
//! \param[in] flux Flux in each energy group (not normalized per eV)
|
||||
//! \return Reaction rate
|
||||
double collapse_rate(int MT, double temperature,
|
||||
gsl::span<const double> energy, gsl::span<const double> flux) const;
|
||||
double collapse_rate(int MT, double temperature, span<const double> energy,
|
||||
span<const double> flux) const;
|
||||
|
||||
//============================================================================
|
||||
// Data members
|
||||
|
|
@ -91,7 +91,7 @@ public:
|
|||
int A_; //!< Mass number
|
||||
int metastable_; //!< Metastable state
|
||||
double awr_; //!< Atomic weight ratio
|
||||
gsl::index index_; //!< Index in the nuclides array
|
||||
int64_t index_; //!< Index in the nuclides array
|
||||
|
||||
// Temperature dependent cross section data
|
||||
vector<double> kTs_; //!< temperatures in eV (k*T)
|
||||
|
|
@ -138,7 +138,7 @@ private:
|
|||
//
|
||||
//! \param[in] T Temperature in [K]
|
||||
//! \return Temperature index and interpolation factor
|
||||
std::pair<gsl::index, double> find_temperature(double T) const;
|
||||
std::pair<int64_t, double> find_temperature(double T) const;
|
||||
|
||||
static int XS_TOTAL;
|
||||
static int XS_ABSORPTION;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include "openmc/vector.h"
|
||||
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <hdf5.h>
|
||||
|
||||
#include <string>
|
||||
|
|
@ -61,7 +60,7 @@ public:
|
|||
// Data members
|
||||
std::string name_; //!< Name of element, e.g. "Zr"
|
||||
int Z_; //!< Atomic number
|
||||
gsl::index index_; //!< Index in global elements vector
|
||||
int64_t index_; //!< Index in global elements vector
|
||||
|
||||
// Microscopic cross sections
|
||||
xt::xtensor<double, 1> energy_;
|
||||
|
|
|
|||
|
|
@ -7,10 +7,10 @@
|
|||
#include <string>
|
||||
|
||||
#include "hdf5.h"
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/particle_data.h"
|
||||
#include "openmc/reaction_product.h"
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -33,7 +33,7 @@ public:
|
|||
//! \param[in] i_temp Temperature index
|
||||
//! \param[in] i_grid Energy grid index
|
||||
//! \param[in] interp_factor Interpolation factor between grid points
|
||||
double xs(gsl::index i_temp, gsl::index i_grid, double interp_factor) const;
|
||||
double xs(int64_t i_temp, int64_t i_grid, double interp_factor) const;
|
||||
|
||||
//! Calculate cross section
|
||||
//
|
||||
|
|
@ -47,8 +47,8 @@ public:
|
|||
//! \param[in] flux Flux in each energy group (not normalized per eV)
|
||||
//! \param[in] grid Nuclide energy grid
|
||||
//! \return Reaction rate
|
||||
double collapse_rate(gsl::index i_temp, gsl::span<const double> energy,
|
||||
gsl::span<const double> flux, const vector<double>& grid) const;
|
||||
double collapse_rate(int64_t i_temp, span<const double> energy,
|
||||
span<const double> flux, const vector<double>& grid) const;
|
||||
|
||||
//! Cross section at a single temperature
|
||||
struct TemperatureXS {
|
||||
|
|
|
|||
237
include/openmc/span.h
Normal file
237
include/openmc/span.h
Normal file
|
|
@ -0,0 +1,237 @@
|
|||
#ifndef OPENMC_SPAN_H
|
||||
#define OPENMC_SPAN_H
|
||||
#include <cstddef> // for std::size_t, std::ptrdiff_t
|
||||
#include <iterator> // for std::begin, std::end
|
||||
#include <stdexcept> // for std::out_of_range
|
||||
#include <type_traits>
|
||||
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
||||
template<typename T>
|
||||
class span {
|
||||
public:
|
||||
using value_type = T;
|
||||
using pointer = T*;
|
||||
using const_pointer = const T*;
|
||||
using reference = T&;
|
||||
using const_reference = const T&;
|
||||
using iterator = T*;
|
||||
using const_iterator = const T*;
|
||||
using size_type = std::size_t;
|
||||
using difference_type = std::ptrdiff_t;
|
||||
|
||||
/**
|
||||
* @brief Default constructor for an empty span.
|
||||
*/
|
||||
span() noexcept : data_(nullptr), size_(0) {}
|
||||
|
||||
/**
|
||||
* @brief Constructs a span from a pointer and size.
|
||||
* @param ptr Pointer to the first element.
|
||||
* @param count Number of elements in the span.
|
||||
*/
|
||||
span(pointer ptr, size_type count) : data_(ptr), size_(count) {}
|
||||
|
||||
/**
|
||||
* @brief Constructs a span from two pointers marking the span range.
|
||||
* @param first Pointer to the first element.
|
||||
* @param last Pointer past the last element.
|
||||
* @throws std::out_of_range if last < first.
|
||||
*/
|
||||
span(pointer first, pointer last) : data_(first), size_(last - first)
|
||||
{
|
||||
if (last < first) {
|
||||
throw std::out_of_range("span: last pointer is before first pointer");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Constructs a span from a non-const std::vector.
|
||||
* @param vec Reference to the vector to create a span from.
|
||||
*/
|
||||
span(std::vector<T>& vec) : data_(vec.data()), size_(vec.size()) {}
|
||||
|
||||
/**
|
||||
* @brief Constructs a span from a const std::vector.
|
||||
*
|
||||
* This is handling the semantics that a span<const double> is used
|
||||
* for read-only access into a vector.
|
||||
* @param vec Reference to the const vector to create a span from.
|
||||
*/
|
||||
template<typename U = T,
|
||||
typename = std::enable_if_t<std::is_same<U, const T>::value>>
|
||||
span(const std::vector<std::remove_const_t<U>>& vec)
|
||||
: data_(vec.data()), size_(vec.size())
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Constructs a read-only span<const T> from a non-const span<T>.
|
||||
*/
|
||||
template<typename U = T, typename = std::enable_if_t<std::is_const<U>::value>>
|
||||
span(const span<std::remove_const_t<U>>& other) noexcept
|
||||
: data_(other.data()), size_(other.size())
|
||||
{}
|
||||
|
||||
/**
|
||||
* @brief Access an element without bounds checking.
|
||||
* @param index Index of the element to access.
|
||||
* @return Reference to the accessed element.
|
||||
*/
|
||||
reference operator[](size_type index) { return data_[index]; }
|
||||
|
||||
/**
|
||||
* @brief Access an element without bounds checking (const version).
|
||||
* @param index Index of the element to access.
|
||||
* @return Const reference to the accessed element.
|
||||
*/
|
||||
const_reference operator[](size_type index) const { return data_[index]; }
|
||||
|
||||
/**
|
||||
* @brief Access an element with bounds checking.
|
||||
* @param index Index of the element to access.
|
||||
* @return Reference to the accessed element.
|
||||
* @throws std::out_of_range if index is out of range.
|
||||
*/
|
||||
reference at(size_type index)
|
||||
{
|
||||
if (index >= size_) {
|
||||
throw std::out_of_range("span: index out of range");
|
||||
}
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Access an element with bounds checking (const version).
|
||||
* @param index Index of the element to access.
|
||||
* @return Const reference to the accessed element.
|
||||
* @throws std::out_of_range if index is out of range.
|
||||
*/
|
||||
const_reference at(size_type index) const
|
||||
{
|
||||
if (index >= size_) {
|
||||
throw std::out_of_range("span: index out of range");
|
||||
}
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a pointer to the underlying data.
|
||||
* @return Pointer to the data, or nullptr if the span is empty.
|
||||
*/
|
||||
pointer data() noexcept { return data_; }
|
||||
|
||||
/**
|
||||
* @brief Get a const pointer to the underlying data.
|
||||
* @return Const pointer to the data, or nullptr if the span is empty.
|
||||
*/
|
||||
const_pointer data() const noexcept { return data_; }
|
||||
|
||||
/**
|
||||
* @brief Get the number of elements in the span.
|
||||
* @return The size of the span.
|
||||
*/
|
||||
size_type size() const noexcept { return size_; }
|
||||
|
||||
/**
|
||||
* @brief Check if the span is empty.
|
||||
* @return True if the span is empty, false otherwise.
|
||||
*/
|
||||
bool empty() const noexcept { return size_ == 0; }
|
||||
|
||||
/**
|
||||
* @brief Get an iterator to the beginning of the span.
|
||||
* @return Iterator pointing to the first element.
|
||||
*/
|
||||
iterator begin() noexcept { return data_; }
|
||||
|
||||
/**
|
||||
* @brief Get a const iterator to the beginning of the span.
|
||||
* @return Const iterator pointing to the first element.
|
||||
*/
|
||||
const_iterator begin() const noexcept { return data_; }
|
||||
|
||||
/**
|
||||
* @brief Get a const iterator to the beginning of the span.
|
||||
* @return Const iterator pointing to the first element.
|
||||
*/
|
||||
const_iterator cbegin() const noexcept { return data_; }
|
||||
|
||||
/**
|
||||
* @brief Get an iterator to the end of the span.
|
||||
* @return Iterator pointing past the last element.
|
||||
*/
|
||||
iterator end() noexcept { return data_ + size_; }
|
||||
|
||||
/**
|
||||
* @brief Get a const iterator to the end of the span.
|
||||
* @return Const iterator pointing past the last element.
|
||||
*/
|
||||
const_iterator end() const noexcept { return data_ + size_; }
|
||||
|
||||
/**
|
||||
* @brief Get a const iterator to the end of the span.
|
||||
* @return Const iterator pointing past the last element.
|
||||
*/
|
||||
const_iterator cend() const noexcept { return data_ + size_; }
|
||||
|
||||
/**
|
||||
* @brief Access the first element.
|
||||
* @return Reference to the first element.
|
||||
* @throws std::out_of_range if the span is empty.
|
||||
*/
|
||||
reference front()
|
||||
{
|
||||
if (empty()) {
|
||||
throw std::out_of_range("span::front(): span is empty");
|
||||
}
|
||||
return data_[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Access the first element (const version).
|
||||
* @return Const reference to the first element.
|
||||
* @throws std::out_of_range if the span is empty.
|
||||
*/
|
||||
const_reference front() const
|
||||
{
|
||||
if (empty()) {
|
||||
throw std::out_of_range("span::front(): span is empty");
|
||||
}
|
||||
return data_[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Access the last element.
|
||||
* @return Reference to the last element.
|
||||
* @throws std::out_of_range if the span is empty.
|
||||
*/
|
||||
reference back()
|
||||
{
|
||||
if (empty()) {
|
||||
throw std::out_of_range("span::back(): span is empty");
|
||||
}
|
||||
return data_[size_ - 1];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Access the last element (const version).
|
||||
* @return Const reference to the last element.
|
||||
* @throws std::out_of_range if the span is empty.
|
||||
*/
|
||||
const_reference back() const
|
||||
{
|
||||
if (empty()) {
|
||||
throw std::out_of_range("span::back(): span is empty");
|
||||
}
|
||||
return data_[size_ - 1];
|
||||
}
|
||||
|
||||
private:
|
||||
pointer data_;
|
||||
size_type size_;
|
||||
};
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_SPAN_H
|
||||
|
|
@ -4,13 +4,12 @@
|
|||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "hdf5.h"
|
||||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/shared_array.h"
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -34,15 +33,18 @@ void load_state_point();
|
|||
// values on each rank, used to create global indexing. This vector
|
||||
// can be created by calling calculate_parallel_index_vector on
|
||||
// source_bank.size() if such a vector is not already available.
|
||||
void write_h5_source_point(const char* filename,
|
||||
gsl::span<SourceSite> source_bank, const vector<int64_t>& bank_index);
|
||||
//
|
||||
// The source_bank variable is used as work space if MPI is used,
|
||||
// so it cannot be given as a const span.
|
||||
void write_h5_source_point(const char* filename, span<SourceSite> source_bank,
|
||||
const vector<int64_t>& bank_index);
|
||||
|
||||
void write_source_point(std::string, gsl::span<SourceSite> source_bank,
|
||||
void write_source_point(std::string, span<SourceSite> source_bank,
|
||||
const vector<int64_t>& bank_index, bool use_mcpl);
|
||||
|
||||
// This appends a source bank specification to an HDF5 file
|
||||
// that's already open. It is used internally by write_source_point.
|
||||
void write_source_bank(hid_t group_id, gsl::span<SourceSite> source_bank,
|
||||
void write_source_bank(hid_t group_id, span<SourceSite> source_bank,
|
||||
const vector<int64_t>& bank_index);
|
||||
|
||||
void read_source_bank(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include <unordered_map>
|
||||
|
||||
#include "pugixml.hpp"
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/hdf5_interface.h"
|
||||
|
|
@ -130,7 +129,7 @@ public:
|
|||
//! \return Number of bins
|
||||
int n_bins() const { return n_bins_; }
|
||||
|
||||
gsl::index index() const { return index_; }
|
||||
int64_t index() const { return index_; }
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
|
|
@ -140,7 +139,7 @@ protected:
|
|||
|
||||
private:
|
||||
int32_t id_ {C_NONE};
|
||||
gsl::index index_;
|
||||
int64_t index_;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#include "openmc/vector.h"
|
||||
#include <string>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -39,7 +38,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
void set_bins(gsl::span<double> bins);
|
||||
void set_bins(span<double> bins);
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -42,7 +41,7 @@ public:
|
|||
|
||||
const vector<int32_t>& cells() const { return cells_; }
|
||||
|
||||
void set_cells(gsl::span<int32_t> cells);
|
||||
void set_cells(span<int32_t> cells);
|
||||
|
||||
protected:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@
|
|||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/cell.h"
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -22,7 +21,7 @@ public:
|
|||
// Constructors, destructors
|
||||
|
||||
CellInstanceFilter() = default;
|
||||
CellInstanceFilter(gsl::span<CellInstance> instances);
|
||||
CellInstanceFilter(span<CellInstance> instances);
|
||||
~CellInstanceFilter() = default;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
@ -47,7 +46,7 @@ public:
|
|||
|
||||
const std::unordered_set<int32_t>& cells() const { return cells_; }
|
||||
|
||||
void set_cell_instances(gsl::span<CellInstance> instances);
|
||||
void set_cell_instances(span<CellInstance> instances);
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
@ -60,7 +59,7 @@ private:
|
|||
std::unordered_set<int32_t> cells_;
|
||||
|
||||
//! A map from cell/instance indices to filter bin indices.
|
||||
std::unordered_map<CellInstance, gsl::index, CellInstanceHash> map_;
|
||||
std::unordered_map<CellInstance, int64_t, CellInstanceHash> map_;
|
||||
|
||||
//! Indicates if filter uses only material-filled cells
|
||||
bool material_cells_only_;
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_COLLISIONS_H
|
||||
#define OPENMC_TALLIES_FILTER_COLLISIONS_H
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ public:
|
|||
// Accessors
|
||||
|
||||
const vector<int>& bins() const { return bins_; }
|
||||
void set_bins(gsl::span<const int> bins);
|
||||
void set_bins(span<const int> bins);
|
||||
|
||||
protected:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_DELAYEDGROUP_H
|
||||
#define OPENMC_TALLIES_FILTER_DELAYEDGROUP_H
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -42,7 +41,7 @@ public:
|
|||
|
||||
const vector<int>& groups() const { return groups_; }
|
||||
|
||||
void set_groups(gsl::span<int> groups);
|
||||
void set_groups(span<int> groups);
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_ENERGY_H
|
||||
#define OPENMC_TALLIES_FILTER_ENERGY_H
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ public:
|
|||
// Accessors
|
||||
|
||||
const vector<double>& bins() const { return bins_; }
|
||||
void set_bins(gsl::span<const double> bins);
|
||||
void set_bins(span<const double> bins);
|
||||
|
||||
bool matches_transport_groups() const { return matches_transport_groups_; }
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define OPENMC_TALLIES_FILTER_ENERGYFUNC_H
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ public:
|
|||
const vector<double>& energy() const { return energy_; }
|
||||
const vector<double>& y() const { return y_; }
|
||||
Interpolation interpolation() const { return interpolation_; }
|
||||
void set_data(gsl::span<const double> energy, gsl::span<const double> y);
|
||||
void set_data(span<const double> energy, span<const double> y);
|
||||
void set_interpolation(const std::string& interpolation);
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ public:
|
|||
|
||||
const vector<int32_t>& materials() const { return materials_; }
|
||||
|
||||
void set_materials(gsl::span<const int32_t> materials);
|
||||
void set_materials(span<const int32_t> materials);
|
||||
|
||||
protected:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_MU_H
|
||||
#define OPENMC_TALLIES_FILTER_MU_H
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
void set_bins(gsl::span<double> bins);
|
||||
void set_bins(span<double> bins);
|
||||
|
||||
protected:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_MU_SURFACE_H
|
||||
#define OPENMC_TALLIES_FILTER_MU_SURFACE_H
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/tallies/filter_mu.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define OPENMC_TALLIES_FILTER_PARTICLE_H
|
||||
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -38,7 +39,7 @@ public:
|
|||
|
||||
const vector<ParticleType>& particles() const { return particles_; }
|
||||
|
||||
void set_particles(gsl::span<ParticleType> particles);
|
||||
void set_particles(span<ParticleType> particles);
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,7 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -39,7 +38,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
void set_bins(gsl::span<double> bins);
|
||||
void set_bins(span<double> bins);
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -3,8 +3,6 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/tallies/filter.h"
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -46,7 +44,7 @@ public:
|
|||
|
||||
SphericalHarmonicsCosine cosine() const { return cosine_; }
|
||||
|
||||
void set_cosine(gsl::cstring_span cosine);
|
||||
void set_cosine(const std::string& cosine);
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -40,7 +39,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
void set_surfaces(gsl::span<int32_t> surfaces);
|
||||
void set_surfaces(span<int32_t> surfaces);
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
#ifndef OPENMC_TALLIES_FILTER_TIME_H
|
||||
#define OPENMC_TALLIES_FILTER_TIME_H
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ public:
|
|||
// Accessors
|
||||
|
||||
const vector<double>& bins() const { return bins_; }
|
||||
void set_bins(gsl::span<const double> bins);
|
||||
void set_bins(span<const double> bins);
|
||||
|
||||
protected:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@
|
|||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -40,7 +39,7 @@ public:
|
|||
//----------------------------------------------------------------------------
|
||||
// Accessors
|
||||
|
||||
void set_universes(gsl::span<int32_t> universes);
|
||||
void set_universes(span<int32_t> universes);
|
||||
|
||||
private:
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/memory.h" // for unique_ptr
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
#include "openmc/tallies/trigger.h"
|
||||
#include "openmc/vector.h"
|
||||
|
|
@ -10,7 +11,6 @@
|
|||
#include "pugixml.hpp"
|
||||
#include "xtensor/xfixed.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
|
@ -93,7 +93,7 @@ public:
|
|||
//! \brief Check if this tally has a specified type of filter
|
||||
bool has_filter(FilterType filter_type) const;
|
||||
|
||||
void set_filters(gsl::span<Filter*> filters);
|
||||
void set_filters(span<Filter*> filters);
|
||||
|
||||
//! Given already-set filters, set the stride lengths
|
||||
void set_strides();
|
||||
|
|
@ -192,7 +192,7 @@ private:
|
|||
//! Whether to multiply by atom density for reaction rates
|
||||
bool multiply_density_ {true};
|
||||
|
||||
gsl::index index_;
|
||||
int64_t index_;
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include "pugixml.hpp"
|
||||
#include "xtensor/xtensor.hpp"
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#ifdef _OPENMP
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include <cstdint>
|
||||
#include <unordered_map>
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <hdf5.h>
|
||||
#include <pugixml.hpp>
|
||||
|
||||
|
|
@ -12,6 +11,7 @@
|
|||
#include "openmc/memory.h"
|
||||
#include "openmc/mesh.h"
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/span.h"
|
||||
#include "openmc/tallies/tally.h"
|
||||
#include "openmc/vector.h"
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ public:
|
|||
//! Set the weight window ID
|
||||
void set_id(int32_t id = -1);
|
||||
|
||||
void set_energy_bounds(gsl::span<const double> bounds);
|
||||
void set_energy_bounds(span<const double> bounds);
|
||||
|
||||
void set_mesh(const std::unique_ptr<Mesh>& mesh);
|
||||
|
||||
|
|
@ -148,9 +148,9 @@ public:
|
|||
void set_bounds(const xt::xtensor<double, 2>& lower_bounds, double ratio);
|
||||
|
||||
void set_bounds(
|
||||
gsl::span<const double> lower_bounds, gsl::span<const double> upper_bounds);
|
||||
span<const double> lower_bounds, span<const double> upper_bounds);
|
||||
|
||||
void set_bounds(gsl::span<const double> lower_bounds, double ratio);
|
||||
void set_bounds(span<const double> lower_bounds, double ratio);
|
||||
|
||||
void set_particle_type(ParticleType p_type);
|
||||
|
||||
|
|
@ -193,7 +193,7 @@ private:
|
|||
//----------------------------------------------------------------------------
|
||||
// Data members
|
||||
int32_t id_; //!< Unique ID
|
||||
gsl::index index_; //!< Index into weight windows vector
|
||||
int64_t index_; //!< Index into weight windows vector
|
||||
ParticleType particle_type_ {
|
||||
ParticleType::neutron}; //!< Particle type to apply weight windows to
|
||||
vector<double> energy_bounds_; //!< Energy boundaries [eV]
|
||||
|
|
|
|||
16
src/cell.cpp
16
src/cell.cpp
|
|
@ -2,6 +2,7 @@
|
|||
#include "openmc/cell.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
|
|
@ -10,7 +11,6 @@
|
|||
#include <string>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/constants.h"
|
||||
|
|
@ -137,7 +137,7 @@ void Cell::set_temperature(double T, int32_t instance, bool set_contained)
|
|||
auto contained_cells = this->get_contained_cells(instance);
|
||||
for (const auto& entry : contained_cells) {
|
||||
auto& cell = model::cells[entry.first];
|
||||
Expects(cell->type_ == Fill::MATERIAL);
|
||||
assert(cell->type_ == Fill::MATERIAL);
|
||||
auto& instances = entry.second;
|
||||
for (auto instance : instances) {
|
||||
cell->set_temperature(T, instance);
|
||||
|
|
@ -179,7 +179,7 @@ void Cell::import_properties_hdf5(hid_t group)
|
|||
// Modify temperatures for the cell
|
||||
sqrtkT_.clear();
|
||||
sqrtkT_.resize(temps.size());
|
||||
for (gsl::index i = 0; i < temps.size(); ++i) {
|
||||
for (int64_t i = 0; i < temps.size(); ++i) {
|
||||
this->set_temperature(temps[i], i);
|
||||
}
|
||||
|
||||
|
|
@ -570,7 +570,7 @@ void Region::apply_demorgan(
|
|||
//! precedence than unions using parentheses.
|
||||
//==============================================================================
|
||||
|
||||
gsl::index Region::add_parentheses(gsl::index start)
|
||||
int64_t Region::add_parentheses(int64_t start)
|
||||
{
|
||||
int32_t start_token = expression_[start];
|
||||
// Add left parenthesis and set new position to be after parenthesis
|
||||
|
|
@ -642,7 +642,7 @@ void Region::add_precedence()
|
|||
int32_t current_op = 0;
|
||||
std::size_t current_dist = 0;
|
||||
|
||||
for (gsl::index i = 0; i < expression_.size(); i++) {
|
||||
for (int64_t i = 0; i < expression_.size(); i++) {
|
||||
int32_t token = expression_[i];
|
||||
|
||||
if (token == OP_UNION || token == OP_INTERSECTION) {
|
||||
|
|
@ -938,7 +938,7 @@ BoundingBox Region::bounding_box_complex(vector<int32_t> postfix) const
|
|||
}
|
||||
}
|
||||
|
||||
Ensures(i_stack == 0);
|
||||
assert(i_stack == 0);
|
||||
return stack.front();
|
||||
}
|
||||
|
||||
|
|
@ -1210,8 +1210,8 @@ struct ParentCell {
|
|||
lattice_index < other.lattice_index);
|
||||
}
|
||||
|
||||
gsl::index cell_index;
|
||||
gsl::index lattice_index;
|
||||
int64_t cell_index;
|
||||
int64_t lattice_index;
|
||||
};
|
||||
|
||||
//! Structure used to insert ParentCell into hashed STL data structures
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "openmc/dagmc.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/container_util.h"
|
||||
#include "openmc/error.h"
|
||||
|
|
@ -800,7 +802,7 @@ Direction DAGSurface::normal(Position r) const
|
|||
|
||||
Direction DAGSurface::reflect(Position r, Direction u, GeometryState* p) const
|
||||
{
|
||||
Expects(p);
|
||||
assert(p);
|
||||
double pnt[3] = {r.x, r.y, r.z};
|
||||
double dir[3];
|
||||
moab::ErrorCode rval =
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
#include <stdexcept> // for runtime_error
|
||||
#include <string> // for string, stod
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/math_functions.h"
|
||||
#include "openmc/random_dist.h"
|
||||
|
|
@ -30,12 +28,12 @@ DiscreteIndex::DiscreteIndex(pugi::xml_node node)
|
|||
assign({params.data() + n, n});
|
||||
}
|
||||
|
||||
DiscreteIndex::DiscreteIndex(gsl::span<const double> p)
|
||||
DiscreteIndex::DiscreteIndex(span<const double> p)
|
||||
{
|
||||
assign(p);
|
||||
}
|
||||
|
||||
void DiscreteIndex::assign(gsl::span<const double> p)
|
||||
void DiscreteIndex::assign(span<const double> p)
|
||||
{
|
||||
prob_.assign(p.begin(), p.end());
|
||||
|
||||
|
|
@ -417,7 +415,7 @@ double Mixture::sample(uint64_t* seed) const
|
|||
p, [](const DistPair& pair, double p) { return pair.first < p; });
|
||||
|
||||
// This should not happen. Catch it
|
||||
Ensures(it != distribution_.cend());
|
||||
assert(it != distribution_.cend());
|
||||
|
||||
// Sample the chosen distribution
|
||||
return it->second->sample(seed);
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ MeshSpatial::MeshSpatial(pugi::xml_node node)
|
|||
elem_idx_dist_.assign(strengths);
|
||||
}
|
||||
|
||||
MeshSpatial::MeshSpatial(int32_t mesh_idx, gsl::span<const double> strengths)
|
||||
MeshSpatial::MeshSpatial(int32_t mesh_idx, span<const double> strengths)
|
||||
: mesh_idx_(mesh_idx)
|
||||
{
|
||||
check_element_types();
|
||||
|
|
@ -331,7 +331,7 @@ PointCloud::PointCloud(pugi::xml_node node)
|
|||
}
|
||||
|
||||
PointCloud::PointCloud(
|
||||
std::vector<Position> point_cloud, gsl::span<const double> strengths)
|
||||
std::vector<Position> point_cloud, span<const double> strengths)
|
||||
{
|
||||
point_cloud_.assign(point_cloud.begin(), point_cloud.end());
|
||||
point_idx_dist_.assign(strengths);
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ void prepare_distribcell(const std::vector<int32_t>* user_distribcells)
|
|||
|
||||
// By default, add material cells to the list of distributed cells
|
||||
if (settings::material_cell_offsets) {
|
||||
for (gsl::index i = 0; i < model::cells.size(); ++i) {
|
||||
for (int64_t i = 0; i < model::cells.size(); ++i) {
|
||||
if (model::cells[i]->type_ == Fill::MATERIAL)
|
||||
distribcells.insert(i);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "openmc/material.h"
|
||||
|
||||
#include <algorithm> // for min, max, sort, fill
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
#include <sstream>
|
||||
|
|
@ -933,7 +934,7 @@ void Material::calculate_photon_xs(Particle& p) const
|
|||
|
||||
void Material::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
assert(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in material map if an ID was already assigned before
|
||||
if (id_ != C_NONE) {
|
||||
|
|
@ -961,9 +962,9 @@ void Material::set_id(int32_t id)
|
|||
model::material_map[id] = index_;
|
||||
}
|
||||
|
||||
void Material::set_density(double density, gsl::cstring_span units)
|
||||
void Material::set_density(double density, const std::string& units)
|
||||
{
|
||||
Expects(density >= 0.0);
|
||||
assert(density >= 0.0);
|
||||
|
||||
if (nuclide_.empty()) {
|
||||
throw std::runtime_error {"No nuclides exist in material yet."};
|
||||
|
|
@ -1006,8 +1007,8 @@ void Material::set_densities(
|
|||
const vector<std::string>& name, const vector<double>& density)
|
||||
{
|
||||
auto n = name.size();
|
||||
Expects(n > 0);
|
||||
Expects(n == density.size());
|
||||
assert(n > 0);
|
||||
assert(n == density.size());
|
||||
|
||||
if (n != nuclide_.size()) {
|
||||
nuclide_.resize(n);
|
||||
|
|
@ -1017,7 +1018,7 @@ void Material::set_densities(
|
|||
}
|
||||
|
||||
double sum_density = 0.0;
|
||||
for (gsl::index i = 0; i < n; ++i) {
|
||||
for (int64_t i = 0; i < n; ++i) {
|
||||
const auto& nuc {name[i]};
|
||||
if (data::nuclide_map.find(nuc) == data::nuclide_map.end()) {
|
||||
int err = openmc_load_nuclide(nuc.c_str(), nullptr, 0);
|
||||
|
|
@ -1026,7 +1027,7 @@ void Material::set_densities(
|
|||
}
|
||||
|
||||
nuclide_[i] = data::nuclide_map.at(nuc);
|
||||
Expects(density[i] > 0.0);
|
||||
assert(density[i] > 0.0);
|
||||
atom_density_(i) = density[i];
|
||||
sum_density += density[i];
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ vector<SourceSite> mcpl_source_sites(std::string path)
|
|||
|
||||
#ifdef OPENMC_MCPL
|
||||
void write_mcpl_source_bank(mcpl_outfile_t file_id,
|
||||
gsl::span<SourceSite> source_bank, const vector<int64_t>& bank_index)
|
||||
span<SourceSite> source_bank, const vector<int64_t>& bank_index)
|
||||
{
|
||||
int64_t dims_size = settings::n_particles;
|
||||
int64_t count_size = simulation::work_per_rank;
|
||||
|
|
@ -188,8 +188,8 @@ void write_mcpl_source_bank(mcpl_outfile_t file_id,
|
|||
|
||||
//==============================================================================
|
||||
|
||||
void write_mcpl_source_point(const char* filename,
|
||||
gsl::span<SourceSite> source_bank, const vector<int64_t>& bank_index)
|
||||
void write_mcpl_source_point(const char* filename, span<SourceSite> source_bank,
|
||||
const vector<int64_t>& bank_index)
|
||||
{
|
||||
std::string filename_(filename);
|
||||
const auto extension = get_file_extension(filename_);
|
||||
|
|
|
|||
10
src/mesh.cpp
10
src/mesh.cpp
|
|
@ -1,9 +1,9 @@
|
|||
#include "openmc/mesh.h"
|
||||
#include <algorithm> // for copy, equal, min, min_element
|
||||
#include <cassert>
|
||||
#define _USE_MATH_DEFINES // to make M_PI declared in Intel and MSVC compilers
|
||||
#include <cmath> // for ceil
|
||||
#include <cstddef> // for size_t
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
#include <string>
|
||||
|
||||
#ifdef OPENMC_MPI
|
||||
|
|
@ -116,7 +116,7 @@ Mesh::Mesh(pugi::xml_node node)
|
|||
|
||||
void Mesh::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
assert(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in mesh map in case one was already assigned
|
||||
if (id_ != C_NONE) {
|
||||
|
|
@ -154,7 +154,7 @@ vector<double> Mesh::volumes() const
|
|||
}
|
||||
|
||||
int Mesh::material_volumes(
|
||||
int n_sample, int bin, gsl::span<MaterialVolume> result, uint64_t* seed) const
|
||||
int n_sample, int bin, span<MaterialVolume> result, uint64_t* seed) const
|
||||
{
|
||||
vector<int32_t> materials;
|
||||
vector<int64_t> hits;
|
||||
|
|
@ -3184,13 +3184,13 @@ void LibMesh::set_score_data(const std::string& var_name,
|
|||
// set value
|
||||
vector<libMesh::dof_id_type> value_dof_indices;
|
||||
dof_map.dof_indices(*it, value_dof_indices, value_num);
|
||||
Ensures(value_dof_indices.size() == 1);
|
||||
assert(value_dof_indices.size() == 1);
|
||||
eqn_sys.solution->set(value_dof_indices[0], values.at(bin));
|
||||
|
||||
// set std dev
|
||||
vector<libMesh::dof_id_type> std_dev_dof_indices;
|
||||
dof_map.dof_indices(*it, std_dev_dof_indices, std_dev_num);
|
||||
Ensures(std_dev_dof_indices.size() == 1);
|
||||
assert(std_dev_dof_indices.size() == 1);
|
||||
eqn_sys.solution->set(std_dev_dof_indices[0], std_dev.at(bin));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
#include "xtensor/xview.hpp"
|
||||
|
||||
#include <algorithm> // for sort, min_element
|
||||
#include <cassert>
|
||||
#include <string> // for to_string, stoi
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -999,19 +1000,19 @@ void Nuclide::calculate_urr_xs(int i_temp, Particle& p) const
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<gsl::index, double> Nuclide::find_temperature(double T) const
|
||||
std::pair<int64_t, double> Nuclide::find_temperature(double T) const
|
||||
{
|
||||
Expects(T >= 0.0);
|
||||
assert(T >= 0.0);
|
||||
|
||||
// Determine temperature index
|
||||
gsl::index i_temp = 0;
|
||||
int64_t i_temp = 0;
|
||||
double f = 0.0;
|
||||
double kT = K_BOLTZMANN * T;
|
||||
gsl::index n = kTs_.size();
|
||||
int64_t n = kTs_.size();
|
||||
switch (settings::temperature_method) {
|
||||
case TemperatureMethod::NEAREST: {
|
||||
double max_diff = INFTY;
|
||||
for (gsl::index t = 0; t < n; ++t) {
|
||||
for (int64_t t = 0; t < n; ++t) {
|
||||
double diff = std::abs(kTs_[t] - kT);
|
||||
if (diff < max_diff) {
|
||||
i_temp = t;
|
||||
|
|
@ -1038,17 +1039,17 @@ std::pair<gsl::index, double> Nuclide::find_temperature(double T) const
|
|||
f = (kT - kTs_[i_temp]) / (kTs_[i_temp + 1] - kTs_[i_temp]);
|
||||
}
|
||||
|
||||
Ensures(i_temp >= 0 && i_temp < n);
|
||||
assert(i_temp >= 0 && i_temp < n);
|
||||
|
||||
return {i_temp, f};
|
||||
}
|
||||
|
||||
double Nuclide::collapse_rate(int MT, double temperature,
|
||||
gsl::span<const double> energy, gsl::span<const double> flux) const
|
||||
span<const double> energy, span<const double> flux) const
|
||||
{
|
||||
Expects(MT > 0);
|
||||
Expects(energy.size() > 0);
|
||||
Expects(energy.size() == flux.size() + 1);
|
||||
assert(MT > 0);
|
||||
assert(energy.size() > 0);
|
||||
assert(energy.size() == flux.size() + 1);
|
||||
|
||||
int i_rx = reaction_index_[MT];
|
||||
if (i_rx < 0)
|
||||
|
|
@ -1056,7 +1057,7 @@ double Nuclide::collapse_rate(int MT, double temperature,
|
|||
const auto& rx = reactions_[i_rx];
|
||||
|
||||
// Determine temperature index
|
||||
gsl::index i_temp;
|
||||
int64_t i_temp;
|
||||
double f;
|
||||
std::tie(i_temp, f) = this->find_temperature(temperature);
|
||||
|
||||
|
|
|
|||
|
|
@ -65,8 +65,7 @@ Reaction::Reaction(hid_t group, const vector<int>& temperatures)
|
|||
}
|
||||
}
|
||||
|
||||
double Reaction::xs(
|
||||
gsl::index i_temp, gsl::index i_grid, double interp_factor) const
|
||||
double Reaction::xs(int64_t i_temp, int64_t i_grid, double interp_factor) const
|
||||
{
|
||||
// If energy is below threshold, return 0. Otherwise interpolate between
|
||||
// nearest grid points
|
||||
|
|
@ -82,9 +81,8 @@ double Reaction::xs(const NuclideMicroXS& micro) const
|
|||
return this->xs(micro.index_temp, micro.index_grid, micro.interp_factor);
|
||||
}
|
||||
|
||||
double Reaction::collapse_rate(gsl::index i_temp,
|
||||
gsl::span<const double> energy, gsl::span<const double> flux,
|
||||
const vector<double>& grid) const
|
||||
double Reaction::collapse_rate(int64_t i_temp, span<const double> energy,
|
||||
span<const double> flux, const vector<double>& grid) const
|
||||
{
|
||||
// Find index corresponding to first energy
|
||||
const auto& xs = xs_[i_temp].value;
|
||||
|
|
|
|||
|
|
@ -4,10 +4,9 @@
|
|||
#include "openmc/random_lcg.h"
|
||||
#include "openmc/search.h"
|
||||
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "xtensor/xview.hpp"
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath> // for log, exp
|
||||
|
||||
namespace openmc {
|
||||
|
|
@ -40,7 +39,7 @@ void CoherentElasticAE::sample(
|
|||
|
||||
const auto& energies {xs_.bragg_edges()};
|
||||
|
||||
Expects(E_in >= energies.front());
|
||||
assert(E_in >= energies.front());
|
||||
|
||||
const int i = lower_bound_index(energies.begin(), energies.end(), E_in);
|
||||
|
||||
|
|
|
|||
|
|
@ -439,7 +439,7 @@ void finalize_batch()
|
|||
int w = std::to_string(settings::n_max_batches).size();
|
||||
std::string source_point_filename = fmt::format("{0}source.{1:0{2}}",
|
||||
settings::path_output, simulation::current_batch, w);
|
||||
gsl::span<SourceSite> bankspan(simulation::source_bank);
|
||||
span<SourceSite> bankspan(simulation::source_bank);
|
||||
write_source_point(source_point_filename, bankspan,
|
||||
simulation::work_index, settings::source_mcpl_write);
|
||||
}
|
||||
|
|
@ -447,7 +447,7 @@ void finalize_batch()
|
|||
// Write a continously-overwritten source point if requested.
|
||||
if (settings::source_latest) {
|
||||
auto filename = settings::path_output + "source";
|
||||
gsl::span<SourceSite> bankspan(simulation::source_bank);
|
||||
span<SourceSite> bankspan(simulation::source_bank);
|
||||
write_source_point(filename, bankspan, simulation::work_index,
|
||||
settings::source_mcpl_write);
|
||||
}
|
||||
|
|
@ -469,7 +469,7 @@ void finalize_batch()
|
|||
// Get span of source bank and calculate parallel index vector
|
||||
auto surf_work_index = mpi::calculate_parallel_index_vector(
|
||||
simulation::surf_source_bank.size());
|
||||
gsl::span<SourceSite> surfbankspan(simulation::surf_source_bank.begin(),
|
||||
span<SourceSite> surfbankspan(simulation::surf_source_bank.begin(),
|
||||
simulation::surf_source_bank.size());
|
||||
|
||||
// Write surface source file
|
||||
|
|
|
|||
|
|
@ -567,7 +567,7 @@ hid_t h5banktype()
|
|||
return banktype;
|
||||
}
|
||||
|
||||
void write_source_point(std::string filename, gsl::span<SourceSite> source_bank,
|
||||
void write_source_point(std::string filename, span<SourceSite> source_bank,
|
||||
const vector<int64_t>& bank_index, bool use_mcpl)
|
||||
{
|
||||
std::string ext = use_mcpl ? "mcpl" : "h5";
|
||||
|
|
@ -584,8 +584,8 @@ void write_source_point(std::string filename, gsl::span<SourceSite> source_bank,
|
|||
}
|
||||
}
|
||||
|
||||
void write_h5_source_point(const char* filename,
|
||||
gsl::span<SourceSite> source_bank, const vector<int64_t>& bank_index)
|
||||
void write_h5_source_point(const char* filename, span<SourceSite> source_bank,
|
||||
const vector<int64_t>& bank_index)
|
||||
{
|
||||
// When using parallel HDF5, the file is written to collectively by all
|
||||
// processes. With MPI-only, the file is opened and written by the master
|
||||
|
|
@ -620,7 +620,7 @@ void write_h5_source_point(const char* filename,
|
|||
file_close(file_id);
|
||||
}
|
||||
|
||||
void write_source_bank(hid_t group_id, gsl::span<SourceSite> source_bank,
|
||||
void write_source_bank(hid_t group_id, span<SourceSite> source_bank,
|
||||
const vector<int64_t>& bank_index)
|
||||
{
|
||||
hid_t banktype = h5banktype();
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@
|
|||
#include <utility>
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/array.h"
|
||||
#include "openmc/container_util.h"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "openmc/tallies/filter.h"
|
||||
|
||||
#include <algorithm> // for max
|
||||
#include <cassert>
|
||||
#include <cstring> // for strcpy
|
||||
#include <string>
|
||||
|
||||
|
|
@ -162,7 +163,7 @@ Filter* Filter::create(const std::string& type, int32_t id)
|
|||
|
||||
void Filter::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
assert(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in filter map if an ID was already assigned before
|
||||
if (id_ != C_NONE) {
|
||||
|
|
|
|||
|
|
@ -34,14 +34,14 @@ void AzimuthalFilter::from_xml(pugi::xml_node node)
|
|||
this->set_bins(bins);
|
||||
}
|
||||
|
||||
void AzimuthalFilter::set_bins(gsl::span<double> bins)
|
||||
void AzimuthalFilter::set_bins(span<double> bins)
|
||||
{
|
||||
// Clear existing bins
|
||||
bins_.clear();
|
||||
bins_.reserve(bins.size());
|
||||
|
||||
// Copy bins, ensuring they are valid
|
||||
for (gsl::index i = 0; i < bins.size(); ++i) {
|
||||
for (int64_t i = 0; i < bins.size(); ++i) {
|
||||
if (i > 0 && bins[i] <= bins[i - 1]) {
|
||||
throw std::runtime_error {
|
||||
"Azimuthal bins must be monotonically increasing."};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "openmc/tallies/filter_cell.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include "openmc/capi.h"
|
||||
|
|
@ -25,7 +27,7 @@ void CellFilter::from_xml(pugi::xml_node node)
|
|||
this->set_cells(cells);
|
||||
}
|
||||
|
||||
void CellFilter::set_cells(gsl::span<int32_t> cells)
|
||||
void CellFilter::set_cells(span<int32_t> cells)
|
||||
{
|
||||
// Clear existing cells
|
||||
cells_.clear();
|
||||
|
|
@ -34,8 +36,8 @@ void CellFilter::set_cells(gsl::span<int32_t> cells)
|
|||
|
||||
// Update cells and mapping
|
||||
for (auto& index : cells) {
|
||||
Expects(index >= 0);
|
||||
Expects(index < model::cells.size());
|
||||
assert(index >= 0);
|
||||
assert(index < model::cells.size());
|
||||
cells_.push_back(index);
|
||||
map_[index] = cells_.size() - 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "openmc/tallies/filter_cell_instance.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
|
@ -12,7 +13,7 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
CellInstanceFilter::CellInstanceFilter(gsl::span<CellInstance> instances)
|
||||
CellInstanceFilter::CellInstanceFilter(span<CellInstance> instances)
|
||||
{
|
||||
this->set_cell_instances(instances);
|
||||
}
|
||||
|
|
@ -21,26 +22,26 @@ void CellInstanceFilter::from_xml(pugi::xml_node node)
|
|||
{
|
||||
// Get cell IDs/instances
|
||||
auto cells = get_node_array<int32_t>(node, "bins");
|
||||
Expects(cells.size() % 2 == 0);
|
||||
assert(cells.size() % 2 == 0);
|
||||
|
||||
// Convert into vector of CellInstance
|
||||
vector<CellInstance> instances;
|
||||
for (gsl::index i = 0; i < cells.size() / 2; ++i) {
|
||||
for (int64_t i = 0; i < cells.size() / 2; ++i) {
|
||||
int32_t cell_id = cells[2 * i];
|
||||
gsl::index instance = cells[2 * i + 1];
|
||||
int64_t instance = cells[2 * i + 1];
|
||||
auto search = model::cell_map.find(cell_id);
|
||||
if (search == model::cell_map.end()) {
|
||||
throw std::runtime_error {fmt::format(
|
||||
"Could not find cell {} specified on tally filter.", cell_id)};
|
||||
}
|
||||
gsl::index index = search->second;
|
||||
int64_t index = search->second;
|
||||
instances.push_back({index, instance});
|
||||
}
|
||||
|
||||
this->set_cell_instances(instances);
|
||||
}
|
||||
|
||||
void CellInstanceFilter::set_cell_instances(gsl::span<CellInstance> instances)
|
||||
void CellInstanceFilter::set_cell_instances(span<CellInstance> instances)
|
||||
{
|
||||
// Clear existing cells
|
||||
cell_instances_.clear();
|
||||
|
|
@ -50,8 +51,8 @@ void CellInstanceFilter::set_cell_instances(gsl::span<CellInstance> instances)
|
|||
|
||||
// Update cells and mapping
|
||||
for (auto& x : instances) {
|
||||
Expects(x.index_cell >= 0);
|
||||
Expects(x.index_cell < model::cells.size());
|
||||
assert(x.index_cell >= 0);
|
||||
assert(x.index_cell < model::cells.size());
|
||||
cell_instances_.push_back(x);
|
||||
cells_.insert(x.index_cell);
|
||||
map_[x] = cell_instances_.size() - 1;
|
||||
|
|
@ -72,8 +73,8 @@ void CellInstanceFilter::set_cell_instances(gsl::span<CellInstance> instances)
|
|||
void CellInstanceFilter::get_all_bins(
|
||||
const Particle& p, TallyEstimator estimator, FilterMatch& match) const
|
||||
{
|
||||
gsl::index index_cell = p.lowest_coord().cell;
|
||||
gsl::index instance = p.cell_instance();
|
||||
int64_t index_cell = p.lowest_coord().cell;
|
||||
int64_t instance = p.cell_instance();
|
||||
|
||||
if (cells_.count(index_cell) > 0) {
|
||||
auto search = map_.find({index_cell, instance});
|
||||
|
|
@ -88,13 +89,13 @@ void CellInstanceFilter::get_all_bins(
|
|||
return;
|
||||
|
||||
for (int i = 0; i < p.n_coord() - 1; i++) {
|
||||
gsl::index index_cell = p.coord(i).cell;
|
||||
int64_t index_cell = p.coord(i).cell;
|
||||
// if this cell isn't used on the filter, move on
|
||||
if (cells_.count(index_cell) == 0)
|
||||
continue;
|
||||
|
||||
// if this cell is used in the filter, check the instance as well
|
||||
gsl::index instance = cell_instance_at_level(p, i);
|
||||
int64_t instance = cell_instance_at_level(p, i);
|
||||
auto search = map_.find({index_cell, instance});
|
||||
if (search != map_.end()) {
|
||||
match.bins_.push_back(search->second);
|
||||
|
|
@ -108,7 +109,7 @@ void CellInstanceFilter::to_statepoint(hid_t filter_group) const
|
|||
Filter::to_statepoint(filter_group);
|
||||
size_t n = cell_instances_.size();
|
||||
xt::xtensor<size_t, 2> data({n, 2});
|
||||
for (gsl::index i = 0; i < n; ++i) {
|
||||
for (int64_t i = 0; i < n; ++i) {
|
||||
const auto& x = cell_instances_[i];
|
||||
data(i, 0) = model::cells[x.index_cell]->id_;
|
||||
data(i, 1) = x.instance;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ void CollisionFilter::from_xml(pugi::xml_node node)
|
|||
this->set_bins(bins);
|
||||
}
|
||||
|
||||
void CollisionFilter::set_bins(gsl::span<const int> bins)
|
||||
void CollisionFilter::set_bins(span<const int> bins)
|
||||
{
|
||||
// Clear existing bins
|
||||
bins_.clear();
|
||||
|
|
@ -27,7 +27,7 @@ void CollisionFilter::set_bins(gsl::span<const int> bins)
|
|||
map_.clear();
|
||||
|
||||
// Copy bins
|
||||
for (gsl::index i = 0; i < bins.size(); ++i) {
|
||||
for (int64_t i = 0; i < bins.size(); ++i) {
|
||||
bins_.push_back(bins[i]);
|
||||
map_[bins[i]] = i;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ void DelayedGroupFilter::from_xml(pugi::xml_node node)
|
|||
this->set_groups(groups);
|
||||
}
|
||||
|
||||
void DelayedGroupFilter::set_groups(gsl::span<int> groups)
|
||||
void DelayedGroupFilter::set_groups(span<int> groups)
|
||||
{
|
||||
// Clear existing groups
|
||||
groups_.clear();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "openmc/tallies/filter_distribcell.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include "openmc/cell.h"
|
||||
|
|
@ -29,8 +31,8 @@ void DistribcellFilter::from_xml(pugi::xml_node node)
|
|||
|
||||
void DistribcellFilter::set_cell(int32_t cell)
|
||||
{
|
||||
Expects(cell >= 0);
|
||||
Expects(cell < model::cells.size());
|
||||
assert(cell >= 0);
|
||||
assert(cell < model::cells.size());
|
||||
cell_ = cell;
|
||||
n_bins_ = model::cells[cell]->n_instances_;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,14 +21,14 @@ void EnergyFilter::from_xml(pugi::xml_node node)
|
|||
this->set_bins(bins);
|
||||
}
|
||||
|
||||
void EnergyFilter::set_bins(gsl::span<const double> bins)
|
||||
void EnergyFilter::set_bins(span<const double> bins)
|
||||
{
|
||||
// Clear existing bins
|
||||
bins_.clear();
|
||||
bins_.reserve(bins.size());
|
||||
|
||||
// Copy bins, ensuring they are valid
|
||||
for (gsl::index i = 0; i < bins.size(); ++i) {
|
||||
for (int64_t i = 0; i < bins.size(); ++i) {
|
||||
if (i > 0 && bins[i] <= bins[i - 1]) {
|
||||
throw std::runtime_error {
|
||||
"Energy bins must be monotonically increasing."};
|
||||
|
|
@ -46,7 +46,7 @@ void EnergyFilter::set_bins(gsl::span<const double> bins)
|
|||
if (!settings::run_CE) {
|
||||
if (n_bins_ == data::mg.num_energy_groups_) {
|
||||
matches_transport_groups_ = true;
|
||||
for (gsl::index i = 0; i < n_bins_ + 1; ++i) {
|
||||
for (int64_t i = 0; i < n_bins_ + 1; ++i) {
|
||||
if (data::mg.rev_energy_bins_[i] != bins_[i]) {
|
||||
matches_transport_groups_ = false;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ void EnergyFunctionFilter::from_xml(pugi::xml_node node)
|
|||
}
|
||||
|
||||
void EnergyFunctionFilter::set_data(
|
||||
gsl::span<const double> energy, gsl::span<const double> y)
|
||||
span<const double> energy, span<const double> y)
|
||||
{
|
||||
// Check for consistent sizes with new data
|
||||
if (energy.size() != y.size()) {
|
||||
|
|
@ -48,7 +48,7 @@ void EnergyFunctionFilter::set_data(
|
|||
y_.reserve(y.size());
|
||||
|
||||
// Copy over energy values, ensuring they are valid
|
||||
for (gsl::index i = 0; i < energy.size(); ++i) {
|
||||
for (int64_t i = 0; i < energy.size(); ++i) {
|
||||
if (i > 0 && energy[i] <= energy[i - 1]) {
|
||||
throw std::runtime_error {
|
||||
"Energy bins must be monotonically increasing."};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "openmc/tallies/filter_material.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include "openmc/capi.h"
|
||||
|
|
@ -24,7 +26,7 @@ void MaterialFilter::from_xml(pugi::xml_node node)
|
|||
this->set_materials(mats);
|
||||
}
|
||||
|
||||
void MaterialFilter::set_materials(gsl::span<const int32_t> materials)
|
||||
void MaterialFilter::set_materials(span<const int32_t> materials)
|
||||
{
|
||||
// Clear existing materials
|
||||
materials_.clear();
|
||||
|
|
@ -33,8 +35,8 @@ void MaterialFilter::set_materials(gsl::span<const int32_t> materials)
|
|||
|
||||
// Update materials and mapping
|
||||
for (auto& index : materials) {
|
||||
Expects(index >= 0);
|
||||
Expects(index < model::materials.size());
|
||||
assert(index >= 0);
|
||||
assert(index < model::materials.size());
|
||||
materials_.push_back(index);
|
||||
map_[index] = materials_.size() - 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include "openmc/tallies/filter_mesh.h"
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/constants.h"
|
||||
|
|
|
|||
|
|
@ -31,14 +31,14 @@ void MuFilter::from_xml(pugi::xml_node node)
|
|||
this->set_bins(bins);
|
||||
}
|
||||
|
||||
void MuFilter::set_bins(gsl::span<double> bins)
|
||||
void MuFilter::set_bins(span<double> bins)
|
||||
{
|
||||
// Clear existing bins
|
||||
bins_.clear();
|
||||
bins_.reserve(bins.size());
|
||||
|
||||
// Copy bins, ensuring they are valid
|
||||
for (gsl::index i = 0; i < bins.size(); ++i) {
|
||||
for (int64_t i = 0; i < bins.size(); ++i) {
|
||||
if (i > 0 && bins[i] <= bins[i - 1]) {
|
||||
throw std::runtime_error {"Mu bins must be monotonically increasing."};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ void ParticleFilter::from_xml(pugi::xml_node node)
|
|||
this->set_particles(types);
|
||||
}
|
||||
|
||||
void ParticleFilter::set_particles(gsl::span<ParticleType> particles)
|
||||
void ParticleFilter::set_particles(span<ParticleType> particles)
|
||||
{
|
||||
// Clear existing particles
|
||||
particles_.clear();
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ void PolarFilter::from_xml(pugi::xml_node node)
|
|||
this->set_bins(bins);
|
||||
}
|
||||
|
||||
void PolarFilter::set_bins(gsl::span<double> bins)
|
||||
void PolarFilter::set_bins(span<double> bins)
|
||||
{
|
||||
// Clear existing bins
|
||||
bins_.clear();
|
||||
bins_.reserve(bins.size());
|
||||
|
||||
// Copy bins, ensuring they are valid
|
||||
for (gsl::index i = 0; i < bins.size(); ++i) {
|
||||
for (int64_t i = 0; i < bins.size(); ++i) {
|
||||
if (i > 0 && bins[i] <= bins[i - 1]) {
|
||||
throw std::runtime_error {"Polar bins must be monotonically increasing."};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
#include "openmc/tallies/filter_sph_harm.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <utility> // For pair
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/error.h"
|
||||
|
|
@ -30,7 +30,7 @@ void SphericalHarmonicsFilter::set_order(int order)
|
|||
n_bins_ = (order_ + 1) * (order_ + 1);
|
||||
}
|
||||
|
||||
void SphericalHarmonicsFilter::set_cosine(gsl::cstring_span cosine)
|
||||
void SphericalHarmonicsFilter::set_cosine(const std::string& cosine)
|
||||
{
|
||||
if (cosine == "scatter") {
|
||||
cosine_ = SphericalHarmonicsCosine::scatter;
|
||||
|
|
@ -39,7 +39,7 @@ void SphericalHarmonicsFilter::set_cosine(gsl::cstring_span cosine)
|
|||
} else {
|
||||
throw std::invalid_argument {fmt::format("Unrecognized cosine type, \"{}\" "
|
||||
"in spherical harmonics filter",
|
||||
gsl::to_string(cosine))};
|
||||
cosine)};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ void SphericalHarmonicsFilter::to_statepoint(hid_t filter_group) const
|
|||
|
||||
std::string SphericalHarmonicsFilter::text_label(int bin) const
|
||||
{
|
||||
Expects(bin >= 0 && bin < n_bins_);
|
||||
assert(bin >= 0 && bin < n_bins_);
|
||||
for (int n = 0; n < order_ + 1; n++) {
|
||||
if (bin < (n + 1) * (n + 1)) {
|
||||
int m = (bin - n * n) - n;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "openmc/tallies/filter_surface.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include "openmc/error.h"
|
||||
|
|
@ -26,7 +28,7 @@ void SurfaceFilter::from_xml(pugi::xml_node node)
|
|||
this->set_surfaces(surfaces);
|
||||
}
|
||||
|
||||
void SurfaceFilter::set_surfaces(gsl::span<int32_t> surfaces)
|
||||
void SurfaceFilter::set_surfaces(span<int32_t> surfaces)
|
||||
{
|
||||
// Clear existing surfaces
|
||||
surfaces_.clear();
|
||||
|
|
@ -35,8 +37,8 @@ void SurfaceFilter::set_surfaces(gsl::span<int32_t> surfaces)
|
|||
|
||||
// Update surfaces and mapping
|
||||
for (auto& index : surfaces) {
|
||||
Expects(index >= 0);
|
||||
Expects(index < model::surfaces.size());
|
||||
assert(index >= 0);
|
||||
assert(index < model::surfaces.size());
|
||||
surfaces_.push_back(index);
|
||||
map_[index] = surfaces_.size() - 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ void TimeFilter::from_xml(pugi::xml_node node)
|
|||
this->set_bins(bins);
|
||||
}
|
||||
|
||||
void TimeFilter::set_bins(gsl::span<const double> bins)
|
||||
void TimeFilter::set_bins(span<const double> bins)
|
||||
{
|
||||
// Clear existing bins
|
||||
bins_.clear();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
#include "openmc/tallies/filter_universe.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include "openmc/cell.h"
|
||||
|
|
@ -24,7 +26,7 @@ void UniverseFilter::from_xml(pugi::xml_node node)
|
|||
this->set_universes(universes);
|
||||
}
|
||||
|
||||
void UniverseFilter::set_universes(gsl::span<int32_t> universes)
|
||||
void UniverseFilter::set_universes(span<int32_t> universes)
|
||||
{
|
||||
// Clear existing universes
|
||||
universes_.clear();
|
||||
|
|
@ -33,8 +35,8 @@ void UniverseFilter::set_universes(gsl::span<int32_t> universes)
|
|||
|
||||
// Update universes and mapping
|
||||
for (auto& index : universes) {
|
||||
Expects(index >= 0);
|
||||
Expects(index < model::universes.size());
|
||||
assert(index >= 0);
|
||||
assert(index < model::universes.size());
|
||||
universes_.push_back(index);
|
||||
map_[index] = universes_.size() - 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
#include "openmc/tallies/filter_zernike.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <sstream>
|
||||
#include <utility> // For pair
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
#include "openmc/capi.h"
|
||||
#include "openmc/error.h"
|
||||
|
|
@ -57,7 +57,7 @@ void ZernikeFilter::to_statepoint(hid_t filter_group) const
|
|||
|
||||
std::string ZernikeFilter::text_label(int bin) const
|
||||
{
|
||||
Expects(bin >= 0 && bin < n_bins_);
|
||||
assert(bin >= 0 && bin < n_bins_);
|
||||
for (int n = 0; n < order_ + 1; n++) {
|
||||
int last = (n + 1) * (n + 2) / 2;
|
||||
if (bin < last) {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include <fmt/core.h>
|
||||
|
||||
#include <algorithm> // for max
|
||||
#include <cassert>
|
||||
#include <cstddef> // for size_t
|
||||
#include <string>
|
||||
|
||||
|
|
@ -140,7 +141,7 @@ Tally::Tally(pugi::xml_node node)
|
|||
// Check for the presence of certain filter types
|
||||
bool has_energyout = energyout_filter_ >= 0;
|
||||
int particle_filter_index = C_NONE;
|
||||
for (gsl::index j = 0; j < filters_.size(); ++j) {
|
||||
for (int64_t j = 0; j < filters_.size(); ++j) {
|
||||
int i_filter = filters_[j];
|
||||
const auto& f = model::tally_filters[i_filter].get();
|
||||
|
||||
|
|
@ -345,7 +346,7 @@ Tally* Tally::create(int32_t id)
|
|||
|
||||
void Tally::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
assert(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in tally map if an ID was already assigned before
|
||||
if (id_ != C_NONE) {
|
||||
|
|
@ -401,7 +402,7 @@ bool Tally::has_filter(FilterType filter_type) const
|
|||
return false;
|
||||
}
|
||||
|
||||
void Tally::set_filters(gsl::span<Filter*> filters)
|
||||
void Tally::set_filters(span<Filter*> filters)
|
||||
{
|
||||
// Clear old data.
|
||||
filters_.clear();
|
||||
|
|
@ -1370,7 +1371,7 @@ extern "C" int openmc_tally_set_filters(
|
|||
try {
|
||||
// Convert indices to filter pointers
|
||||
vector<Filter*> filters;
|
||||
for (gsl::index i = 0; i < n; ++i) {
|
||||
for (int64_t i = 0; i < n; ++i) {
|
||||
int32_t i_filt = indices[i];
|
||||
filters.push_back(model::tally_filters.at(i_filt).get());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include "openmc/weight_windows.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
|
@ -32,7 +33,6 @@
|
|||
#include "openmc/xml_interface.h"
|
||||
|
||||
#include <fmt/core.h>
|
||||
#include <gsl/gsl-lite.hpp>
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ void WeightWindows::allocate_ww_bounds()
|
|||
|
||||
void WeightWindows::set_id(int32_t id)
|
||||
{
|
||||
Expects(id >= 0 || id == C_NONE);
|
||||
assert(id >= 0 || id == C_NONE);
|
||||
|
||||
// Clear entry in mesh map in case one was already assigned
|
||||
if (id_ != C_NONE) {
|
||||
|
|
@ -317,7 +317,7 @@ void WeightWindows::set_id(int32_t id)
|
|||
variance_reduction::ww_map[id] = index_;
|
||||
}
|
||||
|
||||
void WeightWindows::set_energy_bounds(gsl::span<const double> bounds)
|
||||
void WeightWindows::set_energy_bounds(span<const double> bounds)
|
||||
{
|
||||
energy_bounds_.clear();
|
||||
energy_bounds_.insert(energy_bounds_.begin(), bounds.begin(), bounds.end());
|
||||
|
|
@ -452,7 +452,7 @@ void WeightWindows::set_bounds(
|
|||
}
|
||||
|
||||
void WeightWindows::set_bounds(
|
||||
gsl::span<const double> lower_bounds, gsl::span<const double> upper_bounds)
|
||||
span<const double> lower_bounds, span<const double> upper_bounds)
|
||||
{
|
||||
check_bounds(lower_bounds, upper_bounds);
|
||||
auto shape = this->bounds_size();
|
||||
|
|
@ -466,8 +466,7 @@ void WeightWindows::set_bounds(
|
|||
xt::adapt(upper_bounds.data(), upper_ww_.shape());
|
||||
}
|
||||
|
||||
void WeightWindows::set_bounds(
|
||||
gsl::span<const double> lower_bounds, double ratio)
|
||||
void WeightWindows::set_bounds(span<const double> lower_bounds, double ratio)
|
||||
{
|
||||
this->check_bounds(lower_bounds);
|
||||
|
||||
|
|
|
|||
1
vendor/gsl-lite
vendored
1
vendor/gsl-lite
vendored
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 913e86d49c6a1acca980f4e325378f9dc393493a
|
||||
Loading…
Add table
Add a link
Reference in a new issue