diff --git a/include/openmc/mesh.h b/include/openmc/mesh.h index 44b1aa8c3..5d9b2f5a6 100644 --- a/include/openmc/mesh.h +++ b/include/openmc/mesh.h @@ -397,6 +397,7 @@ public: private: moab::Range ehs_; //!< Range of tetrahedra EntityHandle's in the mesh moab::EntityHandle meshset_; //!< EntitySet containing all Tets/Tris + moab::EntityHandle tet_set_; moab::EntityHandle kdtree_root_; //!< Root of the MOAB KDTree std::shared_ptr mbi_; //!< MOAB instance std::unique_ptr kdtree_; //!< MOAB KDTree instance diff --git a/src/mesh.cpp b/src/mesh.cpp index 49eff192a..b74435a95 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -1583,6 +1583,17 @@ UnstructuredMesh::UnstructuredMesh(pugi::xml_node node) : Mesh(node) { warning("Non-tetrahedral elements found in unstructured mesh: " + filename_); } + // make an entity set for all tetrahedra (used later in output) + rval = mbi_->create_meshset(moab::MESHSET_SET, tet_set_); + if (rval != moab::MB_SUCCESS) { + fatal_error("Failed to create an entity set for the tetrahedral elements"); + } + + rval = mbi_->add_entities(tet_set_, ehs_); + if (rval != moab::MB_SUCCESS) { + fatal_error("Failed to add tetrahedra to an entity set."); + } + compute_barycentric_data(ehs_); build_kdtree(ehs_); } @@ -2118,8 +2129,12 @@ UnstructuredMesh::write(std::string base_filename) const { // add extension to the base name base_filename += ".h5m"; + // write the tetrahedral elements of the mesh only + // to avoid clutter from zero-value data on other + // elements during visualization + moab::ErrorCode rval; - rval = mbi_->write_mesh(base_filename.c_str()); + rval = mbi_->write_mesh(base_filename.c_str(), &tet_set_, 1); if (rval != moab::MB_SUCCESS) { std::stringstream msg; msg << "Failed to write unstructured mesh " << id_; diff --git a/src/state_point.cpp b/src/state_point.cpp index 465bab506..a39b6f297 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -717,6 +717,7 @@ void write_unstructured_mesh_results() { tally->id_, simulation::current_batch, w); + umesh->write(umesh_filename); } }