Skip to content

Commit aa4de82

Browse files
gridleypaulromano
andauthored
remove gsl-lite dependency (#3225)
Co-authored-by: Paul Romano <[email protected]>
1 parent bcc2a4c commit aa4de82

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+458
-247
lines changed

.gitmodules

-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
[submodule "vendor/pugixml"]
22
path = vendor/pugixml
33
url = https://github.com/zeux/pugixml.git
4-
[submodule "vendor/gsl-lite"]
5-
path = vendor/gsl-lite
6-
url = https://github.com/martinmoene/gsl-lite.git
74
[submodule "vendor/xtensor"]
85
path = vendor/xtensor
96
url = https://github.com/xtensor-stack/xtensor.git

CMakeLists.txt

+1-14
Original file line numberDiff line numberDiff line change
@@ -293,19 +293,6 @@ if (NOT xtensor_FOUND)
293293
add_subdirectory(vendor/xtensor)
294294
endif()
295295

296-
#===============================================================================
297-
# GSL header-only library
298-
#===============================================================================
299-
300-
find_package_write_status(gsl-lite)
301-
if (NOT gsl-lite_FOUND)
302-
add_subdirectory(vendor/gsl-lite)
303-
304-
# Make sure contract violations throw exceptions
305-
target_compile_definitions(gsl-lite-v1 INTERFACE GSL_THROW_ON_CONTRACT_VIOLATION)
306-
target_compile_definitions(gsl-lite-v1 INTERFACE gsl_CONFIG_ALLOWS_NONSTRICT_SPAN_COMPARISON=1)
307-
endif()
308-
309296
#===============================================================================
310297
# Catch2 library
311298
#===============================================================================
@@ -519,7 +506,7 @@ endif()
519506
# target_link_libraries treats any arguments starting with - but not -l as
520507
# linker flags. Thus, we can pass both linker flags and libraries together.
521508
target_link_libraries(libopenmc ${ldflags} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES}
522-
xtensor gsl::gsl-lite-v1 fmt::fmt ${CMAKE_DL_LIBS})
509+
xtensor fmt::fmt ${CMAKE_DL_LIBS})
523510

524511
if(TARGET pugixml::pugixml)
525512
target_link_libraries(libopenmc pugixml::pugixml)

MANIFEST.in

-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,5 @@ recursive-include vendor *.hh
4343
recursive-include vendor *.hpp
4444
recursive-include vendor *.pc.in
4545
recursive-include vendor *.natvis
46-
include vendor/gsl-lite/include/gsl/gsl
4746
prune docs/build
4847
prune docs/source/pythonapi/generated/

cmake/OpenMCConfig.cmake.in

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
get_filename_component(OpenMC_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY)
22

33
find_package(fmt REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../fmt)
4-
find_package(gsl-lite REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../gsl-lite)
54
find_package(pugixml REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../pugixml)
65
find_package(xtl REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtl)
76
find_package(xtensor REQUIRED HINTS ${OpenMC_CMAKE_DIR}/../xtensor)

include/openmc/cell.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#include "hdf5.h"
1212
#include "pugixml.hpp"
13-
#include <gsl/gsl-lite.hpp>
1413

1514
#include "openmc/bounding_box.h"
1615
#include "openmc/constants.h"
@@ -128,7 +127,7 @@ class Region {
128127
void add_precedence();
129128

130129
//! Add parenthesis to enforce precedence
131-
gsl::index add_parentheses(gsl::index start);
130+
int64_t add_parentheses(int64_t start);
132131

133132
//! Remove complement operators from the expression
134133
void remove_complement_ops();
@@ -418,8 +417,8 @@ struct CellInstance {
418417
return index_cell == other.index_cell && instance == other.instance;
419418
}
420419

421-
gsl::index index_cell;
422-
gsl::index instance;
420+
int64_t index_cell;
421+
int64_t instance;
423422
};
424423

425424
//! Structure necessary for inserting CellInstance into hashed STL data

include/openmc/distribution.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#include <cstddef> // for size_t
88

99
#include "pugixml.hpp"
10-
#include <gsl/gsl-lite.hpp>
1110

1211
#include "openmc/constants.h"
1312
#include "openmc/memory.h" // for unique_ptr
13+
#include "openmc/span.h"
1414
#include "openmc/vector.h" // for vector
1515

