diff --git a/include/openmc/settings.h b/include/openmc/settings.h index ce2e7b10a3..b6044cf483 100644 --- a/include/openmc/settings.h +++ b/include/openmc/settings.h @@ -28,7 +28,7 @@ namespace openmc { namespace settings { #ifdef LIBMESH -extern std::unique_ptr LMI; +extern libMesh::LibMeshInit* LMI; #endif // Boolean flags diff --git a/src/finalize.cpp b/src/finalize.cpp index 7b28b5a7c2..f42e3134af 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -142,6 +142,10 @@ int openmc_finalize() if (mpi::bank != MPI_DATATYPE_NULL) MPI_Type_free(&mpi::bank); #endif +#ifdef LIBMESH + delete settings::LMI; +#endif + return 0; } diff --git a/src/initialize.cpp b/src/initialize.cpp index edc1df5001..d5040976e2 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -56,7 +56,7 @@ int openmc_init(int argc, char* argv[], const void* intracomm) #endif #ifdef LIBMESH - settings::LMI = std::unique_ptr(new libMesh::LibMeshInit(argc, argv)); + settings::LMI = new libMesh::LibMeshInit(argc, argv); #endif diff --git a/src/mesh.cpp b/src/mesh.cpp index c5fb650a01..e65cd912de 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -2280,8 +2280,15 @@ LibMesh::intersect_track(libMesh::Point start, // make sure we found a hit for the tet we're in if (side == -1) { + auto orig_e = e; start += dir * TINY_BIT; // nudge particle forward e = (*point_locator_)(start); + if (!e) { + if (!orig_e->on_boundary()) { + std::cout << "May have incorrectly truncated a track." << std::endl; + } + return; + } continue; } else { // add hit to output @@ -2299,7 +2306,7 @@ LibMesh::intersect_track(libMesh::Point start, // if we exit the mesh, check for re-entry along // the track - if (!next_e and e->on_boundary()) { + if (!next_e) { auto result = locate_boundary_element(start + dir * TINY_BIT, start + dir * track_remaining); if (result.second) { diff --git a/src/settings.cpp b/src/settings.cpp index 3326f0029a..21ce932ad5 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -38,7 +38,7 @@ namespace openmc { namespace settings { #ifdef LIBMESH -std::unique_ptr LMI; +libMesh::LibMeshInit* LMI; #endif // Default values for boolean flags