From 0440d3e63e5f3fcded832f1056625a6cbe83730c Mon Sep 17 00:00:00 2001 From: Romain Boman <r.boman@uliege.be> Date: Wed, 8 Nov 2023 10:41:44 +0100 Subject: [PATCH] port to python 3.10, vs2022, oneapi --- cxxfem/CMakeLists.txt | 2 +- cxxfem/src/femMedium.cpp | 7 ++++++- envs/win-mingw64.cmd | 6 ++---- envs/win-msvc.cmd | 10 ++++------ fossils.py | 18 +++++++++++++++++- models/bonemodel2.py | 2 ++ 6 files changed, 32 insertions(+), 13 deletions(-) diff --git a/cxxfem/CMakeLists.txt b/cxxfem/CMakeLists.txt index 67d8562..8525593 100644 --- a/cxxfem/CMakeLists.txt +++ b/cxxfem/CMakeLists.txt @@ -1,5 +1,5 @@ -PROJECT(FEM CXX) CMAKE_MINIMUM_REQUIRED(VERSION 3.14) +PROJECT(FEM CXX) OPTION(FEM_USE_MKL "Use Pardiso linear solver from MKL" ON) diff --git a/cxxfem/src/femMedium.cpp b/cxxfem/src/femMedium.cpp index d603790..efbbe7e 100644 --- a/cxxfem/src/femMedium.cpp +++ b/cxxfem/src/femMedium.cpp @@ -11,7 +11,12 @@ Medium::Medium(Problem &pbl, std::string const &groupname, if (pbl.entities.empty()) // is the problem already sync'ed? pbl.sync(); - group = pbl.groups_by_name.at(groupname); + group = pbl.groups_by_name.at(groupname); + // (windows) if "fossils" fails here, check that gmsh.dll is not in both bin and lib + // folders of the gmsh folder (otherwise, both are loaded simultaneously, + // one from python, the other from c++! => 2 gmsh DBs are in use!) + // => move (do not copy) the dll from lib to bin + pbl.media.push_back(this); // construct 2D-plane-stress Hooke matrix diff --git a/envs/win-mingw64.cmd b/envs/win-mingw64.cmd index 105d323..a87c733 100644 --- a/envs/win-mingw64.cmd +++ b/envs/win-mingw64.cmd @@ -5,10 +5,8 @@ set COMPILERPATH="C:\mingw-w64" :: Intel MKL -set "INTELPATH=C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.5.281\windows" -@REM set LIB=%INTELPATH%\mkl\lib\intel64_win;%INTELPATH%\compiler\lib\intel64_win;%LIB% -@REM set INCLUDE=%INTELPATH%\mkl\include;%INCLUDE% -call "%INTELPATH%\mkl\bin\mklvars.bat" intel64 vs2019 +set "INTELPATH=C:\Program Files (x86)\Intel\oneAPI" +call "%INTELPATH%\mkl\latest\env\vars.bat" intel64 lp64 :: set the environment of the MinGW compiler CD /d "%~dp0" diff --git a/envs/win-msvc.cmd b/envs/win-msvc.cmd index f6ab0f3..be24e18 100644 --- a/envs/win-msvc.cmd +++ b/envs/win-msvc.cmd @@ -1,14 +1,12 @@ @echo off :: This file opens a terminal which allows you to compile the code with -:: Microsoft Visual Studio 2019 (x64) on Windows +:: Microsoft Visual Studio 2022 (x64) on Windows -set COMPILERPATH="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build" +set COMPILERPATH="C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build" :: Intel MKL -set "INTELPATH=C:\Program Files (x86)\IntelSWTools\compilers_and_libraries_2019.5.281\windows" -@REM set LIB=%INTELPATH%\mkl\lib\intel64_win;%INTELPATH%\compiler\lib\intel64_win;%LIB% -@REM set INCLUDE=%INTELPATH%\mkl\include;%INCLUDE% -call "%INTELPATH%\mkl\bin\mklvars.bat" intel64 vs2019 +set "INTELPATH=C:\Program Files (x86)\Intel\oneAPI" +call "%INTELPATH%\mkl\latest\env\vars.bat" intel64 lp64 :: set the environment of the msvc compiler CD /d "%~dp0" diff --git a/fossils.py b/fossils.py index 7fefe95..fc77b59 100755 --- a/fossils.py +++ b/fossils.py @@ -2,6 +2,13 @@ # -*- coding: utf-8 -*- # Fossils: # main script +# +# note: +# if starting Qt fails with +# qt.qpa.plugin: Could not find the Qt platform plugin "windows" in "" +# this means that an application in the PATH provides another version of Qt +# which is incompatible (MikTeX) +# => move MikTeX to the bottom of the user PATH. from PyQt5.QtCore import * from PyQt5.QtGui import * @@ -246,6 +253,12 @@ def setup_pythonpath(): # 'gmsh-sdk', 'bin')) # gmsh # print(f'sys.path={sys.path}') + # add_dll_directory for python>3.8 (add all folders) + import platform + if platform.system() == 'Windows' and sys.version_info.minor >= 8: + for v in os.environ['path'].split(';'): + if os.path.exists(v): + os.add_dll_directory(v) def build_workspace_name(workspace, testname): """create workspace folder and chdir into it @@ -277,8 +290,11 @@ if __name__ == "__main__": # add main program folder and binaries dir to the PYTHONPATH setup_pythonpath() - # redirect C++ streams to Python + # if the following import fails, check that all the dlls are in the PATH + # (in particular gmsh.dll) import cxxfem + + # redirect C++ streams to Python redirect = cxxfem.StdOutErr2Py() args = cxxfem.parseargs() diff --git a/models/bonemodel2.py b/models/bonemodel2.py index 5a08f4d..bd7cd8f 100644 --- a/models/bonemodel2.py +++ b/models/bonemodel2.py @@ -8,6 +8,8 @@ import cxxfem as fem from . import boneload import os import gmsh +if not gmsh.isInitialized(): + gmsh.initialize() import numpy as np -- GitLab