From cdb4bd201a11a527d0cf694209ce7f59532bfe76 Mon Sep 17 00:00:00 2001 From: acrovato <39187559+acrovato@users.noreply.github.com> Date: Wed, 23 Oct 2019 16:24:15 +0200 Subject: [PATCH] Various fixes for msys2 (windows) build. Rm mpi4py mandatory dependency. Rm catch by value and uninit build warnings for gcc9. Updt onera mesh size for greater robustness. --- CMakeLists.txt | 11 ++--------- flow/models/oneraM6.geo | 6 +++--- fwk/src/fwk.cpp | 4 ++-- fwk/wutils.py | 8 ++++++-- run.py | 5 ++--- tbox/src/wMshConvert.cpp | 2 +- tbox/src/wMshCrack.cpp | 6 +++--- tbox/src/wMumpsInterface.cpp | 8 ++++---- tboxVtk/src/wVtkExport.h | 2 +- tboxVtk/src/wVtkExport_KIM2CLEAN.h | 2 +- 10 files changed, 25 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index db8c4b0f..b7e06d9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake") # print OS MESSAGE(STATUS "CMAKE_SYSTEM_NAME=\"${CMAKE_SYSTEM_NAME}\"") +MESSAGE(STATUS "CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}") # (de)activate modules OPTION(WAVES_USE_FDTD "Compile fdtd module" ON) @@ -43,16 +44,9 @@ OPTION(WAVES_USE_TBB "Compile with TBB" ON) # --- Disable some Options on Windows IF(WIN32) # Trilinos is not available on Windows - IF(WAVES_USE_MRSTLNOS OR WAVES_USE_TLNOS) - MESSAGE("Disabling TRILINOS on Windows") - ENDIF() + MESSAGE("Disabling TRILINOS on Windows") SET(WAVES_USE_MRSTLNOS OFF CACHE BOOL "" FORCE) SET(WAVES_USE_TLNOS OFF CACHE BOOL "" FORCE) - # VTK requires MPI which is not compiled on Windows - IF(WAVES_USE_TBOXVTK) - MESSAGE("Disabling VTK/MPI on Windows") - ENDIF() - SET(WAVES_USE_TBOXVTK OFF CACHE BOOL "" FORCE) ENDIF() # macros/fcts @@ -63,7 +57,6 @@ SET(CMAKE_CXX_STANDARD 11) # newer way to set C++11 (requires cmake>=3.1) SET(CMAKE_CXX_STANDARD_REQUIRED ON) # Set specific languages flags -MESSAGE(STATUS "CMAKE_CXX_COMPILER_ID=${CMAKE_CXX_COMPILER_ID}") IF((CMAKE_CXX_COMPILER_ID MATCHES "GNU") OR (CMAKE_CXX_COMPILER_ID MATCHES "Intel")) IF(NOT APPLE) SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-as-needed") diff --git a/flow/models/oneraM6.geo b/flow/models/oneraM6.geo index 3300e283..6c14627b 100644 --- a/flow/models/oneraM6.geo +++ b/flow/models/oneraM6.geo @@ -177,7 +177,7 @@ Point(153) = {1.124337,1.196000,0.002498}; Point(154) = {1.119873,1.196000,0.003082}; Point(155) = {1.114592,1.196000,0.003771}; Point(156) = {1.108341,1.196000,0.004581}; -Point(157) = {1.100939,1.196000,0.005523,msTeTp}; +Point(157) = {1.100939,1.196000,0.005523,1.5*msTeTp}; Point(158) = {1.092167,1.196000,0.006570}; Point(159) = {1.081765,1.196000,0.007741}; Point(160) = {1.071292,1.196000,0.008870}; @@ -293,7 +293,7 @@ Point(269) = {1.060762,1.196000,-0.009957}; Point(270) = {1.071292,1.196000,-0.008870}; Point(271) = {1.081765,1.196000,-0.007741}; Point(272) = {1.092167,1.196000,-0.006570}; -Point(273) = {1.100939,1.196000,-0.005523,msTeTp}; +Point(273) = {1.100939,1.196000,-0.005523,1.5*msTeTp}; Point(274) = {1.108341,1.196000,-0.004581}; Point(275) = {1.114592,1.196000,-0.003771}; Point(276) = {1.119873,1.196000,-0.003082}; @@ -330,7 +330,7 @@ Point(5109) = {1.124337,1.196620,0.000000}; Point(5110) = {1.119873,1.196773,0.000000}; Point(5111) = {1.114592,1.196954,0.000000}; Point(5112) = {1.108341,1.197168,0.000000}; -Point(5113) = {1.100939,1.197422,0.000000,msTeTp}; +Point(5113) = {1.100939,1.197422,0.000000,1.5*msTeTp}; Point(5114) = {1.092167,1.197722,0.000000}; Point(5115) = {1.081765,1.198079,0.000000}; Point(5116) = {1.071292,1.198438,0.000000}; diff --git a/fwk/src/fwk.cpp b/fwk/src/fwk.cpp index 90e0c3b3..62abc853 100644 --- a/fwk/src/fwk.cpp +++ b/fwk/src/fwk.cpp @@ -48,10 +48,10 @@ FWK_API void enableFpe() */ FWK_API void disableFpe() { -#if defined(__GNUC__) && !defined(__clang__) +#if defined(__GNUC__) && !defined(__clang__) && !defined(__MINGW32__) std::cout << ANSI_COLOR_BLUE << "Disabling Floating-Point Exceptions..." << ANSI_COLOR_RESET << std::endl; fedisableexcept(FE_ALL_EXCEPT); #else std::cout << "disableFpe() is not implemented" << std::endl; #endif -} \ No newline at end of file +} diff --git a/fwk/wutils.py b/fwk/wutils.py index c3e4b4bc..ddadbdf0 100644 --- a/fwk/wutils.py +++ b/fwk/wutils.py @@ -69,10 +69,14 @@ def findbins(modname, dirB=['build','wavesB'], verb=False): # changer wavesB en if pyexe.find('_d.exe')>=0: print "[findbins] looking for win/debug libs" libpath.append(os.path.join(spath, 'bin/Debug'.replace('/',os.sep))) + if 'GCC' in sys.version: # windows+gcc = mingw => needs to append lib dir to PATH + os.environ['PATH'] += ';' + os.path.join(spath, 'bin') elif pyexe.find('.exe')>=0: print "[findbins] looking for win/release libs" libpath.append(os.path.join(spath, 'bin/Release'.replace('/',os.sep))) libpath.append(os.path.join(spath, 'bin/RelWithDebInfo'.replace('/',os.sep))) + if 'GCC' in sys.version: # windows+gcc = mingw => needs to append lib dir to PATH + os.environ['PATH'] += ';' + os.path.join(spath, 'bin') else: print "[findbins] looking for linux/mingw libs" libpath.append( os.path.join(spath, 'bin') ) # also for win-mingw @@ -179,8 +183,8 @@ def setupwdir(testname): for i in range(1,siz): comm.send(1, dest=i, tag=11) else: - # the others block and wait for rank0 ([RB] why not "mpi_barrier"????) - data = comm.recv(source=0, tag=11) + # the others block and wait for rank0 ([AC] before by KL, data = comm.recv(source=0, tag=11)) + comm.barrier() # we can now safely go into the new folder os.chdir(wdir) diff --git a/run.py b/run.py index c63eccf2..150d2f6b 100755 --- a/run.py +++ b/run.py @@ -41,12 +41,11 @@ def main(thisfile): global __file__ # required for run_pfem.py global __name__ # required for run_pfem.py import sys, os - import mpi4py.MPI as mpi # adds "." to the pythonpath - thisdir = os.path.split(thisfile)[0] - sys.path.append(thisdir) + sys.path.append(os.path.dirname(os.path.realpath(__file__))) import fwk.wutils as wu from fwk.coloring import ccolors + import fwk.testing # [AC]tmp fix for win-msys, to be removed once we understand why python cannot import this module outside run.py # redirect C++ streams to Python import fwk diff --git a/tbox/src/wMshConvert.cpp b/tbox/src/wMshConvert.cpp index bd8bb9e2..38a79f22 100644 --- a/tbox/src/wMshConvert.cpp +++ b/tbox/src/wMshConvert.cpp @@ -166,7 +166,7 @@ void MshConvert::ansys_gmsh(std::string const &fname1, std::string const &fname2 int i = 0; - int n1, n2, n3, n4; + int n1 = 0, n2 = 0, n3 = 0, n4 = 0; for (;;) { long double n; diff --git a/tbox/src/wMshCrack.cpp b/tbox/src/wMshCrack.cpp index d2201715..58046eaf 100644 --- a/tbox/src/wMshCrack.cpp +++ b/tbox/src/wMshCrack.cpp @@ -72,7 +72,7 @@ void MshCrack::addBoundaries(std::vector<std::string> const &bndName) bndGrps.push_back(gs); } // ... if not, an algorithm will later try to to separate the elements according to the side of the crack they are touching - catch (std::out_of_range) + catch (const std::out_of_range&) { Group *g = new Group(msh, name); bndGrp.push_back(g); @@ -161,7 +161,7 @@ void MshCrack::openCrack() { nods[j] = nodMap.at(e->nodes[e->nodes.size() - j - 1]); } - catch (std::out_of_range) + catch (const std::out_of_range&) { nods[j] = e->nodes[e->nodes.size() - j - 1]; } @@ -273,7 +273,7 @@ void MshCrack::swapNodes(Element *e) { e->nodes[i] = nodMap.at(e->nodes[i]); } - catch (std::out_of_range) + catch (const std::out_of_range&) { //std::cout << e->nodes[i]->no << "not found in map!\n"; } diff --git a/tbox/src/wMumpsInterface.cpp b/tbox/src/wMumpsInterface.cpp index e3f1aeed..98683b59 100644 --- a/tbox/src/wMumpsInterface.cpp +++ b/tbox/src/wMumpsInterface.cpp @@ -119,7 +119,7 @@ void MumpsInterface::setOptions(std::map<std::string, int> const &opts) } id.ICNTL(4) = opts.at("verbosity"); // level of printing [def=2] } - catch (std::out_of_range) + catch (const std::out_of_range&) { id.ICNTL(1) = -1; id.ICNTL(2) = -1; @@ -139,7 +139,7 @@ void MumpsInterface::setOptions(std::map<std::string, int> const &opts) else id.ICNTL(28) = 1; // sequential ordering } - catch (std::out_of_range) + catch (const std::out_of_range&) { id.ICNTL(7) = 3; // defaults to scotch because mumps comes witch scotch if install using apt } @@ -148,7 +148,7 @@ void MumpsInterface::setOptions(std::map<std::string, int> const &opts) { id.ICNTL(11) = opts.at("error_analysis"); // enable error analysis [def=0] } - catch (std::out_of_range) + catch (const std::out_of_range&) { id.ICNTL(11) = 0; // disabled } @@ -159,7 +159,7 @@ void MumpsInterface::setOptions(std::map<std::string, int> const &opts) { id.ICNTL(33) = opts.at("compute_determinant"); // compute determinant of A } - catch (std::out_of_range) + catch (const std::out_of_range&) { id.ICNTL(33) = 0; } diff --git a/tboxVtk/src/wVtkExport.h b/tboxVtk/src/wVtkExport.h index f551cbba..df458bf5 100644 --- a/tboxVtk/src/wVtkExport.h +++ b/tboxVtk/src/wVtkExport.h @@ -20,7 +20,7 @@ namespace tboxVtk * @brief Write mesh in VTK format * @authors Adrien Crovato, Romain Boman */ -class TBOX_API VtkExport : public tbox::MshExport +class TBOXVTK_API VtkExport : public tbox::MshExport { vtkSmartPointer<vtkUnstructuredGrid> grid; void create(); diff --git a/tboxVtk/src/wVtkExport_KIM2CLEAN.h b/tboxVtk/src/wVtkExport_KIM2CLEAN.h index a25d4d27..8a7a249d 100644 --- a/tboxVtk/src/wVtkExport_KIM2CLEAN.h +++ b/tboxVtk/src/wVtkExport_KIM2CLEAN.h @@ -24,7 +24,7 @@ namespace tboxVtk { * and finalization will have to be used. Those can be done using some unwanted #ifdef VTK_HAS_MPI or using more * elegant strategies or requiring VTK binaries that support MPI. */ -class TBOX_API VtkExport_KIM2CLEAN +class TBOXVTK_API VtkExport_KIM2CLEAN { public: std::shared_ptr<tbox::MshData> msh; -- GitLab