Start of libmesh implementation.

This commit is contained in:
Patrick Shriwise 2019-12-05 22:29:47 -06:00
parent 8b7a09eee1
commit 26fafd319e
2 changed files with 47 additions and 0 deletions

View file

@ -73,6 +73,16 @@ if(libmesh)
find_package(LIBMESH REQUIRED)
endif()
#===============================================================================
# libmesh Unstructured Mesh Support
#===============================================================================
if(libmesh)
find_package(LIBMESH REQUIRED)
set(LIBMESH_LIBRARIES mesh_opt)
set(LIBMESH_INCLUDE_DIRS "${LIBMESH}/../include/")
link_directories(${LIBMESH})
endif()
#===============================================================================
# HDF5 for binary output
#===============================================================================
@ -418,6 +428,12 @@ if(libmesh)
target_link_libraries(libopenmc PkgConfig::LIBMESH)
endif()
if(libmesh)
target_compile_definitions(libopenmc PRIVATE LIBMESH)
target_link_libraries(libopenmc ${LIBMESH_LIBRARIES})
target_include_directories(libopenmc PRIVATE ${LIBMESH_INCLUDE_DIRS})
endif()
#===============================================================================
# openmc executable
#===============================================================================

View file

@ -2372,6 +2372,37 @@ double LibMesh::volume(int bin) const { return m_->elem_ref(bin).volume(); }
#endif // LIBMESH
UnstructuredMeshBase::UnstructuredMeshBase(pugi::xml_node node) : Mesh(node) {
// check the mesh type
if (check_for_node(node, "type")) {
auto temp = get_node_value(node, "type", true, true);
if (temp != "unstructured") {
fatal_error("Invalid mesh type: " + temp);
}
}
// get the filename of the unstructured mesh to load
if (check_for_node(node, "mesh_file")) {
filename_ = get_node_value(node, "mesh_file");
}
else {
fatal_error("No filename supplied for unstructured mesh with ID: " +
std::to_string(id_));
}
}
#ifdef LIBMESH
LibMesh::LibMesh(pugi::xml_node node) : UnstructuredMeshBase(node) {
libMesh::LibMeshInit init(0, NULL);
m_ = std::unique_ptr<libMesh::Mesh>(new libMesh::Mesh(init.comm(), 3));
m_->read(filename_);
point_locator_ = m_->sub_point_locator();
m_->find_neighbors();
}
#endif
//==============================================================================
// Non-member functions
//==============================================================================