1616
namespace openmc {
@@ -44,9 +44,9 @@ class DiscreteIndex {
4444
public:
4545
DiscreteIndex() {};
4646
DiscreteIndex(pugi::xml_node node);
47-
DiscreteIndex(gsl::span<const double> p);
47+
DiscreteIndex(span<const double> p);
4848

49-
void assign(gsl::span<const double> p);
49+
void assign(span<const double> p);
5050

5151
//! Sample a value from the distribution
5252
//! \param seed Pseudorandom number seed pointer

include/openmc/distribution_spatial.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "openmc/distribution.h"
77
#include "openmc/mesh.h"
88
#include "openmc/position.h"
9+
#include "openmc/span.h"
910

1011
namespace openmc {
1112

@@ -104,7 +105,7 @@ class SphericalIndependent : public SpatialDistribution {
104105
class MeshSpatial : public SpatialDistribution {
105106
public:
106107
explicit MeshSpatial(pugi::xml_node node);
107-
explicit MeshSpatial(int32_t mesh_id, gsl::span<const double> strengths);
108+
explicit MeshSpatial(int32_t mesh_id, span<const double> strengths);
108109

109110
//! Sample a position from the distribution
110111
//! \param seed Pseudorandom number seed pointer
@@ -144,7 +145,7 @@ class PointCloud : public SpatialDistribution {
144145
public:
145146
explicit PointCloud(pugi::xml_node node);
146147
explicit PointCloud(
147-
std::vector<Position> point_cloud, gsl::span<const double> strengths);
148+
std::vector<Position> point_cloud, span<const double> strengths);
148149

149150
//! Sample a position from the distribution
150151
//! \param seed Pseudorandom number seed pointer

include/openmc/interpolate.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
#include <cmath>
55
#include <vector>
66

7-
#include <gsl/gsl-lite.hpp>
8-
97
#include "openmc/error.h"
108
#include "openmc/search.h"
9+
#include "openmc/span.h"
1110

1211
namespace openmc {
1312

@@ -36,8 +35,8 @@ inline double interpolate_log_log(
3635
return y0 * std::exp(f * std::log(y1 / y0));
3736
}
3837

39-
inline double interpolate_lagrangian(gsl::span<const double> xs,
40-
gsl::span<const double> ys, int idx, double x, int order)
38+
inline double interpolate_lagrangian(
39+
span<const double> xs, span<const double> ys, int idx, double x, int order)
4140
{
4241
double output {0.0};
4342

@@ -56,9 +55,8 @@ inline double interpolate_lagrangian(gsl::span<const double> xs,
5655
return output;
5756
}
5857

59-
inline double interpolate(gsl::span<const double> xs,
60-
gsl::span<const double> ys, double x,
61-
Interpolation i = Interpolation::lin_lin)
58+
inline double interpolate(span<const double> xs, span<const double> ys,
59+
double x, Interpolation i = Interpolation::lin_lin)
6260
{
6361
int idx = lower_bound_index(xs.begin(), xs.end(), x);
6462

include/openmc/material.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
#include <string>
55
#include <unordered_map>
66

7+
#include "openmc/span.h"
78
#include "pugixml.hpp"
89
#include "xtensor/xtensor.hpp"
9-
#include <gsl/gsl-lite.hpp>
1010
#include <hdf5.h>
1111

1212
#include "openmc/bremsstrahlung.h"
@@ -118,21 +118,21 @@ class Material {
118118
//
119119
//! \param[in] density Density value
120120
//! \param[in] units Units of density
121-
void set_density(double density, gsl::cstring_span units);
121+
void set_density(double density, const std::string& units);
122122

123123
//! Set temperature of the material
124124
void set_temperature(double temperature) { temperature_ = temperature; };
125125

126126
//! Get nuclides in material
127127
//! \return Indices into the global nuclides vector
128-
gsl::span<const int> nuclides() const
128+
span<const int> nuclides() const
129129
{
130130
return {nuclide_.data(), nuclide_.size()};
131131
}
132132

133133
//! Get densities of each nuclide in material
134134
//! \return Densities in [atom/b-cm]
135-
gsl::span<const double> densities() const
135+
span<const double> densities() const
136136
{
137137
return {atom_density_.data(), atom_density_.size()};
138138
}
@@ -210,7 +210,7 @@ class Material {
210210

211211
//----------------------------------------------------------------------------
212212
// Private data members
213-
gsl::index index_;
213+
int64_t index_;
214214

215215
bool depletable_ {false}; //!< Is the material depletable?
216216
bool fissionable_ {

include/openmc/mcpl_interface.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
#define OPENMC_MCPL_INTERFACE_H
33

44
#include "openmc/particle_data.h"
5+
#include "openmc/span.h"
56
#include "openmc/vector.h"
67

7-
#include <gsl/gsl-lite.hpp>
8-
98
#include <string>
109

1110
namespace openmc {
@@ -30,13 +29,14 @@ vector<SourceSite> mcpl_source_sites(std::string path);
3029
//
3130
//! \param[in] filename Path to MCPL file
3231
//! \param[in] source_bank Vector of SourceSites to write to file for this
33-
//! MPI rank
32+
//! MPI rank. Note that this can't be const due to
33+
//! it being used as work space by MPI.
3434
//! \param[in] bank_indx Pointer to vector of site index ranges over all
3535
//! MPI ranks. This can be computed by calling
3636
//! calculate_parallel_index_vector on
3737
//! source_bank.size().
38-
void write_mcpl_source_point(const char* filename,
39-
gsl::span<SourceSite> source_bank, vector<int64_t> const& bank_index);
38+
void write_mcpl_source_point(const char* filename, span<SourceSite> source_bank,
39+
const vector<int64_t>& bank_index);
4040
} // namespace openmc
4141

4242
#endif // OPENMC_MCPL_INTERFACE_H

include/openmc/mesh.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
#include "hdf5.h"
1010
#include "pugixml.hpp"
1111
#include "xtensor/xtensor.hpp"
12-
#include <gsl/gsl-lite.hpp>
1312

1413
#include "openmc/bounding_box.h"
1514
#include "openmc/error.h"
1615
#include "openmc/memory.h" // for unique_ptr
1716
#include "openmc/particle.h"
1817
#include "openmc/position.h"
18+
#include "openmc/span.h"
1919
#include "openmc/vector.h"
2020
#include "openmc/xml_interface.h"
2121

@@ -179,8 +179,8 @@ class Mesh {
179179
//! \param[out] Array of (material index, volume) for desired element
180180
//! \param[inout] seed Pseudorandom number seed
181181
//! \return Number of materials within element
182-
int material_volumes(int n_sample, int bin, gsl::span<MaterialVolume> volumes,
183-
uint64_t* seed) const;
182+
int material_volumes(
183+
int n_sample, int bin, span<MaterialVolume> volumes, uint64_t* seed) const;
184184

185185
//! Determine volume of materials within a single mesh elemenet
186186
//

include/openmc/nuclide.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <unordered_map>
88
#include <utility> // for pair
99

10-
#include <gsl/gsl-lite.hpp>
1110
#include <hdf5.h>
1211

1312
#include "openmc/array.h"
@@ -17,6 +16,7 @@
1716
#include "openmc/particle.h"
1817
#include "openmc/reaction.h"
1918
#include "openmc/reaction_product.h"
19+
#include "openmc/span.h"
2020
#include "openmc/urr.h"
2121
#include "openmc/vector.h"
2222
#include "openmc/wmp.h"
@@ -81,8 +81,8 @@ class Nuclide {
8181
//! \param[in] energy Energy group boundaries in [eV]
8282
//! \param[in] flux Flux in each energy group (not normalized per eV)
8383
//! \return Reaction rate
84-
double collapse_rate(int MT, double temperature,
85-
gsl::span<const double> energy, gsl::span<const double> flux) const;
84+
double collapse_rate(int MT, double temperature, span<const double> energy,
85+
span<const double> flux) const;
8686

8787
//============================================================================
8888
// Data members
@@ -91,7 +91,7 @@ class Nuclide {
9191
int A_; //!< Mass number
9292
int metastable_; //!< Metastable state
9393
double awr_; //!< Atomic weight ratio
94-
gsl::index index_; //!< Index in the nuclides array
94+
int64_t index_; //!< Index in the nuclides array
9595

9696
// Temperature dependent cross section data
9797
vector<double> kTs_; //!< temperatures in eV (k*T)
@@ -138,7 +138,7 @@ class Nuclide {
138138
//
139139
//! \param[in] T Temperature in [K]
140140
//! \return Temperature index and interpolation factor
141-
std::pair<gsl::index, double> find_temperature(double T) const;
141+
std::pair<int64_t, double> find_temperature(double T) const;
142142

143143
static int XS_TOTAL;
144144
static int XS_ABSORPTION;

include/openmc/photon.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include "openmc/vector.h"
88

99
#include "xtensor/xtensor.hpp"
10-
#include <gsl/gsl-lite.hpp>
1110
#include <hdf5.h>
1211

1312
#include <string>
@@ -61,7 +60,7 @@ class PhotonInteraction {
6160
// Data members
6261
std::string name_; //!< Name of element, e.g. "Zr"
6362
int Z_; //!< Atomic number
64-
gsl::index index_; //!< Index in global elements vector
63+
int64_t index_; //!< Index in global elements vector
6564

6665
// Microscopic cross sections
6766
xt::xtensor<double, 1> energy_;

include/openmc/reaction.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#include <string>
88

99
#include "hdf5.h"
10-
#include <gsl/gsl-lite.hpp>
1110

1211
#include "openmc/particle_data.h"
1312
#include "openmc/reaction_product.h"
13+
#include "openmc/span.h"
1414
#include "openmc/vector.h"
1515

1616
namespace openmc {
@@ -33,7 +33,7 @@ class Reaction {
3333
//! \param[in] i_temp Temperature index
3434
//! \param[in] i_grid Energy grid index
3535
//! \param[in] interp_factor Interpolation factor between grid points
36-
double xs(gsl::index i_temp, gsl::index i_grid, double interp_factor) const;
36+
double xs(int64_t i_temp, int64_t i_grid, double interp_factor) const;
3737

3838
//! Calculate cross section
3939
//
@@ -47,8 +47,8 @@ class Reaction {
4747
//! \param[in] flux Flux in each energy group (not normalized per eV)
4848
//! \param[in] grid Nuclide energy grid
4949
//! \return Reaction rate
50-
double collapse_rate(gsl::index i_temp, gsl::span<const double> energy,
51-
gsl::span<const double> flux, const vector<double>& grid) const;
50+
double collapse_rate(int64_t i_temp, span<const double> energy,
51+
span<const double> flux, const vector<double>& grid) const;
5252

5353
//! Cross section at a single temperature
5454
struct TemperatureXS {

0 commit comments

Comments
 (0)