Skip to content
Snippets Groups Projects
Commit 82fe314d authored by wenqing's avatar wenqing
Browse files

[PMesh] Enabled the compilation of METIS into partmesh

parent 977afc56
No related branches found
No related tags found
No related merge requests found
if(UTILS_PARTMESH_BUILD_WITH_METIS)
include_directories(${METIS_PATH}/libmetis)
include_directories(${METIS_PATH}/programs)
include_directories(
${CMAKE_SOURCE_DIR}/Utils/PartitionMesh
${CMAKE_SOURCE_DIR}/BaseLib
${CMAKE_SOURCE_DIR}/FileIO
${CMAKE_SOURCE_DIR}/MeshLib
)
set(METIS_SOURCES
${METIS_PATH}/programs/mpmetis.c
${METIS_PATH}/programs/cmdline_mpmetis.c
${METIS_PATH}/programs/io.c
${METIS_PATH}/programs/stat.c
metis_main.h
)
ADD_LIBRARY(METIS_Lib STATIC ${METIS_SOURCES} )
add_executable(partmesh PartitionMesh.cpp MeshPartitioning.h MeshPartitioning.cpp)
set_target_properties(partmesh PROPERTIES FOLDER Utilities)
target_link_libraries(partmesh FileIO METIS_Lib metis)
else()
add_executable(partmesh PartitionMesh.cpp MeshPartitioning.h MeshPartitioning.cpp)
set_target_properties(partmesh PROPERTIES FOLDER Utilities)
target_link_libraries(partmesh FileIO)
endif()
add_executable(partmesh PartitionMesh.cpp MeshPartitioning.h MeshPartitioning.cpp)
set_target_properties(partmesh PROPERTIES FOLDER Utilities)
target_link_libraries(partmesh FileIO)
ADD_VTK_DEPENDENCY(partmesh)
####################
......
MESSAGE( STATUS "The METIS package is copyrighted by the Regents of the University of Minnesota." )
MESSAGE( STATUS "Please read the license of the METIS package carefully before you use the METIS." )
add_definitions(-DUSE_GKREGEX)
set(GKLIB_PATH "${METIS_PATH}/GKlib" CACHE PATH "path to GKlib")
set(SHARED FALSE CACHE BOOL "build a shared library")
if(MSVC)
set(METIS_INSTALL FALSE)
else()
set(METIS_INSTALL TRUE)
endif()
# Configure libmetis library.
if(SHARED)
set(METIS_LIBRARY_TYPE SHARED)
else()
set(METIS_LIBRARY_TYPE STATIC)
endif(SHARED)
include(${GKLIB_PATH}/GKlibSystem.cmake)
# Add include directories.
include_directories(${GKLIB_PATH})
include_directories(${METIS_PATH}/include)
# Recursively look for CMakeLists.txt in subdirs.
add_subdirectory("${METIS_PATH}/include")
add_subdirectory("${METIS_PATH}/libmetis")
......@@ -16,7 +16,13 @@
#include "logog/include/logog.hpp"
#include "LogogSimpleFormatter.h"
#ifdef BUILD_WITH_METIS
extern "C" {
#include "metis_main.h"
}
#endif
#include "BaseLib/LogogSimpleFormatter.h"
#include "BaseLib/FileTools.h"
#include "MeshLib/IO/readMeshFromFile.h"
......@@ -88,14 +94,36 @@ int main (int argc, char* argv[])
else
{
const int num_partitions = nparts.getValue();
std::string str_nparts = std::to_string(num_partitions);
// With the metis source code being compiled
if (num_partitions > 1)
{
#ifdef BUILD_WITH_METIS
INFO("METIS is running ...");
const int argc_m = 4;
char *argv_m[argc_m];
std::string unsc = "-"; // Avoid compilation warning by argv_m[0] = "-";
argv_m[0] = &unsc[0];
std::string option = "-gtype=nodal";
argv_m[1] = &option[0];
std::string part_mesh_file = file_name_base + ".mesh";
argv_m[2] = &part_mesh_file[0];
argv_m[3] = &str_nparts[0];
metis_main(argc_m, argv_m);
#endif
}
INFO("Partitioning the mesh in the node wise way ...");
// Binary output is default.
mesh->partitionByNodeMETIS(file_name_base, num_partitions, !asci_flag.getValue());
mesh->partitionByNodeMETIS(file_name_base, num_partitions,
!asci_flag.getValue());
INFO("Write the mesh with renumbered node indicies into VTU");
MeshLib::IO::VtuInterface writer(mesh);
writer.writeToFile(file_name_base + "_node_id_renumbered_partitions_" + std::to_string(num_partitions) + ".vtu");
writer.writeToFile(file_name_base + "_node_id_renumbered_partitions_"
+ str_nparts + ".vtu");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment