Storing the first element ID rather than its pointer.

This commit is contained in:
Patrick Shriwise 2021-02-10 11:14:12 -06:00
parent 314e87b990
commit 6156e1b3ae
2 changed files with 4 additions and 3 deletions

View file

@ -544,7 +544,7 @@ private:
std::string eq_system_name_; //!< name of the equation system holding OpenMC results
std::unordered_map<std::string, unsigned int> variable_map_; //!< mapping of variable names (tally scores) to libMesh variable numbers
libMesh::BoundingBox bbox_; //!< bounding box of the mesh
libMesh::Elem* first_element_; //!< pointer to the first element in the mesh (maybe should be a key?)
libMesh::dof_id_type first_element_id_; //!< if of the first element in the mesh
};
#endif

View file

@ -2184,7 +2184,8 @@ void LibMesh::initialize()
}
// store first element in the mesh to use as an offset for bin indices
first_element_ = *m_->elements_begin();
auto first_elem = *m_->elements_begin();
first_element_id_ = first_elem->id();
// bounding box for the mesh for quick rejection checks
bbox_ = libMesh::MeshTools::create_bounding_box(*m_);
@ -2325,7 +2326,7 @@ LibMesh::get_bin(Position r) const
int
LibMesh::get_bin_from_element(const libMesh::Elem* elem) const
{
int bin = elem->id() - first_element_->id();
int bin = elem->id() - first_element_id_;
if (bin >= n_bins() || bin < 0) {
fatal_error(fmt::format("Invalid bin: {}", bin));
}