diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 6bc0843861..6c052b3e28 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -544,7 +544,7 @@ private: std::string eq_system_name_; //!< name of the equation system holding OpenMC results std::unordered_map variable_map_; //!< mapping of variable names (tally scores) to libMesh variable numbers libMesh::BoundingBox bbox_; //!< bounding box of the mesh - 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 diff --git a/src/mesh.cpp b/src/mesh.cpp index 32aa7c16a0..f746913344 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -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)); }