Make sure RegularMesh methods are const. Address other comments by @smharper

This commit is contained in:
Paul Romano 2018-09-06 10:19:41 -05:00
parent 7807c169c4
commit 4c47d868b4
2 changed files with 29 additions and 34 deletions

View file

@ -35,50 +35,50 @@ public:
//! \param[out] bins Bins that were crossed
//! \param[out] lengths Fraction of tracklength in each bin
void bins_crossed(const Particle* p, std::vector<int>& bins,
std::vector<double>& lengths);
std::vector<double>& lengths) const;
//! Determine which surface bins were crossed by a particle
//!
//! \param[in] p Particle to check
//! \param[out] bins Surface bins that were crossed
void surface_bins_crossed(const Particle* p, std::vector<int>& bins);
void surface_bins_crossed(const Particle* p, std::vector<int>& bins) const;
//! Get bin at a given position in space
//!
//! \param[in] r Position to get bin for
//! \return Mesh bin
int get_bin(Position r);
int get_bin(Position r) const;
//! Get bin given mesh indices
//!
//! \param[in] Array of mesh indices
//! \return Mesh bin
int get_bin_from_indices(const int* ijk);
int get_bin_from_indices(const int* ijk) const;
//! Get mesh indices given a position
//!
//! \param[in] r Position to get indices for
//! \param[out] ijk Array of mesh indices
//! \param[out] in_mesh Whether position is in mesh
void get_indices(Position r, int* ijk, bool* in_mesh);
void get_indices(Position r, int* ijk, bool* in_mesh) const;
//! Get mesh indices corresponding to a mesh bin
//!
//! \param[in] bin Mesh bin
//! \param[out] ijk Mesh indices
void get_indices_from_bin(int bin, int* ijk);
void get_indices_from_bin(int bin, int* ijk) const;
//! Check if a line connected by two points intersects the mesh
//!
//! \param[in] r0 Starting position
//! \param[in] r1 Ending position
//! \return Whether line connecting r0 and r1 intersects mesh
bool intersects(Position r0, Position r1);
bool intersects(Position r0, Position r1) const;
//! Write mesh data to an HDF5 group
//!
//! \param[in] group HDF5 group
void to_hdf5(hid_t group);
void to_hdf5(hid_t group) const;
//! Count number of bank sites in each mesh bin / energy bin
//!
@ -89,7 +89,7 @@ public:
//! \param[out] Whether any bank sites are outside the mesh
//! \return Array indicating number of sites in each mesh/energy bin
xt::xarray<double> count_sites(int64_t n, const Bank* bank,
int n_energy, const double* energies, bool* outside);
int n_energy, const double* energies, bool* outside) const;
int id_ {-1}; //!< User-specified ID
int n_dimension_; //!< Number of dimensions
@ -100,9 +100,9 @@ public:
xt::xarray<double> width_; //!< Width of each mesh element
private:
bool intersects_1d(Position r0, Position r1);
bool intersects_2d(Position r0, Position r1);
bool intersects_3d(Position r0, Position r1);
bool intersects_1d(Position r0, Position r1) const;
bool intersects_2d(Position r0, Position r1) const;
bool intersects_3d(Position r0, Position r1) const;
};
//==============================================================================