Start of libmesh implementation.

This commit is contained in:
Patrick Shriwise 2019-12-05 22:29:47 -06:00
parent 01f4e5674e
commit c95a0a914a
4 changed files with 91 additions and 0 deletions

View file

@ -31,6 +31,7 @@ option(debug "Compile with debug flags" OFF)
option(optimize "Turn on all compiler optimization flags" OFF)
option(coverage "Compile with coverage analysis flags" OFF)
option(dagmc "Enable support for DAGMC (CAD) geometry" OFF)
option(libmesh "Enable support for libmesh unstructured mesh tallies" OFF)
#===============================================================================
# MPI for distributed-memory parallelism
@ -65,6 +66,14 @@ if(pugixml_FOUND)
message(STATUS "Found pugixml: ${pugixml_DIR}")
else()
message(STATUS "Did not find pugixml, will use submodule instead")
#===============================================================================
# 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()
#===============================================================================
@ -405,6 +414,12 @@ if(dagmc)
target_link_libraries(libopenmc dagmc-shared uwuw-shared)
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

@ -0,0 +1,21 @@
# Try to find LIBMESH
#
# Once done this will define
#
# LIBMESH_FOUND - system has LIBMESH
# LIBMESH_INCLUDE_DIRS - the LIBMESH include directory
# LIBMESH_LIBRARIES - Link these to use LIBMESH
# LIBMESH_DEFINITIONS - Compiler switches required for using LIBMESH
find_path(LIBMESH NAMES libmesh_opt.so
HINTS ${LIBMESH_ROOT} $ENV{LIBMESH_ROOT}
PATHS ENV LD_LIBRARY_PATH
PATH_SUFFIXES lib Lib
NO_DEFAULT_PATH)
if(DEFINED LIBMESH)
set(LIBMESH_FOUND TRUE)
endif()
message(STATUS "Found LIBMESH in ${LIBMESH}")

View file

@ -22,6 +22,11 @@
#include "moab/GeomUtil.hpp"
#endif
#ifdef LIBMESH
#include "libmesh/libmesh.h"
#include "libmesh/mesh.h"
#endif
namespace openmc {
//==============================================================================
@ -251,6 +256,12 @@ public:
int set_grid();
};
class UnstructuredMeshBase : public Mesh {
public:
UnstructuredMeshBase(pugi::xml_node node);
std::string filename_;
};
#ifdef DAGMC
class UnstructuredMesh : public Mesh {
@ -422,6 +433,19 @@ private:
#endif
#ifdef LIBMESH
class LibMesh : public UnstructuredMeshBase {
public:
// constructor
LibMesh(pugi::xml_node node);
private:
std::unique_ptr<libMesh::Mesh> m_;
std::unique_ptr<libMesh::PointLocatorBase> point_locator_;
};
#endif
//==============================================================================
// Non-member functions
//==============================================================================

View file

@ -2027,6 +2027,37 @@ double UnstructuredMesh::get_volume_frac(int bin = -1) const {
#endif
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
//==============================================================================