Relying on the libmesh communicator to create new mesh instances.

This commit is contained in:
Patrick Shriwise 2021-03-12 08:45:38 -06:00
parent 0abf803bb7
commit fd00bd94b2
3 changed files with 7 additions and 3 deletions

View file

@ -55,6 +55,7 @@ extern std::vector<std::unique_ptr<Mesh>> meshes;
namespace settings {
// used when creating new libMesh::Mesh instances
extern std::unique_ptr<libMesh::LibMeshInit> libmesh_init;
extern const libMesh::Parallel::Communicator* libmesh_comm;
}
#endif

View file

@ -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<libMesh::LibMeshInit>(argc, argv, 0, n_threads);
#endif
settings::libmesh_comm = &(settings::libmesh_init->comm());
}
#endif

View file

@ -60,6 +60,7 @@ std::vector<std::unique_ptr<Mesh>> meshes;
#ifdef LIBMESH
namespace settings {
std::unique_ptr<libMesh::LibMeshInit> 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<libMesh::Mesh>(settings::libmesh_init->comm(), n_dimension_);
m_ = std::make_unique<libMesh::Mesh>(*settings::libmesh_comm, n_dimension_);
m_->read(filename_);
m_->prepare_for_use();