From 605021f22593a0d24d0aa307e1c97deb34a467be Mon Sep 17 00:00:00 2001 From: Luca Heltai Date: Tue, 5 Dec 2017 15:58:29 +0100 Subject: [PATCH] Added FindGMSH to look for GMSH executable. --- cmake/configure/configure_gmsh.cmake | 20 ++++++ .../macros/macro_deal_ii_package_handle.cmake | 3 +- cmake/modules/FindGMSH.cmake | 36 ++++++++++ include/deal.II/base/config.h.in | 9 +++ tests/gmsh/CMakeLists.txt | 6 ++ tests/gmsh/create_tria_01.cc | 47 +++++++++++++ tests/gmsh/create_tria_01.output | 69 +++++++++++++++++++ 7 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 cmake/configure/configure_gmsh.cmake create mode 100644 cmake/modules/FindGMSH.cmake create mode 100644 tests/gmsh/CMakeLists.txt create mode 100644 tests/gmsh/create_tria_01.cc create mode 100644 tests/gmsh/create_tria_01.output diff --git a/cmake/configure/configure_gmsh.cmake b/cmake/configure/configure_gmsh.cmake new file mode 100644 index 0000000000..777b65fe3a --- /dev/null +++ b/cmake/configure/configure_gmsh.cmake @@ -0,0 +1,20 @@ +## --------------------------------------------------------------------- +## +## Copyright (C) 2017 by the deal.II authors +## +## This file is part of the deal.II library. +## +## The deal.II library is free software; you can use it, redistribute +## it, and/or modify it under the terms of the GNU Lesser General +## Public License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## The full text of the license can be found in the file LICENSE at +## the top level of the deal.II distribution. +## +## --------------------------------------------------------------------- + +# +# Configuration for the gmsh executable: +# + +CONFIGURE_FEATURE(GMSH) diff --git a/cmake/macros/macro_deal_ii_package_handle.cmake b/cmake/macros/macro_deal_ii_package_handle.cmake index 7c8ae71191..bedef00f0d 100644 --- a/cmake/macros/macro_deal_ii_package_handle.cmake +++ b/cmake/macros/macro_deal_ii_package_handle.cmake @@ -65,7 +65,8 @@ MACRO(DEAL_II_PACKAGE_HANDLE _feature _var) OR _arg MATCHES "^(|BUNDLED_|USER_)INCLUDE_DIRS$" OR _arg MATCHES "^(|USER_)DEFINITIONS(|_DEBUG|_RELEASE)$" OR _arg MATCHES "^CXX_FLAGS(|_DEBUG|_RELEASE)" - OR _arg MATCHES "^LINKER_FLAGS(|_DEBUG|_RELEASE)") + OR _arg MATCHES "^LINKER_FLAGS(|_DEBUG|_RELEASE)" + OR _arg MATCHES "^EXECUTABLE(|_DEBUG|_RELEASE)") IF(_fine) IF(_variable MATCHES "^CXX_FLAGS(|_DEBUG|_RELEASE)" diff --git a/cmake/modules/FindGMSH.cmake b/cmake/modules/FindGMSH.cmake new file mode 100644 index 0000000000..d138494fee --- /dev/null +++ b/cmake/modules/FindGMSH.cmake @@ -0,0 +1,36 @@ +## --------------------------------------------------------------------- +## +## Copyright (C) 2017 by the deal.II authors +## +## This file is part of the deal.II library. +## +## The deal.II library is free software; you can use it, redistribute +## it, and/or modify it under the terms of the GNU Lesser General +## Public License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## The full text of the license can be found in the file LICENSE at +## the top level of the deal.II distribution. +## +## --------------------------------------------------------------------- + +# +# Try to find the GMSH library +# +# This module exports +# +# GMSH_EXECUTABLE +# + +SET(GMSH_DIR "" CACHE PATH "An optional hint to a GMSH installation containing the gmsh executable") +SET_IF_EMPTY(GMSH_DIR "$ENV{GMSH_DIR}") + +DEAL_II_FIND_FILE(GMSH_EXE gmsh${CMAKE_EXECUTABLE_SUFFIX} + HINTS ${GMSH_DIR} + PATH_SUFFIXES bin + ) + +DEAL_II_PACKAGE_HANDLE(GMSH + EXECUTABLE REQUIRED GMSH_EXE + CLEAR + GMSH_EXE + ) diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index c56784bb77..cb6b5c4a70 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -41,6 +41,7 @@ #cmakedefine DEAL_II_WITH_CUDA #cmakedefine DEAL_II_WITH_CXX14 #cmakedefine DEAL_II_WITH_GSL +#cmakedefine DEAL_II_WITH_GMSH #cmakedefine DEAL_II_WITH_HDF5 #cmakedefine DEAL_II_WITH_LAPACK #cmakedefine DEAL_II_WITH_METIS @@ -192,6 +193,14 @@ >= \ (major)*10000 + (minor)*100 + (subminor)) + +/* + * gmsh: + */ +#ifdef DEAL_II_WITH_GMSH +# define GMSH_EXECUTABLE @GMSH_EXECUTABLE@ +#endif + /* * p4est: */ diff --git a/tests/gmsh/CMakeLists.txt b/tests/gmsh/CMakeLists.txt new file mode 100644 index 0000000000..3c209477af --- /dev/null +++ b/tests/gmsh/CMakeLists.txt @@ -0,0 +1,6 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) +INCLUDE(../setup_testsubproject.cmake) +PROJECT(testsuite CXX) +IF(DEAL_II_WITH_GMSH) + DEAL_II_PICKUP_TESTS() +ENDIF() diff --git a/tests/gmsh/create_tria_01.cc b/tests/gmsh/create_tria_01.cc new file mode 100644 index 0000000000..96327afe64 --- /dev/null +++ b/tests/gmsh/create_tria_01.cc @@ -0,0 +1,47 @@ +//----------------------------------------------------------- +// +// Copyright (C) 2014 - 2017 by the deal.II authors +// +// This file is subject to LGPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//----------------------------------------------------------- + +// Read a file in iges format, and write it out again in the same +// format. + +#include "../tests.h" + +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +int main () +{ + initlog(); + std::ofstream geo("file.geo"); + + geo << "Lx = 25.0;" << std::endl + << "Ly = 1.0;" << std::endl + << "Point(1) = {0, 0, 0, 1};" << std::endl + << "Point(2) = {Lx, 0, 0, 1};" << std::endl + << "Point(3) = {Lx, Ly, 0, 1};" << std::endl + << "Point(4) = {0, Ly, 0, 1};" << std::endl + << "Line(1) = {1, 2};" << std::endl + << "Line(2) = {2, 3};" << std::endl + << "Line(3) = {3, 4};" << std::endl + << "Line(4) = {4, 1};" << std::endl + << "Line Loop(5) = {3, 4, 1, 2};" << std::endl + << "Plane Surface(0) = {5};" << std::endl + << "Transfinite Surface{0} = {5};" << std::endl + << "Recombine Surface {0};" << std::endl; + + geo.close(); + + std::system(TOSTRING(GMSH_EXECUTABLE) " -2 file.geo 1>file.log 2>file_warn.log"); + + cat_file("file.msh"); + + return 0; +} diff --git a/tests/gmsh/create_tria_01.output b/tests/gmsh/create_tria_01.output new file mode 100644 index 0000000000..9233a4400d --- /dev/null +++ b/tests/gmsh/create_tria_01.output @@ -0,0 +1,69 @@ + +$MeshFormat +2.2 0 8 +$EndMeshFormat +$Nodes +22 +1 0 0 0 +2 25 0 0 +3 25 1 0 +4 0 1 0 +5 2.499999999990396 0 0 +6 4.999999999978534 0 0 +7 7.499999999965566 0 0 +8 9.999999999960014 0 0 +9 12.49999999995592 0 0 +10 14.99999999995182 0 0 +11 17.49999999995897 0 0 +12 19.99999999997264 0 0 +13 22.49999999998631 0 0 +14 22.50000000001776 1 0 +15 20.00000000003553 1 0 +16 17.50000000005329 1 0 +17 15.00000000006453 1 0 +18 12.50000000006454 1 0 +19 10.00000000006455 1 0 +20 7.500000000053301 1 0 +21 5.000000000035541 1 0 +22 2.500000000017781 1 0 +$EndNodes +$Elements +36 +1 15 2 0 1 1 +2 15 2 0 2 2 +3 15 2 0 3 3 +4 15 2 0 4 4 +5 1 2 0 1 1 5 +6 1 2 0 1 5 6 +7 1 2 0 1 6 7 +8 1 2 0 1 7 8 +9 1 2 0 1 8 9 +10 1 2 0 1 9 10 +11 1 2 0 1 10 11 +12 1 2 0 1 11 12 +13 1 2 0 1 12 13 +14 1 2 0 1 13 2 +15 1 2 0 2 2 3 +16 1 2 0 3 3 14 +17 1 2 0 3 14 15 +18 1 2 0 3 15 16 +19 1 2 0 3 16 17 +20 1 2 0 3 17 18 +21 1 2 0 3 18 19 +22 1 2 0 3 19 20 +23 1 2 0 3 20 21 +24 1 2 0 3 21 22 +25 1 2 0 3 22 4 +26 1 2 0 4 4 1 +27 3 2 0 0 3 14 13 2 +28 3 2 0 0 14 15 12 13 +29 3 2 0 0 15 16 11 12 +30 3 2 0 0 16 17 10 11 +31 3 2 0 0 17 18 9 10 +32 3 2 0 0 18 19 8 9 +33 3 2 0 0 19 20 7 8 +34 3 2 0 0 20 21 6 7 +35 3 2 0 0 21 22 5 6 +36 3 2 0 0 22 4 1 5 +$EndElements + -- 2.39.5