Promote moab instance from unique to shared ptr and check null before calling constructor

This commit is contained in:
helen-brooks 2021-06-04 12:46:04 +01:00
parent 9ab4ae4755
commit 12bd847129
2 changed files with 10 additions and 7 deletions

View file

@ -506,7 +506,7 @@ private:
moab::Range ehs_; //!< Range of tetrahedra EntityHandle's in the mesh
moab::EntityHandle tetset_; //!< EntitySet containing all tetrahedra
moab::EntityHandle kdtree_root_; //!< Root of the MOAB KDTree
unique_ptr<moab::Interface> mbi_; //!< MOAB instance
std::shared_ptr<moab::Interface> mbi_; //!< MOAB instance
unique_ptr<moab::AdaptiveKDTree> kdtree_; //!< MOAB KDTree instance
vector<moab::Matrix3> baryc_data_; //!< Barycentric data for tetrahedra
vector<std::string> tag_names_; //!< Names of score tags added to the mesh

View file

@ -1621,13 +1621,16 @@ void MOABMesh::initialize() {
void
MOABMesh::create_interface()
{
// create MOAB instance
mbi_ = make_unique<moab::Core>();
if(mbi_ == nullptr){
// create MOAB instance
mbi_ = std::make_shared<moab::Core>();
// load unstructured mesh file
moab::ErrorCode rval = mbi_->load_file(filename_.c_str());
if (rval != moab::MB_SUCCESS) {
fatal_error("Failed to load the unstructured mesh file: " + filename_);
}
// load unstructured mesh file
moab::ErrorCode rval = mbi_->load_file(filename_.c_str());
if (rval != moab::MB_SUCCESS) {
fatal_error("Failed to load the unstructured mesh file: " + filename_);
}
}