Commit ed6a8b5a authored by Thomas Steinreiter's avatar Thomas Steinreiter
Browse files

initial commit of libmesh example

parent 3b86bc6f
# Packages are optional: if they are not present, certain code samples are not compiled
cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
find_package(MPI) # Built-in in CMake
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/common.cmake)
#TODO: this is ugly, use cached variables
set(LIBMESH_INCLUDE_PATH $ENV{HOME}/libmesh/libmesh_install/include)
set(LIBMESH_LIBRARY_PATH $ENV{HOME}/libmesh/libmesh_install/lib)
set(LIBMESH_LIBRARIES mesh_opt)
# ==================================================================================================
if ("${DWARF_PREFIX}" STREQUAL "")
set(DWARF_PREFIX 8_unstructured)
endif()
set(NAME ${DWARF_PREFIX}_libmesh)
#TODO: check for libmesh too
if (MPI_FOUND)
enable_language(CXX)
include_directories(${MPI_INCLUDE_PATH} ${LIBMESH_INCLUDE_PATH})
link_directories(${LIBMESH_LIBRARY_PATH})
add_executable(${NAME} main.cpp)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost -std=c++14")
endif()
set_target_properties(${NAME} PROPERTIES CXX_STANDARD 14 CXX_STANDARD_REQUIRED YES)
target_link_libraries(${NAME} ${LIBMESH_LIBRARIES} ${MPI_LIBRARIES})
install(TARGETS ${NAME} DESTINATION bin)
message("** Enabling '${NAME}': with MPI")
else()
message("## Skipping '${NAME}': MPI support missing")
# dummy_install(${NAME} "MPI")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS}")
unset(NAME)
# ==================================================================================================
#include <cstdlib>
#include <iostream>
#include "libmesh/libmesh.h"
#include "libmesh/mesh.h"
using namespace libMesh;
int main(int argc, char* argv[]) {
LibMeshInit init(argc, argv);
if (argc < 4) {
libmesh_error_msg("Usage: " << argv[0] << " -d 2 in.mesh [-o out.mesh]");
}
const unsigned int dim = std::atoi(argv[2]);
Mesh mesh(init.comm());
std::string input_filename = argv[3];
mesh.read(argv[3]);
mesh.print_info();
if (argc >= 6 && std::string("-o") == argv[4]) {
// We may need XDR support compiled in to read binary .xdr files
std::string output_filename = argv[5];
mesh.write(argv[5]);
}
return EXIT_SUCCESS;
}
This diff is collapsed.
libMesh-0.7.0+
1 # number of elements
27 # number of nodes
. # boundary condition specification file
n/a # subdomain id specification file
n/a # processor id specification file
n/a # p-level specification file
1 # n_elem at level 0, [ type (n0 ... nN-1) ]
12 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
-1.00000000000000000e+00 -1.00000000000000000e+00 -1.00000000000000000e+00
1.00000000000000000e+00 -1.00000000000000000e+00 -1.00000000000000000e+00
1.00000000000000000e+00 1.00000000000000000e+00 -1.00000000000000000e+00
-1.00000000000000000e+00 1.00000000000000000e+00 -1.00000000000000000e+00
-1.00000000000000000e+00 -1.00000000000000000e+00 1.00000000000000000e+00
1.00000000000000000e+00 -1.00000000000000000e+00 1.00000000000000000e+00
1.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00
-1.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00
0.00000000000000000e+00 -1.00000000000000000e+00 -1.00000000000000000e+00
1.00000000000000000e+00 0.00000000000000000e+00 -1.00000000000000000e+00
0.00000000000000000e+00 1.00000000000000000e+00 -1.00000000000000000e+00
-1.00000000000000000e+00 0.00000000000000000e+00 -1.00000000000000000e+00
-1.00000000000000000e+00 -1.00000000000000000e+00 0.00000000000000000e+00
1.00000000000000000e+00 -1.00000000000000000e+00 0.00000000000000000e+00
1.00000000000000000e+00 1.00000000000000000e+00 0.00000000000000000e+00
-1.00000000000000000e+00 1.00000000000000000e+00 0.00000000000000000e+00
0.00000000000000000e+00 -1.00000000000000000e+00 1.00000000000000000e+00
1.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000000e+00
0.00000000000000000e+00 1.00000000000000000e+00 1.00000000000000000e+00
-1.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000000e+00
0.00000000000000000e+00 0.00000000000000000e+00 -1.00000000000000000e+00
0.00000000000000000e+00 -1.00000000000000000e+00 0.00000000000000000e+00
1.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00
0.00000000000000000e+00 1.00000000000000000e+00 0.00000000000000000e+00
-1.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00
0.00000000000000000e+00 0.00000000000000000e+00 1.00000000000000000e+00
0.00000000000000000e+00 0.00000000000000000e+00 0.00000000000000000e+00
6 # number of boundary conditions
0 0 0
0 1 1
0 2 2
0 3 3
0 4 4
0 5 5
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment