From fd00bd94b213f3c75af8cbfd9dde4ad0141fe6ee Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 12 Mar 2021 08:45:38 -0600 Subject: [PATCH] Relying on the libmesh communicator to create new mesh instances. --- include/openmc/mesh.h | 1 + src/initialize.cpp | 2 ++ src/mesh.cpp | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index d787db15a..cc0169ce0 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -55,6 +55,7 @@ extern std::vector> meshes; namespace settings { // used when creating new libMesh::Mesh instances extern std::unique_ptr libmesh_init; +extern const libMesh::Parallel::Communicator* libmesh_comm; } #endif diff --git a/src/initialize.cpp b/src/initialize.cpp index c480392cb..f6e927b68 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -80,6 +80,8 @@ if (!settings::libmesh_init && !libMesh::initialized()) // pass command line args, empty MPI communicator, and number of threads settings::libmesh_init = std::make_unique(argc, argv, 0, n_threads); #endif + + settings::libmesh_comm = &(settings::libmesh_init->comm()); } #endif diff --git a/src/mesh.cpp b/src/mesh.cpp index f74691334..30553c8c7 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -60,6 +60,7 @@ std::vector> meshes; #ifdef LIBMESH namespace settings { std::unique_ptr libmesh_init; +const libMesh::Parallel::Communicator* libmesh_comm; } #endif @@ -2150,11 +2151,11 @@ LibMesh::LibMesh(const std::string& filename) void LibMesh::initialize() { - if (!settings::libmesh_init) { - fatal_error("Attempting to use an unstructured mesh without a libMesh::LibMeshInit object."); + if (!settings::libmesh_comm) { + fatal_error("Attempting to use an unstructured mesh without a libMesh communicator."); } - m_ = std::make_unique(settings::libmesh_init->comm(), n_dimension_); + m_ = std::make_unique(*settings::libmesh_comm, n_dimension_); m_->read(filename_); m_->prepare_for_use();