From dbdba9efbafd2623d76bda2c53eac971b7ac05f2 Mon Sep 17 00:00:00 2001 From: Romain Boman <romain.boman@gmail.com> Date: Wed, 23 Mar 2022 13:30:01 +0100 Subject: [PATCH] add amfe dependency (spirou:OK except lift3) --- .gitignore | 1 + .gitlab-ci.yml | 11 + .gitmodules | 3 + CMake/FindEIGEN.cmake | 78 --- CMake/FindMUMPS.cmake | 81 --- CMake/FindNUMPY.cmake | 21 - CMake/FindPYTEUCHOS.cmake | 21 - CMake/FindTBB.cmake | 281 -------- CMake/codeblocks.cmake | 20 - CMake/fwkMacros.cmake | 63 -- CMake/spring.cmake | 24 - CMake/ubuntu.cmake | 23 - CMakeLists.txt | 65 +- README.md | 7 +- ext/CMakeLists.txt | 1 + ext/amfe | 1 + flow/_src/CMakeLists.txt | 15 +- flow/default.py | 3 +- flow/src/CMakeLists.txt | 2 + fwk/CMakeLists.txt | 20 - fwk/__init__.py | 8 - fwk/_src/CMakeLists.txt | 43 -- fwk/_src/fwkw.h | 24 - fwk/_src/fwkw.i | 124 ---- fwk/_src/fwkw.swg | 105 --- fwk/_src/wCppBuf2Py.cpp | 102 --- fwk/_src/wCppBuf2Py.h | 69 -- fwk/coloring.py | 24 - fwk/src/CMakeLists.txt | 26 - fwk/src/fwk.cpp | 73 -- fwk/src/fwk.h | 67 -- fwk/src/wExtract.cpp | 35 - fwk/src/wExtract.h | 44 -- fwk/src/wHMSTime.cpp | 73 -- fwk/src/wHMSTime.h | 46 -- fwk/src/wObject.cpp | 44 -- fwk/src/wObject.h | 74 -- fwk/src/wObserver.cpp | 25 - fwk/src/wObserver.h | 39 -- fwk/src/wTime.cpp | 73 -- fwk/src/wTime.h | 115 ---- fwk/src/wTimer.cpp | 78 --- fwk/src/wTimer.h | 56 -- fwk/src/wTimers.cpp | 56 -- fwk/src/wTimers.h | 47 -- fwk/src/wTimes.cpp | 56 -- fwk/src/wTimes.h | 75 -- fwk/src/wTimes.inl | 53 -- fwk/testing.py | 80 --- fwk/tests/timers.py | 71 -- fwk/wutils.py | 270 -------- heat/_src/CMakeLists.txt | 15 +- heat/src/CMakeLists.txt | 2 + katoptron/_src/CMakeLists.txt | 32 +- katoptron/exe/CMakeLists.txt | 4 +- katoptron/src/CMakeLists.txt | 7 +- .../src/wVtkExport_KIM2CLEAN.cpp | 0 .../src/wVtkExport_KIM2CLEAN.h | 4 +- mirrors/_src/CMakeLists.txt | 15 +- mirrors/src/CMakeLists.txt | 2 + run.py | 92 +-- tbox/CMakeLists.txt | 20 - tbox/__init__.py | 21 - tbox/_src/CMakeLists.txt | 47 -- tbox/_src/tboxw.h | 67 -- tbox/_src/tboxw.i | 268 -------- tbox/gmsh.py | 136 ---- tbox/solvers.py | 38 -- tbox/src/CMakeLists.txt | 98 --- tbox/src/eigen_extra.cpp | 38 -- tbox/src/eigen_extra.h | 31 - tbox/src/std_extra.h | 43 -- tbox/src/tbox.h | 111 --- tbox/src/wCache.cpp | 28 - tbox/src/wCache.h | 52 -- tbox/src/wCache.inl | 35 - tbox/src/wCacheHex8.cpp | 40 -- tbox/src/wCacheHex8.h | 46 -- tbox/src/wCacheLine2.cpp | 40 -- tbox/src/wCacheLine2.h | 46 -- tbox/src/wCachePoint1.cpp | 23 - tbox/src/wCachePoint1.h | 41 -- tbox/src/wCacheQuad4.cpp | 40 -- tbox/src/wCacheQuad4.h | 46 -- tbox/src/wCacheTetra4.cpp | 40 -- tbox/src/wCacheTetra4.h | 46 -- tbox/src/wCacheTri3.cpp | 40 -- tbox/src/wCacheTri3.h | 46 -- tbox/src/wElement.cpp | 196 ------ tbox/src/wElement.h | 137 ---- tbox/src/wElement.inl | 166 ----- tbox/src/wFct0.cpp | 114 ---- tbox/src/wFct0.h | 125 ---- tbox/src/wFct1.cpp | 24 - tbox/src/wFct1.h | 82 --- tbox/src/wFct2.cpp | 132 ---- tbox/src/wFct2.h | 141 ---- tbox/src/wGauss.cpp | 23 - tbox/src/wGauss.h | 51 -- tbox/src/wGauss.inl | 39 -- tbox/src/wGaussHex8.cpp | 36 - tbox/src/wGaussHex8.h | 38 -- tbox/src/wGaussLine2.cpp | 51 -- tbox/src/wGaussLine2.h | 38 -- tbox/src/wGaussQuad4.cpp | 35 - tbox/src/wGaussQuad4.h | 38 -- tbox/src/wGaussTetra4.cpp | 56 -- tbox/src/wGaussTetra4.h | 38 -- tbox/src/wGaussTri3.cpp | 61 -- tbox/src/wGaussTri3.h | 38 -- tbox/src/wGmres.cpp | 51 -- tbox/src/wGmres.h | 63 -- tbox/src/wGmshExport.cpp | 304 --------- tbox/src/wGmshExport.h | 48 -- tbox/src/wGmshImport.cpp | 620 ----------------- tbox/src/wGmshImport.h | 62 -- tbox/src/wGroup.cpp | 55 -- tbox/src/wGroup.h | 46 -- tbox/src/wGroups.cpp | 63 -- tbox/src/wGroups.h | 48 -- tbox/src/wHex8.cpp | 132 ---- tbox/src/wHex8.h | 60 -- tbox/src/wHex8.inl | 24 - tbox/src/wLazy.h | 61 -- tbox/src/wLine2.cpp | 223 ------ tbox/src/wLine2.h | 66 -- tbox/src/wLine2.inl | 24 - tbox/src/wLinearSolver.cpp | 61 -- tbox/src/wLinearSolver.h | 50 -- tbox/src/wLinesearch.cpp | 397 ----------- tbox/src/wLinesearch.h | 127 ---- tbox/src/wMshConvert.cpp | 346 ---------- tbox/src/wMshConvert.h | 48 -- tbox/src/wMshCrack.cpp | 295 -------- tbox/src/wMshCrack.h | 71 -- tbox/src/wMshData.cpp | 68 -- tbox/src/wMshData.h | 57 -- tbox/src/wMshDeform.cpp | 511 -------------- tbox/src/wMshDeform.h | 87 --- tbox/src/wMshExport.cpp | 34 - tbox/src/wMshExport.h | 50 -- tbox/src/wMshImport.cpp | 34 - tbox/src/wMshImport.h | 47 -- tbox/src/wMumps.cpp | 171 ----- tbox/src/wMumps.h | 75 -- tbox/src/wNode.cpp | 35 - tbox/src/wNode.h | 49 -- tbox/src/wPardiso.cpp | 56 -- tbox/src/wPardiso.h | 60 -- tbox/src/wPoint1.cpp | 37 - tbox/src/wPoint1.h | 43 -- tbox/src/wQuad4.cpp | 195 ------ tbox/src/wQuad4.h | 64 -- tbox/src/wQuad4.inl | 24 - tbox/src/wResults.cpp | 79 --- tbox/src/wResults.h | 58 -- tbox/src/wSfHex8.cpp | 69 -- tbox/src/wSfHex8.h | 40 -- tbox/src/wSfLine2.cpp | 36 - tbox/src/wSfLine2.h | 40 -- tbox/src/wSfQuad4.cpp | 47 -- tbox/src/wSfQuad4.h | 40 -- tbox/src/wSfTetra4.cpp | 50 -- tbox/src/wSfTetra4.h | 40 -- tbox/src/wSfTri3.cpp | 42 -- tbox/src/wSfTri3.h | 40 -- tbox/src/wSparseLu.cpp | 41 -- tbox/src/wSparseLu.h | 57 -- tbox/src/wTag.cpp | 36 - tbox/src/wTag.h | 60 -- tbox/src/wTetra4.cpp | 195 ------ tbox/src/wTetra4.h | 63 -- tbox/src/wTetra4.inl | 24 - tbox/src/wTri3.cpp | 311 --------- tbox/src/wTri3.h | 69 -- tbox/src/wTri3.inl | 24 - tbox/src/wUnitTest.cpp | 98 --- tbox/src/wUnitTest.h | 44 -- tbox/tests/basicops.py | 35 - tbox/tests/fem/elem1s.py | 34 - tbox/tests/fem/hex1.geo | 49 -- tbox/tests/fem/quad1.geo | 36 - tbox/tests/fem/tri1.geo | 21 - tbox/tests/gmshio.py | 51 -- tbox/tests/helloworld.slurm.sh | 18 - tbox/tests/meshDeformation.py | 73 -- tbox/tests/meshDeformation3.py | 72 -- tbox/tests/models/beam.geo | 21 - tbox/tests/models/beam3.geo | 47 -- tbox/tests/models/model.geo | 14 - tbox/tests/mpi/helloworld.py | 32 - tbox/utils.py | 96 --- tbox/viewer.py | 44 -- tboxVtk/CMakeLists.txt | 20 - tboxVtk/__init__.py | 21 - tboxVtk/_src/CMakeLists.txt | 49 -- tboxVtk/_src/tboxVtkw.h | 17 - tboxVtk/_src/tboxVtkw.i | 55 -- tboxVtk/cutter.py | 89 --- tboxVtk/lineExtractor.py | 153 ----- tboxVtk/qt5vtk6/QVTKRenderWindowInteractor.py | 644 ------------------ tboxVtk/qt5vtk6/README.txt | 4 - tboxVtk/qt5vtk6/__init__.py | 0 tboxVtk/reader.py | 45 -- tboxVtk/src/CMakeLists.txt | 66 -- tboxVtk/src/tboxVtk.h | 46 -- tboxVtk/src/wVtkExport.cpp | 260 ------- tboxVtk/src/wVtkExport.h | 58 -- tboxVtk/tests/models/model.geo | 14 - tboxVtk/tests/vtkio.py | 44 -- tlnos/_src/CMakeLists.txt | 18 +- tlnos/src/CMakeLists.txt | 3 +- waves-config.cmake.in | 39 -- waves/CMakeLists.txt | 11 + waves/_src/CMakeLists.txt | 15 +- waves/exe/CMakeLists.txt | 2 +- waves/src/CMakeLists.txt | 2 + waves_config.h.in | 2 - 218 files changed, 154 insertions(+), 14986 deletions(-) create mode 100644 .gitmodules delete mode 100644 CMake/FindEIGEN.cmake delete mode 100644 CMake/FindMUMPS.cmake delete mode 100644 CMake/FindNUMPY.cmake delete mode 100644 CMake/FindPYTEUCHOS.cmake delete mode 100644 CMake/FindTBB.cmake delete mode 100644 CMake/codeblocks.cmake delete mode 100644 CMake/fwkMacros.cmake delete mode 100644 CMake/spring.cmake delete mode 100644 CMake/ubuntu.cmake create mode 100644 ext/CMakeLists.txt create mode 160000 ext/amfe delete mode 100644 fwk/CMakeLists.txt delete mode 100644 fwk/__init__.py delete mode 100644 fwk/_src/CMakeLists.txt delete mode 100644 fwk/_src/fwkw.h delete mode 100644 fwk/_src/fwkw.i delete mode 100644 fwk/_src/fwkw.swg delete mode 100644 fwk/_src/wCppBuf2Py.cpp delete mode 100644 fwk/_src/wCppBuf2Py.h delete mode 100644 fwk/coloring.py delete mode 100644 fwk/src/CMakeLists.txt delete mode 100644 fwk/src/fwk.cpp delete mode 100644 fwk/src/fwk.h delete mode 100644 fwk/src/wExtract.cpp delete mode 100644 fwk/src/wExtract.h delete mode 100644 fwk/src/wHMSTime.cpp delete mode 100644 fwk/src/wHMSTime.h delete mode 100644 fwk/src/wObject.cpp delete mode 100644 fwk/src/wObject.h delete mode 100644 fwk/src/wObserver.cpp delete mode 100644 fwk/src/wObserver.h delete mode 100644 fwk/src/wTime.cpp delete mode 100644 fwk/src/wTime.h delete mode 100644 fwk/src/wTimer.cpp delete mode 100644 fwk/src/wTimer.h delete mode 100644 fwk/src/wTimers.cpp delete mode 100644 fwk/src/wTimers.h delete mode 100644 fwk/src/wTimes.cpp delete mode 100644 fwk/src/wTimes.h delete mode 100644 fwk/src/wTimes.inl delete mode 100644 fwk/testing.py delete mode 100644 fwk/tests/timers.py delete mode 100644 fwk/wutils.py rename {tboxVtk => katoptron}/src/wVtkExport_KIM2CLEAN.cpp (100%) rename {tboxVtk => katoptron}/src/wVtkExport_KIM2CLEAN.h (97%) delete mode 100644 tbox/CMakeLists.txt delete mode 100644 tbox/__init__.py delete mode 100644 tbox/_src/CMakeLists.txt delete mode 100644 tbox/_src/tboxw.h delete mode 100644 tbox/_src/tboxw.i delete mode 100644 tbox/gmsh.py delete mode 100644 tbox/solvers.py delete mode 100644 tbox/src/CMakeLists.txt delete mode 100644 tbox/src/eigen_extra.cpp delete mode 100644 tbox/src/eigen_extra.h delete mode 100644 tbox/src/std_extra.h delete mode 100644 tbox/src/tbox.h delete mode 100644 tbox/src/wCache.cpp delete mode 100644 tbox/src/wCache.h delete mode 100644 tbox/src/wCache.inl delete mode 100644 tbox/src/wCacheHex8.cpp delete mode 100644 tbox/src/wCacheHex8.h delete mode 100644 tbox/src/wCacheLine2.cpp delete mode 100644 tbox/src/wCacheLine2.h delete mode 100644 tbox/src/wCachePoint1.cpp delete mode 100644 tbox/src/wCachePoint1.h delete mode 100644 tbox/src/wCacheQuad4.cpp delete mode 100644 tbox/src/wCacheQuad4.h delete mode 100644 tbox/src/wCacheTetra4.cpp delete mode 100644 tbox/src/wCacheTetra4.h delete mode 100644 tbox/src/wCacheTri3.cpp delete mode 100644 tbox/src/wCacheTri3.h delete mode 100644 tbox/src/wElement.cpp delete mode 100644 tbox/src/wElement.h delete mode 100644 tbox/src/wElement.inl delete mode 100644 tbox/src/wFct0.cpp delete mode 100644 tbox/src/wFct0.h delete mode 100644 tbox/src/wFct1.cpp delete mode 100644 tbox/src/wFct1.h delete mode 100644 tbox/src/wFct2.cpp delete mode 100644 tbox/src/wFct2.h delete mode 100644 tbox/src/wGauss.cpp delete mode 100644 tbox/src/wGauss.h delete mode 100644 tbox/src/wGauss.inl delete mode 100644 tbox/src/wGaussHex8.cpp delete mode 100644 tbox/src/wGaussHex8.h delete mode 100644 tbox/src/wGaussLine2.cpp delete mode 100644 tbox/src/wGaussLine2.h delete mode 100644 tbox/src/wGaussQuad4.cpp delete mode 100644 tbox/src/wGaussQuad4.h delete mode 100644 tbox/src/wGaussTetra4.cpp delete mode 100644 tbox/src/wGaussTetra4.h delete mode 100644 tbox/src/wGaussTri3.cpp delete mode 100644 tbox/src/wGaussTri3.h delete mode 100644 tbox/src/wGmres.cpp delete mode 100644 tbox/src/wGmres.h delete mode 100644 tbox/src/wGmshExport.cpp delete mode 100644 tbox/src/wGmshExport.h delete mode 100644 tbox/src/wGmshImport.cpp delete mode 100644 tbox/src/wGmshImport.h delete mode 100644 tbox/src/wGroup.cpp delete mode 100644 tbox/src/wGroup.h delete mode 100644 tbox/src/wGroups.cpp delete mode 100644 tbox/src/wGroups.h delete mode 100644 tbox/src/wHex8.cpp delete mode 100644 tbox/src/wHex8.h delete mode 100644 tbox/src/wHex8.inl delete mode 100644 tbox/src/wLazy.h delete mode 100644 tbox/src/wLine2.cpp delete mode 100644 tbox/src/wLine2.h delete mode 100644 tbox/src/wLine2.inl delete mode 100644 tbox/src/wLinearSolver.cpp delete mode 100644 tbox/src/wLinearSolver.h delete mode 100644 tbox/src/wLinesearch.cpp delete mode 100644 tbox/src/wLinesearch.h delete mode 100644 tbox/src/wMshConvert.cpp delete mode 100644 tbox/src/wMshConvert.h delete mode 100644 tbox/src/wMshCrack.cpp delete mode 100644 tbox/src/wMshCrack.h delete mode 100644 tbox/src/wMshData.cpp delete mode 100644 tbox/src/wMshData.h delete mode 100644 tbox/src/wMshDeform.cpp delete mode 100644 tbox/src/wMshDeform.h delete mode 100644 tbox/src/wMshExport.cpp delete mode 100644 tbox/src/wMshExport.h delete mode 100644 tbox/src/wMshImport.cpp delete mode 100644 tbox/src/wMshImport.h delete mode 100644 tbox/src/wMumps.cpp delete mode 100644 tbox/src/wMumps.h delete mode 100644 tbox/src/wNode.cpp delete mode 100644 tbox/src/wNode.h delete mode 100644 tbox/src/wPardiso.cpp delete mode 100644 tbox/src/wPardiso.h delete mode 100644 tbox/src/wPoint1.cpp delete mode 100644 tbox/src/wPoint1.h delete mode 100644 tbox/src/wQuad4.cpp delete mode 100644 tbox/src/wQuad4.h delete mode 100644 tbox/src/wQuad4.inl delete mode 100644 tbox/src/wResults.cpp delete mode 100644 tbox/src/wResults.h delete mode 100644 tbox/src/wSfHex8.cpp delete mode 100644 tbox/src/wSfHex8.h delete mode 100644 tbox/src/wSfLine2.cpp delete mode 100644 tbox/src/wSfLine2.h delete mode 100644 tbox/src/wSfQuad4.cpp delete mode 100644 tbox/src/wSfQuad4.h delete mode 100644 tbox/src/wSfTetra4.cpp delete mode 100644 tbox/src/wSfTetra4.h delete mode 100644 tbox/src/wSfTri3.cpp delete mode 100644 tbox/src/wSfTri3.h delete mode 100644 tbox/src/wSparseLu.cpp delete mode 100644 tbox/src/wSparseLu.h delete mode 100644 tbox/src/wTag.cpp delete mode 100644 tbox/src/wTag.h delete mode 100644 tbox/src/wTetra4.cpp delete mode 100644 tbox/src/wTetra4.h delete mode 100644 tbox/src/wTetra4.inl delete mode 100644 tbox/src/wTri3.cpp delete mode 100644 tbox/src/wTri3.h delete mode 100644 tbox/src/wTri3.inl delete mode 100644 tbox/src/wUnitTest.cpp delete mode 100644 tbox/src/wUnitTest.h delete mode 100644 tbox/tests/basicops.py delete mode 100644 tbox/tests/fem/elem1s.py delete mode 100644 tbox/tests/fem/hex1.geo delete mode 100644 tbox/tests/fem/quad1.geo delete mode 100644 tbox/tests/fem/tri1.geo delete mode 100755 tbox/tests/gmshio.py delete mode 100755 tbox/tests/helloworld.slurm.sh delete mode 100644 tbox/tests/meshDeformation.py delete mode 100644 tbox/tests/meshDeformation3.py delete mode 100644 tbox/tests/models/beam.geo delete mode 100644 tbox/tests/models/beam3.geo delete mode 100644 tbox/tests/models/model.geo delete mode 100644 tbox/tests/mpi/helloworld.py delete mode 100644 tbox/utils.py delete mode 100644 tbox/viewer.py delete mode 100644 tboxVtk/CMakeLists.txt delete mode 100644 tboxVtk/__init__.py delete mode 100644 tboxVtk/_src/CMakeLists.txt delete mode 100644 tboxVtk/_src/tboxVtkw.h delete mode 100644 tboxVtk/_src/tboxVtkw.i delete mode 100644 tboxVtk/cutter.py delete mode 100644 tboxVtk/lineExtractor.py delete mode 100644 tboxVtk/qt5vtk6/QVTKRenderWindowInteractor.py delete mode 100644 tboxVtk/qt5vtk6/README.txt delete mode 100644 tboxVtk/qt5vtk6/__init__.py delete mode 100644 tboxVtk/reader.py delete mode 100644 tboxVtk/src/CMakeLists.txt delete mode 100644 tboxVtk/src/tboxVtk.h delete mode 100644 tboxVtk/src/wVtkExport.cpp delete mode 100644 tboxVtk/src/wVtkExport.h delete mode 100644 tboxVtk/tests/models/model.geo delete mode 100755 tboxVtk/tests/vtkio.py delete mode 100644 waves-config.cmake.in delete mode 100644 waves_config.h.in diff --git a/.gitignore b/.gitignore index f177c5cc..c75d6969 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ # Misc core *.pyc +__pycache__/ *.*~ # OS diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 451ca6ee..6b823055 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,6 +13,11 @@ default: - mn2l # - warson # you can choose a set of runners here +variables: + GIT_SUBMODULE_STRATEGY: recursive + GIT_STRATEGY: clone # workaround full clone for each pipeline (https://gitlab.com/gitlab-org/gitlab-runner/-/issues/26993) + GIT_LFS_SKIP_SMUDGE: 1 # do not pull LFS + stages: - build - test @@ -36,6 +41,8 @@ build-no-tlnos: <<: *global_tag_def stage: build script: + - git submodule init + - git submodule update - rm -rf build workspace - mkdir build - cd build @@ -46,6 +53,8 @@ build: <<: *global_tag_def stage: build script: + - git submodule init + - git submodule update - rm -rf build workspace - mkdir build - cd build @@ -61,6 +70,8 @@ build-red: image: rboman/waves-py3-red:2020.3 stage: build script: + - git submodule init + - git submodule update - rm -rf build workspace - mkdir build - cd build diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..e84a099a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ext/amfe"] + path = ext/amfe + url = ../amfe.git diff --git a/CMake/FindEIGEN.cmake b/CMake/FindEIGEN.cmake deleted file mode 100644 index 6ac879ee..00000000 --- a/CMake/FindEIGEN.cmake +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# FindEIGEN.cmake - try to find Eigen 3 headers -# The logic that checks the version comes from FindEigen3.cmake (source dir) -# ---------------------------------------------------------------------------- -# output: -# EIGEN_FOUND : TRUE/FALSE -# EIGEN_INCLUDE_DIRS : where the Eigen/*.h are [cached] -# EIGEN_VERSION : version number of Eigen -# ---------------------------------------------------------------------------- -# autodetection: -# utiliser "CMAKE_PREFIX_PATH=c:\local" -# ou "CMAKE_INCLUDE_PATH=c:\local\include" -# ou "INCLUDE=c:\local\include" -# ---------------------------------------------------------------------------- - -# Check version (only for Eigen 3) -macro(_eigen3_check_version) - file(READ "${EIGEN_INCLUDE_DIRS}/Eigen/src/Core/util/Macros.h" _eigen3_version_header) - - string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}") - set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}") - set(EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1}") - string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}") - set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}") - - set(EIGEN_VERSION ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION}) - - if(${EIGEN_VERSION} VERSION_LESS ${EIGEN_FIND_VERSION}) - message(FATAL_ERROR "Eigen version ${EIGEN_VERSION} found in ${EIGEN_INCLUDE_DIRS}, but at least version ${EIGEN_FIND_VERSION} is required!") - endif() -endmacro() - -# Set a dummy version if not provided -if(NOT EIGEN_FIND_VERSION) - if(NOT EIGEN_FIND_VERSION_MAJOR) - set(EIGEN_FIND_VERSION_MAJOR 3) - endif() - if(NOT EIGEN_FIND_VERSION_MINOR) - set(EIGEN_FIND_VERSION_MINOR 3) - endif() - if(NOT EIGEN_FIND_VERSION_PATCH) - set(EIGEN_FIND_VERSION_PATCH 4) - endif() - - set(EIGEN_FIND_VERSION "${EIGEN_FIND_VERSION_MAJOR}.${EIGEN_FIND_VERSION_MINOR}.${EIGEN_FIND_VERSION_PATCH}") -endif() - -# Find the header and check the version -find_path(EIGEN_INCLUDE_DIRS "Eigen/Dense" PATHS "/usr/include/eigen3") -if (EIGEN_INCLUDE_DIRS) - _eigen3_check_version() -else() - message(FATAL_ERROR "Eigen3 headers not found! Define the path in the INCLUDE environment variable.") -endif() - -# handle the QUIETLY and REQUIRED arguments and set EIGEN_FOUND to TRUE -# if all listed variables are TRUE -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(EIGEN - FOUND_VAR EIGEN_FOUND - REQUIRED_VARS EIGEN_INCLUDE_DIRS - VERSION_VAR EIGEN_VERSION) - -#MESSAGE(STATUS "EIGEN_FOUND = ${EIGEN_FOUND}") diff --git a/CMake/FindMUMPS.cmake b/CMake/FindMUMPS.cmake deleted file mode 100644 index 78a24c74..00000000 --- a/CMake/FindMUMPS.cmake +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# FindMUMPS.cmake - try to find MUMPS and associated libraries -# (RoBo) -# ---------------------------------------------------------------------------- -# output: -# MUMPS_FOUND : TRUE/FALSE -# MUMPS_LIBRARIES : list of MUMPS libraries to link with -# MUMPS_INCLUDE_DIRS : where the *.h are [cached] -# ---------------------------------------------------------------------------- - - -find_path(MUMPS_INCLUDE_DIRS NAMES "dmumps_c.h") - -set(MUMPS_LIBRARIES "") -if(MSVC) - SET(_MUMPS_LIBSET_SO dmumps_pord_seq_mkl) # mumps/seq (dynamic) - SET(_MUMPS_LIBSET_A dmumps_c dmumps_fortran - mumps_common_c pord_c libseq_c - libseq_fortran ifconsol libifcoremd - libifportmd libmmd libirc svml_dispmd) # mumps/seq (static) -else() - SET(_MUMPS_LIBSET_SO dmumps_seq - dmumps_pord_seq - dmumps_pord_seq_mkl - dmumps_pord_seq_openblas) # mumps/seq (dynamic) - SET(_MUMPS_LIBSET_A dmumps mumps_common pord mpiseq) # mumps/seq (static) -endif() - -# try the dyn libs first -find_library(FOUND_LIB_SO NAMES ${_MUMPS_LIBSET_SO}) -#MESSAGE(STATUS "${_MUMPS_LIBSET_SO} = ${FOUND_LIB_SO}") -if(FOUND_LIB_SO) - list(APPEND MUMPS_LIBRARIES ${FOUND_LIB_SO}) -else() - # ".so" not found => try ".a" - foreach(LIB ${_MUMPS_LIBSET_A}) - find_library(FOUND_LIB_A ${LIB}) - MESSAGE(STATUS "${LIB}=${FOUND_LIB_A}") - if(FOUND_LIB_A) - list(APPEND MUMPS_LIBRARIES ${FOUND_LIB_A}) - endif() - unset(FOUND_LIB_A CACHE) - endforeach() - - # add fortran libs - IF(MUMPS_LIBRARIES) - IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU") - list(APPEND MUMPS_LIBRARIES -lgfortran) - ENDIF() - IF(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - list(APPEND MUMPS_LIBRARIES -lifcoremt) - ENDIF() - ENDIF() -endif() -unset(FOUND_LIB_SO CACHE) - - -#MESSAGE(STATUS "MUMPS_LIBRARIES = ${MUMPS_LIBRARIES}") - -# ---------------------------------------------------------------------------- - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(MUMPS DEFAULT_MSG - MUMPS_INCLUDE_DIRS - MUMPS_LIBRARIES) - -#MESSAGE(STATUS "MUMPS_FOUND = ${MUMPS_FOUND}") -# ---------------------------------------------------------------------------- diff --git a/CMake/FindNUMPY.cmake b/CMake/FindNUMPY.cmake deleted file mode 100644 index 1196c8e6..00000000 --- a/CMake/FindNUMPY.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -find_path(NUMPY_INCLUDE_DIR "numpy/arrayobject.h") - -# ---------------------------------------------------------------------------- - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(NUMPY DEFAULT_MSG - NUMPY_INCLUDE_DIR) diff --git a/CMake/FindPYTEUCHOS.cmake b/CMake/FindPYTEUCHOS.cmake deleted file mode 100644 index 87f87ef1..00000000 --- a/CMake/FindPYTEUCHOS.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -find_path(PYTEUCHOS_INCLUDE_DIR "Teuchos.i") - -# ---------------------------------------------------------------------------- - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(PYTEUCHOS DEFAULT_MSG - PYTEUCHOS_INCLUDE_DIR) diff --git a/CMake/FindTBB.cmake b/CMake/FindTBB.cmake deleted file mode 100644 index 71565cc7..00000000 --- a/CMake/FindTBB.cmake +++ /dev/null @@ -1,281 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# FindTBB.cmake - try to find Intel Threading Building Blocks libraries -# (RoBo) -# ---------------------------------------------------------------------------- -# input: -# ENABLE_TBBMALLOC : ON/OFF -# output: -# TBB_FOUND : TRUE/FALSE -# TBB_LIBRARIES : list of tbb libraries to link with -# TBB_LIB_PATH : where the optimized .so/.lib are [cached] -# TBB_LIB_PATH_DEBUG : where the debug .so/.lib are [cached] -# TBB_INCLUDE_DIRS : where the tbb/*.h are [cached] -# TBB_VERSION_INTERFACE : -# TBB_VERSION_MAJOR : -# TBB_VERSION_MINOR : -# TBB_VERSION_STRING : version such as "4.2" -# TBB_CXX_FLAGS_DEBUG : to be added to -# ---------------------------------------------------------------------------- -# todo: -# TBB_DEFINITIONS ? (args suppl en debug) -# -# autodetection: -# succeeds if tbb.dll/tbb_debug.dll are in the PATH/LD_LIBRARY_PATH -# otherwise, you may set TBB_LIB_PATH, TBB_LIB_PATH_DEBUG manually -# -# main advantage: -# the link will be always performed with the library corresponding -# to dynamic lib the PATH -# => avoids problem when 2 sets of libs are installed in the system -# -# remarks: -# $ENV{TBBROOT} is *not* used here because it is rather difficult -# to guess the wanted target architecture -# -# tested on: -# win7-msvc + official tbb binaries -# winxp-mingw32 + tbb compiled from src -# linux + installed parallel studio -# -# memo: -# http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries#Writing_find_modules -# ---------------------------------------------------------------------------- - -set (_VERB 0) # set to 1 for debugging - -OPTION(ENABLE_TBBMALLOC "Use TBBMALLOC" OFF) - -IF(_VERB) # Debug - MESSAGE(STATUS "-------------------------------------") - MESSAGE(STATUS " FindTBB") - MESSAGE(STATUS "-------------------------------------") - - MESSAGE(STATUS "CMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}") - MESSAGE(STATUS "CMAKE_SHARED_MODULE_SUFFIX=${CMAKE_SHARED_MODULE_SUFFIX}") - MESSAGE(STATUS "CMAKE_FIND_LIBRARY_SUFFIX=${CMAKE_FIND_LIBRARY_SUFFIX}") - MESSAGE(STATUS "TBB_FIND_REQUIRED=${TBB_FIND_REQUIRED}") # automatiquement à 1 si REQUIRED - MESSAGE(STATUS "TBB_USE_TBBMALLOC=${TBB_USE_TBBMALLOC}") - MESSAGE(STATUS "WIN32=${WIN32}") - MESSAGE(STATUS "MSVC=${MSVC}") - MESSAGE(STATUS "MINGW=${MINGW}") - MESSAGE(STATUS "TBBROOT=$ENV{TBBROOT}") -ENDIF() - -SET(TBB_CXX_FLAGS_DEBUG "-DTBB_USE_THREADING_TOOLS=1 -DTBB_USE_DEBUG=1") - -# --- List of libraries to be found --- - -IF(DEFINED ENV{ONEAPI_ROOT}) - set(_TBB_TBBLIB_NAME "tbb12") -ELSE() - set(_TBB_TBBLIB_NAME "tbb") -ENDIF() -set(_TBB_PROXYLIB_NAME "tbbmalloc_proxy") -set(_TBB_MALLOCLIB_NAME "tbbmalloc") - -set(_TBB_LIBSET1 ${_TBB_TBBLIB_NAME}) -set(_TBB_LIBSET2 ${_TBB_PROXYLIB_NAME} ${_TBB_MALLOCLIB_NAME}) - -# ---------------------------------------------------------------------------- -# --- TBB_LIB_PATH --- -# ---------------------------------------------------------------------------- -# method: -# - look for the dynamic lib in the PATH/LD_LIBRARY_PATH -# on linux or win/mingw; this path is correct -# - on win/msvc, replace "bin" => "lib" in the path previously found - -SET(_TBB_LIB_PATH ${TBB_LIB_PATH}) # copy cached value -IF(NOT _TBB_LIB_PATH) # work on copy - # try to find "(lib)tbb.dll/so" from the env variables - IF(MSVC) - find_file(_TBB_TBBDLL "${_TBB_TBBLIB_NAME}.dll" PATHS "$ENV{TBBROOT}/lib/$ENV{TBB_ARCH_PLATFORM}" ) - ELSEIF(APPLE) - find_library(_TBB_TBBDLL ${_TBB_TBBLIB_NAME} PATHS "" ENV DYLD_LIBRARY_PATH) - ELSE() - find_library(_TBB_TBBDLL ${_TBB_TBBLIB_NAME} PATHS "" ENV LD_LIBRARY_PATH) - ENDIF() - #MESSAGE(STATUS "_TBB_TBBDLL=${_TBB_TBBDLL}") - IF(_TBB_TBBDLL) - get_filename_component(_TBB_DLL_PATH ${_TBB_TBBDLL} PATH CACHE) - unset(_TBB_TBBDLL CACHE) - - IF(MSVC) - STRING(REPLACE "/bin/" "/lib/" _TBB_LIB_PATH ${_TBB_DLL_PATH}) - ELSE() - SET(_TBB_LIB_PATH ${_TBB_DLL_PATH}) - ENDIF() - unset(_TBB_DLL_PATH CACHE) - #MESSAGE(STATUS "_TBB_LIB_PATH=${_TBB_LIB_PATH}") - ELSE() - MESSAGE(WARNING "!!!!!!!! ${CMAKE_SHARED_LIBRARY_PREFIX}${_TBB_TBBLIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} should be in PATH/LD_LIBRARY_PATH !!!!!!!!!") - ENDIF() - unset(_TBB_TBBDLL CACHE) -ENDIF() -IF(NOT TBB_LIB_PATH) # set cache if needed - SET(TBB_LIB_PATH "${_TBB_LIB_PATH}" CACHE PATH "where the optimized .so/.lib are" FORCE) -ENDIF() - -# ---------------------------------------------------------------------------- -# --- TBB_LIB_PATH_DEBUG --- -# ---------------------------------------------------------------------------- -# same method for debug libs - -SET(_TBB_LIB_PATH_DEBUG ${TBB_LIB_PATH_DEBUG}) # copy cached value -IF(NOT _TBB_LIB_PATH_DEBUG) # work on copy - # try to find "(lib)tbb_debug.dll/so" from the env variables - IF(MSVC) - find_file(_TBB_TBBDLL_DEBUG "${_TBB_TBBLIB_NAME}_debug.dll" "${_TBB_TBBLIB_NAME}.dll" PATHS "$ENV{TBBROOT}/lib/$ENV{TBB_ARCH_PLATFORM}" ) - ELSEIF(APPLE) - find_library(_TBB_TBBDLL_DEBUG "${_TBB_TBBLIB_NAME}_debug" ${_TBB_TBBLIB_NAME} PATHS "" ENV DYLD_LIBRARY_PATH) - ELSE() - find_library(_TBB_TBBDLL_DEBUG "${_TBB_TBBLIB_NAME}_debug" ${_TBB_TBBLIB_NAME} PATHS "" ENV LD_LIBRARY_PATH) - ENDIF() - #MESSAGE(STATUS "_TBB_TBBDLL_DEBUG=${_TBB_TBBDLL_DEBUG}") - IF(_TBB_TBBDLL_DEBUG) - get_filename_component(_TBB_DLL_PATH_DEBUG ${_TBB_TBBDLL_DEBUG} PATH CACHE) - unset(_TBB_TBBDLL_DEBUG CACHE) - - IF(MSVC) - STRING(REPLACE "/bin/" "/lib/" _TBB_LIB_PATH_DEBUG ${_TBB_DLL_PATH_DEBUG}) - ELSE() - SET(_TBB_LIB_PATH_DEBUG ${_TBB_DLL_PATH_DEBUG}) - ENDIF() - unset(_TBB_DLL_PATH_DEBUG CACHE) - #MESSAGE(STATUS "_TBB_LIB_PATH_DEBUG=${_TBB_LIB_PATH_DEBUG}") - ELSE() - MESSAGE(WARNING "!!!!!!!! ${CMAKE_SHARED_LIBRARY_PREFIX}${_TBB_TBBLIB_NAME}_debug${CMAKE_SHARED_LIBRARY_SUFFIX} should be in PATH/LD_LIBRARY_PATH !!!!!!!!!") - ENDIF() - unset(_TBB_TBBDLL_DEBUG CACHE) -ENDIF() -IF(NOT TBB_LIB_PATH_DEBUG) # set cache if needed - SET(TBB_LIB_PATH_DEBUG ${_TBB_LIB_PATH_DEBUG} CACHE PATH "where the debug .so/.lib are" FORCE) -ENDIF() - -# ---------------------------------------------------------------------------- -# TBB_LIBRARIES: search full path of all libraries -# ---------------------------------------------------------------------------- - -macro(resolveLibs VARNAME LISTNAME) - foreach(LIB ${${LISTNAME}}) - # look for optimized version - find_library(FOUND_LIB ${LIB} PATHS ${TBB_LIB_PATH} "$ENV{TBBROOT}/lib/$ENV{TBB_ARCH_PLATFORM}") - #MESSAGE(STATUS "FOUND_LIB=${FOUND_LIB}") - if(FOUND_LIB) - list(APPEND ${VARNAME} "optimized" ${FOUND_LIB}) - endif() - unset(FOUND_LIB CACHE) - # look for debug version - find_library(FOUND_LIB ${LIB}_debug PATHS ${TBB_LIB_PATH_DEBUG} "$ENV{TBBROOT}/lib/$ENV{TBB_ARCH_PLATFORM}") - #MESSAGE(STATUS "FOUND_LIB=${FOUND_LIB}") - if(FOUND_LIB) - list(APPEND ${VARNAME} "debug" ${FOUND_LIB}) - endif() - unset(FOUND_LIB CACHE) - endforeach() -endmacro() - -# search for all libs -IF( TBB_LIB_PATH AND TBB_LIB_PATH_DEBUG) - resolveLibs(_TBB_LIBSET1_DIRS _TBB_LIBSET1) - resolveLibs(_TBB_LIBSET2_DIRS _TBB_LIBSET2) -ENDIF() - -# build full list of libs -set(TBB_LIBRARIES ${_TBB_LIBSET1_DIRS}) -IF(ENABLE_TBBMALLOC) - LIST(APPEND TBB_LIBRARIES ${_TBB_LIBSET2_DIRS} ) -ENDIF() - -# print for debug -IF(_VERB) - foreach(LIB ${TBB_LIBRARIES}) - MESSAGE(STATUS "lib=${LIB}") - endforeach() -ENDIF() - -# ---------------------------------------------------------------------------- -# TBB_INCLUDE_DIRS: search include dir -# ---------------------------------------------------------------------------- - -SET(_TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIRS}) -IF( (NOT _TBB_INCLUDE_DIRS) AND (TBB_LIB_PATH)) - SET(_VAR1 ${TBB_LIB_PATH}) - SET(_BASENAME ${_VAR1}) - SET(_TBB_TBBROOT "_TBB_TBBROOT-NOTFOUND") - WHILE( (NOT _TBB_TBBROOT) AND (_BASENAME) ) - get_filename_component(_DIRNAME ${_VAR1} PATH) - #MESSAGE(STATUS "_DIRNAME=${_DIRNAME}") - get_filename_component(_BASENAME ${_VAR1} NAME) - #MESSAGE(STATUS "_BASENAME=${_BASENAME}") # on remonte jusqu'à un "lib" ou "build" - - IF( ("${_BASENAME}" STREQUAL "lib") OR ("${_BASENAME}" STREQUAL "build") OR ("${_BASENAME}" STREQUAL "bin") ) - SET(_TBB_TBBROOT ${_DIRNAME}) - ELSE() - SET(_VAR1 ${_DIRNAME}) - ENDIF() - ENDWHILE() - #MESSAGE(STATUS "_TBB_TBBROOT=${_TBB_TBBROOT}") - - FIND_PATH(_TBB_INCLUDE_DIRS - NAMES tbb/parallel_for.h - PATHS "${_TBB_TBBROOT}" "$ENV{TBBROOT}" - PATH_SUFFIXES include - ) - #MESSAGE(STATUS "_TBB_INCLUDE_DIRS=${_TBB_INCLUDE_DIRS}") -ENDIF() -IF(NOT TBB_INCLUDE_DIRS) # set cache if needed - SET(TBB_INCLUDE_DIRS ${_TBB_INCLUDE_DIRS} CACHE PATH "where the tbb/*.h are" FORCE) -ENDIF() -unset(_TBB_INCLUDE_DIRS CACHE) - -# ---------------------------------------------------------------------------- -# Versions -# ---------------------------------------------------------------------------- - -SET(_TBB_VERSION_INTERFACE ${TBB_VERSION_INTERFACE}) -IF( (NOT TBB_VERSION_INTERFACE) AND TBB_INCLUDE_DIRS AND NOT DEFINED ENV{ONEAPI_ROOT}) - FILE(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _FILE) - set(_TBB_VERSION_MAJOR 0) - set(_TBB_VERSION_MINOR 0) - STRING(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" _TBB_VERSION_INTERFACE "${_FILE}") - STRING(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" _TBB_VERSION_MAJOR "${_FILE}") - STRING(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" _TBB_VERSION_MINOR "${_FILE}") - set(_TBB_VERSION_STRING "${_TBB_VERSION_MAJOR}.${_TBB_VERSION_MINOR}") - unset(_FILE) -ENDIF() -IF(NOT TBB_VERSION_INTERFACE) - SET(TBB_VERSION_INTERFACE ${_TBB_VERSION_INTERFACE} CACHE STRING "" FORCE) - SET(TBB_VERSION_MAJOR ${_TBB_VERSION_MAJOR} CACHE INTERNAL "" FORCE) - SET(TBB_VERSION_MINOR ${_TBB_VERSION_MINOR} CACHE INTERNAL "" FORCE) - SET(TBB_VERSION_STRING ${_TBB_VERSION_STRING} CACHE STRING "" FORCE) - mark_as_advanced(TBB_VERSION_INTERFACE) - mark_as_advanced(TBB_VERSION_MAJOR) - mark_as_advanced(TBB_VERSION_MINOR) - mark_as_advanced(TBB_VERSION_STRING) -ENDIF() -# ---------------------------------------------------------------------------- - -include(FindPackageHandleStandardArgs) -# handle the QUIETLY and REQUIRED arguments and set TBB_FOUND to TRUE -# if all listed variables are TRUE -find_package_handle_standard_args(TBB DEFAULT_MSG - TBB_LIBRARIES TBB_INCLUDE_DIRS - TBB_LIB_PATH TBB_LIB_PATH_DEBUG) - -#MESSAGE(STATUS "TBB_FOUND = ${TBB_FOUND}") -# ---------------------------------------------------------------------------- - -unset(_VERB) diff --git a/CMake/codeblocks.cmake b/CMake/codeblocks.cmake deleted file mode 100644 index 9462769b..00000000 --- a/CMake/codeblocks.cmake +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -#SET(CMAKE_GENERATOR "CodeBlocks - Unix Makefiles" CACHE INTERNAL "" FORCE) - -SET(MKL_LIB_PATH "/opt/intel/mkl/lib/intel64;/opt/intel/lib/intel64" CACHE PATH "" FORCE) -SET(MKL_INCLUDE_PATH "/opt/intel/mkl/include" CACHE PATH "" FORCE) - diff --git a/CMake/fwkMacros.cmake b/CMake/fwkMacros.cmake deleted file mode 100644 index 306c0f2b..00000000 --- a/CMake/fwkMacros.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# useful macros/fcts - - -MACRO(MACRO_AddTest srcDir) - #message(STATUS "Adding test directory ${srcDir}") - - #Extract the number of MPI processes used to - #launch one test. - #If no extra arguments are given, the number - #is set to 1. - set (extra_macro_args ${ARGN}) - list(LENGTH extra_macro_args num_extra_args) - if (${num_extra_args} GREATER 0) - list(GET extra_macro_args 0 nProcs) - else() - set(nProcs 1) - endif () - - file(GLOB tfiles RELATIVE ${srcDir} ${srcDir}/*) - #message(STATUS "tfiles=${tfiles}") - foreach(tfile ${tfiles}) - set(spath ${srcDir}/${tfile}) - if(NOT IS_DIRECTORY ${spath} AND - ${spath} MATCHES ".+\\.py$" AND - NOT ${tfile} STREQUAL "__init__.py") - string(REPLACE "${PROJECT_SOURCE_DIR}/" "" strip ${spath}) - message(STATUS "Adding test ${strip}") - if (${nProcs} GREATER 1) - add_test(NAME "${strip}-MPI${nProcs}" - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND mpirun -np ${nProcs} --allow-run-as-root ${PYTHON_EXECUTABLE} run.py --nogui --clean ${strip}) - # (mpi is run as root in docker) - else() - add_test(NAME ${strip} - WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} - COMMAND ${PYTHON_EXECUTABLE} run.py --nogui --clean ${strip}) - endif () - else() - MACRO_AddTest(${srcDir}/${tfile} ${nProcs}) - endif() - endforeach() -ENDMACRO() - - -MACRO(MACRO_DebugPostfix libname) - IF(MSVC) - SET_TARGET_PROPERTIES(${libname} PROPERTIES DEBUG_POSTFIX "_d") - ENDIF(MSVC) -ENDMACRO() diff --git a/CMake/spring.cmake b/CMake/spring.cmake deleted file mode 100644 index 776f28b8..00000000 --- a/CMake/spring.cmake +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES icpc) -FIND_PROGRAM(CMAKE_C_COMPILER NAMES icc) - -# force to look for mkl -SET(BLA_VENDOR "Intel10_64lp" CACHE STRING "" FORCE) - -# Trilinos not available on spring -LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) -INCLUDE(disable-trilinos) - diff --git a/CMake/ubuntu.cmake b/CMake/ubuntu.cmake deleted file mode 100644 index e6e3eea8..00000000 --- a/CMake/ubuntu.cmake +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -#FIND_PROGRAM(CMAKE_CXX_COMPILER NAMES icpc) -#FIND_PROGRAM(CMAKE_C_COMPILER NAMES icc) - -#SET(CMAKE_BUILD_TYPE "Debug" CACHE FILEPATH "" FORCE) - -#SET(BLA_VENDOR "Intel10_64lp" CACHE STRING "" FORCE) # useless for cmake 3.5 (xenial) -#SET(SWIG_EXECUTABLE "/home/boman/local/swig3/bin/swig" CACHE FILEPATH "" FORCE) - diff --git a/CMakeLists.txt b/CMakeLists.txt index aa76b306..c25b2e47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright 2020 University of Liège +# Copyright 2022 University of Liège # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -21,27 +21,25 @@ IF(${CMAKE_VERSION} VERSION_GREATER "3.14.0") # we might want to update the proj cmake_policy(SET CMP0086 OLD) ENDIF() +# -- I/O +# Lib/Exe dir SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single output directory for building all libraries.") SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single output directory for building all executables.") MARK_AS_ADVANCED(LIBRARY_OUTPUT_PATH EXECUTABLE_OUTPUT_PATH) +# Build type IF(NOT CMAKE_BUILD_TYPE) SET( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE) ENDIF(NOT CMAKE_BUILD_TYPE) -MESSAGE(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake") # -- GENERAL OPTIONS -# 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_FLOW "Compile flow module" ON) OPTION(WAVES_USE_HEAT "Compile heat module" ON) @@ -50,11 +48,6 @@ OPTION(WAVES_USE_KATOPTRON "Compile katoptron module" ON) OPTION(WAVES_USE_PARAMS "Compile params module" ON) OPTION(WAVES_USE_TLNOS "Compile tlnos module" ON) OPTION(WAVES_USE_WAVES "Compile waves module" ON) -# (de)activate extensions -OPTION(WAVES_USE_TBOXVTK "Compile tboxVtk module" ON) -# (de)activate external packages -OPTION(WAVES_USE_MKL "Compile with Intel MKL" ON) -OPTION(WAVES_USE_MUMPS "Compile with MUMPS" ON) # --- Disable some Options on Windows IF(WIN32) @@ -65,7 +58,7 @@ IF(WIN32) ENDIF() # macros/fcts -INCLUDE(fwkMacros) +# INCLUDE(fwkMacros) # -- C++11 SET(CMAKE_CXX_STANDARD 11) # newer way to set C++11 (requires cmake>=3.1) @@ -98,7 +91,7 @@ IF (CMAKE_VERSION VERSION_LESS 3.12.0) FIND_PACKAGE(PythonInterp 3.6 REQUIRED) FIND_PACKAGE(PythonLibs 3.6 REQUIRED) ELSE() - find_package (Python3 COMPONENTS Interpreter Development) + FIND_PACKAGE(Python3 COMPONENTS Interpreter Development) # use Python3_ROOT_DIR if wrong python found (e.g. anaconda) SET(PYTHON_EXECUTABLE ${Python3_EXECUTABLE}) SET(PYTHON_LIBRARIES ${Python3_LIBRARIES}) @@ -127,11 +120,8 @@ IF(DOXYGEN_FOUND) # set input and output files SET(DOXYGEN_IN ${PROJECT_SOURCE_DIR}/Doxyfile.in) SET(DOXYGEN_OUT ${PROJECT_BINARY_DIR}/Doxyfile) - # request to configure the file CONFIGURE_FILE(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY) - #message("Doxygen build started") - # note the option ALL which allows to build the docs together with the application # "make dox" rebuilds the doc ADD_CUSTOM_TARGET( dox #ALL @@ -140,25 +130,27 @@ IF(DOXYGEN_FOUND) COMMENT "Generating API documentation with Doxygen" VERBATIM ) ELSE() - MESSAGE("Doxygen need to be installed to generate the doxygen documentation") + MESSAGE("Doxygen needs to be installed to generate the doxygen documentation") ENDIF() -# -- Configure file (for SWIG to detect definitions) -CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/waves_config.h.in - ${PROJECT_BINARY_DIR}/waves_config.h) -INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) # to find "waves_config.h" +INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}) # to find "amfe_def.h" # -- CTest ENABLE_TESTING() -# -- Sub directories +# -- INSTALL +IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -m site --user-site OUTPUT_VARIABLE PY_SITE OUTPUT_STRIP_TRAILING_WHITESPACE) + SET(CMAKE_INSTALL_PREFIX "${PY_SITE}/waves" CACHE STRING "Install location" FORCE) + SET(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE) +ENDIF() +IF(UNIX AND NOT APPLE) + SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}") +ENDIF() -ADD_SUBDIRECTORY( fwk ) -ADD_SUBDIRECTORY( tbox ) +# -- Sub directories -IF(WAVES_USE_TBOXVTK) - ADD_SUBDIRECTORY( tboxVtk ) -ENDIF() +ADD_SUBDIRECTORY( ext ) IF(WAVES_USE_FLOW) ADD_SUBDIRECTORY( flow ) @@ -188,12 +180,13 @@ IF(WAVES_USE_WAVES) ADD_SUBDIRECTORY( waves ) ENDIF() -# -- Packaging -# set paths and target names -SET(WAVES_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/fwk/src" "${PROJECT_SOURCE_DIR}/tbox/src" "${PROJECT_BINARY_DIR}") -SET(WAVES_SWIG_DIRS "${PROJECT_SOURCE_DIR}/fwk/_src" "${PROJECT_SOURCE_DIR}/tbox/_src") -SET(WAVES_LIBRARIES fwk tbox) -# export target config -EXPORT(TARGETS ${WAVES_LIBRARIES} FILE "${PROJECT_BINARY_DIR}/wavesTargets.cmake") -# generate configuration file with absolute paths -CONFIGURE_FILE(waves-config.cmake.in "${PROJECT_BINARY_DIR}/waves-config.cmake" @ONLY) +# -- FINAL +MESSAGE(STATUS "PROJECT: ${CMAKE_PROJECT_NAME}") +MESSAGE(STATUS "* SYSTEM NAME=\"${CMAKE_SYSTEM_NAME}\"") +MESSAGE(STATUS "* CXX COMPILER: ${CMAKE_CXX_COMPILER_ID}") +MESSAGE(STATUS "* CXX STANDARD: ${CMAKE_CXX_STANDARD}") +MESSAGE(STATUS "* INSTALL DIR: ${CMAKE_INSTALL_PREFIX}") +MESSAGE(STATUS "* BUILD TYPE: ${CMAKE_BUILD_TYPE}") +MESSAGE(STATUS "* VTK SUPPORT: ${USE_VTK}") +MESSAGE(STATUS "* MKL SUPPORT: ${USE_MKL}") +MESSAGE(STATUS "* MUMPS SUPPORT: ${USE_MUMPS}") diff --git a/README.md b/README.md index 7829bbab..93754a57 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,6 @@ Waves is a collection of general utilities and finite element tools for solving ## Features Set of python/C++ modules: - - [fwk](/fwk): general utilities (timers, ...) - - [tbox](/tbox): general finite element utilities (mesh handler, nodes/elements handler, ...) - - [tboxVtk](/tboxVtk): VTK extensions for tbox - [waves](/waves): 3D(Hex8) transient wave equation solver (FEM) - [flow](/flow): 2D(Tri3) and 3D(Tetra4) steady full potential equation solver (FEM) - [heat](/heat): 2D(Tri3) steady nonlinear heat equation solver (multiscale FE²M) @@ -17,8 +14,8 @@ Set of python/C++ modules: - [tlnos](/tlnos): basic Trilinos examples Additional features: - - [x] [gmsh](http://geuz.org/gmsh/) support for mesh and post-processing - - [x] [vtk](http://www.vtk.org/)/[PyQt](https://riverbankcomputing.com/software/pyqt/intro) support for post processing and basic GUI + - [x] [Gmsh](http://geuz.org/gmsh/) support for mesh and post-processing + - [x] [VTK](http://www.vtk.org/)/[PyQt](https://riverbankcomputing.com/software/pyqt/intro) support for post processing and basic GUI - [x] [OpenBLAS](http://www.openblas.net/) or [Intel MKL](https://software.intel.com/en-us/intel-mkl) support - [x] [Eigen3](http://eigen.tuxfamily.org/index.php?title=Main_Page) support for linear algebra - [Intel Pardiso](https://software.intel.com/content/www/us/en/develop/documentation/mkl-developer-reference-c/top/sparse-solver-routines/intel-mkl-pardiso-parallel-direct-sparse-solver-interface/pardiso.html) support diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt new file mode 100644 index 00000000..3c75cd07 --- /dev/null +++ b/ext/CMakeLists.txt @@ -0,0 +1 @@ +ADD_SUBDIRECTORY(amfe) diff --git a/ext/amfe b/ext/amfe new file mode 160000 index 00000000..054ba00c --- /dev/null +++ b/ext/amfe @@ -0,0 +1 @@ +Subproject commit 054ba00c327e4f2745ff9c559832247f90c3cec9 diff --git a/flow/_src/CMakeLists.txt b/flow/_src/CMakeLists.txt index 12e3f6ed..98d7f823 100644 --- a/flow/_src/CMakeLists.txt +++ b/flow/_src/CMakeLists.txt @@ -24,10 +24,10 @@ SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES CPLUSPLUS ON) SET(SWINCFLAGS -I${PROJECT_SOURCE_DIR}/flow/src --I${PROJECT_SOURCE_DIR}/tbox/src --I${PROJECT_SOURCE_DIR}/tbox/_src --I${PROJECT_SOURCE_DIR}/fwk/src --I${PROJECT_SOURCE_DIR}/fwk/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src ) SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES SWIG_FLAGS "${SWINCFLAGS}") @@ -39,11 +39,14 @@ endif() MACRO_DebugPostfix(_floww) TARGET_INCLUDE_DIRECTORIES(_floww PRIVATE ${PROJECT_SOURCE_DIR}/flow/_src - ${PROJECT_SOURCE_DIR}/fwk/_src - ${PROJECT_SOURCE_DIR}/tbox/_src + ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src ${PYTHON_INCLUDE_PATH} ) SWIG_LINK_LIBRARIES(floww flow tbox fwk ${PYTHON_LIBRARIES} ) + +INSTALL(FILES ${CMAKE_SWIG_OUTDIR}/floww.py DESTINATION ${CMAKE_INSTALL_PREFIX}) +INSTALL(TARGETS _floww DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/flow/default.py b/flow/default.py index 50b4bb56..500ce6be 100644 --- a/flow/default.py +++ b/flow/default.py @@ -119,8 +119,7 @@ def meshMorpher(msh, dim, mov, fxd = ['upstream', 'farfield', 'downstream'], fld '''Initialize mesh morpher ''' args = parseargs() - mshDef = tbox.MshDeform(msh, dim) - mshDef.nthreads = args.k + mshDef = tbox.MshDeform(msh, dim, args.k) mshDef.setField(fld) mshDef.addFixed(fxd) mshDef.addMoving(mov) diff --git a/flow/src/CMakeLists.txt b/flow/src/CMakeLists.txt index 2fd589db..d6a008ce 100644 --- a/flow/src/CMakeLists.txt +++ b/flow/src/CMakeLists.txt @@ -22,5 +22,7 @@ TARGET_INCLUDE_DIRECTORIES(flow PUBLIC ${PROJECT_SOURCE_DIR}/flow/src) TARGET_LINK_LIBRARIES(flow tbox) +INSTALL(TARGETS flow DESTINATION ${CMAKE_INSTALL_PREFIX}) + SOURCE_GROUP(base REGULAR_EXPRESSION ".*\\.(cpp|inl|hpp|h)") diff --git a/fwk/CMakeLists.txt b/fwk/CMakeLists.txt deleted file mode 100644 index 156e07c4..00000000 --- a/fwk/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Add source dir -ADD_SUBDIRECTORY( src ) -ADD_SUBDIRECTORY( _src ) - -# Add test dir -MACRO_AddTest(${CMAKE_CURRENT_SOURCE_DIR}/tests) diff --git a/fwk/__init__.py b/fwk/__init__.py deleted file mode 100644 index fe2254ff..00000000 --- a/fwk/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -# -*- coding: utf-8 -*- -# fwk MODULE initialization file - -from . import wutils -wutils.findbins('fwk') - -from fwkw import * - diff --git a/fwk/_src/CMakeLists.txt b/fwk/_src/CMakeLists.txt deleted file mode 100644 index 7e59712e..00000000 --- a/fwk/_src/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake file for the SWIG interface of fwk.so - -INCLUDE(${SWIG_USE_FILE}) - -FILE(GLOB SRCS *.h *.cpp *.inl *.swg) -FILE(GLOB ISRCS *.i) - -SET(CMAKE_SWIG_FLAGS "") -SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES CPLUSPLUS ON) - -SET(SWINCFLAGS --I${PROJECT_SOURCE_DIR}/fwk/src -) -SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES SWIG_FLAGS "${SWINCFLAGS}") - -if (${CMAKE_VERSION} VERSION_LESS "3.8.0") - SWIG_ADD_MODULE(fwkw python ${ISRCS} ${SRCS}) -else() - SWIG_ADD_LIBRARY(fwkw LANGUAGE python SOURCES ${ISRCS} ${SRCS}) -endif() -MACRO_DebugPostfix(_fwkw) - -TARGET_INCLUDE_DIRECTORIES(_fwkw PRIVATE ${PROJECT_SOURCE_DIR}/fwk/_src - ${PYTHON_INCLUDE_PATH} -) - -SWIG_LINK_LIBRARIES(fwkw - fwk ${PYTHON_LIBRARIES} -) diff --git a/fwk/_src/fwkw.h b/fwk/_src/fwkw.h deleted file mode 100644 index 8d6ee8b7..00000000 --- a/fwk/_src/fwkw.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wCppBuf2Py.h" -#include "wExtract.h" -#include "wHMSTime.h" -#include "wObject.h" -#include "wTime.h" -#include "wTimer.h" -#include "wTimers.h" -#include "wTimes.h" \ No newline at end of file diff --git a/fwk/_src/fwkw.i b/fwk/_src/fwkw.i deleted file mode 100644 index 3f3b930f..00000000 --- a/fwk/_src/fwkw.i +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// fwk.i: SWIG input file of the fwk python interface - -%feature("autodoc","1"); - -%module(docstring= -"'fwkw' module: base framework -(c) ULg - A&M", -directors="1", -threads="1" -) fwkw -%{ - -//#if defined(_WIN32) && defined(__GNUC__) -#undef _hypot -#include <cmath> -//#endif - -#include <memory> -#include <string> -#include <sstream> -#include <typeinfo> - -#include "fwk.h" -#include "fwkw.h" - -%} - -%include "fwkw.swg" - -%include "fwk.h" - -//%#define SHARED_PTR_DISOWN $disown -%include <std_shared_ptr.i> - -%shared_ptr(fwk::wSharedObject); - -%include "wObject.h" -%include "wHMSTime.h" -%include "wTime.h" -%include "wTimes.h" -%include "wTimer.h" -%include "wTimers.h" - -namespace fwk { - -%extend wObject { - std::string __str__() { - std::stringstream str; str << *self; - return str.str(); - } -} - -%extend wSharedObject { - std::string __str__() { - std::stringstream str; str << *self; - return str.str(); - } -} - -%extend HMSTime { - std::string __str__() { - std::stringstream str; str << *self; - return str.str(); - } -} - -%extend Timer { - std::string __str__() { - std::stringstream str; str << *self; - return str.str(); - } -} - -%extend Time { - std::string __str__() { - std::stringstream str; str << *self; - return str.str(); - } -} - -%extend Times { - std::string __str__() { - std::stringstream str; str << *self; - return str.str(); - } -} -}; - -%include "wExtract.h" - -%warnfilter(401); //Nothing known about base class 'std::basic_streambuf< char >' -%include "wCppBuf2Py.h" -%warnfilter(+401); - -// -------------------------------------------------------------------- -namespace fwk { -%extend Timers { - Timer &getitem(std::string const &name) - { - return (*self)[name]; - } - - %pythoncode { -def __getitem__(self, name): - return self.getitem(name) - } -} -}; diff --git a/fwk/_src/fwkw.swg b/fwk/_src/fwkw.swg deleted file mode 100644 index 0add1dde..00000000 --- a/fwk/_src/fwkw.swg +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - // common includes - -// !! mingw + c++11 + python: -// cmath doit être inclus AVANT Python.h (et en particulier pyconfig.h) -// car il renomme hypot en _hypoth (bidouille liée au visual) -%begin %{ -#if defined(_WIN32) && defined(__GNUC__) -#include <cmath> -#endif -%} - -// petite bidouille pour pouvoir compiler avec "threads=1" et iterer sur des std_vector -// (sinon ca explose � la destruction de l'iterateur) -%nothread swig::SwigPyIterator::~SwigPyIterator(); - -%include "std_string.i" -%include "exception.i" -%include "std_vector.i" -%include "std_list.i" -%include "std_map.i" - -/* -%exception { - try { - $action - } - catch(std::exception &e) - { - std::stringstream txt; - txt << e.what(); // << ' ' << typeid(e).name(); - SWIG_exception(SWIG_RuntimeError, txt.str().c_str()); - } - catch (Swig::DirectorException &) - { - SWIG_exception(SWIG_RuntimeError, "DirectorException!"); - } - catch(...) - { - SWIG_exception(SWIG_RuntimeError, "Unknown C++ Runtime Error"); - } -} -*/ - -// from: http://swig.10945.n7.nabble.com/Trapping-Swig-DirectorException-td6013.html -// le code suivant permet de voir la call stack dans les appels C++ => python - -%{ - static void handle_exception(void) { - try { - throw; - } catch (std::exception &e) { - std::stringstream txt; - txt << e.what(); // << ' ' << typeid(e).name(); - PyErr_SetString(PyExc_RuntimeError, e.what()); - } - catch(...) - { - PyErr_SetString(PyExc_RuntimeError, "Unknown C++ Runtime Error"); - } - } -%} - -%exception { - try { - $action - } catch (...) { - // Note that if a director method failed, the Python error indicator - // already contains full details of the exception, and it will be - // reraised when we go to SWIG_fail; so no need to convert the C++ - // exception back to a Python one - if (!PyErr_Occurred()) { - handle_exception(); - } - SWIG_fail; - } -} - -%feature("director:except") { - if ($error != NULL) { - throw Swig::DirectorMethodException(); - } -} - - -%ignore operator<<; - - - - diff --git a/fwk/_src/wCppBuf2Py.cpp b/fwk/_src/wCppBuf2Py.cpp deleted file mode 100644 index d4d4d0ee..00000000 --- a/fwk/_src/wCppBuf2Py.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <Python.h> -#include "wCppBuf2Py.h" -#include <stdio.h> -#include <algorithm> - -CppBuf2Py::CppBuf2Py(std::ostream &o1, bool err) : stream(o1), errstream(err) -{ - oldbuf = stream.rdbuf(); - stream.rdbuf(this); - verb = false; -} - -CppBuf2Py::~CppBuf2Py() -{ - stream.rdbuf(oldbuf); // restore the ostream -} - -std::streamsize -CppBuf2Py::xsputn(const char *s, std::streamsize n) -{ - if (verb) - printf("CppBuf2Py::xsputn(%ld)\n", static_cast<long>(n)); - // PySys_WriteStdout truncates to 1000 chars - static const std::streamsize MAXSIZE = 1000; - std::streamsize written = std::min(n, MAXSIZE); - if (verb) - printf("written=%ld\n", static_cast<long>(written)); - std::string str(s, n); - if (verb) - printf("string=%s\n", str.c_str()); - - PyGILState_STATE gstate = PyGILState_Ensure(); - if (errstream) - PySys_WriteStderr("%s", str.c_str()); - else - PySys_WriteStdout("%s", str.c_str()); - PyGILState_Release(gstate); - - return written; -} - -int CppBuf2Py::overflow(int c) -{ - if (verb) - printf("CppBuf2Py::overflow(%d)\n", c); - - if (c != EOF) - { - PyGILState_STATE gstate = PyGILState_Ensure(); - if (errstream) - PySys_WriteStderr("%c", c); - else - PySys_WriteStdout("%c", c); - PyGILState_Release(gstate); - } - return c; -} - -void CppBuf2Py::test() -{ - CppBuf2Py buf(std::cout); - for (int i = 0; i < 1000; ++i) - std::cout << "(" << i << ")" - << " this is a test - "; -} - -// ============================================================================= - -StdOutErr2Py::StdOutErr2Py() : out(std::cout), err(std::cerr, true) -{ -} - -void StdOutErr2Py::test() -{ - StdOutErr2Py redirector; - - for (int i = 0; i < 50; ++i) - { - std::cout << "(" << i << ")" - << " this is a test - "; - std::cerr << "(" << i << ")" - << " error - "; - } - std::cout << '\n'; - std::cerr << '\n'; -} diff --git a/fwk/_src/wCppBuf2Py.h b/fwk/_src/wCppBuf2Py.h deleted file mode 100644 index 7dafad98..00000000 --- a/fwk/_src/wCppBuf2Py.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef CPPBUF2PY_H -#define CPPBUF2PY_H - -#include "fwk.h" -#include <iostream> - -// http://bo-peng.blogspot.be/2004/10/how-to-re-direct-cout-to-python_05.html -// https://docs.python.org/2/c-api/sys.html#system-functions - -/** - * @brief redirect a std::stream to python - */ -#ifndef SWIG -class CppBuf2Py : public std::basic_streambuf<char> -{ -public: - typedef std::char_traits<char> traits_type; - typedef traits_type::int_type int_type; - -private: - std::ostream &stream; - std::streambuf *oldbuf; - bool verb; - bool errstream; - -public: - CppBuf2Py(std::ostream &o1, bool err = false); - ~CppBuf2Py(); - - static void test(); - -protected: - virtual std::streamsize xsputn(const char *s, std::streamsize n); - virtual int_type overflow(int c); -}; -#endif //SWIG - -/** - * @brief redirect std::cout/std::cerr to python sys.stdout/sys.stderr - */ - -class StdOutErr2Py -{ - CppBuf2Py out; - CppBuf2Py err; - -public: - StdOutErr2Py(); - - static void test(); -}; - -#endif //CPPBUF2PY_H diff --git a/fwk/coloring.py b/fwk/coloring.py deleted file mode 100644 index a57b1b5a..00000000 --- a/fwk/coloring.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# custom color class - -class ccolors: - ANSI_RED = '\x1b[1;31m' - ANSI_GREEN = '\x1b[1;32m' - ANSI_YELLOW = '\x1b[1;33m' - ANSI_BLUE = '\x1b[1;34m' - ANSI_RESET = '\x1b[0m' diff --git a/fwk/src/CMakeLists.txt b/fwk/src/CMakeLists.txt deleted file mode 100644 index 02e45112..00000000 --- a/fwk/src/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake input file of fwk.so - -FILE(GLOB SRCS *.h *.cpp *.inl *.hpp) - -ADD_LIBRARY(fwk SHARED ${SRCS}) -MACRO_DebugPostfix(fwk) - -TARGET_INCLUDE_DIRECTORIES(fwk PUBLIC ${PROJECT_SOURCE_DIR}/fwk/src) - -# --- -SOURCE_GROUP(base REGULAR_EXPRESSION ".*\\.(cpp|inl|hpp|h)") -SOURCE_GROUP(timer REGULAR_EXPRESSION ".+(Time).+") diff --git a/fwk/src/fwk.cpp b/fwk/src/fwk.cpp deleted file mode 100644 index 9f54df7c..00000000 --- a/fwk/src/fwk.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "fwk.h" -#include <iostream> - -#if defined(WIN32) -#include <float.h> -#elif defined(__GNUC__) -#include <fenv.h> -#endif - -#define ANSI_COLOR_YELLOW "\x1b[1;33m" -#define ANSI_COLOR_BLUE "\x1b[1;34m" -#define ANSI_COLOR_RESET "\x1b[0m" - -FWK_API void testswig(bool i) // testswig(3.0) displays 1 (no error and cast float=>bool) -{ - std::cout << "testswig received i = " << i << '\n'; -} - -/** - * @brief Enable Floating Point Exception - * - * Imported from Metafor - * @authors Adrien Crovato - */ -FWK_API void enableFpe() -{ -#if !defined(__MINGW32__) // MinGW: 2 "float.h" and the wrong one is included by default... - std::cout << ANSI_COLOR_BLUE << "Enabling Floating-Point Exceptions..." << ANSI_COLOR_RESET << std::endl; -#if defined(WIN32) - // doc https://msdn.microsoft.com/en-us/library/e9b52ceh(v=vs.110).aspx - // _EM_INVALID | _EM_DENORMAL | _EM_ZERODIVIDE | _EM_OVERFLOW | _EM_UNDERFLOW | _EM_INEXACT - _clear87(); // doc : "clearing the mask sets the exceptions" - _control87(_EM_INVALID | _EM_DENORMAL | _EM_UNDERFLOW | _EM_INEXACT, _MCW_EM); // doc : "setting the _MCW_EM mask hides the exception" -#elif defined(__APPLE__) - // we should try feraiseexcept (c++11) -#elif defined(__GNUC__) - // FE_ALL_EXCEPT|FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW - feenableexcept(FE_OVERFLOW | FE_DIVBYZERO | FE_INVALID); -#else // defined(WIN32) - std::cout << ANSI_COLOR_YELLOW << "Floating-Point Exceptions not implemented for this compiler!" << ANSI_COLOR_RESET << std::endl; -#endif -#endif //!defined(__MINGW32__) -} - -/** - * @brief Disable Floating Point Exception - * @authors Adrien Crovato - */ -FWK_API void disableFpe() -{ -#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 -} diff --git a/fwk/src/fwk.h b/fwk/src/fwk.h deleted file mode 100644 index 85c99132..00000000 --- a/fwk/src/fwk.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// fwk global header - -#ifndef FWK_H -#define FWK_H - -#if defined(WIN32) -#ifdef fwk_EXPORTS -#define FWK_API __declspec(dllexport) -#else -#define FWK_API __declspec(dllimport) -#endif -#else -#define FWK_API -#endif - -#ifdef _MSC_VER -#if !defined(_CRT_SECURE_NO_WARNINGS) -#define _CRT_SECURE_NO_WARNINGS 1 -#endif - -#pragma warning(disable : 4251) // DLL/templates non exportes -#pragma warning(disable : 4275) // non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' - -#define NOMINMAX // avoids the definition of "min/max" macro in <minwindef.h> (which could shadow std::max) - -#endif //_MSC_VER - -#include "waves_config.h" - -namespace fwk -{ - -class wObject; -class Extract; -class Observer; - -class HMSTime; -class Time; -class Timer; -class Timers; -class Times; - -} // namespace fwk - -// global fcts - -FWK_API void testswig(bool i); -FWK_API void enableFpe(); -FWK_API void disableFpe(); - -#endif //FWK_H diff --git a/fwk/src/wExtract.cpp b/fwk/src/wExtract.cpp deleted file mode 100644 index e8068b89..00000000 --- a/fwk/src/wExtract.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wExtract.h" - -using namespace fwk; - -Extract::Extract() -{ -} - -void Extract::write(std::ostream &out) const -{ - out << "Extract"; -} - -std::vector<double> -Extract::execute() -{ - std::vector<double> ret; - return ret; -} diff --git a/fwk/src/wExtract.h b/fwk/src/wExtract.h deleted file mode 100644 index d6ee0031..00000000 --- a/fwk/src/wExtract.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WEXTRACT_H -#define WEXTRACT_H - -#include "fwk.h" -#include "wObject.h" -#include <vector> - -namespace fwk -{ - -/** - * @brief an object able to extract scalar results from the model - */ - -class FWK_API Extract : public wObject -{ -public: - Extract(); - virtual std::vector<double> execute(); - -#ifndef SWIG - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace fwk - -#endif //WEXTRACT_H diff --git a/fwk/src/wHMSTime.cpp b/fwk/src/wHMSTime.cpp deleted file mode 100644 index 4aa47a56..00000000 --- a/fwk/src/wHMSTime.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wHMSTime.h" -#include <iomanip> -#include <sstream> - -using namespace fwk; - -HMSTime::HMSTime(double time) -{ - double secinmins = 60; - double secinhours = 60 * secinmins; - double secindays = 24 * secinhours; - double secinmonths = 30 * secindays; - double secinyears = 365 * secinmonths; - - years = static_cast<int>(time / secinyears); - time -= years * secinyears; - - months = static_cast<int>(time / secinmonths); - time -= months * secinmonths; - - days = static_cast<int>(time / secindays); - time -= days * secindays; - - hours = static_cast<int>(time / secinhours); - time -= hours * secinhours; - - mins = static_cast<int>(time / secinmins); - secs = time - mins * secinmins; -} - -std::string -HMSTime::str() const -{ - std::ostringstream st; - if (years) - st << years << "y"; - if (years || months) - st << months << "mo"; - if (years || months || days) - st << days << "d"; - if (years || months || days || hours) - st << hours << "h"; - if (years || months || days || hours || mins) - st << mins << "m"; - st << std::fixed << std::setprecision(2) << secs << "s"; - - return st.str(); -} -namespace fwk -{ -FWK_API std::ostream & -operator<<(std::ostream &out, HMSTime const &obj) -{ - out << obj.str(); - return out; -} -}; // namespace fwk diff --git a/fwk/src/wHMSTime.h b/fwk/src/wHMSTime.h deleted file mode 100644 index 6af798d6..00000000 --- a/fwk/src/wHMSTime.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WHMSTIME_H -#define WHMSTIME_H - -#include "fwk.h" -#include <iostream> - -namespace fwk -{ - -/** - * @brief Convert seconds to a HMS string - */ - -class FWK_API HMSTime -{ - int years; - int months; - int days; - int hours; - int mins; - double secs; - -public: - explicit HMSTime(double sec = 0.0); - friend FWK_API std::ostream &operator<<(std::ostream &out, HMSTime const &obj); - std::string str() const; -}; -} // namespace fwk - -#endif //WHMSTIME_H diff --git a/fwk/src/wObject.cpp b/fwk/src/wObject.cpp deleted file mode 100644 index 5ae407c5..00000000 --- a/fwk/src/wObject.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wObject.h" - -namespace fwk -{ - -FWK_API std::ostream & -operator<<(std::ostream &out, wObject const &obj) -{ - obj.write(out); - return out; -} - -void wObject::write(std::ostream &out) const -{ -} - -FWK_API std::ostream & -operator<<(std::ostream &out, wSharedObject const &obj) -{ - obj.write(out); - return out; -} - -void wSharedObject::write(std::ostream &out) const -{ -} - -} // namespace fwk diff --git a/fwk/src/wObject.h b/fwk/src/wObject.h deleted file mode 100644 index 663a8b98..00000000 --- a/fwk/src/wObject.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WOBJECT_H -#define WOBJECT_H - -#include "fwk.h" -#include <iostream> - -namespace fwk -{ - -/** - * @brief Base class of all virtual objects - * - * The only purpose of this class is that it avoids many copy/paste for - * the print function (__str__() fct) in SWIG/python - */ - -class FWK_API wObject -{ -public: - wObject() = default; - virtual ~wObject() {} - wObject(const wObject &) = delete; - wObject &operator=(const wObject &) = delete; - -#ifndef SWIG - friend FWK_API std::ostream &operator<<(std::ostream &out, wObject const &obj); - virtual void write(std::ostream &out) const; -#endif -}; - -/** - * @brief Base class of smart-pointed objects (shared_ptr) - * - * This base class is only required for "print" in SWIG/python. - * std::cout << *o works from C++ (it calls "write") even if the object inherits from wObject - * which is not defined in SWIG as shared_ptr-managed object - * However "print o" fails in python if the shared object inherits from wObject. - * This class also avoids a warning in SWIG telling that some derived or base classes are not - * managed by shared_ptr. - */ - -class FWK_API wSharedObject -{ -public: - wSharedObject() = default; - virtual ~wSharedObject() {} - wSharedObject(const wSharedObject &) = delete; - wSharedObject &operator=(const wSharedObject &) = delete; - -#ifndef SWIG - friend FWK_API std::ostream &operator<<(std::ostream &out, wSharedObject const &obj); - virtual void write(std::ostream &out) const; -#endif -}; - -} // namespace fwk - -#endif //WOBJECT_H diff --git a/fwk/src/wObserver.cpp b/fwk/src/wObserver.cpp deleted file mode 100644 index 0162b4a3..00000000 --- a/fwk/src/wObserver.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wObserver.h" -#include <stdexcept> - -using namespace fwk; - -void Observer::update(double data) -{ - throw std::runtime_error("fwk::Observer::update() not implemented!\n"); -} \ No newline at end of file diff --git a/fwk/src/wObserver.h b/fwk/src/wObserver.h deleted file mode 100644 index cabc058c..00000000 --- a/fwk/src/wObserver.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WOBSERVER_H -#define WOBSERVER_H - -#include "fwk.h" - -namespace fwk -{ - -/** - * @brief Base class that obsverves another class, and that updates accordingly - */ - -class FWK_API Observer -{ -public: - Observer() {} - virtual ~Observer() {} - virtual void update(double data); -}; - -} // namespace fwk - -#endif //WOBSERVER_H diff --git a/fwk/src/wTime.cpp b/fwk/src/wTime.cpp deleted file mode 100644 index 9ee5a2c4..00000000 --- a/fwk/src/wTime.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WIN32 -#include <unistd.h> -#endif -#include "wTime.h" -#include "wHMSTime.h" - -using namespace fwk; - -namespace fwk -{ - -FWK_API std::ostream & -operator<<(std::ostream &out, Time const &obj) -{ - out << obj.hms(); - return out; -} - -} // namespace fwk - -std::string -Time::hms() const -{ - return HMSTime(sec()).str(); -} - -#ifdef WIN32 - -double -Int64Time::sec() const -{ - static __int64 freq = 10000000U; - return time / static_cast<double>(freq); -} -#else - -double -UnixClockTime::sec() const -{ - static clock_t freq = sysconf(_SC_CLK_TCK); - return time / static_cast<double>(freq); -} - -#endif - -double -ClockTime::sec() const -{ - static clock_t freq = CLOCKS_PER_SEC; - return time / static_cast<double>(freq); -} - -double -DblTime::sec() const -{ - return time; -} diff --git a/fwk/src/wTime.h b/fwk/src/wTime.h deleted file mode 100644 index c782967c..00000000 --- a/fwk/src/wTime.h +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WTIME_H -#define WTIME_H - -#include "fwk.h" -#include <time.h> -#include <string> -#include <iostream> - -namespace fwk -{ - -/** - * @brief Portable base class handling a time - */ -class FWK_API Time -{ -public: - virtual double sec() const = 0; - std::string hms() const; -#ifndef SWIG - friend FWK_API std::ostream &operator<<(std::ostream &out, Time const &obj); -#endif -}; - -//----------------------------------------------------------------------------------------- - -#ifndef SWIG - -#ifdef WIN32 - -/** - * @brief Time as a __int64 (MS Windows only) - */ -class FWK_API Int64Time : public Time -{ - __int64 time; - -public: - explicit Int64Time(__int64 t = 0) : time(t) {} - virtual double sec() const override; - operator bool() const { return time != 0; } - Int64Time operator+(Int64Time const &obj) const { return Int64Time(time + obj.time); } - Int64Time operator-(Int64Time const &obj) const { return Int64Time(time - obj.time); } -}; - -#else //WIN32 - -class FWK_API UnixClockTime : public Time -{ - clock_t time; - -public: - explicit UnixClockTime(clock_t t = 0) : time(t) {} - virtual double sec() const override; - operator bool() const { return time != 0; } - UnixClockTime operator+(UnixClockTime const &obj) const { return UnixClockTime(time + obj.time); } - UnixClockTime operator-(UnixClockTime const &obj) const { return UnixClockTime(time - obj.time); } -}; - -#endif //WIN32 - -//----------------------------------------------------------------------------------------- - -/** - * @brief Time as a clock_t (freq = CLOCKS_PER_SEC) - */ -class FWK_API ClockTime : public Time -{ - clock_t time; - -public: - explicit ClockTime(clock_t t = 0) : time(t) {} - virtual double sec() const override; - operator bool() const { return time != 0; } - ClockTime operator+(ClockTime const &obj) const { return ClockTime(time + obj.time); } - ClockTime operator-(ClockTime const &obj) const { return ClockTime(time - obj.time); } -}; - -//----------------------------------------------------------------------------------------- - -/** - * @brief Time as a double - */ -class FWK_API DblTime : public Time -{ - double time; - -public: - explicit DblTime(double t = 0.0) : time(t) {} - virtual double sec() const override; - operator bool() const { return time != 0.0; } - DblTime operator+(DblTime const &obj) const { return DblTime(time + obj.time); } - DblTime operator-(DblTime const &obj) const { return DblTime(time - obj.time); } -}; - -#endif //SWIG - -}; // namespace fwk -#endif //WTIME_H diff --git a/fwk/src/wTimer.cpp b/fwk/src/wTimer.cpp deleted file mode 100644 index 2242c0e1..00000000 --- a/fwk/src/wTimer.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wTimer.h" - -using namespace fwk; - -Timer::Timer() -{ - reset(); -} - -/** - * @brief reset the timer - */ - -void Timer::reset() -{ - tStart = Times(); - tElaps = Times(); - isOn = false; -} - -/** - * @brief Start the timer from last "elapsed time" - */ - -void Timer::start() -{ - isOn = true; - tStart.read(); -} - -/** - * @brief stop the timer - */ - -void Timer::stop() -{ - tElaps = read(); - tStart = Times(); - isOn = false; -} - -/** - * @brief read current time (without stopping the timer) - */ - -Times Timer::read() const -{ - if (isOn) - return tElaps + Times().read() - tStart; - else - return tElaps; -} - -namespace fwk -{ -FWK_API std::ostream & -operator<<(std::ostream &out, Timer const &obj) -{ - out << obj.read(); - return out; -} -} // namespace fwk diff --git a/fwk/src/wTimer.h b/fwk/src/wTimer.h deleted file mode 100644 index 2a960587..00000000 --- a/fwk/src/wTimer.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WTIMER_H -#define WTIMER_H - -#include "fwk.h" -#include "wTimes.h" - -namespace fwk -{ - -/** - * @brief Un simple chronometre - */ - -class FWK_API Timer -{ - Times tStart; - Times tElaps; - - bool isOn; - -public: - Timer(); - - void start(); - void stop(); - void reset(); - Times read() const; - - friend FWK_API std::ostream &operator<<(std::ostream &out, Timer const &obj); - -#ifndef SWIG - void setTStart(Times times) - { - tStart = times; - }; - void setTElaps(Times times) { tElaps = times; }; -#endif -}; -}; // namespace fwk -#endif //TIMER_H diff --git a/fwk/src/wTimers.cpp b/fwk/src/wTimers.cpp deleted file mode 100644 index 69ae39ba..00000000 --- a/fwk/src/wTimers.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wTimers.h" -#include <iomanip> - -using namespace fwk; - -Timers::Timers() -{ -} - -Timer & -Timers::operator[](std::string const &name) -{ - return timers[name]; -} - -void Timers::reset() -{ - for (auto it = timers.begin(); it != timers.end(); ++it) - it->second.reset(); -} - -void Timers::write(std::ostream &out) const -{ - out << std::fixed << std::setprecision(1); - out << std::setw(15) << std::left << " " - << std::setw(10) << std::right << "user" - << std::setw(10) << std::right << "real" - << std::setw(10) << std::right << "kernel" - << '\n'; - - for (auto it = timers.begin(); it != timers.end(); ++it) - { - Times tm = it->second.read(); - out << std::setw(15) << std::left << it->first - << std::setw(10) << std::right << tm.getUser().sec() - << std::setw(10) << std::right << tm.getReal().sec() - << std::setw(10) << std::right << tm.getKernel().sec() - << '\n'; - } -} diff --git a/fwk/src/wTimers.h b/fwk/src/wTimers.h deleted file mode 100644 index 779994be..00000000 --- a/fwk/src/wTimers.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WTIMERS_H -#define WTIMERS_H - -#include "fwk.h" -#include "wObject.h" -#include "wTimer.h" -#include <map> - -namespace fwk -{ - -/** - * @brief list of named timers - */ - -class FWK_API Timers : public wObject -{ - std::map<std::string, Timer> timers; - -public: - Timers(); - void reset(); - -#ifndef SWIG - - Timer &operator[](std::string const &name); - virtual void write(std::ostream &out) const override; -#endif -}; -}; // namespace fwk -#endif //TIMERS_H diff --git a/fwk/src/wTimes.cpp b/fwk/src/wTimes.cpp deleted file mode 100644 index 1ee97deb..00000000 --- a/fwk/src/wTimes.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wTimes.h" - -#ifdef WIN32 -#include <windows.h> -#else -#include <unistd.h> // needed by Linux 32-bit only! -#include <sys/times.h> -#endif - -using namespace fwk; - -Times Times::read() -{ -#ifdef WIN32 - HANDLE hProcess = GetCurrentProcess(); - FILETIME ftCreation, ftExit, ftKernel, ftUser; - GetProcessTimes(hProcess, &ftCreation, &ftExit, &ftKernel, &ftUser); - user = Int64Time(*(reinterpret_cast<__int64 *>(&ftUser))); - kernel = Int64Time(*(reinterpret_cast<__int64 *>(&ftKernel))); - real = ClockTime(clock()); -#else - struct tms tm; - real = UnixClockTime(times(&tm)); - user = UnixClockTime(tm.tms_utime); - kernel = UnixClockTime(tm.tms_stime); -#endif - return *this; -} - -namespace fwk -{ -FWK_API std::ostream & -operator<<(std::ostream &out, Times const &obj) -{ - out << "usr:" << obj.getUser(); - out << " kern:" << obj.getKernel(); - out << " real:" << obj.getReal(); - return out; -} -} // namespace fwk diff --git a/fwk/src/wTimes.h b/fwk/src/wTimes.h deleted file mode 100644 index 42c17ce8..00000000 --- a/fwk/src/wTimes.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WTIMES_H -#define WTIMES_H - -#include "fwk.h" -#include "wTime.h" - -namespace fwk -{ -/** - * @brief Class containing user, kernel, real (wall clock) CPU time counters - */ - -class FWK_API Times -{ -#ifdef WIN32 - Int64Time user; - Int64Time kernel; - ClockTime real; -#else - UnixClockTime user; - UnixClockTime kernel; - UnixClockTime real; -#endif - -public: - Times read(); - - Time const &getUser() const; - Time const &getKernel() const; - Time const &getReal() const; - -#ifndef SWIG - // [RB] the following 3 routines looks like a dirty hack from Kim - // to display Trilinos timers as waves ones - // @todo remove these calls or replace them by an appropriate (copy) constructor -#ifdef WIN32 - void setUser(Int64Time time) - { - user = time; - } - void setKernel(Int64Time time) { kernel = time; } - void setReal(ClockTime time) { real = time; } -#else - void setUser(UnixClockTime time) - { - user = time; - } - void setKernel(UnixClockTime time) { kernel = time; } - void setReal(UnixClockTime time) { real = time; } -#endif - Times operator+(Times const &obj) const; - Times operator-(Times const &obj) const; - friend FWK_API std::ostream &operator<<(std::ostream &out, Times const &obj); -#endif -}; - -#include "wTimes.inl" -}; // namespace fwk -#endif //WTIMES_H diff --git a/fwk/src/wTimes.inl b/fwk/src/wTimes.inl deleted file mode 100644 index 1c339839..00000000 --- a/fwk/src/wTimes.inl +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -inline Time const & -Times::getUser() const -{ - return user; -} - -inline Time const & -Times::getKernel() const -{ - return kernel; -} - -inline Time const & -Times::getReal() const -{ - return real; -} - -inline Times -Times::operator+(Times const &obj) const -{ - Times ret; - ret.user = user + obj.user; - ret.kernel = kernel + obj.kernel; - ret.real = real + obj.real; - return ret; -} - -inline Times -Times::operator-(Times const &obj) const -{ - Times ret; - ret.user = user - obj.user; - ret.kernel = kernel - obj.kernel; - ret.real = real - obj.real; - return ret; -} diff --git a/fwk/testing.py b/fwk/testing.py deleted file mode 100644 index e6de9e76..00000000 --- a/fwk/testing.py +++ /dev/null @@ -1,80 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# testing classes (for ctest) - -from .coloring import ccolors - -class CTest: - def __init__(self, name, val, expected, maxdiff=1e-10, refval=0.0, forceabs=False): - self.name = name # name of the test - self.val = float(val) # calculated value - self.expected = float(expected) # expected value - self.maxdiff = abs(float(maxdiff)) # tolerance on max difference - self.refval = abs(float(refval)) # optional value used as denominator - # if the expected one is close to 0 - self.forceabs = forceabs # force the calculation of an absolute diff - - def run(self): - ok = True - adiff = abs(self.val-self.expected) # absolute diff - - # the ref value is the largest among the expected value and - # the one provided by the user - denom = max(abs(self.refval), abs(self.expected)) - - if not self.forceabs and denom>self.maxdiff: - diff = adiff / denom # relative diff - typ='rel' - percent = '%3.1f%%' % (self.maxdiff*100) - else: - diff = adiff # absolute diff - typ='abs' - percent = '%f' % self.maxdiff - - print("[CTest] %s = %f (expected %f +/- %s)" % \ - (self.name, self.val, self.expected, percent)) - - if diff<=self.maxdiff: - sgn = '<=' - info = "ok" - else: - sgn = '>' - ok = False - info = "wrong!" - print("\t%s diff = %e %s %e [%s]" % (typ, diff, sgn, self.maxdiff, info)) - return ok - -class CTests: - def __init__(self): - self.tests = [] - def add(self, t): - self.tests.append(t) - def run(self): - ok = True - for i,t in enumerate(self.tests): - #print "running test %d/%d..." % (i+1,len(self.tests)) - ok = t.run() and ok - - if ok: - print(ccolors.ANSI_GREEN + '** All tests are OK!' + ccolors.ANSI_RESET) - else: - print('\n\n') - raise Exception(ccolors.ANSI_RED + '** Some tests failed!' + ccolors.ANSI_RESET) - - - diff --git a/fwk/tests/timers.py b/fwk/tests/timers.py deleted file mode 100644 index 5df6f545..00000000 --- a/fwk/tests/timers.py +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# basic test of timers - -import fwk -from time import sleep - - -delay = 0.2 - -print('-'*79) -print("Timer - a simple Timer") -print('-'*79) - -timer = fwk.Timer() -timer.start() -for i in range(3): - sleep(delay) - print(timer) -timer.stop() -sleep(delay) -print(timer) - -print('-'*79) -print("Times - a cpu time (usr, real, kernel)") -print('-'*79) - -times = timer.read() -print("it lasted %f secs" % times.getReal().sec()) -print("CPU time = %f secs" % times.getUser().sec()) - -print("once again...") -#print "it lasted %f secs" % timer.read().getReal().sec() # plante car retour de read() desalloue lors de sec(). -#print "CPU time = %f secs" % timer.read().getUser().sec() - - -print('-'*79) -print("HMSTime - conversion from sec to HMS") -print('-'*79) - -nsec = 100000 -print("%s secs equals to %s" % (nsec, fwk.HMSTime(nsec))) - -print('-'*79) -print("Timers - list of Timers") -print('-'*79) - -timers = fwk.Timers() -timers['cpu1'].start() -sleep(delay) -timers['cpu2'].start() -sleep(delay) -timers['cpu3'].start() -sleep(delay) -print(timers) - diff --git a/fwk/wutils.py b/fwk/wutils.py deleted file mode 100644 index 7383760e..00000000 --- a/fwk/wutils.py +++ /dev/null @@ -1,270 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# Python utilities - -try: # permet d'importer les .so de mkl à partir d'un module python - import sys,DLFCN - sys.setdlopenflags(DLFCN.RTLD_NOW|DLFCN.RTLD_GLOBAL) -except: - pass - -# ------------------------------------------------------------------------------ - -def findbins(modname, dirB=['build','wavesB'], verb=False): # changer wavesB en autre chose ! - """ - try to find where the binaries related to a python module are - if modname='fwk' => look for 'fwkw.[so|pyd]' - """ - - modwrap = modname+'w' # assumption: SWIG-generated module = module+'w' - - # are we lucky? - try: - __import__(modwrap) #import fwkw - if verb: - print("[findbins] module %s already in the PYTHONPATH!" % modwrap) - return # nothing to do - except: - pass - if verb: - print("[findbins] module %s is not in the PYTHONPATH!" % modwrap) - - # the module is not in the pythonpath - # let's look for a folder called "dirB" in parent directories - # result in "spath" - import sys, os, os.path - path = os.path.abspath(sys.modules[modname].__file__) - found = False - while True: - for dir in dirB: - spath = os.path.join(path,dir) - if verb: - print("[findbins] path = ", path) - print("[findbins] spath = ", spath) - print("[findbins] os.path.isdir(spath) = ", os.path.isdir(spath)) - if(os.path.isdir(spath)): - found = True - if verb: - print("[findbins] break with ",dir) - break - uppath = os.path.split(path)[0] - if(path==uppath): - raise Exception('[findbins] binary dir not found in '+repr(dirB)+' !') - path=uppath - - if found == True : # to break the while ... - break - if verb: - print("[findbins] spath=", spath) - - - # build a list of possible directories (libpath) - # according to the system and the runtime environment - - pyexe = os.path.basename(sys.executable) - if verb: - print("[findbins] pyexe=", pyexe) - - libpath = [] - 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 - - # check the paths one by one - for p in libpath: - if os.path.isdir(p): - if verb: - print("[findbins] adding %s to sys.path" % p) - sys.path.append(p) - if verb: - print("[findbins] sys.path =", sys.path) - break - else: - raise Exception("[findbins] '%s' not found!" % libpath) - - #exec("import %s" % modwrap) - #mod = sys.modules[modwrap] - mod = __import__(modwrap) - print('[findbins] loading ', mod.__file__) - - # initialisations - initDLL() - initMKL(parseargs().k) - -# attention! si waves and heat possedent des classes de mêmes noms, -# c'est celle du premier module qui sera chargée! -# => ne pas charger waves et heat en même temps tant qu'il n'y a pas de namespaces -# distingant les 2 ensembles de classes - -#------------------------------------------------------------------------------- - -def initDLL(): - # For new versions of python, DLLs must be loaded via a specific command - import platform, os, sys - if 'Windows' in platform.uname() and sys.version_info.minor >= 8: - lookfor = ['tbb', 'mkl', 'vtk'] - for k in lookfor: - for v in os.environ['path'].split(';'): - if k in v.lower(): - os.add_dll_directory(v) - break - -# ------------------------------------------------------------------------------ - -def initMKL(nthreads): - import os - # we try to have full control over the threading environment - # => set MKL/OMP variables if (and only if) they are not set! - # number of "default" threads for MKL (available MKL domains: ALL, BLAS, VML, PARDISO) - if not 'MKL_NUM_THREADS' in os.environ: - os.environ['MKL_NUM_THREADS'] = '%d' % nthreads - os.environ['MKL_DOMAIN_NUM_THREADS'] = 'MKL_DOMAIN_ALL=%d' % nthreads - # threading interface - if not 'MKL_THREADING_LAYER' in os.environ: - if nthreads == 1: - os.environ['MKL_THREADING_LAYER'] = 'SEQUENTIAL' - else: - os.environ['MKL_THREADING_LAYER'] = 'TBB' - # interface (32 or 64 bits) - if not 'MKL_INTERFACE_LAYER' in os.environ: - os.environ['MKL_INTERFACE_LAYER'] = 'LP64' # 32 bits (default), ILP64 for 64 bits - # we do not want to use OpenMP - if not 'OMP_NUM_THREADS' in os.environ: - os.environ['OMP_NUM_THREADS'] = '1' - if not 'MKL_DYNAMIC' in os.environ: - os.environ['MKL_DYNAMIC'] = 'FALSE' - if not 'OMP_DYNAMIC' in os.environ: - os.environ['OMP_DYNAMIC'] = 'FALSE' - # display variables - for s in ['OMP_', 'MKL', 'KMP']: - print('* %s environment:' % s) - for key, value in os.environ.items(): - if s in key: - print('\t%s = %s' % (key, value)) - -# ------------------------------------------------------------------------------ - -def setupwdir(testname): - """ - creates a single working folder for the given test - """ - try: - # are we using MPI? - import mpi4py.MPI as mpi - comm = mpi.COMM_WORLD - rank = comm.rank - siz = comm.size - name = mpi.Get_processor_name() - status = mpi.Status() - except: - comm = None - rank = 0 - siz = 1 - name = "noname" - import os, os.path - - # builds the name of the workspace folder - #print "__file__=",__file__ - dir1 = os.path.abspath(os.path.dirname(__file__)+os.sep+"..")+os.sep - print("dir1=",dir1) - print("testname=",testname) - common = os.path.commonprefix( (testname, dir1) ) - #print "common=", common - resdir = testname[len(common):].replace(os.sep,"_") - resdir = os.path.splitext(resdir)[0] # remove ".py" - if siz>1: - # append the mpi size if mpi is used - # (so that the same test can be run concurrently with - # sevral mpi sizes in ctest) - resdir += "_mpi%d" % siz - #print "resdir=", resdir - wdir = os.path.join('workspace', resdir) - - if rank == 0: - # rank0 is in charge of creating the folder... - args = parseargs() - if not os.path.isdir(wdir): - print("creating", wdir) - os.makedirs(wdir) - elif os.path.isdir(wdir) and args.clean: - print('cleaning', wdir) - import shutil - for f in os.listdir(wdir): - fpth = os.path.join(wdir, f) - if os.path.isfile(fpth): - os.remove(fpth) - elif os.path.isdir(fpth): - shutil.rmtree(fpth) - - if siz>1: # if multiple process => send sync to slaves. - comm.Barrier() - - # we can now safely go into the new folder - os.chdir(wdir) - -# ------------------------------------------------------------------------------ - -def parseargs(): - """ - parses command line arguments - """ - import argparse - parser = argparse.ArgumentParser() - parser.add_argument("-v", "--verb", help="increase output verbosity", action="count", default=0) - parser.add_argument("--nogui", help="disable any graphical output", action="store_true") - parser.add_argument("--fpe", help="enable floating point exceptions", action="store_true") - parser.add_argument("--clean", help="clean workspace", action="store_true") - parser.add_argument("-k", help="nb of threads", type=int, default=1) - parser.add_argument('file', nargs='*', help='python files') - args = parser.parse_args() - return args - -# ------------------------------------------------------------------------------ - -def pth(filename, caller=''): - import os, os.path - retname = filename - # try to build the name of the file if a caller file or dir is given - if not os.path.isabs(filename): - if caller: - #print "caller=",caller - if os.path.isfile(caller): - dirname = os.path.split(caller)[0] - elif os.path.isdir(caller): - dirname = caller - else: - raise Exception("neither a file nor a dir (%s)" %caller) - f = os.path.join(dirname, filename) - if os.path.isfile(f): - retname = f - # check if the file exist - if not os.path.isfile(retname): - raise Exception("path to a non-existent file! (%s)" % filename) - #print "retname=",retname - return retname diff --git a/heat/_src/CMakeLists.txt b/heat/_src/CMakeLists.txt index c74b28c7..8784cebd 100644 --- a/heat/_src/CMakeLists.txt +++ b/heat/_src/CMakeLists.txt @@ -25,10 +25,10 @@ SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES CPLUSPLUS ON) SET(SWINCFLAGS -I${PROJECT_SOURCE_DIR}/heat/src --I${PROJECT_SOURCE_DIR}/tbox/src --I${PROJECT_SOURCE_DIR}/tbox/_src --I${PROJECT_SOURCE_DIR}/fwk/src --I${PROJECT_SOURCE_DIR}/fwk/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src ) SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES SWIG_FLAGS "${SWINCFLAGS}") @@ -39,11 +39,14 @@ else() endif() MACRO_DebugPostfix(_heatw) -TARGET_INCLUDE_DIRECTORIES(_heatw PRIVATE ${PROJECT_SOURCE_DIR}/fwk/_src - ${PROJECT_SOURCE_DIR}/tbox/_src +TARGET_INCLUDE_DIRECTORIES(_heatw PRIVATE ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src ${PYTHON_INCLUDE_PATH} ) SWIG_LINK_LIBRARIES(heatw heat tbox fwk ${PYTHON_LIBRARIES} ) + +INSTALL(FILES ${CMAKE_SWIG_OUTDIR}/heatw.py DESTINATION ${CMAKE_INSTALL_PREFIX}) +INSTALL(TARGETS _heatw DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/heat/src/CMakeLists.txt b/heat/src/CMakeLists.txt index 3fc96b69..31b8dffa 100644 --- a/heat/src/CMakeLists.txt +++ b/heat/src/CMakeLists.txt @@ -22,4 +22,6 @@ TARGET_INCLUDE_DIRECTORIES(heat PUBLIC ${PROJECT_SOURCE_DIR}/heat/src) TARGET_LINK_LIBRARIES(heat tbox) +INSTALL(TARGETS heat DESTINATION ${CMAKE_INSTALL_PREFIX}) + SOURCE_GROUP(base REGULAR_EXPRESSION ".*\\.(cpp|inl|hpp|h)") diff --git a/katoptron/_src/CMakeLists.txt b/katoptron/_src/CMakeLists.txt index fec7116b..d7fd03c0 100644 --- a/katoptron/_src/CMakeLists.txt +++ b/katoptron/_src/CMakeLists.txt @@ -14,7 +14,6 @@ SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES CPLUSPLUS ON) # -- Search for Trilinos FIND_PACKAGE(Trilinos REQUIRED) FIND_PACKAGE(MPI4PY REQUIRED) -#FIND_PACKAGE(PYTEUCHOS REQUIRED) #FIND_PACKAGE(NUMPY REQUIRED) set (_VERB 1) # set to 1 for debugging @@ -54,10 +53,10 @@ endif() IF(1) SET(SWINCFLAGS -I${PROJECT_SOURCE_DIR}/katoptron/src --I${PROJECT_SOURCE_DIR}/tbox/src --I${PROJECT_SOURCE_DIR}/tbox/_src --I${PROJECT_SOURCE_DIR}/fwk/src --I${PROJECT_SOURCE_DIR}/fwk/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src -I${MPI4PY_INCLUDE_DIR} -I${Trilinos_INCLUDE_DIRS} -I${TRILINOS_SOURCE_DIR}/packages/PyTrilinos/src @@ -67,10 +66,10 @@ SET(SWINCFLAGS ELSE() SET(SWINCFLAGS -I${PROJECT_SOURCE_DIR}/katoptron/src --I${PROJECT_SOURCE_DIR}/tbox/src --I${PROJECT_SOURCE_DIR}/tbox/_src --I${PROJECT_SOURCE_DIR}/fwk/src --I${PROJECT_SOURCE_DIR}/fwk/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src -I${MPI4PY_INCLUDE_DIR} -I${Trilinos_INCLUDE_DIRS} ) @@ -88,10 +87,10 @@ MACRO_DebugPostfix(_katoptronw) IF(1) INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/katoptron/src - ${PROJECT_SOURCE_DIR}/tbox/src - ${PROJECT_SOURCE_DIR}/fwk/src - ${PROJECT_SOURCE_DIR}/fwk/_src - ${PROJECT_SOURCE_DIR}/tbox/_src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src + ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src + ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src ${Trilinos_INCLUDE_DIRS} ${Trilinos_TPL_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} @@ -102,8 +101,8 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/katoptron/src ${NUMPY_INCLUDE_DIR}) ELSE() INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/katoptron/src - ${PROJECT_SOURCE_DIR}/tbox/src - ${PROJECT_SOURCE_DIR}/fwk/src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src + ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src ${Trilinos_INCLUDE_DIRS} ${Trilinos_TPL_INCLUDE_DIRS} ${MPI_INCLUDE_PATH} @@ -113,3 +112,6 @@ ENDIF() SWIG_LINK_LIBRARIES(katoptronw katoptron tbox fwk ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES} ${PYTHON_LIBRARIES} ) + +INSTALL(FILES ${CMAKE_SWIG_OUTDIR}/katoptronw.py DESTINATION ${CMAKE_INSTALL_PREFIX}) +INSTALL(TARGETS _katoptronw DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/katoptron/exe/CMakeLists.txt b/katoptron/exe/CMakeLists.txt index 14cc3cd0..d69d7975 100644 --- a/katoptron/exe/CMakeLists.txt +++ b/katoptron/exe/CMakeLists.txt @@ -73,8 +73,8 @@ list(REMOVE_ITEM Trilinos_LIBRARIES pytrilinos) INCLUDE_DIRECTORIES( ${MPI_INCLUDE_PATH} ${PROJECT_SOURCE_DIR}/katoptron/src - ${PROJECT_SOURCE_DIR}/tbox/src - ${PROJECT_SOURCE_DIR}/fwk/src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src + ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src ${Trilinos_INCLUDE_DIRS} ${Trilinos_TPL_INCLUDE_DIRS} ) diff --git a/katoptron/src/CMakeLists.txt b/katoptron/src/CMakeLists.txt index 4e275939..5c97361a 100644 --- a/katoptron/src/CMakeLists.txt +++ b/katoptron/src/CMakeLists.txt @@ -84,8 +84,8 @@ IF(_VERB) MESSAGE(" Trilinos_LIBRARIES = ${Trilinos_LIBRARIES}") ENDIF() -INCLUDE_DIRECTORIES ( ${PROJECT_SOURCE_DIR}/tbox/src - ${PROJECT_SOURCE_DIR}/fwk/src +INCLUDE_DIRECTORIES ( ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src + ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src ${Trilinos_INCLUDE_DIRS} ${Trilinos_TPL_INCLUDE_DIRS} ${MPI_INCLUDE_PATH}) @@ -94,5 +94,4 @@ LINK_DIRECTORIES (${Trilinos_LIBRARY_DIRS} ${Trilinos_TPL_LIBRARY_DIRS}) TARGET_LINK_LIBRARIES(katoptron tbox tboxVtk fwk ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES} ${MPI_LIBRARIES}) -#SOURCE_GROUP(base REGULAR_EXPRESSION ".*\\.(cpp|inl|hpp|h)") - +INSTALL(TARGETS katoptron DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/tboxVtk/src/wVtkExport_KIM2CLEAN.cpp b/katoptron/src/wVtkExport_KIM2CLEAN.cpp similarity index 100% rename from tboxVtk/src/wVtkExport_KIM2CLEAN.cpp rename to katoptron/src/wVtkExport_KIM2CLEAN.cpp diff --git a/tboxVtk/src/wVtkExport_KIM2CLEAN.h b/katoptron/src/wVtkExport_KIM2CLEAN.h similarity index 97% rename from tboxVtk/src/wVtkExport_KIM2CLEAN.h rename to katoptron/src/wVtkExport_KIM2CLEAN.h index 6c4e10c0..e47a29e8 100644 --- a/tboxVtk/src/wVtkExport_KIM2CLEAN.h +++ b/katoptron/src/wVtkExport_KIM2CLEAN.h @@ -17,7 +17,7 @@ #ifndef WVTKEXPORT_KIM2CLEAN_H #define WVTKEXPORT_KIM2CLEAN_H -#include "tboxVtk.h" +#include "katoptron.h" #include <string> #include <memory> #include <vector> @@ -42,7 +42,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 TBOXVTK_API VtkExport_KIM2CLEAN +class KATOPTRON_API VtkExport_KIM2CLEAN { public: std::shared_ptr<tbox::MshData> msh; diff --git a/mirrors/_src/CMakeLists.txt b/mirrors/_src/CMakeLists.txt index 8ef37374..fe6600e3 100644 --- a/mirrors/_src/CMakeLists.txt +++ b/mirrors/_src/CMakeLists.txt @@ -24,10 +24,10 @@ SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES CPLUSPLUS ON) SET(SWINCFLAGS -I${PROJECT_SOURCE_DIR}/mirrors/src --I${PROJECT_SOURCE_DIR}/tbox/src --I${PROJECT_SOURCE_DIR}/tbox/_src --I${PROJECT_SOURCE_DIR}/fwk/src --I${PROJECT_SOURCE_DIR}/fwk/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src ) SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES SWIG_FLAGS "${SWINCFLAGS}") @@ -38,11 +38,14 @@ else() endif() MACRO_DebugPostfix(_mirrorsw) -TARGET_INCLUDE_DIRECTORIES(_mirrorsw PRIVATE ${PROJECT_SOURCE_DIR}/fwk/_src - ${PROJECT_SOURCE_DIR}/tbox/_src +TARGET_INCLUDE_DIRECTORIES(_mirrorsw PRIVATE ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src ${PYTHON_INCLUDE_PATH} ) SWIG_LINK_LIBRARIES(mirrorsw mirrors tbox fwk ${PYTHON_LIBRARIES} ) + +INSTALL(FILES ${CMAKE_SWIG_OUTDIR}/mirrorsw.py DESTINATION ${CMAKE_INSTALL_PREFIX}) +INSTALL(TARGETS _mirrorsw DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/mirrors/src/CMakeLists.txt b/mirrors/src/CMakeLists.txt index 359324c6..a7689259 100644 --- a/mirrors/src/CMakeLists.txt +++ b/mirrors/src/CMakeLists.txt @@ -22,5 +22,7 @@ TARGET_INCLUDE_DIRECTORIES(mirrors PUBLIC ${PROJECT_SOURCE_DIR}/mirrors/src) TARGET_LINK_LIBRARIES(mirrors tbox) +INSTALL(TARGETS mirrors DESTINATION ${CMAKE_INSTALL_PREFIX}) + SOURCE_GROUP(base REGULAR_EXPRESSION ".*\\.(cpp|inl|hpp|h)") diff --git a/run.py b/run.py index 76b9a05b..1f4e1109 100755 --- a/run.py +++ b/run.py @@ -16,85 +16,21 @@ # See the License for the specific language governing permissions and # limitations under the License. - -# -# runs a test as if it was installed -# - fixes the python path in a dev environment -# - creates a workspace folder - - -class DupStream: - def __init__(self, stream1, stream2): - self.stream1 = stream1 - self.stream2 = stream2 - - def write(self, data): - self.stream1.write(data) - self.stream2.write(data) - - def flush(self): - self.stream1.flush() - self.stream2.flush() - - -class Tee: - def __init__(self, name): - import sys - self.file = open(name, 'w') - self.stdoutbak = sys.stdout - self.stderrbak = sys.stderr - sys.stdout = DupStream(sys.stdout, self.file) - sys.stderr = DupStream(sys.stderr, self.file) - - def __del__(self): - import sys - sys.stdout = self.stdoutbak - sys.stderr = self.stderrbak - self.file.close() - - -def main(thisfile): - global __file__ # required for run_pfem.py - global __name__ # required for run_pfem.py - import sys, os +# Calls fwk.wutils.run to execute a script as if dartflo was installed + +def main(): + import os.path, sys + # adds fwk/tbox to the python path + thisdir = os.path.split(os.path.abspath(__file__))[0] + fwkdir = os.path.abspath(os.path.join(thisdir, 'ext', 'amfe')) + if not os.path.isdir(fwkdir): + raise Exception('waves/ext/amfe not found!\n') + sys.path.append(fwkdir) # adds "." to the pythonpath - 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 - redirect = fwk.StdOutErr2Py() - - # parse args - args = wu.parseargs() - if args.fpe: - fwk.enableFpe() # enables floating point exceptions at runtime - print(ccolors.ANSI_YELLOW + 'Floating point exceptions will cause numpy to overflow!' + ccolors.ANSI_RESET) + sys.path.append(thisdir) - # run all tests sequentially - for testname in args.file: - testname = os.path.abspath(testname) - if not os.path.isfile(testname): - raise Exception("file not found: %s" % testname) - - wu.setupwdir(testname) - - __file__ = testname - __name__ = "__main__" - print("[run.py] __file__", __file__) - # split streams - tee = Tee('stdout.txt') - - # start test - import time, socket - print('-' * 80) - print(ccolors.ANSI_BLUE + 'PyStarting...' + ccolors.ANSI_RESET) - print("starting test", testname) - print("time:", time.strftime("%c")) - print("hostname:", socket.gethostname()) - exec(open(testname, 'r', encoding='utf8').read(), globals(), globals()) # exec at global level!! + import fwk.wutils as wu + wu.run() if __name__ == "__main__": - main(__file__) + main() diff --git a/tbox/CMakeLists.txt b/tbox/CMakeLists.txt deleted file mode 100644 index 156e07c4..00000000 --- a/tbox/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Add source dir -ADD_SUBDIRECTORY( src ) -ADD_SUBDIRECTORY( _src ) - -# Add test dir -MACRO_AddTest(${CMAKE_CURRENT_SOURCE_DIR}/tests) diff --git a/tbox/__init__.py b/tbox/__init__.py deleted file mode 100644 index 9ee55c94..00000000 --- a/tbox/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# tbox MODULE initialization file - -# Copyright 2018 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import fwk -from tboxw import * - diff --git a/tbox/_src/CMakeLists.txt b/tbox/_src/CMakeLists.txt deleted file mode 100644 index dca92118..00000000 --- a/tbox/_src/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake file for the SWIG interface of tbox.so - -INCLUDE(${SWIG_USE_FILE}) - -FILE(GLOB SRCS *.h *.cpp *.inl *.swg) -FILE(GLOB ISRCS *.i) - -SET(CMAKE_SWIG_FLAGS "") -SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES CPLUSPLUS ON) - -SET(SWINCFLAGS --I${PROJECT_SOURCE_DIR}/tbox/src --I${PROJECT_SOURCE_DIR}/tbox/_src --I${PROJECT_SOURCE_DIR}/fwk/src --I${PROJECT_SOURCE_DIR}/fwk/_src -) -SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES SWIG_FLAGS "${SWINCFLAGS}") - -if (${CMAKE_VERSION} VERSION_LESS "3.8.0") - SWIG_ADD_MODULE(tboxw python ${ISRCS} ${SRCS}) -else() - SWIG_ADD_LIBRARY(tboxw LANGUAGE python SOURCES ${ISRCS} ${SRCS}) -endif() -MACRO_DebugPostfix(_tboxw) - -TARGET_INCLUDE_DIRECTORIES(_tboxw PRIVATE ${PROJECT_SOURCE_DIR}/fwk/_src - ${PROJECT_SOURCE_DIR}/tbox/_src - ${PYTHON_INCLUDE_PATH} -) - -SWIG_LINK_LIBRARIES(tboxw - tbox fwk ${PYTHON_LIBRARIES} -) diff --git a/tbox/_src/tboxw.h b/tbox/_src/tboxw.h deleted file mode 100644 index b9feacda..00000000 --- a/tbox/_src/tboxw.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "tbox.h" -#include "eigen_extra.h" -#include "std_extra.h" - -#include "wCache.h" -#include "wCacheHex8.h" -#include "wCacheLine2.h" -#include "wCachePoint1.h" -#include "wCacheQuad4.h" -#include "wCacheTetra4.h" -#include "wCacheTri3.h" -#include "wElement.h" -#include "wFct0.h" -#include "wFct1.h" -#include "wFct2.h" -#include "wGaussHex8.h" -#include "wGaussLine2.h" -#include "wGaussQuad4.h" -#include "wGaussTetra4.h" -#include "wGaussTri3.h" -#include "wGmres.h" -#include "wGmshExport.h" -#include "wGmshImport.h" -#include "wGroup.h" -#include "wGroups.h" -#include "wHex8.h" -#include "wLazy.h" -#include "wLine2.h" -#include "wLinearSolver.h" -#include "wMshConvert.h" -#include "wMshCrack.h" -#include "wMshData.h" -#include "wMshDeform.h" -#include "wMshExport.h" -#include "wMshImport.h" -#include "wMumps.h" -#include "wNode.h" -#include "wPardiso.h" -#include "wPoint1.h" -#include "wQuad4.h" -#include "wResults.h" -#include "wSfHex8.h" -#include "wSfLine2.h" -#include "wSfQuad4.h" -#include "wSfTetra4.h" -#include "wSfTri3.h" -#include "wSparseLu.h" -#include "wTag.h" -#include "wTetra4.h" -#include "wTri3.h" -#include "wUnitTest.h" \ No newline at end of file diff --git a/tbox/_src/tboxw.i b/tbox/_src/tboxw.i deleted file mode 100644 index 58f05923..00000000 --- a/tbox/_src/tboxw.i +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// tbox.i: SWIG input file of the tbox python interface - -%feature("autodoc","1"); - -%module(docstring= -"'tboxw' module: shared tools -(c) ULg - A&M", -directors="1", -threads="1" -) tboxw -%{ - -//#if defined(_WIN32) && defined(__GNUC__) -#undef _hypot -#include <cmath> -//#endif - -#include <memory> -#include <string> -#include <sstream> -#include <typeinfo> - -#include "tbox.h" -#include <Eigen/Dense> - -// ---fwk--- -#include "fwkw.h" - -// ---tbox--- -#include "tboxw.h" - -%} - -%include "waves_config.h" -%include "fwkw.swg" - -// ----------- MODULES UTILISES ------------ -%import "fwkw.i" - -// ----------- TBOX CLASSES ---------------- -%include "tbox.h" - -// Instantiate some std templates -namespace std { - %template(std_vector_int) std::vector<int>; - %template(std_vector_double) std::vector<double>; - %template(std_vector_vector_double) std::vector<std::vector<double>>; - %template(std_vector_string) std::vector<std::string>; -} - -// %nodefault: for pure virtual (abstract) class -// %feature("director"): allows C++ to see inherited classe extensions implemented in python -// %pythonappend ... self.__disown__(): set thisown=0, which directly increments the python reference count by 1 (only for directors) -%feature("director") tbox::Fct0XYZ; -%pythonappend tbox::Fct0XYZ::Fct0XYZ "self.__disown__()" -%shared_ptr(tbox::Fct0); -%shared_ptr(tbox::Fct0C); -%shared_ptr(tbox::Fct0XYZ); -%shared_ptr(tbox::Fct0U); -%shared_ptr(tbox::PwLf) -%nodefault tbox::Fct0; // Fct0 is pure virtual but swig doesn't know it. -%include "wFct0.h" - -%shared_ptr(tbox::Fct1); -%shared_ptr(tbox::Fct1C); -%nodefault tbox::Fct1; // Fct1 is pure virtual but swig doesn't know it. -%include "wFct1.h" - -%feature("director") tbox::Fct2; -%feature("director") tbox::Fct2XYZ; -%feature("director") tbox::Fct2U; -%feature("director") tbox::Fct2UdU; -%shared_ptr(tbox::Fct2); -%shared_ptr(tbox::Fct2C); -%shared_ptr(tbox::Fct2XYZ); -%shared_ptr(tbox::Fct2U); -%shared_ptr(tbox::Fct2UdU); -%shared_ptr(tbox::Fct2PwLf); -%nodefault tbox::Fct2; // Fct2 is pure virtual but swig doesn't know it. -%include "wFct2.h" - -%include "wNode.h" -%nodefault tbox::Element; // Element is pure virtual but swig doesn't know it. -%warnfilter(509); // Shadowed overloaded method MATTYPE. Code compiling and running. -%include "wElement.h" -%warnfilter(+509); -%include "wTag.h" -%include "wQuad4.h" -%include "wTetra4.h" -%include "wHex8.h" -%include "wLine2.h" -%include "wPoint1.h" - -%shared_ptr(tbox::MshData); -%include "wMshData.h" - -%shared_ptr(tbox::MshImport) -%nodefault tbox::MshImport; -%include "wMshImport.h" -%shared_ptr(tbox::MshExport) -%nodefault tbox::MshExport; -%include "wMshExport.h" -%shared_ptr(tbox::GmshImport) -%include "wGmshImport.h" -%shared_ptr(tbox::GmshExport) -%include "wGmshExport.h" - -%shared_ptr(tbox::MshConvert) -%include "wMshConvert.h" - -// Instantiate some std templates -%template(std_vector_Nodep) std::vector<tbox::Node *>; -%template(std_vector_Elementp) std::vector<tbox::Element *>; -%template(std_vector_pair_Nodep) std::vector<std::pair<tbox::Node *, tbox::Node *>>; -%template(std_map_Nodep) std::map<tbox::Node *, tbox::Node *>; -%template(std_vector_Tagp) std::vector<tbox::Tag*>; -%template(std_map_int_Tagp) std::map<int, tbox::Tag*>; -%template(std_map_string_Tagp) std::map<std::string, tbox::Tag*>; - -%shared_ptr(tbox::Group); -%include "wGroup.h" -%shared_ptr(tbox::Groups); -%warnfilter(509); // Shadowed constructor. Code compiling and running. -%include "wGroups.h" -%warnfilter(+509); -%shared_ptr(tbox::MshDeform); -%include "wMshDeform.h" // included after std templates because it needs them -%shared_ptr(tbox::MshCrack); -%include "wMshCrack.h" - -// Instantiate some std templates -%template(std_vector_Groupp) std::vector<tbox::Group*>; - -%shared_ptr(tbox::LinearSolver); -%nodefault tbox::LinearSolver; -%include "wLinearSolver.h" -%shared_ptr(tbox::Pardiso); -%include "wPardiso.h" -%shared_ptr(tbox::Mumps); -%include "wMumps.h" -%shared_ptr(tbox::SparseLu); -%include "wSparseLu.h" -%shared_ptr(tbox::Gmres); -%include "wGmres.h" - -%include "wUnitTest.h" - -// -------------------------------------------------------------------- -// Minimal interface for Eigen -// TODO add interface to numpy -// -------------------------------------------------------------------- -namespace Eigen -{ -class MatrixXd -{ -}; -class VectorXd -{ -}; -class Vector3d -{ -public: - Vector3d(); -}; -} - -%extend Eigen::MatrixXd { - void resize(int nR, int nC) - { - (*self).resize(nR, nC); - } - double getitem(int i, int j) - { - return (*self)(i,j); - } - void setitem(int i, int j, double a) - { - (*self)(i,j) = a; - } - std::string __str__() - { - std::ostringstream out; out << *self; return out.str(); - } - - %pythoncode { -def __resize__(self, nR, nC): - self.resize(nR, nC) -def __getitem__(self, idx): - return self.getitem(idx[0],idx[1]) -def __setitem__(self, idx, v): - return self.setitem(idx[0],idx[1], v) - } -} - -%extend Eigen::VectorXd { - double getitem(int i) - { - return (*self)(i); - } - std::string __str__() - { - std::ostringstream out; out << *self; return out.str(); - } - - %pythoncode { -def __getitem__(self, idx): - return self.getitem(idx) - } -} - -%extend Eigen::Vector3d { - Vector3d(double x, double y, double z) - { - Eigen::Vector3d *v = new Eigen::Vector3d(); - *v << x,y,z; - return v; - } - double getitem(int i) - { - return (*self)(i); - } - void setitem(int i, double a) - { - (*self)(i) = a; - } - std::string __str__() - { - std::ostringstream out; out << *self; return out.str(); - } - - Vector3d operator-(const Vector3d &v) const - { - return Eigen::Vector3d((*self)(0) - v(0), (*self)(1) - v(1), (*self)(2) - v(2)); - } - double norm() - { - return sqrt((*self)(0) * (*self)(0) + (*self)(1) * (*self)(1) + (*self)(2) * (*self)(2)); - } - int size() - { - return 3; - } - - %pythoncode { -def __getitem__(self, idx): - return self.getitem(idx) -def __setitem__(self, idx, v): - return self.setitem(idx, v) - } -} - -%template(std_vector_V3d) std::vector<Eigen::Vector3d>; diff --git a/tbox/gmsh.py b/tbox/gmsh.py deleted file mode 100644 index 40bc9cf6..00000000 --- a/tbox/gmsh.py +++ /dev/null @@ -1,136 +0,0 @@ -# -*- coding: utf8 -*- -# gmsh utilities - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import os, os.path, sys -import fwk.wutils as wu - -class MeshLoader: - """ - Chargement d'un fichier 'geo' (execute gmsh si nécessaire) - gmsh doit être dans le PATH - """ - def __init__(self, filename, caller=''): - self.filename = wu.pth(filename, caller) - self.verb = False - - def convert_from_APDL(self, oldfilename): - import tbox - msh = tbox.MshData() - mshConv = tbox.MshConvert(msh) - mshConv.ansys_gmsh(oldfilename, self.filename) - - def execute(self, myrank=-1, **pars): - print(" [%s] processing %s" % (self.__class__, self.filename)) - ext = os.path.splitext(self.filename)[1] - if ext == '.msh': - return self.__loadMSH(self.filename, myrank) - elif ext == '.geo': - self.__execGMSH(self.filename, pars) - return self.__loadMSH(os.path.basename(self.filename.replace('.geo','.msh')), myrank) - else: - raise Exception("Error %s: bad gmsh extension") - - def __buildParList(self, pars): - parcmd="" - for k,v in pars.items(): - if k[0] == '-': - parcmd += "%s %s " % (k,v) # option - else: - parcmd += "-setnumber %s %s " % (k,v) # parameter - return parcmd - - def __execGMSH(self, geofile, pars): - mshfile=os.path.basename(geofile.replace('.geo','.msh')) - - parnew=str(pars) - if self.verb: print(" [%s] new set of pars=%s" % (self.__class__, parnew)) - - # force rebuild if pars have changed although .msh exists - parfile=os.path.basename(geofile.replace('.geo','.par')) - rebuild=True - if os.path.isfile(mshfile): - if self.verb: print(" [%s] an older version of .msh has been found" %self.__class__) - if os.path.getmtime(mshfile) < os.path.getmtime(geofile): - if self.verb: print(" [%s] .geo has been modified => gmsh should be rerun" %self.__class__) - else: - if self.verb: print(" [%s] .geo and .msh match" %self.__class__) - if os.path.isfile(parfile): - # a parfile exists - f = open(parfile,'r') - parold = f.readline() - f.close() - if self.verb: print(" [%s] old set of pars=%s" % (self.__class__, parold)) - if parold==parnew: - rebuild=False - if self.verb: print(" [%s] pars are the same => gmsh run avoided" %self.__class__) - else: - if self.verb: print(" [%s] pars are different => gmsh should be rerun" %self.__class__) - else: - if self.verb: print(" [%s] %s not found" % (self.__class__, parfile)) - - if rebuild: - print(' [%s] running gmsh on "%s"...' % (self.__class__, geofile)) - parcmd = self.__buildParList(pars) - # TEMPORARY FIX: force gmsh to produce meshes in v2 format [RB] - cmd = 'gmsh -3 -format msh2 %s -o "%s" "%s"'% (parcmd, mshfile, geofile) - if self.verb: print(" [%s] cmd= %s" % (self.__class__, cmd)) - - import shlex - args=shlex.split(cmd) - - # lance gmsh et réagit si "gmsh" n'est pas trouvé - import subprocess - try: - sproc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=os.environ) - out, err = sproc.communicate() - except Exception as e: - print("Error:", e) - print("\n** Check that gmsh in your PATH!!\n") - raise e - - # redirige la sortie de gmsh vers le stdout (eventuellement GUI) via un PIPE - # (evite d'imprimer hors de la fenetre) - for l in out.splitlines(): - print(" [gmsh-out] ", l) - for l in err.splitlines(): - print(" [gmsh-err] ", l) - - if not os.path.isfile(mshfile): - raise Exception("Problem during gmsh run") - - # write pars - if self.verb: print(" [%s] writing parameters to %s" % (self.__class__, parfile)) - f = open(parfile,'w') - f.write(parnew) - f.close() - - else: - print(' [%s] "%s" up-to-date' % (self.__class__, mshfile)) - self.mshfile = mshfile - - def __loadMSH(self, mshfile, myrank): - import tbox - msh = tbox.MshData() - gmshLoader = tbox.GmshImport(msh) - gmshLoader.load(mshfile, myrank) - msh.name = os.path.basename(os.path.splitext(mshfile)[0]) - return msh - -# ------------------------------------------------------------------------------ - - diff --git a/tbox/solvers.py b/tbox/solvers.py deleted file mode 100644 index 8e3e8b42..00000000 --- a/tbox/solvers.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from fwk.coloring import ccolors -import tbox - -## Check and set linear (inner) third-party solver -# -# Adrien Crovato -class LinearSolver: - def __init__(self): - pass - def pardiso(self): - try: - return tbox.Pardiso() - except: - print(ccolors.ANSI_YELLOW + 'Intel MKL Pardiso not found, using SparseLU (Eigen) instead!' + ccolors.ANSI_RESET) - return tbox.SparseLu() - def mumps(self): - try: - return tbox.Mumps() - except: - print(ccolors.ANSI_YELLOW + 'MUMPS not found, using SparseLU (Eigen) instead!' + ccolors.ANSI_RESET) - return tbox.SparseLu() diff --git a/tbox/src/CMakeLists.txt b/tbox/src/CMakeLists.txt deleted file mode 100644 index 51a04a10..00000000 --- a/tbox/src/CMakeLists.txt +++ /dev/null @@ -1,98 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake input file of tboxw.so - -FILE(GLOB SRCS *.h *.cpp *.inl *.hpp) - -ADD_LIBRARY(tbox SHARED ${SRCS}) -MACRO_DebugPostfix(tbox) - -TARGET_INCLUDE_DIRECTORIES(tbox PUBLIC ${PROJECT_SOURCE_DIR}/tbox/src) - -# -- TBB -- -FIND_PACKAGE(TBB REQUIRED) -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${TBB_CXX_FLAGS_DEBUG}") -TARGET_INCLUDE_DIRECTORIES(tbox PUBLIC ${TBB_INCLUDE_DIRS}) -IF(TBB_VERSION_INTERFACE LESS 11004) - TARGET_COMPILE_DEFINITIONS(tbox PUBLIC TBB_PREVIEW_GLOBAL_CONTROL) -ENDIF() -TARGET_LINK_LIBRARIES(tbox ${TBB_LIBRARIES}) - -# -- MKL/BLAS/LAPACK -- -# Do not forget to set your environement variables using: (default path) -# - "C:\Program Files (x86)\Intel\Composer XE\mkl\bin\intel64\mklvars_intel64.bat" (windows, check that VS is in x64 mode) -# - source /opt/intel/mkl/bin/mklvars.sh intel64 (linux) - -# Find MKL -IF(WAVES_USE_MKL) - # header (mkl.h) searched using INCLUDE or MKLROOT - FIND_PATH(MKL_INCLUDE_DIRS NAMES "mkl.h" PATHS "$ENV{MKLROOT}/include") - MESSAGE(STATUS "MKL_INCLUDE_DIRS=${MKL_INCLUDE_DIRS}") - # library (mkl_rt.so) searched using LIBRARY_PATH (Linux/macOS) or LIB (windows) - FIND_LIBRARY(MKL_LIBRARIES mkl_rt PATHS ENV LIBRARY_PATH) - MESSAGE(STATUS "MKL_LIBRARIES=${MKL_LIBRARIES}") - IF(MKL_INCLUDE_DIRS AND MKL_LIBRARIES) - MESSAGE(STATUS "Found Intel MKL") - SET(FOUND_MKL TRUE) - SET(LAPACK_INCLUDE_DIRS ${MKL_INCLUDE_DIRS}) - SET(LAPACK_LIBRARIES ${MKL_LIBRARIES}) - ELSE() - MESSAGE(FATAL_ERROR "Intel MKL not found!") - ENDIF() -# Find BLAS -ELSE() - IF(${BLA_VENDOR} MATCHES "OpenBlas") - FIND_LIBRARY(LAPACK_LIBRARIES openblas) - ELSE() - FIND_PACKAGE(LAPACK REQUIRED) #FIND_LAPACK calls FIND_BLAS - ENDIF() - IF(NOT LAPACK_LIBRARIES) - MESSAGE(FATAL_ERROR "BLAS/LAPACK not found!") - ENDIF() - MESSAGE(STATUS "LAPACK_LIBRARIES=${LAPACK_LIBRARIES}") - MESSAGE(STATUS "LAPACK_LINKER_FLAGS=${LAPACK_LINKER_FLAGS}") - MESSAGE(STATUS "BLA_VENDOR=${BLA_VENDOR}") - MESSAGE(STATUS "BLA_STATIC=${BLA_STATIC}") -ENDIF() - -# -- Eigen -- -FIND_PACKAGE(EIGEN 3.3.4 REQUIRED) -TARGET_INCLUDE_DIRECTORIES(tbox PUBLIC ${EIGEN_INCLUDE_DIRS} ${LAPACK_INCLUDE_DIRS}) -TARGET_COMPILE_DEFINITIONS(tbox PUBLIC EIGEN_DONT_PARALLELIZE) -IF(FOUND_MKL) - MESSAGE(STATUS "Linking Eigen with MKL") - TARGET_COMPILE_DEFINITIONS(tbox PUBLIC EIGEN_USE_MKL_ALL) -ELSE() - MESSAGE(STATUS "Linking Eigen with BLAS ${BLA_VENDOR}") - TARGET_COMPILE_DEFINITIONS(tbox PUBLIC EIGEN_USE_BLAS) -ENDIF() -TARGET_LINK_LIBRARIES(tbox ${LAPACK_LIBRARIES}) - -# -- MUMPS -- -IF (WAVES_USE_MUMPS) - FIND_PACKAGE(MUMPS REQUIRED) - TARGET_INCLUDE_DIRECTORIES(tbox PUBLIC ${MUMPS_INCLUDE_DIRS}) - TARGET_LINK_LIBRARIES(tbox ${MUMPS_LIBRARIES}) -ENDIF() - -TARGET_LINK_LIBRARIES(tbox fwk) - -SOURCE_GROUP(base REGULAR_EXPRESSION ".*\\.(cpp|inl|hpp|h)") -SOURCE_GROUP(timer REGULAR_EXPRESSION ".+(Time).+") -SOURCE_GROUP(hex8 REGULAR_EXPRESSION ".+(Hex8).+") -SOURCE_GROUP(quad4 REGULAR_EXPRESSION ".+(Quad4).+") -SOURCE_GROUP(tri3 REGULAR_EXPRESSION ".+(Tri3).+") -SOURCE_GROUP(line2 REGULAR_EXPRESSION ".+(Line2).+") -SOURCE_GROUP(point1 REGULAR_EXPRESSION ".+(Point1).+") diff --git a/tbox/src/eigen_extra.cpp b/tbox/src/eigen_extra.cpp deleted file mode 100644 index 845994f0..00000000 --- a/tbox/src/eigen_extra.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "eigen_extra.h" -#include <fstream> - -using namespace tbox; - -/** - * @brief save CSR matrix to a file - * - * matlab usage: load K.txt; K=spconvert(K) - */ - -TBOX_API void -tomatlab(std::string const &fname, Eigen::SparseMatrix<double> const &A) -{ - std::ofstream f(fname.c_str()); - - for (int k = 0; k < A.outerSize(); ++k) - for (Eigen::SparseMatrix<double>::InnerIterator it(A, k); it; ++it) - f << it.row() + 1 << ' ' << it.col() + 1 << ' ' << it.value() << '\n'; - - f.close(); -} diff --git a/tbox/src/eigen_extra.h b/tbox/src/eigen_extra.h deleted file mode 100644 index 09559a73..00000000 --- a/tbox/src/eigen_extra.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef EIGEN_EXTRA_H -#define EIGEN_EXTRA_H - -#include "tbox.h" -#include <string> -#include <Eigen/Sparse> - -namespace tbox -{ - -TBOX_API void -tomatlab(std::string const &fname, Eigen::SparseMatrix<double> const &A); -} - -#endif //EIGEN_EXTRA_H diff --git a/tbox/src/std_extra.h b/tbox/src/std_extra.h deleted file mode 100644 index 16b70c1a..00000000 --- a/tbox/src/std_extra.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef STD_EXTRA_H -#define STD_EXTRA_H - -#include "tbox.h" -#include <iostream> -#include <vector> - -namespace std -{ - -template <typename T> -ostream &operator<<(ostream &out, vector<T> const &v) -{ - out << '['; - for (size_t i = 0; i < v.size(); ++i) - { - out << v[i]; - if (i != v.size() - 1) - out << ", "; - } - out << ']'; - return out; -} - -} // namespace std - -#endif //STD_EXTRA_H diff --git a/tbox/src/tbox.h b/tbox/src/tbox.h deleted file mode 100644 index b6814d4c..00000000 --- a/tbox/src/tbox.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// tbox global header - -#ifndef TBOX_H -#define TBOX_H - -#if defined(WIN32) -#ifdef tbox_EXPORTS -#define TBOX_API __declspec(dllexport) -#else -#define TBOX_API __declspec(dllimport) -#endif -#else -#define TBOX_API -#endif - -#include "fwk.h" - -namespace tbox -{ - -// Mesh handling -class MshData; -class Node; -class Element; -class Group; -class Groups; -class Tag; - -// Element handling -class Cache; - -// Point1 -class Point1; -class CachePoint1; - -// Line2 -class SfLine2; -class CacheLine2; -class GaussLine2; -class Line2; - -// Tri3 -class SfTri3; -class CacheTri3; -class GaussTri3; -class Tri3; - -// Quad4 -class SfQuad4; -class CacheQuad4; -class GaussQuad4; -class Quad4; - -// Tetra4 -class SfTetra4; -class CacheTetra4; -class GaussTetra4; -class Tetra4; - -// Hex8 -class SfHex8; -class CacheHex8; -class GaussHex8; -class Hex8; - -// Mesh utilities -class MshImport; -class MshExport; -class GmshImport; -class GmshExport; -class MshDeform; -class MshCrack; -class MshConvert; - -// Utilities -class PwLf; -class Fct0; -class Fct1; -class Fct2; -class Results; -class Linesearch; - -// Linear solvers -class LinearSolver; -class Pardiso; -class Mumps; -class SparseLu; -class Gmres; - -// Testing -class UnitTest; - -} // namespace tbox - -#endif //TBOX_H diff --git a/tbox/src/wCache.cpp b/tbox/src/wCache.cpp deleted file mode 100644 index 1ad82077..00000000 --- a/tbox/src/wCache.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wCache.h" - -using namespace tbox; - -Cache::Cache(int _n) : n(_n) -{ -} - -Gauss &Cache::getVGauss() -{ - throw std::runtime_error("Cache::getGauss not implemented!\n"); -} \ No newline at end of file diff --git a/tbox/src/wCache.h b/tbox/src/wCache.h deleted file mode 100644 index f20921ce..00000000 --- a/tbox/src/wCache.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WCACHE_H -#define WCACHE_H - -#include "tbox.h" -#include "wGauss.h" -#include <vector> -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Base cache for element - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API Cache -{ -protected: - int n; ///< degree of element - std::vector<Eigen::MatrixXd> dff; ///< derivative of shape functions - std::vector<Eigen::VectorXd> ff; ///< shape functions - -public: - explicit Cache(int _n); - virtual ~Cache() {} - - inline Eigen::MatrixXd const &getDsf(size_t k); - inline Eigen::VectorXd const &getSf(size_t k); - virtual Gauss &getVGauss(); -}; - -#include "wCache.inl" - -} // namespace tbox - -#endif //WCACHE_H diff --git a/tbox/src/wCache.inl b/tbox/src/wCache.inl deleted file mode 100644 index eb7b8608..00000000 --- a/tbox/src/wCache.inl +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @brief Return the shape function derivatives at Gauss point k - * - * dff[k](i, j) contains the ith derivative of the shape function associated to node j - */ -inline Eigen::MatrixXd const &Cache::getDsf(size_t k) -{ - return dff[k]; -} - -/** - * @brief Return the shape functions at Gauss point k - * - * ff[k](i) contains the shape function associated to node i - */ -inline Eigen::VectorXd const &Cache::getSf(size_t k) -{ - return ff[k]; -} diff --git a/tbox/src/wCacheHex8.cpp b/tbox/src/wCacheHex8.cpp deleted file mode 100644 index 1d1293d3..00000000 --- a/tbox/src/wCacheHex8.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wCacheHex8.h" - -using namespace tbox; - -CacheHex8::CacheHex8(int _n) : Cache(_n), gauss(_n) -{ - // get number of gauss points - size_t ngp = gauss.getN(); - - // pre-compute dff and ff - dff.resize(ngp); - ff.resize(ngp); - for (size_t k = 0; k < ngp; ++k) - { - Eigen::Vector3d const &ksi = gauss.getP(k); - sf.evalD(ksi, dff[k]); - sf.eval(ksi, ff[k]); - } -} - -Gauss &CacheHex8::getVGauss() -{ - return gauss; -} diff --git a/tbox/src/wCacheHex8.h b/tbox/src/wCacheHex8.h deleted file mode 100644 index 212dba30..00000000 --- a/tbox/src/wCacheHex8.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WCACHEHEX8_H -#define WCACHEHEX8_H - -#include "tbox.h" -#include "wCache.h" -#include "wSfHex8.h" -#include "wGaussHex8.h" -#include <vector> - -namespace tbox -{ - -/** - * @brief Cache handling Hex8 shape functions and gauss points - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API CacheHex8 : public Cache -{ -public: - SfHex8 sf; - GaussHex8 gauss; - - explicit CacheHex8(int _n = 2); - - virtual Gauss &getVGauss() override; -}; - -} // namespace tbox - -#endif //WCACHEHEX8_H diff --git a/tbox/src/wCacheLine2.cpp b/tbox/src/wCacheLine2.cpp deleted file mode 100644 index 779ea413..00000000 --- a/tbox/src/wCacheLine2.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wCacheLine2.h" - -using namespace tbox; - -CacheLine2::CacheLine2(int _n) : Cache(_n), gauss(_n) -{ - // get number of gauss points - size_t ngp = gauss.getN(); - - // pre-compute dff and ff - dff.resize(ngp); - ff.resize(ngp); - for (size_t k = 0; k < ngp; ++k) - { - Eigen::Vector3d const &ksi = gauss.getP(k); - sf.evalD(ksi, dff[k]); - sf.eval(ksi, ff[k]); - } -} - -Gauss &CacheLine2::getVGauss() -{ - return gauss; -} diff --git a/tbox/src/wCacheLine2.h b/tbox/src/wCacheLine2.h deleted file mode 100644 index a912013a..00000000 --- a/tbox/src/wCacheLine2.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WCACHELINE2_H -#define WCACHELINE2_H - -#include "tbox.h" -#include "wCache.h" -#include "wSfLine2.h" -#include "wGaussLine2.h" -#include <vector> - -namespace tbox -{ - -/** - * @brief Cache handling Line2 shape functions and gauss points - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API CacheLine2 : public Cache -{ -public: - SfLine2 sf; - GaussLine2 gauss; - - explicit CacheLine2(int _n = 2); - - virtual Gauss &getVGauss() override; -}; - -} // namespace tbox - -#endif //WCACHELINE2_H diff --git a/tbox/src/wCachePoint1.cpp b/tbox/src/wCachePoint1.cpp deleted file mode 100644 index 51364dcc..00000000 --- a/tbox/src/wCachePoint1.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wCachePoint1.h" - -using namespace tbox; - -CachePoint1::CachePoint1(int _npg) : Cache(_npg) -{ -} diff --git a/tbox/src/wCachePoint1.h b/tbox/src/wCachePoint1.h deleted file mode 100644 index 9d5f290b..00000000 --- a/tbox/src/wCachePoint1.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WCACHEPOINT1_H -#define WCACHEPOINT1_H - -#include "tbox.h" -#include "wCache.h" -#include "wSfLine2.h" -#include "wGaussLine2.h" -#include <vector> - -namespace tbox -{ - -/** - * @brief Cache handling Point1 shape functions and gauss points - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API CachePoint1 : public Cache -{ -public: - explicit CachePoint1(int _n = 0); -}; - -} // namespace tbox - -#endif //WCACHEPOINT1_H diff --git a/tbox/src/wCacheQuad4.cpp b/tbox/src/wCacheQuad4.cpp deleted file mode 100644 index 3a70e5b0..00000000 --- a/tbox/src/wCacheQuad4.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wCacheQuad4.h" - -using namespace tbox; - -CacheQuad4::CacheQuad4(int _n) : Cache(_n), gauss(_n) -{ - // get number of gauss points - size_t ngp = gauss.getN(); - - // pre-compute dff and ff - dff.resize(ngp); - ff.resize(ngp); - for (size_t k = 0; k < ngp; ++k) - { - Eigen::Vector3d const &ksi = gauss.getP(k); - sf.evalD(ksi, dff[k]); - sf.eval(ksi, ff[k]); - } -} - -Gauss &CacheQuad4::getVGauss() -{ - return gauss; -} \ No newline at end of file diff --git a/tbox/src/wCacheQuad4.h b/tbox/src/wCacheQuad4.h deleted file mode 100644 index 49a2fb1e..00000000 --- a/tbox/src/wCacheQuad4.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WCACHEQUAD4_H -#define WCACHEQUAD4_H - -#include "tbox.h" -#include "wCache.h" -#include "wSfQuad4.h" -#include "wGaussQuad4.h" -#include <vector> - -namespace tbox -{ - -/** - * @brief Cache handling Quad4 shape functions and gauss points - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API CacheQuad4 : public Cache -{ -public: - SfQuad4 sf; - GaussQuad4 gauss; - - explicit CacheQuad4(int _n = 2); - - virtual Gauss &getVGauss() override; -}; - -} // namespace tbox - -#endif //WCACHEQUAD4_H diff --git a/tbox/src/wCacheTetra4.cpp b/tbox/src/wCacheTetra4.cpp deleted file mode 100644 index e9d8dace..00000000 --- a/tbox/src/wCacheTetra4.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wCacheTetra4.h" - -using namespace tbox; - -CacheTetra4::CacheTetra4(int _n) : Cache(_n), gauss(_n) -{ - // get number of gauss points - size_t ngp = gauss.getN(); - - // pre-compute dff and ff - dff.resize(ngp); - ff.resize(ngp); - for (size_t k = 0; k < ngp; ++k) - { - Eigen::Vector3d const &ksi = gauss.getP(k); - sf.evalD(ksi, dff[k]); - sf.eval(ksi, ff[k]); - } -} - -Gauss &CacheTetra4::getVGauss() -{ - return gauss; -} diff --git a/tbox/src/wCacheTetra4.h b/tbox/src/wCacheTetra4.h deleted file mode 100644 index 4d1062ff..00000000 --- a/tbox/src/wCacheTetra4.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WCACHETETRA4_H -#define WCACHETETRA4_H - -#include "tbox.h" -#include "wCache.h" -#include "wSfTetra4.h" -#include "wGaussTetra4.h" -#include <vector> - -namespace tbox -{ - -/** - * @brief Cache handling Tetra4 shape functions and gauss points - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API CacheTetra4 : public Cache -{ -public: - SfTetra4 sf; - GaussTetra4 gauss; - - explicit CacheTetra4(int _n = 2); - - virtual Gauss &getVGauss() override; -}; - -} // namespace tbox - -#endif //WCACHETETRA4_H diff --git a/tbox/src/wCacheTri3.cpp b/tbox/src/wCacheTri3.cpp deleted file mode 100644 index fd638428..00000000 --- a/tbox/src/wCacheTri3.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wCacheTri3.h" - -using namespace tbox; - -CacheTri3::CacheTri3(int _n) : Cache(_n), gauss(_n) -{ - // get number of gauss points - size_t ngp = gauss.getN(); - - // pre-compute dff and ff - dff.resize(ngp); - ff.resize(ngp); - for (size_t k = 0; k < ngp; ++k) - { - Eigen::Vector3d const &ksi = gauss.getP(k); - sf.evalD(ksi, dff[k]); - sf.eval(ksi, ff[k]); - } -} - -Gauss &CacheTri3::getVGauss() -{ - return gauss; -} \ No newline at end of file diff --git a/tbox/src/wCacheTri3.h b/tbox/src/wCacheTri3.h deleted file mode 100644 index c7491eb7..00000000 --- a/tbox/src/wCacheTri3.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WCACHETRI3_H -#define WCACHETRI3_H - -#include "tbox.h" -#include "wCache.h" -#include "wSfTri3.h" -#include "wGaussTri3.h" -#include <vector> - -namespace tbox -{ - -/** - * @brief Cache handling Tri3 shape functions and gauss points - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API CacheTri3 : public Cache -{ -public: - SfTri3 sf; - GaussTri3 gauss; - - explicit CacheTri3(int _n = 2); - - virtual Gauss &getVGauss() override; -}; - -} // namespace tbox - -#endif //WCACHETRI3_H diff --git a/tbox/src/wElement.cpp b/tbox/src/wElement.cpp deleted file mode 100644 index f2755ff8..00000000 --- a/tbox/src/wElement.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wElement.h" -#include "wNode.h" -#include "wTag.h" -#include "wCache.h" -#include "std_extra.h" - -using namespace tbox; - -namespace tbox -{ - -TBOX_API std::ostream & -operator<<(std::ostream &out, ELTYPE const &obj) -{ - switch (obj) - { - case ELTYPE::LINE2: - out << "LINE2"; - break; - case ELTYPE::TRI3: - out << "TRI3"; - break; - case ELTYPE::QUAD4: - out << "QUAD4"; - break; - case ELTYPE::TETRA4: - out << "TETRA4"; - break; - case ELTYPE::HEX8: - out << "HEX8"; - break; - case ELTYPE::POINT1: - out << "POINT1"; - break; - default: - out << "UNKNOWN-" << static_cast<int>(obj); - break; - } - return out; -} - -} // namespace tbox - -Element::Element(int n, Tag *_ptag, Tag *_etag, - std::vector<Tag *> &_parts, std::vector<Node *> &nods) - : wObject(), order(0), hasVals(false), hasGrads(false), isVol(false), - no(n), ptag(_ptag), etag(_etag), parts(_parts), nodes(nods) -{ - if (ptag) - ptag->elems.push_back(this); - if (etag) - etag->elems.push_back(this); - - for (auto p : parts) - p->elems.push_back(this); -} - -void Element::initValues(bool isvol, int ordr) -{ - throw std::runtime_error("Element::initValues() not implemented!\n"); -} -void Element::initGradients() -{ - throw std::runtime_error("Element::initGradients() not implemented!\n"); -} -void Element::update() -{ - throw std::runtime_error("Element::update() not implemented!\n"); -} - -/** - * @brief Check that determinant of Jacobian is positive - */ -void Element::checkJac(size_t k) const -{ - if (detJs[k] <= 0) - { - std::stringstream err; - err << "Negative jacobian detected for element: " << *this << "\n"; - throw std::runtime_error(err.str()); - } -} - -void Element::buildJ() -{ - throw std::runtime_error("Element::buildJ not implemented\n"); -} -void Element::buildSurfaceJ() -{ - throw std::runtime_error("Element::buildSurfaceJ not implemented\n"); -} -void Element::buildGradientJ() -{ - throw std::runtime_error("Element::buildGradientJ not implemented\n"); -} -void Element::buildGradientSurfaceJ() -{ - throw std::runtime_error("Element::buildGradientSurfaceJ not implemented\n"); -} - -void Element::computeV() -{ - throw std::runtime_error("Element::computeV not implemented\n"); -} -void Element::buildGradientV(int dim) -{ - throw std::runtime_error("Element::buildGradientV not implemented\n"); -} - -/** - * @brief Compute center of gravity of element - */ -void Element::computeCg() -{ - cg = Eigen::Vector3d::Zero(); - for (auto n : nodes) - cg += n->pos; - cg /= static_cast<double>(nodes.size()); -} - -std::vector<Eigen::Vector3d> Element::computeTangents() const -{ - throw std::runtime_error("Element::computeTangents not implemented\n"); -} -std::vector<Eigen::Vector3d> Element::buildTangents(size_t k) const -{ - throw std::runtime_error("Element::buildTangents not implemented\n"); -} - -void Element::computeNormal() -{ - throw std::runtime_error("Element::computeNormal not implemented\n"); -} -void Element::computeGradientNormal() -{ - throw std::runtime_error("Element::computeGradientNormal not implemented\n"); -} - -/** - * @brief Return the values extrapolated at all the element nodes - * based on the values at Gauss points - */ -Eigen::MatrixXd Element::gp2node(Eigen::MatrixXd &values_at_gp) const -{ - Cache &cache = getVCache(); - size_t ngp = cache.getVGauss().getN(); - - Eigen::MatrixXd A(ngp, nodes.size()); - for (size_t i = 0; i < ngp; ++i) - A.row(i) = cache.getSf(i).transpose(); - - return (A.transpose() * A).inverse() * A.transpose() * values_at_gp; // nodes.size() * 18 -} - -Eigen::VectorXd Element::computeGradient(std::vector<double> const &u, size_t k) const -{ - throw std::runtime_error("Element::computeGradient not implemented\n"); -} - -void Element::write(std::ostream &out) const -{ - out << type() << " #" << no << ":"; - - out << " nodes=[ "; - for (auto n : nodes) - out << "#" << n->no << ' '; - out << "]"; - - if (ptag) - out << " ptag #" << ptag->no; - if (etag) - out << " etag #" << etag->no; - if (!parts.empty()) - { - out << " parts=[ "; - for (auto p : parts) - out << "#" << p->no << ' '; - out << "]"; - } -} diff --git a/tbox/src/wElement.h b/tbox/src/wElement.h deleted file mode 100644 index 3c02267a..00000000 --- a/tbox/src/wElement.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WELEMENT_H -#define WELEMENT_H - -#include "tbox.h" -#include "wObject.h" -#include <vector> -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief element types (from gmsh) - * @authors Romain Boman - */ -enum class ELTYPE -{ - UNKNOWN = 0, - LINE2 = 1, - TRI3 = 2, - QUAD4 = 3, - TETRA4 = 4, - HEX8 = 5, - POINT1 = 15 -}; -#ifndef SWIG -TBOX_API std::ostream &operator<<(std::ostream &out, ELTYPE const &obj); -#endif - -/** - * @brief Base finite element class - * @authors Romain Boman, Kim Liegeois, Adrien Crovato - */ -class TBOX_API Element : public fwk::wObject -{ - friend class MshCrack; // so that MshCrack can access normal and cg before update -protected: - int order; ///< order of integration (Gauss quadrature) - // Flags - bool hasVals; ///< true if (precomputed) values have been initialized - bool hasGrads; ///< true if (precomputed) gradients have been initialized - bool isVol; ///< true if element is a volume element - // Jacobian - std::vector<double> detJs; ///< determinant of Jacobian matrix - std::vector<Eigen::MatrixXd> Js; ///< Jacobian matrix - std::vector<Eigen::MatrixXd> iJs; ///< inverse of Jacobian matrix - std::vector<std::vector<double>> gradDetJs; ///< gradient of Jacobian determinant wrt to nodes position - std::vector<std::vector<Eigen::MatrixXd>> gradJs; ///< gradient of Jacobian matrix wrt to nodes position - // Volume and CG - double vol; ///< element volume - Eigen::Vector3d cg; ///< element center of gravity - std::vector<double> gradVol; ///< gradient of volume wrt to nodes position - // Normal vectors - Eigen::Vector3d normal; ///< unit normal vector - std::vector<Eigen::Vector3d> gradNormal; ///< graident of unit normal vector wrt to nodes position - -public: - int no; ///< label - Tag *ptag; ///< physical tag (group) - Tag *etag; ///< elementary tag (geometry) - std::vector<Tag *> parts; ///< partitions - std::vector<Node *> nodes; ///< nodes - -#ifndef SWIG - Element(int n, Tag *_ptag, Tag *_etag, std::vector<Tag *> &_parts, std::vector<Node *> &nods); - virtual ~Element() {} -#endif - virtual ELTYPE type() const - { - return ELTYPE::UNKNOWN; - } - -#ifndef SWIG -protected: - // Jacobian - void checkJac(size_t k) const; - virtual void buildJ(); - virtual void buildSurfaceJ(); - virtual void buildGradientJ(); - virtual void buildGradientSurfaceJ(); - // CG and Volume - void computeCg(); - virtual void computeV(); - virtual void buildGradientV(int dim); - // Tangent and normal vectors - virtual std::vector<Eigen::Vector3d> computeTangents() const; - virtual std::vector<Eigen::Vector3d> buildTangents(size_t k) const; - virtual void computeNormal(); - virtual void computeGradientNormal(); - -public: - // Initialize and update precomputed values - virtual void initValues(bool isvol, int ordr = 2); - virtual void initGradients(); - virtual void update(); - // Getters - virtual Cache &getVCache() const = 0; - inline bool hasValues() const; - inline bool hasGradients() const; - inline double getDetJ(size_t k) const; - inline Eigen::MatrixXd const &getJ(size_t k) const; - inline Eigen::MatrixXd const &getJinv(size_t k) const; - inline std::vector<double> const &getGradDetJ(size_t k) const; - inline std::vector<Eigen::MatrixXd> const &getGradJ(size_t k) const; - inline double getVol() const; - inline Eigen::Vector3d const &getCg() const; - inline std::vector<double> const &getGradVol() const; - inline Eigen::Vector3d const &getNormal() const; - inline std::vector<Eigen::Vector3d> const &getGradNormal() const; - // Utilities - virtual Eigen::VectorXd computeGradient(std::vector<double> const &u, size_t k) const; - Eigen::MatrixXd gp2node(Eigen::MatrixXd &values_at_gp) const; - virtual void write(std::ostream &out) const override; -#endif -}; - -#include "wElement.inl" - -} // namespace tbox - -#endif //WELEMENT_H diff --git a/tbox/src/wElement.inl b/tbox/src/wElement.inl deleted file mode 100644 index 9bed1207..00000000 --- a/tbox/src/wElement.inl +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @brief Return wether the element values have been initialized or not - */ -inline bool Element::hasValues() const -{ - return hasVals; -} - -/** - * @brief Return wether the element gradients have been initialized or not - */ -inline bool Element::hasGradients() const -{ - return hasGrads; -} - -/** - * @brief Return the determinant of the Jacobian at Gauss point k - */ -inline double Element::getDetJ(size_t k) const -{ - if (hasVals) - return detJs[k]; - else - throw std::runtime_error("Element::getDetJ is invalid because element memory is not up-to-date!\n"); -} - -/** - * @brief Return the the Jacobian matrix at Gauss point k - */ -inline Eigen::MatrixXd const &Element::getJ(size_t k) const -{ - if (hasVals) - { - if (isVol) - return Js[k]; - else - throw std::runtime_error("Element::getJ Jacobian matrix is not available for surface element!\n"); - } - else - throw std::runtime_error("Element::getJ is invalid because element memory is not up-to-date!\n"); -} - -/** - * @brief Return the inverse of the Jacobian matrix at Gauss point k - */ -inline Eigen::MatrixXd const &Element::getJinv(size_t k) const -{ - if (hasVals) - { - if (isVol) - return iJs[k]; - else - throw std::runtime_error("Element::getJinv inverse Jacobian matrix is not available for surface element!\n"); - } - else - throw std::runtime_error("Element::getJinv is invalid because element memory is not up-to-date!\n"); -} - -/** - * @brief Return the volume of the element - */ -inline double Element::getVol() const -{ - if (hasVals) - return vol; - else - throw std::runtime_error("Mem::getVol is invalid because element memory is not up-to-date!\n"); -} - -/** - * @brief Return the center of gravity of the element - */ -inline Eigen::Vector3d const &Element::getCg() const -{ - if (hasVals) - return cg; - else - throw std::runtime_error("Element::getCg is invalid because element memory is not up-to-date!\n"); -} - -/** - * @brief Return the unit normal vector of the element - */ -inline Eigen::Vector3d const &Element::getNormal() const -{ - if (hasVals) - { - if (!isVol) - return normal; - else - throw std::runtime_error("Element::getNormal normal vector is not available for volume element!\n"); - } - else - throw std::runtime_error("Element::getNormal is invalid because element memory is not up-to-date!\n"); -} - -/** - * @brief Return the gradient of determinant of the Jacobian with respect to node positions at Gauss point k - */ -inline std::vector<double> const &Element::getGradDetJ(size_t k) const -{ - if (hasGrads) - return gradDetJs[k]; - else - throw std::runtime_error("Element::getGradDetJ is invalid because element memory (gradient) is not up-to-date!\n"); -} - -/** - * @brief Return the gradient of the Jacobian matrix with respect to node positions at Gauss point k - */ -inline std::vector<Eigen::MatrixXd> const &Element::getGradJ(size_t k) const -{ - if (hasGrads) - { - if (isVol) - return gradJs[k]; - else - throw std::runtime_error("Element::getGradJ gradient of Jacobian matrix is not available for surface element!\n"); - } - else - throw std::runtime_error("Element::getGradJ is invalid because element memory (gradient) is not up-to-date!\n"); -} - -/** - * @brief Return the gradient of the volume with respect to node positions - */ -inline std::vector<double> const &Element::getGradVol() const -{ - if (hasGrads) - return gradVol; - else - throw std::runtime_error("Element::getGradVol is invalid because element memory (gradient) is not up-to-date!\n"); -} - -/** - * @brief Return the gradient of the unit normal vector with respect to node positions - */ -inline std::vector<Eigen::Vector3d> const &Element::getGradNormal() const -{ - if (hasGrads) - { - if (!isVol) - return gradNormal; - else - throw std::runtime_error("Element::getGradNormal normal vector gradient is not available for volume element!\n"); - } - else - throw std::runtime_error("Element::getGradNormal is invalid because element memory (gradient) is not up-to-date!\n"); -} diff --git a/tbox/src/wFct0.cpp b/tbox/src/wFct0.cpp deleted file mode 100644 index 2f4618d3..00000000 --- a/tbox/src/wFct0.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wFct0.h" -#include "wElement.h" -#include "wNode.h" -#include "wCache.h" - -using namespace tbox; - -void PwLf::add(double x, double y) -{ - auto it = pts.find(x); - if (it != pts.end()) - { - std::ostringstream str; - str << "PwLf: value at " << x << " already exist!\n"; - throw std::runtime_error(str.str()); - } - pts[x] = y; -} - -double PwLf::eval(double x) const -{ - auto it1 = pts.begin(); - if (it1 == pts.end()) - throw std::runtime_error("PwLf is empty!"); - auto it2 = it1; - ++it2; - if (it2 == pts.end()) - return it1->second; //fct is a constant - auto it3 = it2; - ++it3; - - for (; it3 != pts.end(); ++it1, ++it2, ++it3) - if (x <= it2->first) - break; - - // eval using it1-it2 - double x1 = it1->first; - double y1 = it1->second; - double x2 = it2->first; - double y2 = it2->second; - return y1 + (y2 - y1) / (x2 - x1) * (x - x1); -} - -void PwLf::write(std::ostream &out) const -{ - out << "PwLf="; - for (auto &p : pts) - out << "\tx=" << p.first << " y=" << p.second << '\n'; -} - -//------------------------------------------------------------------------- - -void Fct0C::write(std::ostream &out) const -{ - out << "Fct0C=" << v; -} - -//------------------------------------------------------------------------- - -double -Fct0XYZ::eval(Element const &e, std::vector<double> const &u, size_t k) const -{ - Cache &cache = e.getVCache(); - Eigen::VectorXd const &ff = cache.getSf(k); - - // position pg en x,y - Eigen::Vector3d xpg(0, 0, 0); - for (size_t i = 0; i < e.nodes.size(); ++i) - xpg += ff(i) * e.nodes[i]->pos; - - return this->eval(xpg); -} - -void Fct0XYZ::write(std::ostream &out) const -{ - out << "Fct0XYZ"; -} - -//------------------------------------------------------------------------- - -double -Fct0U::eval(Element const &e, std::vector<double> const &u, size_t k) const -{ - Cache &cache = e.getVCache(); - Eigen::VectorXd const &ff = cache.getSf(k); - - // u au pg - double upg = 0.0; - for (size_t i = 0; i < e.nodes.size(); ++i) - upg += ff(i) * u[e.nodes[i]->row]; - - return this->eval(upg); -} - -void Fct0U::write(std::ostream &out) const -{ - out << "Fct0U"; -} diff --git a/tbox/src/wFct0.h b/tbox/src/wFct0.h deleted file mode 100644 index 591b6d51..00000000 --- a/tbox/src/wFct0.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WFCT0_H -#define WFCT0_H - -#include "tbox.h" -#include "wObject.h" -#include <vector> -#include <map> -#include <Eigen/Dense> - -namespace tbox -{ - -class TBOX_API PwLf : public fwk::wSharedObject -{ - std::map<double, double> pts; - -public: - PwLf() : wSharedObject() {} - void add(double x, double y); - double eval(double x) const; -#ifndef SWIG - virtual void write(std::ostream &out) const override; -#endif -}; - -/** - * @brief Scalar functions to be integrated over an element - * - * eval() evaluates the function at kth Gauss point - * @authors Romain Boman - */ -class TBOX_API Fct0 : public fwk::wSharedObject -{ -public: -#ifndef SWIG - Fct0() : wSharedObject() - { - } -#endif - virtual ~Fct0() - { - } - -#ifndef SWIG - virtual double eval(Element const &e, - std::vector<double> const &u, - size_t k) const = 0; -#endif -}; - -/** - * @brief Constant function - * @authors Romain Boman - */ -class TBOX_API Fct0C : public Fct0 -{ - double v; - -public: - Fct0C(double _v) : Fct0(), v(_v) {} - -#ifndef SWIG - virtual double eval(Element const &e, - std::vector<double> const &u, - size_t k) const override - { - return v; - } - virtual void write(std::ostream &out) const override; -#endif -}; - -/** - * @brief Function depending on position - * @authors Romain Boman - */ -class TBOX_API Fct0XYZ : public Fct0 -{ -public: - virtual double eval(Eigen::Vector3d const &pos) const = 0; - -#ifndef SWIG - virtual double eval(Element const &e, - std::vector<double> const &u, - size_t k) const override; - virtual void write(std::ostream &out) const override; -#endif -}; - -/** - * @brief function depending on element - * @authors Romain Boman - */ -class TBOX_API Fct0U : public Fct0 -{ -public: - virtual double eval(double u) const = 0; - -#ifndef SWIG - virtual double eval(Element const &e, - std::vector<double> const &u, - size_t k) const override; - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace tbox - -#endif //WFCT0_H diff --git a/tbox/src/wFct1.cpp b/tbox/src/wFct1.cpp deleted file mode 100644 index 5d90ba81..00000000 --- a/tbox/src/wFct1.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wFct1.h" - -using namespace tbox; - -void Fct1C::write(std::ostream &out) const -{ - out << "Fct1C = " << v; -} diff --git a/tbox/src/wFct1.h b/tbox/src/wFct1.h deleted file mode 100644 index f82320d1..00000000 --- a/tbox/src/wFct1.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WFCT1_H -#define WFCT1_H - -#include "tbox.h" -#include "wObject.h" -#include <vector> -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Vector functions to be integrated over an element - * - * eval() evaluates the function at kth Gauss point - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API Fct1 : public fwk::wSharedObject -{ -public: -#ifndef SWIG - Fct1() : wSharedObject() - { - } -#endif - virtual ~Fct1() - { - } - -#ifndef SWIG - virtual Eigen::Vector3d eval(Element const &e, - std::vector<double> const &u, - size_t k) const = 0; -#endif -}; - -/** - * @brief Constant function - * @authors Adrien Crovato - */ -class TBOX_API Fct1C : public Fct1 -{ - Eigen::Vector3d v; - -public: - Fct1C(double _v0, double _v1, double _v2) : Fct1() - { - v(0) = _v0; - v(1) = _v1; - v(2) = _v2; - } - -#ifndef SWIG - virtual Eigen::Vector3d eval(Element const &e, - std::vector<double> const &u, - size_t k) const override - { - return v; - } - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace tbox - -#endif //WFCT1_H diff --git a/tbox/src/wFct2.cpp b/tbox/src/wFct2.cpp deleted file mode 100644 index 9abe21bc..00000000 --- a/tbox/src/wFct2.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wFct2.h" -#include "wFct0.h" -#include "wElement.h" -#include "wNode.h" -#include "wCache.h" -#include <Eigen/Dense> - -using namespace tbox; - -Fct2C::Fct2C(double _v11, double _v22, double _v12) : Fct2() -{ - v(0, 0) = _v11; - v(1, 1) = _v22; - v(1, 0) = _v12; - v(0, 1) = _v12; - - double det = v.determinant(); - if (det <= 0.0) - throw std::runtime_error("det(Fct2C)<0!"); -} - -void Fct2C::eval(Element const &e, - std::vector<double> const &u, - size_t k, Eigen::MatrixXd &out, bool fake) const -{ - out = v; // Eigen resizes automatically -} - -void Fct2C::write(std::ostream &out) const -{ - out << "Fct2C=" << v; -} - -//------------------------------------------------------------------------- - -void Fct2XYZ::eval(Element const &e, - std::vector<double> const &u, - size_t k, Eigen::MatrixXd &out, bool fake) const -{ - Cache &cache = e.getVCache(); - Eigen::VectorXd const &ff = cache.getSf(k); - - // position pg en x,y - Eigen::Vector3d xpg(0, 0, 0); - for (size_t i = 0; i < e.nodes.size(); ++i) - xpg += ff(i) * e.nodes[i]->pos; - - this->eval(xpg, out, fake); -} - -void Fct2XYZ::write(std::ostream &out) const -{ - out << "Fct2XYZ"; -} - -//------------------------------------------------------------------------- - -void Fct2U::eval(Element const &e, - std::vector<double> const &u, - size_t k, Eigen::MatrixXd &out, bool fake) const -{ - Cache &cache = e.getVCache(); - Eigen::VectorXd const &ff = cache.getSf(k); - - // u au pg - double upg = 0.0; - for (size_t i = 0; i < e.nodes.size(); ++i) - upg += ff(i) * u[e.nodes[i]->row]; - - this->eval(upg, out, fake); -} - -void Fct2U::write(std::ostream &out) const -{ - out << "Fct2U"; -} - -//------------------------------------------------------------------------- - -void Fct2UdU::eval(Element const &e, - std::vector<double> const &u, - size_t k, Eigen::MatrixXd &out, bool fake) const -{ - Cache &cache = e.getVCache(); - Eigen::VectorXd const &ff = cache.getSf(k); - - // u au pg => upg - double upg = 0.0; - for (size_t i = 0; i < e.nodes.size(); ++i) - upg += ff(i) * u[e.nodes[i]->row]; - - //gradU au pg => gradupg - Eigen::VectorXd gradupg = e.computeGradient(u, k); - - this->eval(e, k, upg, gradupg, out, fake); -} - -void Fct2UdU::write(std::ostream &out) const -{ - out << "Fct2UdU"; -} - -//------------------------------------------------------------------------- - -void Fct2PwLf::eval(double u, Eigen::MatrixXd &v, bool fake) const -{ - v.resize(2, 2); - v(0, 0) = v11->eval(u); - v(1, 1) = v22->eval(u); - v(1, 0) = v(0, 1) = v12->eval(u); -} - -void Fct2PwLf::write(std::ostream &out) const -{ - out << "Fct2PwLf"; -} diff --git a/tbox/src/wFct2.h b/tbox/src/wFct2.h deleted file mode 100644 index ed200d74..00000000 --- a/tbox/src/wFct2.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WFCT2_H -#define WFCT2_H - -#include "tbox.h" -#include "wObject.h" -#include <memory> -#include <vector> -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Matrix functions to be integrated over an element - * - * eval() evaluates the function at kth Gauss point - * @authors Romain Boman - */ -class TBOX_API Fct2 : public fwk::wSharedObject -{ -public: -#ifndef SWIG - Fct2() : wSharedObject() - { - } -#endif - virtual ~Fct2() - { - } - - virtual void evalall() {} -#ifndef SWIG - virtual void eval(Element const &e, - std::vector<double> const &u, - size_t k, Eigen::MatrixXd &out, bool fake) const = 0; -#endif -}; - -/** - * @brief matrix function M = Cte - */ -class TBOX_API Fct2C : public Fct2 -{ - Eigen::Matrix2d v; - -public: - Fct2C(double _v11, double _v22, double _v12); - -#ifndef SWIG - virtual void eval(Element const &e, - std::vector<double> const &u, - size_t k, Eigen::MatrixXd &out, bool fake) const override; - virtual void write(std::ostream &out) const override; -#endif -}; - -/** - * @brief matrix function M = fct(x,y,z) - */ -class TBOX_API Fct2XYZ : public Fct2 -{ -public: - virtual void eval(Eigen::Vector3d const &pos, Eigen::MatrixXd &v, bool fake) const = 0; - -#ifndef SWIG - virtual void eval(Element const &e, - std::vector<double> const &u, - size_t k, Eigen::MatrixXd &out, bool fake) const override; - virtual void write(std::ostream &out) const override; -#endif -}; - -/** - * @brief matrix function M = fct(u) - */ -class TBOX_API Fct2U : public Fct2 -{ -public: - virtual void eval(double u, Eigen::MatrixXd &v, bool fake) const = 0; - -#ifndef SWIG - virtual void eval(Element const &e, - std::vector<double> const &u, - size_t k, Eigen::MatrixXd &out, bool fake) const override; - virtual void write(std::ostream &out) const override; -#endif -}; -/** - * @brief matrix function M = fct(u, gradU) - */ -class TBOX_API Fct2UdU : public Fct2 -{ -public: - virtual void eval(Element const &e, size_t k, double u, Eigen::VectorXd const &gradu, - Eigen::MatrixXd &v, bool fake) const = 0; -#ifndef SWIG - virtual void eval(Element const &e, - std::vector<double> const &u, - size_t k, Eigen::MatrixXd &out, bool fake) const override; - virtual void write(std::ostream &out) const override; -#endif -}; - -/** - * @brief matrix function M = fct(u) - */ -class TBOX_API Fct2PwLf : public Fct2U -{ - std::shared_ptr<PwLf> v11; - std::shared_ptr<PwLf> v22; - std::shared_ptr<PwLf> v12; - -public: - Fct2PwLf(std::shared_ptr<PwLf> _v11, std::shared_ptr<PwLf> _v22, std::shared_ptr<PwLf> _v12) : Fct2U(), v11(_v11), v22(_v22), v12(_v12) {} - - virtual void eval(double u, Eigen::MatrixXd &v, bool fake) const override; - -#ifndef SWIG - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace tbox - -#endif //WFCT2_H diff --git a/tbox/src/wGauss.cpp b/tbox/src/wGauss.cpp deleted file mode 100644 index 3bcadf2d..00000000 --- a/tbox/src/wGauss.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGauss.h" - -using namespace tbox; - -Gauss::Gauss() : p(0), w(0) -{ -} diff --git a/tbox/src/wGauss.h b/tbox/src/wGauss.h deleted file mode 100644 index 02409ad6..00000000 --- a/tbox/src/wGauss.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGAUSS_H -#define WGAUSS_H - -#include "tbox.h" -#include <vector> -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Base class for Gauss points - * @authors Adrien Crovato, Romain Boman, Kim Liegeois - */ -class TBOX_API Gauss -{ -protected: - size_t ngp; ///< number of Gauss points - std::vector<Eigen::Vector3d> p; ///< positions - std::vector<double> w; ///< weights - -public: - explicit Gauss(); - virtual ~Gauss() {} - - inline size_t getN(); - inline Eigen::Vector3d const &getP(size_t k); - inline double getW(size_t k); -}; - -#include "wGauss.inl" - -} // namespace tbox - -#endif //WGAUSS_H diff --git a/tbox/src/wGauss.inl b/tbox/src/wGauss.inl deleted file mode 100644 index 06fd2ce5..00000000 --- a/tbox/src/wGauss.inl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @brief Return the number of Gauss points - */ -inline size_t Gauss::getN() -{ - return ngp; -} - -/** - * @brief Return the position in local coordinates of Gauss point k - */ -inline Eigen::Vector3d const &Gauss::getP(size_t k) -{ - return p[k]; -} - -/** - * @brief Return the weight of Gauss point k - */ -inline double Gauss::getW(size_t k) -{ - return w[k]; -} diff --git a/tbox/src/wGaussHex8.cpp b/tbox/src/wGaussHex8.cpp deleted file mode 100644 index 226e1953..00000000 --- a/tbox/src/wGaussHex8.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGaussHex8.h" -#include "wGaussLine2.h" -#include <stdexcept> -#include <cmath> - -using namespace tbox; - -GaussHex8::GaussHex8(int n) : Gauss() -{ - GaussLine2 g(n); - - ngp = n * n * n; - for (int i = 0; i < n; ++i) - for (int j = 0; j < n; ++j) - for (int k = 0; k < n; ++k) - { - p.push_back(Eigen::Vector3d(g.getP(i)(0), g.getP(j)(0), g.getP(k)(0))); - w.push_back(g.getW(i) * g.getW(j) * g.getW(k)); - } -} diff --git a/tbox/src/wGaussHex8.h b/tbox/src/wGaussHex8.h deleted file mode 100644 index 7208fca1..00000000 --- a/tbox/src/wGaussHex8.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGAUSSHEX8_H -#define WGAUSSHEX8_H - -#include "tbox.h" -#include "wGauss.h" - -namespace tbox -{ - -/** - * @brief Gauss points for Hex8 - * @authors Adrien Crovato, Romain Boman, Kim Liegeois - */ -class TBOX_API GaussHex8 : public Gauss -{ -public: - explicit GaussHex8(int n); -}; - -} // namespace tbox - -#endif //WGAUSSHEX8_H diff --git a/tbox/src/wGaussLine2.cpp b/tbox/src/wGaussLine2.cpp deleted file mode 100644 index fff3f28a..00000000 --- a/tbox/src/wGaussLine2.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGaussLine2.h" -#include <stdexcept> -#include <cmath> - -using namespace tbox; - -GaussLine2::GaussLine2(int n) : Gauss() -{ - p.resize(n); - w.resize(n); - ngp = n; - switch (n) - { - case 1: - p[0] = Eigen::Vector3d(0.0, 0.0, 0.0); - w[0] = 2.; - break; - case 2: - p[0] = Eigen::Vector3d(-1.0 / sqrt(3.0), 0.0, 0.0); - w[0] = 1.; - p[1] = Eigen::Vector3d(+1.0 / sqrt(3.0), 0.0, 0.0); - w[1] = 1.; - break; - case 3: - p[0] = Eigen::Vector3d(-sqrt(3.0 / 5.0), 0.0, 0.0); - w[0] = 5. / 9.; - p[1] = Eigen::Vector3d(0.0, 0.0, 0.0); - w[1] = 8. / 9.; - p[2] = Eigen::Vector3d(+sqrt(3.0 / 5.0), 0.0, 0.0); - w[2] = 5. / 9.; - break; - default: - throw std::runtime_error("not implemented (GaussLine2)!"); - } -} diff --git a/tbox/src/wGaussLine2.h b/tbox/src/wGaussLine2.h deleted file mode 100644 index f836fbad..00000000 --- a/tbox/src/wGaussLine2.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGAUSSLINE2_H -#define WGAUSSLINE2_H - -#include "tbox.h" -#include "wGauss.h" - -namespace tbox -{ - -/** - * @brief Gauss points for Line2 - * @authors Adrien Crovato, Romain Boman, Kim Liegeois - */ -class TBOX_API GaussLine2 : public Gauss -{ -public: - explicit GaussLine2(int n); -}; - -} // namespace tbox - -#endif //WGAUSSLINE2_H diff --git a/tbox/src/wGaussQuad4.cpp b/tbox/src/wGaussQuad4.cpp deleted file mode 100644 index b9b46e78..00000000 --- a/tbox/src/wGaussQuad4.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGaussQuad4.h" -#include "wGaussLine2.h" -#include <stdexcept> -#include <cmath> - -using namespace tbox; - -GaussQuad4::GaussQuad4(int n) : Gauss() -{ - GaussLine2 g(n); - - ngp = n * n; - for (int i = 0; i < n; ++i) - for (int j = 0; j < n; ++j) - { - p.push_back(Eigen::Vector3d(g.getP(i)(0), g.getP(j)(0), 0.0)); - w.push_back(g.getW(i) * g.getW(j)); - } -} diff --git a/tbox/src/wGaussQuad4.h b/tbox/src/wGaussQuad4.h deleted file mode 100644 index e2a5c858..00000000 --- a/tbox/src/wGaussQuad4.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGAUSSQUAD4_H -#define WGAUSSQUAD4_H - -#include "tbox.h" -#include "wGauss.h" - -namespace tbox -{ - -/** - * @brief Gauss points for Quad4 - * @authors Adrien Crovato, Romain Boman, Kim Liegeois - */ -class TBOX_API GaussQuad4 : public Gauss -{ -public: - explicit GaussQuad4(int n); -}; - -} // namespace tbox - -#endif //WGAUSSQUAD4_H diff --git a/tbox/src/wGaussTetra4.cpp b/tbox/src/wGaussTetra4.cpp deleted file mode 100644 index 0e1a4e35..00000000 --- a/tbox/src/wGaussTetra4.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGaussTetra4.h" -#include <stdexcept> -#include <cmath> - -using namespace tbox; - -GaussTetra4::GaussTetra4(int n) : Gauss() -{ - switch (n) - { - case 1: - { - p.resize(1); - w.resize(1); - ngp = 1; - p[0] = Eigen::Vector3d(0.25, 0.25, 0.25); - w[0] = 1. / 6.; - break; - } - case 2: - { - p.resize(4); - w.resize(4); // 4 pts ! - ngp = 4; - double a = (5. - sqrt(5.)) / 20.; - double b = (5. + 3. * sqrt(5.)) / 20.; - p[0] = Eigen::Vector3d(a, a, a); - w[0] = 1. / 4. / 6.; - p[1] = Eigen::Vector3d(a, a, b); - w[1] = 1. / 4. / 6.; - p[2] = Eigen::Vector3d(a, b, a); - w[2] = 1. / 4. / 6.; - p[3] = Eigen::Vector3d(b, a, a); - w[3] = 1. / 4. / 6.; - break; - } - default: - throw std::runtime_error("not implemented (GaussTetra4)!"); - } -} diff --git a/tbox/src/wGaussTetra4.h b/tbox/src/wGaussTetra4.h deleted file mode 100644 index abc4daed..00000000 --- a/tbox/src/wGaussTetra4.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGAUSSTETRA4_H -#define WGAUSSTETRA4_H - -#include "tbox.h" -#include "wGauss.h" - -namespace tbox -{ - -/** - * @brief Gauss points for Tetra4 - * @authors Adrien Crovato, Romain Boman, Kim Liegeois - */ -class TBOX_API GaussTetra4 : public Gauss -{ -public: - explicit GaussTetra4(int n); // n is the degree (ngp can be higher!) -}; - -} // namespace tbox - -#endif //WGAUSSTETRA4_H diff --git a/tbox/src/wGaussTri3.cpp b/tbox/src/wGaussTri3.cpp deleted file mode 100644 index 39be394b..00000000 --- a/tbox/src/wGaussTri3.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGaussTri3.h" -#include <stdexcept> -#include <cmath> - -using namespace tbox; - -GaussTri3::GaussTri3(int n) : Gauss() -{ - switch (n) - { - case 1: - p.resize(1); - w.resize(1); - ngp = 1; - p[0] = Eigen::Vector3d(1. / 3, 1. / 3, 0.0); - w[0] = 1. / 2.; // ! sum=1/2 - break; - case 2: - p.resize(3); - w.resize(3); // 3 pts ! - ngp = 3; - p[0] = Eigen::Vector3d(1. / 6, 1. / 6, 0.0); - w[0] = 1. / 3. / 2.; - p[1] = Eigen::Vector3d(2. / 3, 1. / 6, 0.0); - w[1] = 1. / 3. / 2.; - p[2] = Eigen::Vector3d(1. / 6, 2. / 3, 0.0); - w[2] = 1. / 3. / 2.; - break; - case 3: - p.resize(4); - w.resize(4); - ngp = 4; - p[0] = Eigen::Vector3d(1. / 3, 1. / 3, 0.0); - w[0] = -27. / 48. / 2.; - p[1] = Eigen::Vector3d(1. / 5, 3. / 5, 0.0); - w[1] = 25. / 48. / 2.; - p[2] = Eigen::Vector3d(1. / 5, 1. / 5, 0.0); - w[2] = 25. / 48. / 2.; - p[3] = Eigen::Vector3d(3. / 5, 1. / 5, 0.0); - w[3] = 25. / 48. / 2.; - break; - default: - throw std::runtime_error("not implemented (GaussTri3)!"); - } -} diff --git a/tbox/src/wGaussTri3.h b/tbox/src/wGaussTri3.h deleted file mode 100644 index ee8291cc..00000000 --- a/tbox/src/wGaussTri3.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGAUSSTRI3_H -#define WGAUSSTRI3_H - -#include "tbox.h" -#include "wGauss.h" - -namespace tbox -{ - -/** - * @brief Gauss points for Tri3 - * @authors Adrien Crovato, Romain Boman, Kim Liegeois - */ -class TBOX_API GaussTri3 : public Gauss -{ -public: - explicit GaussTri3(int n); // n is the degree (ngp can be higher!) -}; - -} // namespace tbox - -#endif //WGAUSSTRI3_H diff --git a/tbox/src/wGmres.cpp b/tbox/src/wGmres.cpp deleted file mode 100644 index b708c6e5..00000000 --- a/tbox/src/wGmres.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGmres.h" -using namespace tbox; - -Gmres::Gmres() : LinearSolver() -{ - // set the preconditioner and solver parameters to "good" starting values - solver.preconditioner().setFillfactor(1); - solver.preconditioner().setDroptol(1e-6); - solver.set_restart(50); - solver.setTolerance(1e-8); - solver.setMaxIterations(1000); -} - -void Gmres::analyze(Eigen::SparseMatrix<double> const &A) -{ - solver.analyzePattern(A); -} -void Gmres::factorize(Eigen::SparseMatrix<double> const &A) -{ - solver.factorize(A); -} -void Gmres::solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - x = solver.solve(b); -} -void Gmres::compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - solver.compute(A); - x = solver.solve(b); -} - -void Gmres::write(std::ostream &out) const -{ - out << "GMRES (Eigen)" << std::endl; -} diff --git a/tbox/src/wGmres.h b/tbox/src/wGmres.h deleted file mode 100644 index b0a4a44c..00000000 --- a/tbox/src/wGmres.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGMRES_H -#define WGMRES_H - -#include "tbox.h" -#include "wLinearSolver.h" -#include <unsupported/Eigen/IterativeSolvers> - -namespace tbox -{ - -/** - * @brief GMRES interface - * @authors Adrien Crovato - */ -class TBOX_API Gmres : public LinearSolver -{ - Eigen::GMRES<Eigen::SparseMatrix<double>, Eigen::IncompleteLUT<double>> solver; - -public: - Gmres(); - virtual ~Gmres() {} - -#ifndef SWIG - virtual void analyze(Eigen::SparseMatrix<double> const &A) override; - virtual void factorize(Eigen::SparseMatrix<double> const &A) override; - virtual void solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) override; - virtual void compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) override; - - virtual double getError() override { return solver.error(); } - virtual int getIterations() override { return solver.iterations(); } - - virtual void write(std::ostream &out) const override; -#endif - - void setFillFactor(int f) - { - solver.preconditioner().setFillfactor(f); - } - void setDropTol(double t) { solver.preconditioner().setDroptol(t); } - void setTolerance(double t) { solver.setTolerance(t); } - void setRestart(int r) { solver.set_restart(r); } - void setMaxIterations(int n) { solver.setMaxIterations(n); } -}; - -} // namespace tbox - -#endif // WGMRES_H diff --git a/tbox/src/wGmshExport.cpp b/tbox/src/wGmshExport.cpp deleted file mode 100644 index 6487d0db..00000000 --- a/tbox/src/wGmshExport.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGmshExport.h" -#include "wTag.h" -#include "wElement.h" -#include "wNode.h" -#include "wResults.h" - -using namespace tbox; - -GmshExport::GmshExport(std::shared_ptr<MshData> _msh) : MshExport(_msh) -{ -} - -GmshExport::~GmshExport() -{ - std::cout << "~GmshExport()\n"; -} - -/** - * @brief Save the mesh on disk - */ -void GmshExport::save(std::string const &fname) const -{ - std::string wname = fname + ".msh"; - std::cout << "writing file: " << wname << "... " << std::flush; - - // write gmsh .msh file with stdio commands - FILE *file = fopen(wname.c_str(), "wt"); - if (!file) - throw std::runtime_error("Error opening file (save)"); - - // write format - fprintf(file, "$MeshFormat\n"); - fprintf(file, "2.2 %d %d\n", 0, 8); - fprintf(file, "$EndMeshFormat\n"); - - // write physical names - fprintf(file, "$PhysicalNames\n"); - std::vector<Tag *> named; - for (auto &p : msh->ptags) - if (p.second->name != Tag::defaultName()) - named.push_back(p.second); - fprintf(file, "%lu\n", static_cast<unsigned long>(named.size())); - for (auto t : named) - fprintf(file, "%d %d \"%s\"\n", t->dim, t->no, t->name.c_str()); - fprintf(file, "$EndPhysicalNames\n"); - - // nodes - fprintf(file, "$Nodes\n"); - fprintf(file, "%lu\n", static_cast<unsigned long>(msh->nodes.size())); - for (auto n : msh->nodes) - fprintf(file, "%d %.16g %.16g %.16g\n", n->no, n->pos(0), n->pos(1), n->pos(2)); - fprintf(file, "$EndNodes\n"); - - // elements - fprintf(file, "$Elements\n"); - fprintf(file, "%lu\n", static_cast<unsigned long>(msh->elems.size())); - for (auto e : msh->elems) - { - size_t ntag = 2; - if (!e->parts.empty()) - ntag += 1 + e->parts.size(); - fprintf(file, "%d %d %lu", e->no, static_cast<int>(e->type()), static_cast<unsigned long>(ntag)); - if (e->ptag) - fprintf(file, " %d", e->ptag->no); - else - fprintf(file, " 0"); - if (e->etag) - fprintf(file, " %d", e->etag->no); - else - fprintf(file, " 0"); - if (!e->parts.empty()) - { - fprintf(file, " %lu", static_cast<unsigned long>(e->parts.size())); - for (auto p : e->parts) - fprintf(file, " %d", p->no); - } - for (auto n : e->nodes) - fprintf(file, " %d", n->no); - fprintf(file, "\n"); - } - fprintf(file, "$EndElements\n"); - - // close file - fclose(file); - std::cout << "done" << std::endl; -} - -/** - * @brief Save results (associated to a mesh) on disk - */ -void GmshExport::save(std::string const &fname, Results const &r) const -{ - std::string wname = fname + ".pos"; - std::cout << "writing file: " << wname << "... " << std::flush; - - FILE *file; - if (binary) - file = fopen(wname.c_str(), "wb"); - else - file = fopen(wname.c_str(), "wt"); - if (!file) - throw std::runtime_error("Error opening file (save)"); - - // write format - fprintf(file, "$MeshFormat\n"); - fprintf(file, "2.2 %d %d\n", binary ? 1 : 0, 8); - if (binary) - { - int one = 1; - fwrite(&one, sizeof(int), 1, file); - } - fprintf(file, "$EndMeshFormat\n"); - - // node data: scalars_at_nodes - for (auto &p : r.scalars_at_nodes) - { - fprintf(file, "$NodeData\n"); - fprintf(file, "%d\n", 1); // nb of string tags - fprintf(file, "\"%s\"\n", p.first.c_str()); // the name of the view - fprintf(file, "%d\n", 1); // nb of real tags (1) - fprintf(file, "%.16g\n", r.time); // 1. the time value - fprintf(file, "%d\n", 3); // nb of integer tags (3) - fprintf(file, "%d\n", r.nt); // 1. time step index - fprintf(file, "%d\n", 1); // 2. nb of field component (1, 3 or 9) - fprintf(file, "%lu\n", static_cast<unsigned long>(msh->nodes.size())); // 3. nb of entities in the view - for (size_t ii = 0; ii < msh->nodes.size(); ++ii) - { - if (binary) - { - fwrite(&(msh->nodes[ii]->no), sizeof(int), 1, file); - fwrite(&((*(p.second))[ii]), sizeof(double), 1, file); - } - else - fprintf(file, "%d %.16g\n", msh->nodes[ii]->no, (*(p.second))[ii]); - } - fprintf(file, "$EndNodeData\n"); - } - - // element data: scalars_at_elems - for (auto &p : r.scalars_at_elems) - { - fprintf(file, "$ElementData\n"); - fprintf(file, "%d\n", 1); // nb of string tags - fprintf(file, "\"%s\"\n", p.first.c_str()); // the name of the view - fprintf(file, "%d\n", 1); // nb of real tags (1) - fprintf(file, "%.16g\n", r.time); // 1. the time value - fprintf(file, "%d\n", 3); // nb of integer tags (3) - fprintf(file, "%d\n", r.nt); // 1. time step index - fprintf(file, "%d\n", 1); // 2. nb of field component (1, 3 or 9) - fprintf(file, "%lu\n", static_cast<unsigned long>(msh->elems.size())); // 3. nb of entities in the view - for (size_t ii = 0; ii < msh->elems.size(); ++ii) - { - if (binary) - { - fwrite(&msh->elems[ii]->no, sizeof(int), 1, file); - fwrite(&(*(p.second))[ii], sizeof(double), 1, file); - } - else - fprintf(file, "%d %.16g\n", msh->elems[ii]->no, (*(p.second))[ii]); - } - fprintf(file, "$EndElementData\n"); - } - - // node data: vectors_at_nodes - for (auto &p : r.vectors_at_nodes) - { - fprintf(file, "$NodeData\n"); - fprintf(file, "%d\n", 1); // nb of string tags - fprintf(file, "\"%s\"\n", p.first.c_str()); // the name of the view - fprintf(file, "%d\n", 1); // nb of real tags (1) - fprintf(file, "%.16g\n", r.time); // 1. the time value - fprintf(file, "%d\n", 3); // nb of integer tags (3) - fprintf(file, "%d\n", r.nt); // 1. time step index - fprintf(file, "%d\n", 3); // 2. nb of field component (1, 3 or 9) - fprintf(file, "%lu\n", static_cast<unsigned long>(msh->nodes.size())); // 3. nb of entities in the view - for (size_t ii = 0; ii < msh->nodes.size(); ++ii) - { - Eigen::Vector3d const &v = (*(p.second))[ii]; - if (binary) - { - fwrite(&msh->nodes[ii]->no, sizeof(int), 1, file); - fwrite(&(v(0)), sizeof(double), 3, file); - } - else - fprintf(file, "%d %.16g %.16g %.16g\n", msh->nodes[ii]->no, v(0), v(1), v(2)); - } - fprintf(file, "$EndNodeData\n"); - } - - // element data: vectors_at_elems - for (auto &p : r.vectors_at_elems) - { - fprintf(file, "$ElementData\n"); - fprintf(file, "%d\n", 1); // nb of string tags - fprintf(file, "\"%s\"\n", p.first.c_str()); // the name of the view - fprintf(file, "%d\n", 1); // nb of real tags (1) - fprintf(file, "%.16g\n", r.time); // 1. the time value - fprintf(file, "%d\n", 3); // nb of integer tags (3) - fprintf(file, "%d\n", r.nt); // 1. time step index - fprintf(file, "%d\n", 3); // 2. nb of field component (1, 3 or 9) - fprintf(file, "%lu\n", static_cast<unsigned long>(msh->elems.size())); // 3. nb of entities in the view - for (size_t ii = 0; ii < msh->elems.size(); ++ii) - { - Eigen::Vector3d const &v = (*(p.second))[ii]; - if (binary) - { - fwrite(&(msh->elems[ii]->no), sizeof(int), 1, file); - fwrite(&(v(0)), sizeof(double), 3, file); - } - else - fprintf(file, "%d %.16g %.16g %.16g\n", msh->elems[ii]->no, v(0), v(1), v(2)); - } - fprintf(file, "$EndElementData\n"); - } - - // node data: tensors_at_nodes - for (auto &p : r.tensors_at_nodes) - { - fprintf(file, "$NodeData\n"); - fprintf(file, "%d\n", 1); // nb of string tags - fprintf(file, "\"%s\"\n", p.first.c_str()); // the name of the view - fprintf(file, "%d\n", 1); // nb of real tags (1) - fprintf(file, "%.16g\n", r.time); // 1. the time value - fprintf(file, "%d\n", 3); // nb of integer tags (3) - fprintf(file, "%d\n", r.nt); // 1. time step index - fprintf(file, "%d\n", 9); // 2. nb of field component (1, 3 or 9) - fprintf(file, "%lu\n", static_cast<unsigned long>(msh->nodes.size())); // 3. nb of entities in the view - for (size_t ii = 0; ii < msh->nodes.size(); ++ii) - { - Eigen::MatrixXd const &v = (*(p.second))[ii]; - if (binary) - { - fwrite(&msh->nodes[ii]->no, sizeof(int), 1, file); - for (int i = 0; i < 3; ++i) - for (int j = 0; j < 3; ++j) - fwrite(&(v(i, j)), sizeof(double), 1, file); - } - else - fprintf(file, "%d %.16g %.16g %.16g %.16g %.16g %.16g %.16g %.16g %.16g\n", - msh->nodes[ii]->no, - v(0, 0), v(0, 1), v(0, 2), - v(1, 0), v(1, 1), v(1, 2), - v(2, 0), v(2, 1), v(2, 2)); - } - fprintf(file, "$EndNodeData\n"); - } - - // element data: tensors_at_elems - for (auto &p : r.tensors_at_elems) - { - fprintf(file, "$ElementData\n"); - fprintf(file, "%d\n", 1); // nb of string tags - fprintf(file, "\"%s\"\n", p.first.c_str()); // the name of the view - fprintf(file, "%d\n", 1); // nb of real tags (1) - fprintf(file, "%.16g\n", r.time); // 1. the time value - fprintf(file, "%d\n", 3); // nb of integer tags (3) - fprintf(file, "%d\n", r.nt); // 1. time step index - fprintf(file, "%d\n", 9); // 2. nb of field component (1, 3 or 9) - fprintf(file, "%lu\n", static_cast<unsigned long>(msh->elems.size())); // 3. nb of entities in the view - for (size_t ii = 0; ii < msh->elems.size(); ++ii) - { - Eigen::MatrixXd const &v = (*(p.second))[ii]; - if (binary) - { - fwrite(&(msh->elems[ii]->no), sizeof(int), 1, file); - for (int i = 0; i < 3; ++i) - for (int j = 0; j < 3; ++j) - fwrite(&(v(i, j)), sizeof(double), 1, file); - } - else - fprintf(file, "%d %.16g %.16g %.16g %.16g %.16g %.16g %.16g %.16g %.16g\n", - msh->elems[ii]->no, - v(0, 0), v(0, 1), v(0, 2), - v(1, 0), v(1, 1), v(1, 2), - v(2, 0), v(2, 1), v(2, 2)); - } - fprintf(file, "$EndElementData\n"); - } - - // close file - fclose(file); - std::cout << "done" << std::endl; -} - -void GmshExport::write(std::ostream &out) const -{ - out << "GmshExport on " << *msh << std::endl; -} \ No newline at end of file diff --git a/tbox/src/wGmshExport.h b/tbox/src/wGmshExport.h deleted file mode 100644 index eefcf447..00000000 --- a/tbox/src/wGmshExport.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGMSHEXPORT_H -#define WGMSHEXPORT_H - -#include "tbox.h" -#include "wMshExport.h" -#include <vector> -#include <map> - -namespace tbox -{ - -/** - * @brief Write mesh in gmsh format - * @authors Adrien Crovato, Romain Boman - */ -class TBOX_API GmshExport : public MshExport -{ -public: - GmshExport(std::shared_ptr<MshData> _msh); - virtual ~GmshExport(); - - virtual void save(std::string const &fname) const override; -#ifndef SWIG - virtual void save(std::string const &fname, Results const &r) const override; -#endif - - virtual void write(std::ostream &out) const override; -}; - -} // namespace tbox - -#endif //WGMSHUTILS_H diff --git a/tbox/src/wGmshImport.cpp b/tbox/src/wGmshImport.cpp deleted file mode 100644 index 3ea091dc..00000000 --- a/tbox/src/wGmshImport.cpp +++ /dev/null @@ -1,620 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGmshImport.h" -#include "wTag.h" -#include "wElement.h" -#include "wNode.h" -#include "wHex8.h" -#include "wTetra4.h" -#include "wQuad4.h" -#include "wTri3.h" -#include "wLine2.h" -#include "wPoint1.h" -#include "wResults.h" - -using namespace tbox; - -GmshImport::GmshImport(std::shared_ptr<MshData> _msh) : MshImport(_msh) -{ -} - -GmshImport::~GmshImport() -{ - std::cout << "~GmshImport()\n"; - nodemap.clear(); -} - -/** - * @brief Load a mesh from a file - */ -void GmshImport::load(std::string const &fname, int myrank) -{ - // clear data structure - msh->clear(); - nodemap.clear(); - - std::cout << "reading file " << fname << "...\n"; - - // read filename - auto idx = fname.find(".msh"); - if (idx != std::string::npos) - { - msh->name = fname.substr(0, idx); - std::cout << "\tsetting mesh name to \"" << msh->name << "\"\n"; - } - - // read gmsh .msh file with stdio commands - FILE *file = fopen(fname.c_str(), "r"); - if (!file) - throw std::runtime_error("Error opening file (load)"); - - int skipped = 0; - while (1) - { - // read next line - char line[128]; - if (fgets(line, sizeof line, file) == NULL) - break; - - // process code - if (searchCode("$MeshFormat", line) == 0) - readMshFormat(file); - else if (searchCode("$Nodes", line) == 0) - readMshNodes(file); - else if (searchCode("$Elements", line) == 0) - readMshElements(file, myrank); - else if (searchCode("$PhysicalNames", line) == 0) - readMshPhyNames(file); - else - { - skipped += 1; - if (verb) - std::cout << "\t" - << "[code] skipping line:\"" << line << "\"\n"; - } - } - if (verb) - std::cout << skipped << " lines skipped\n"; - - // close file - fclose(file); - nodemap.clear(); - std::cout << "done" << std::endl; -} - -/** - * @brief Read results from a file at time step index n - */ -void GmshImport::load(std::string const &fname, Results &r, int n) -{ - // Sanity checks - if (msh == nullptr) - throw std::runtime_error("tbox::GmshImport::load mesh data structure is empty. Please load a mesh before reading the results!\n"); - - // Create index maps - std::map<int, size_t> nimap, eimap; - for (size_t i = 0; i < msh->nodes.size(); ++i) - nimap[msh->nodes[i]->no] = i; - for (size_t i = 0; i < msh->elems.size(); ++i) - eimap[msh->elems[i]->no] = i; - - // Open file - std::cout << "reading file " << fname << "...\n"; - FILE *file = fopen(fname.c_str(), "r"); - if (!file) - throw std::runtime_error("Error opening file (load)"); - - // Read results - int skipped = 0; - while (1) - { - // read next line - char line[128]; - if (fgets(line, sizeof line, file) == NULL) - break; - - // process code - if (searchCode("$MeshFormat", line) == 0) - readMshFormat(file); - else if (searchCode("$NodeData", line) == 0) - readResNodes(file, line, nimap, r, n); - else if (searchCode("$ElementData", line) == 0) - readResElements(file, line, eimap, r, n); - else - { - skipped += 1; - if (verb) - std::cout << "\t" - << "[code] skipping line:\"" << line << "\"\n"; - } - } - if (verb) - std::cout << skipped << " lines skipped\n"; - - // close file - fclose(file); - std::cout << "done" << std::endl; -} - -/** - * @brief Search for a line in a code - */ -int GmshImport::searchCode(char const *code, char const *line) const -{ - return strncmp(code, line, strlen(code)); -} - -/** - * @brief Read mesh format type (version) - */ -void GmshImport::readMshFormat(FILE *file) -{ - double version = 0.0; - int ftype = 0, dsize = 0; - if (fscanf(file, "%lf %d %d\n", &version, &ftype, &dsize) != 3) - throw std::runtime_error("Error reading file (readMshFormat)"); - if (ftype != 0) - throw std::runtime_error("tbox::GmshImport::readMshFormat cannot read binary format!\n"); - double eps = 1e-5; - if (version < 2.2 - eps || version > 2.2 + eps) - { - std::stringstream str; - str << "bad .msh version: (" << version << ")"; - throw std::runtime_error(str.str()); - } - else - std::cout << "\treading .msh format " << version << "\n"; -} - -/** - * @brief Read the nodes - */ -void GmshImport::readMshNodes(FILE *file) -{ - // read number of nodes - int nbnod = 0; - if (fscanf(file, "%d\n", &nbnod) != 1) - throw std::runtime_error("Error reading number of nodes (readMshNodes)"); - std::cout << "\tcounted " << nbnod << " nodes\n"; - - // allocate memory and read the nodes - msh->nodes.reserve(nbnod); - for (int i = 0; i < nbnod; ++i) - { - int no = 0; - double x = 0.0, y = 0.0, z = 0.0; - if (fscanf(file, "%d %lf %lf %lf\n", &no, &x, &y, &z) != 4) - break; - if (verb) - std::cout << "\t" << no << ((i == nbnod - 1) ? ".\n" : ","); - Node *nod = new Node(no, Eigen::Vector3d(x, y, z), i); - msh->nodes.push_back(nod); - - nodemap[no] = nod; - } -} - -/** - * @brief Read the elements - */ -void GmshImport::readMshElements(FILE *file, int myrank) -{ - // read number of elements - int nbelm = 0; - if (fscanf(file, "%d\n", &nbelm) != 1) - throw std::runtime_error("Error reading number of elements (readMshElements)"); - std::cout << "\tcounted " << nbelm << " elements\n"; - - // allocate memory and read the elements - msh->elems.reserve(nbelm); - for (int i = 0; i < nbelm; ++i) - { - // read number, type and nb of tags - int no = 0, type = 0, nbtags = 0; - if (fscanf(file, "%d %d %d", &no, &type, &nbtags) != 3) - throw std::runtime_error("Error reading &no, &type, &nbtags (readMshElements)"); - if (verb) - std::cout << "\t" << no << ((i == nbelm - 1) ? ".\n" : ","); - - // read/create/link tags - // physical tag (group) - Tag *ptag = nullptr; - if (nbtags > 0) - ptag = addTag(file, msh->ptags); - // elementary tag (geometry) - Tag *etag = nullptr; - if (nbtags > 1) - etag = addTag(file, msh->etags); - // partitions - bool belongsToPart = false; - std::vector<Tag *> prts; - if (nbtags > 2) - { - // read number of part - int nbpart = 0; - if (fscanf(file, "%d", &nbpart) != 1) - throw std::runtime_error("Error reading &nbpart (readMshElements)"); - for (int j = 0; j < nbpart; ++j) - { - Tag *tag = addTag(file, msh->parts); - prts.push_back(tag); - if (myrank + 1 == tag->no || (myrank + 1 == -(tag->no))) - belongsToPart = true; - } - } - if (static_cast<ELTYPE>(type) == ELTYPE::POINT1) - belongsToPart = true; - - bool skipline = true; - // read/link nodes (if serial run or elements belong to partition) - if (myrank < 0 || belongsToPart) - { - skipline = false; - std::vector<Node *> nods; - if (static_cast<ELTYPE>(type) == ELTYPE::HEX8) // 8-node hexa - { - readElNods(file, 8, nods); - msh->elems.push_back(new Hex8(no, ptag, etag, prts, nods)); - } - else if (static_cast<ELTYPE>(type) == ELTYPE::QUAD4) // 4-node quad - { - readElNods(file, 4, nods); - msh->elems.push_back(new Quad4(no, ptag, etag, prts, nods)); - } - else if (static_cast<ELTYPE>(type) == ELTYPE::TETRA4) // 4-node tetra - { - readElNods(file, 4, nods); - msh->elems.push_back(new Tetra4(no, ptag, etag, prts, nods)); - } - else if (static_cast<ELTYPE>(type) == ELTYPE::LINE2) // 2-node line - { - readElNods(file, 2, nods); - msh->elems.push_back(new Line2(no, ptag, etag, prts, nods)); - } - else if (static_cast<ELTYPE>(type) == ELTYPE::POINT1) // 1-node point - { - readElNods(file, 1, nods); - msh->elems.push_back(new Point1(no, ptag, etag, prts, nods)); - } - else if (static_cast<ELTYPE>(type) == ELTYPE::TRI3) // 3-node triangle - { - readElNods(file, 3, nods); - msh->elems.push_back(new Tri3(no, ptag, etag, prts, nods)); - } - else - skipline = true; - } - if (skipline) - { - // skip line - char line[128]; - if (fgets(line, sizeof line, file) == NULL) - throw std::runtime_error("Error skipping line (readMshElements)"); - if (verb) - std::cout << "[elm] skipping line:\"" << line << "\"\n"; - } - } -} - -/** - * @brief Read physical group names - */ -void GmshImport::readMshPhyNames(FILE *file) -{ - // read number of names - int nbtag = 0; - if (fscanf(file, "%d\n", &nbtag) != 1) - throw std::runtime_error("Error reading number of physical names (readMshPhyNames)"); - - // read the names - for (int i = 0; i < nbtag; ++i) - { - // read dimension, label and name - int dim = 0, no = 0; - char pname[128]; - if (fscanf(file, "%d %d \"%[^\"]\"", &dim, &no, pname) != 3) - throw std::runtime_error("Error reading &dim, &no, &name (readMshPhyNames)"); - // add tag to gtag list - auto it = msh->ptags.find(no); - if (it == msh->ptags.end()) - msh->ptags[no] = new Tag(no, pname, dim); - msh->ntags[pname] = msh->ptags[no]; - } -} - -/** - * @brief Read nodes of an element - */ -void GmshImport::readElNods(FILE *file, int n, std::vector<Node *> &nods) -{ - int nn; - for (int j = 0; j < n; ++j) - { - if (fscanf(file, "%d", &nn) != 1) - throw std::runtime_error("Error reading element/node links (readElNods)"); - - auto it = nodemap.find(nn); - if (it == nodemap.end()) - throw std::runtime_error("Unknown node label (readElNods)"); - nods.push_back(it->second); - } -} - -/** - * @brief Create a tag for each physical group - */ -Tag *GmshImport::addTag(FILE *file, std::map<int, Tag *> &tmap) -{ - int tag; - if (fscanf(file, "%d", &tag) != 1) - throw std::runtime_error("Error reading tags (addtag)"); - auto it = tmap.find(tag); - if (it == tmap.end()) - tmap[tag] = new Tag(tag); - return tmap[tag]; -} - -/** - * @brief Read header of results - */ -void GmshImport::readResHeader(FILE *file, char *line, char *vname, unsigned long &nd, int &nc, int &nt, double &time) -{ - // Read the header - int nstrtags = 0, nrealtags = 0, ninttags = 0; // number of string, real and integer tags - // get the number of string tags - if (fscanf(file, "%d", &nstrtags) != 1) - throw std::runtime_error("tbox::GmshImport::readResHeader error reading file!\n"); - // get the (first) name of the view (variable), and skip the others if any - if (fscanf(file, " \"%[^\"]\"", vname) != 1) - throw std::runtime_error("tbox::GmshImport::readResHeader error reading file!\n"); - for (int i = 0; i < nstrtags - 1; ++i) - if (fgets(line, sizeof line, file) == NULL) - throw std::runtime_error("tbox::GmshImport::readResHeader end-of-file reached before all lines could be read!\n"); - // get the number of real tags - if (fscanf(file, "%d", &nrealtags) != 1) - throw std::runtime_error("tbox::GmshImport::readResHeader error reading file!\n"); - if (nrealtags != 1) - throw std::runtime_error("tbox::GmshImport::readResHeader error reading file!\n"); - // get the time - if (fscanf(file, "%lg", &time) != 1) - throw std::runtime_error("tbox::GmshImport::readResHeader error reading file!\n"); - // get the number of integer tags - if (fscanf(file, "%d", &ninttags) != 1) - throw std::runtime_error("tbox::GmshImport::readResHeader error reading file!\n"); - // get the time step index - if (fscanf(file, "%d", &nt) != 1) - throw std::runtime_error("tbox::GmshImport::readResHeader error reading file!\n"); - // get the number of components - if (fscanf(file, "%d", &nc) != 1) - throw std::runtime_error("tbox::GmshImport::readResHeader error reading file!\n"); - // get the number of data - if (fscanf(file, "%lu", &nd) != 1) - throw std::runtime_error("tbox::GmshImport::readResHeader error reading file!\n"); - // skip the number of partition, if given - if (ninttags == 4) - if (fgets(line, sizeof line, file) == NULL) - throw std::runtime_error("tbox::GmshImport::readResHeader end-of-file reached before all lines could be read!\n"); -} - -/** - * @brief Read results at nodes - */ -void GmshImport::readResNodes(FILE *file, char *line, std::map<int, size_t> &nimap, Results &r, int n) -{ - // Read header - char vname[128]; // name of view (variable to be read) - int nc = 0, nt = 0; // number of components and time step index - unsigned long nd = 0; // number of data points - double time = 0.; // current time - this->readResHeader(file, line, vname, nd, nc, nt, time); - - // Perform checks and read - // check the number of nodes - if (nd != static_cast<unsigned long>(msh->nodes.size())) - throw std::runtime_error("tbox::GmshImport::readResNodes the number of data to be read does not match the number of nodes in the mesh!\n"); - // check if the view name matches a variable, and if the time step index matches the requested time step - if (nc == 1) - { - auto resm = r.scalars_at_nodes; - // set time and read data - if (resm.find(vname) != resm.end() && nt == n) - { - std::cout << "\treading node data \"" << vname << "\" at time step #" << nt << std::endl; - r.nt = nt; - r.time = time; - for (unsigned long i = 0; i < nd; ++i) - { - int no = 0; - double da = 0.; - if (fscanf(file, "%d %lg", &no, &da) != nc + 1) - throw std::runtime_error("tbox::GmshImport::readResNodes error reading file!\n"); - resm.at(vname)->at(nimap[no]) = da; - } - } - // skip - else - { - std::cout << "\tskipping node data \"" << vname << "\" at time step #" << nt << std::endl; - for (unsigned long i = 0; i < nd; ++i) - if (fgets(line, sizeof line, file) == NULL) - throw std::runtime_error("tbox::GmshImport::readResNodes end-of-file reached before all data could be read!\n"); - } - } - else if (nc == 3) - { - auto resm = r.vectors_at_nodes; - // set time and read data - if (resm.find(vname) != resm.end() && nt == n) - { - std::cout << "\treading node data \"" << vname << "\" at time step #" << nt << std::endl; - r.nt = nt; - r.time = time; - for (unsigned long i = 0; i < nd; ++i) - { - int no = 0; - double da0 = 0., da1 = 0., da2 = 0.; - if (fscanf(file, "%d %lg %lg %lg", &no, &da0, &da1, &da2) != nc + 1) - throw std::runtime_error("tbox::GmshImport::readResNodes error reading file!\n"); - resm.at(vname)->at(nimap[no]) = Eigen::Vector3d(da0, da1, da2); - } - } - // skip - else - { - std::cout << "\tskipping node data \"" << vname << "\" at time step #" << nt << std::endl; - for (unsigned long i = 0; i < nd; ++i) - if (fgets(line, sizeof line, file) == NULL) - throw std::runtime_error("tbox::GmshImport::readResNodes end-of-file reached before all data could be read!\n"); - } - } - else if (nc == 9) - { - auto resm = r.tensors_at_nodes; - // set time and read data - if (resm.find(vname) != resm.end() && nt == n) - { - std::cout << "\treading node data \"" << vname << "\" at time step #" << nt << std::endl; - r.nt = nt; - r.time = time; - for (unsigned long i = 0; i < nd; ++i) - { - int no = 0; - double da0 = 0., da1 = 0., da2 = 0., da3 = 0., da4 = 0., da5 = 0., da6 = 0., da7 = 0., da8 = 0.; - if (fscanf(file, "%d %lg %lg %lg %lg %lg %lg %lg %lg %lg", &no, &da0, &da1, &da2, &da3, &da4, &da5, &da6, &da7, &da8) != nc + 1) - throw std::runtime_error("tbox::GmshImport::readResNodes error reading file!\n"); - resm.at(vname)->at(nimap[no]) << da0, da1, da2, da3, da4, da5, da6, da7, da8; - } - } - // skip - else - { - std::cout << "\tskipping node data \"" << vname << "\" at time step #" << nt << std::endl; - for (unsigned long i = 0; i < nd; ++i) - if (fgets(line, sizeof line, file) == NULL) - throw std::runtime_error("tbox::GmshImport::readResNodes end-of-file reached before all data could be read!\n"); - } - } - else - throw std::runtime_error("tbox::GmshImport::readResNodes the number of components must be 1, 3, or 9!\n"); -} - -/** - * @brief Read results at elements - */ -void GmshImport::readResElements(FILE *file, char *line, std::map<int, size_t> &eimap, Results &r, int n) -{ - // Read header - char vname[128]; // name of view (variable to be read) - int nc = 0, nt = 0; // number of components and time step index - unsigned long nd = 0; // number of data points - double time = 0.; // current time - this->readResHeader(file, line, vname, nd, nc, nt, time); - - // Perform checks and read - // check the number of elements - if (nd != static_cast<unsigned long>(msh->elems.size())) - throw std::runtime_error("tbox::GmshImport::readResElements the number of data to be read does not match the number of elements in the mesh!\n"); - // check if the view name matches a variable, and if the time step index matches the requested time step - if (nc == 1) - { - auto resm = r.scalars_at_elems; - // set time and read data - if (resm.find(vname) != resm.end() && nt == n) - { - std::cout << "\treading element data \"" << vname << "\" at time step #" << nt << std::endl; - r.nt = nt; - r.time = time; - for (unsigned long i = 0; i < nd; ++i) - { - int no = 0; - double da = 0.; - if (fscanf(file, "%d %lg", &no, &da) != nc + 1) - throw std::runtime_error("tbox::GmshImport::readResElements error reading file!\n"); - resm.at(vname)->at(eimap[no]) = da; - } - } - // skip - else - { - std::cout << "\tskipping element data \"" << vname << "\" at time step #" << nt << std::endl; - for (unsigned long i = 0; i < nd; ++i) - if (fgets(line, sizeof line, file) == NULL) - throw std::runtime_error("tbox::GmshImport::readResNodes end-of-file reached before all data could be read!\n"); - } - } - else if (nc == 3) - { - auto resm = r.vectors_at_elems; - // set time and read data - if (resm.find(vname) != resm.end() && nt == n) - { - std::cout << "\treading element data \"" << vname << "\" at time step #" << nt << std::endl; - r.nt = nt; - r.time = time; - for (unsigned long i = 0; i < nd; ++i) - { - int no = 0; - double da0 = 0., da1 = 0., da2 = 0.; - if (fscanf(file, "%d %lg %lg %lg", &no, &da0, &da1, &da2) != nc + 1) - throw std::runtime_error("tbox::GmshImport::readResElements error reading file!\n"); - resm.at(vname)->at(eimap[no]) = Eigen::Vector3d(da0, da1, da2); - } - } - // skip - else - { - std::cout << "\tskipping element data \"" << vname << "\" at time step #" << nt << std::endl; - for (unsigned long i = 0; i < nd; ++i) - if (fgets(line, sizeof line, file) == NULL) - throw std::runtime_error("tbox::GmshImport::readResNodes end-of-file reached before all data could be read!\n"); - } - } - else if (nc == 9) - { - auto resm = r.tensors_at_elems; - // set time and read data - if (resm.find(vname) != resm.end() && nt == n) - { - std::cout << "\treading element data \"" << vname << "\" at time step #" << nt << std::endl; - r.nt = nt; - r.time = time; - for (unsigned long i = 0; i < nd; ++i) - { - int no = 0; - double da0 = 0., da1 = 0., da2 = 0., da3 = 0., da4 = 0., da5 = 0., da6 = 0., da7 = 0., da8 = 0.; - if (fscanf(file, "%d %lg %lg %lg %lg %lg %lg %lg %lg %lg", &no, &da0, &da1, &da2, &da3, &da4, &da5, &da6, &da7, &da8) != nc + 1) - throw std::runtime_error("tbox::GmshImport::readResElements error reading file!\n"); - resm.at(vname)->at(eimap[no]) << da0, da1, da2, da3, da4, da5, da6, da7, da8; - } - } - // skip - else - { - std::cout << "\tskipping element data \"" << vname << "\" at time step #" << nt << std::endl; - for (unsigned long i = 0; i < nd; ++i) - if (fgets(line, sizeof line, file) == NULL) - throw std::runtime_error("tbox::GmshImport::readResNodes end-of-file reached before all data could be read!\n"); - } - } - else - throw std::runtime_error("tbox::GmshImport::readResElements the number of components must be 1, 3, or 9!\n"); -} - -void GmshImport::write(std::ostream &out) const -{ - out << "GmshImport on " << *msh << std::endl; -} diff --git a/tbox/src/wGmshImport.h b/tbox/src/wGmshImport.h deleted file mode 100644 index 6afac564..00000000 --- a/tbox/src/wGmshImport.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGMSHIMPORT_H -#define WGMSHIMPORT_H - -#include "tbox.h" -#include "wMshImport.h" -#include <vector> -#include <map> - -namespace tbox -{ - -/** - * @brief Read and load gmsh mesh - * @authors Adrien Crovato, Romain Boman - * @todo only ASCII files are suported, extend to binary? - * @todo upgrade to mesh format 4 - */ -class TBOX_API GmshImport : public MshImport -{ - std::map<int, Node *> nodemap; ///< Map between node and its id number - - int searchCode(char const *code, char const *line) const; - void readMshFormat(FILE *file); - void readMshNodes(FILE *file); - void readMshElements(FILE *file, int myrank); - void readMshPhyNames(FILE *file); - void readElNods(FILE *file, int n, std::vector<Node *> &nods); - Tag *addTag(FILE *file, std::map<int, Tag *> &tmap); - - void readResHeader(FILE *file, char *line, char *vname, unsigned long &nd, int &nc, int &nt, double &time); - void readResNodes(FILE *file, char *line, std::map<int, size_t> &nimap, Results &r, int n); - void readResElements(FILE *file, char *line, std::map<int, size_t> &eimap, Results &r, int n); - -public: - GmshImport(std::shared_ptr<MshData> _msh); - virtual ~GmshImport(); - - virtual void load(std::string const &fname, int myrank) override; - virtual void load(std::string const &fname, Results &r, int n = 0) override; - - virtual void write(std::ostream &out) const override; -}; - -} // namespace tbox - -#endif //WGMSHIMPORT_H diff --git a/tbox/src/wGroup.cpp b/tbox/src/wGroup.cpp deleted file mode 100644 index c26634fd..00000000 --- a/tbox/src/wGroup.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGroup.h" -#include "wMshData.h" -#include <sstream> -#include <stdexcept> -#include <iterator> - -using namespace tbox; - -Group::Group(std::shared_ptr<MshData> _msh, int no) : wSharedObject(), msh(_msh), tag(NULL) -{ - auto it = msh->ptags.find(no); - if (it == msh->ptags.end()) - { - std::stringstream out; - out << "Physical Group #" << no << " not found among physical tags"; - throw std::out_of_range(out.str()); - } - tag = it->second; -} - -Group::Group(std::shared_ptr<MshData> _msh, std::string const &name) : wSharedObject(), msh(_msh) -{ - auto it = msh->ntags.find(name); - if (it == msh->ntags.end()) - { - std::stringstream out; - out << "Physical Group \"" << name << "\" not found among physical tags\n"; - out << "[info] available tags:\n\t"; - for (auto it = msh->ntags.begin(); it != msh->ntags.end(); ++it) - { - auto itn(it); - ++itn; - out << (it->first) << ((itn != msh->ntags.end()) ? ", " : "\n\n"); - //out << (it->first) << ((std::next(it)!=msh->ntags.end())? ", " : "\n\n"); - } - throw std::out_of_range(out.str()); - } - tag = it->second; -} diff --git a/tbox/src/wGroup.h b/tbox/src/wGroup.h deleted file mode 100644 index fd3e155d..00000000 --- a/tbox/src/wGroup.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGROUP_H -#define WGROUP_H - -#include "tbox.h" -#include "wObject.h" -#include <string> -#include <memory> - -namespace tbox -{ - -/** - * @brief Group handling a set of elements - * @authors Romain Boman - */ -class TBOX_API Group : public fwk::wSharedObject -{ -public: -#ifndef SWIG - std::shared_ptr<MshData> msh; -#endif - Tag *tag; - - Group(std::shared_ptr<MshData> _msh, int no); - Group(std::shared_ptr<MshData> _msh, std::string const &name); -}; - -} // namespace tbox - -#endif //WGROUP_H diff --git a/tbox/src/wGroups.cpp b/tbox/src/wGroups.cpp deleted file mode 100644 index 217ac020..00000000 --- a/tbox/src/wGroups.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wGroups.h" -#include "wGroup.h" -#include "wMshData.h" -#include <sstream> -#include <stdexcept> -#include <iterator> - -using namespace tbox; - -Groups::Groups(std::shared_ptr<MshData> _msh, std::vector<int> const &nos) : wSharedObject(), msh(_msh) -{ - // Sanity check - if (nos.size() < 2) - { - std::stringstream err; - err << "Groups should be built with at least 2 physical groups but " << nos.size() << " were given!"; - throw std::runtime_error(err.str()); - } - // Fill Groups - for (auto no : nos) - { - Group *g = new Group(msh, no); - groups.push_back(g); - } -} -Groups::Groups(std::shared_ptr<MshData> _msh, std::vector<std::string> const &names) - : wSharedObject(), msh(_msh) -{ - // Sanity check - if (names.size() < 2) - { - std::stringstream err; - err << "Groups should be built with at least 2 physical groups but " << names.size() << " were given!"; - throw std::runtime_error(err.str()); - } - // Fill Groups - for (auto name : names) - { - Group *g = new Group(msh, name); - groups.push_back(g); - } -} -Groups::~Groups() -{ - for (auto g : groups) - delete g; -} \ No newline at end of file diff --git a/tbox/src/wGroups.h b/tbox/src/wGroups.h deleted file mode 100644 index 895fabc4..00000000 --- a/tbox/src/wGroups.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WGROUPS_H -#define WGROUPS_H - -#include "tbox.h" -#include "wObject.h" -#include <vector> -#include <string> -#include <memory> - -namespace tbox -{ - -/** - * @brief Handle group of several physical regions (tag) - * @authors Adrien Crovato - */ -class TBOX_API Groups : public fwk::wSharedObject -{ -public: -#ifndef SWIG - std::shared_ptr<MshData> msh; -#endif - std::vector<Group *> groups; - - Groups(std::shared_ptr<MshData> _msh, std::vector<int> const &nos); - Groups(std::shared_ptr<MshData> _msh, std::vector<std::string> const &names); - ~Groups(); -}; - -} // namespace tbox - -#endif //WGROUPS_H diff --git a/tbox/src/wHex8.cpp b/tbox/src/wHex8.cpp deleted file mode 100644 index 606ce106..00000000 --- a/tbox/src/wHex8.cpp +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wHex8.h" -#include "wSfHex8.h" -#include "wGaussHex8.h" -#include "wCacheHex8.h" -#include "wNode.h" - -using namespace tbox; - -Hex8::Hex8(int n, Tag *_ptag, Tag *_etag, - std::vector<Tag *> &_parts, std::vector<Node *> &nods) : Element(n, _ptag, _etag, _parts, nods) -{ -} - -/** - * @brief Return cache handling shape functions and Gauss points for all Hex8 elements - */ -Cache &Hex8::getVCache() const -{ - return getCache(order); -} - -/** - * @brief Initialize precomputed values - */ -void Hex8::initValues(bool isvol, int ordr) -{ - // Set flags - isVol = isvol; - order = ordr; - hasVals = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - Js.resize(ngp); - iJs.resize(ngp); - detJs.resize(ngp); - this->update(); -} -/** - * @brief Initialize precomputed gradients - */ -void Hex8::initGradients() -{ - // Set flags - hasGrads = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - gradJs.resize(ngp); - gradDetJs.resize(ngp); - this->update(); -} -/** - * @brief Update Hex8 precomputed values and gradients - */ -void Hex8::update() -{ - // Update values - if (hasVals) - { - // Jacobian - if (!isVol) - throw std::runtime_error("Hex8::update(): the problem must always have the same dimension as Hex8!\n"); - // Hex8 is always of same dimension as Problem (volume element) - this->buildJ(); - // Volume and CG - this->computeV(); - this->computeCg(); - } - // Update gradients - if (hasGrads) - { - // Jacobian - if (!isVol) - throw std::runtime_error("Hex8::updateGradients(): the problem must always have the same dimension as Hex8!\n"); - // Hex8 is always of same dimension as Problem (volume element) - this->buildGradientJ(); - // Volume - this->buildGradientV(3); - } -} - -/** - * @brief Compute Jacobian matrix, inverse and determinant - * - * J_ij(3,3) = diN_n * xj_n (n is the node) - */ -void Hex8::buildJ() -{ - CacheHex8 &cache = getCache(order); - for (size_t k = 0; k < cache.getVGauss().getN(); ++k) - { - Eigen::MatrixXd const &dff = cache.getDsf(k); - - Eigen::Matrix3d JJ = Eigen::Matrix3d::Zero(); // temporary fixed-size matrix to efficiently compute the inverse - size_t i = 0; - for (auto it = nodes.begin(); it != nodes.end(); ++it, ++i) - JJ += dff.col(i) * (*it)->pos.transpose(); - Js[k] = JJ; - iJs[k] = JJ.inverse(); - detJs[k] = JJ.determinant(); - this->checkJac(k); - } -} - -/** - * @brief Compute the element volume - */ -void Hex8::computeV() -{ - CacheHex8 &cache = getCache(order); - GaussHex8 &gauss = cache.gauss; - - // Gauss integration - vol = 0.0; - for (size_t k = 0; k < gauss.getN(); ++k) - vol += gauss.getW(k) * this->getDetJ(k); -} diff --git a/tbox/src/wHex8.h b/tbox/src/wHex8.h deleted file mode 100644 index 391b73dc..00000000 --- a/tbox/src/wHex8.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WHEX8_H -#define WHEX8_H - -#include "tbox.h" -#include "wLazy.h" -#include "wElement.h" -#include "wCacheHex8.h" - -namespace tbox -{ - -/** - * @brief Linear hexaedron finite element - * @authors Kim Liegeois, Romain Boman, Adrien Crovato - */ -class TBOX_API Hex8 : public Element -{ -#ifndef SWIG -private: - inline static CacheHex8 &getCache(int n); - -protected: - virtual void buildJ() override; - virtual void computeV() override; -#endif - -public: - Hex8(int n, Tag *_ptag, Tag *_etag, std::vector<Tag *> &_parts, std::vector<Node *> &nods); - virtual ~Hex8() {} - virtual ELTYPE type() const override { return ELTYPE::HEX8; } - -#ifndef SWIG - virtual void initValues(bool isvol, int ordr = 2) override; - virtual void initGradients() override; - virtual void update() override; - virtual Cache &getVCache() const override; -#endif -}; - -#include "wHex8.inl" - -} // namespace tbox - -#endif //WHEX8_H diff --git a/tbox/src/wHex8.inl b/tbox/src/wHex8.inl deleted file mode 100644 index a2c43adf..00000000 --- a/tbox/src/wHex8.inl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @brief Return cache for Hex8 private methods - */ -inline CacheHex8 &Hex8::getCache(int n) -{ - static Lazy<CacheHex8> cache(n); - return cache.get(); -} diff --git a/tbox/src/wLazy.h b/tbox/src/wLazy.h deleted file mode 100644 index 3d8e7970..00000000 --- a/tbox/src/wLazy.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WLAZY_H -#define WLAZY_H - -#include "tbox.h" - -#include <mutex> -#include <atomic> - -namespace tbox -{ - -/** - * @brief TBB implementation of a "lazy initialization" - * (thread safe allocation of a shared pointer) - */ - -template <typename T> -class Lazy -{ - std::atomic<T *> value; - std::mutex mut; - int np; - -public: - Lazy(int _np) : value(), np(_np) {} - ~Lazy() - { - delete value; - //std::cout << "lazy pointer deleted\n"; - } - T &get() - { - if (!value) - { - std::unique_lock<std::mutex> lock(mut); - if (!value) - value = new T(np); - } - return *value; - } -}; - -} // namespace tbox - -#endif //WLAZY_H diff --git a/tbox/src/wLine2.cpp b/tbox/src/wLine2.cpp deleted file mode 100644 index b28d1316..00000000 --- a/tbox/src/wLine2.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wLine2.h" -#include "wSfLine2.h" -#include "wGaussLine2.h" -#include "wCacheLine2.h" -#include "wNode.h" - -using namespace tbox; - -Line2::Line2(int n, Tag *_ptag, Tag *_etag, - std::vector<Tag *> &_parts, std::vector<Node *> &nods) : Element(n, _ptag, _etag, _parts, nods) -{ -} - -/** - * @brief Return cache holding shape functions and Gauss points for all Line2 elements - */ -Cache &Line2::getVCache() const -{ - return getCache(order); -} - -/** - * @brief Initialize precomputed values - */ -void Line2::initValues(bool isvol, int ordr) -{ - // Set flags - isVol = isvol; - order = ordr; - hasVals = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - Js.resize(ngp); - iJs.resize(ngp); - detJs.resize(ngp); - this->update(); -} -/** - * @brief Initialize precomputed gradients - */ -void Line2::initGradients() -{ - // Set flags - hasGrads = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - gradJs.resize(ngp); - gradDetJs.resize(ngp); - this->update(); -} -/** - * @brief Update precomputed values and gradients - */ -void Line2::update() -{ - // Update values - if (hasVals) - { - // Jacobian - if (isVol) - throw std::runtime_error("Line2::update(): the problem must always have a dimension less than Line2!\n"); - // Line2 is never of same dimension as Problem (surface element) - this->buildSurfaceJ(); - // Length and CG - this->computeV(); - this->computeCg(); - // Normal - this->computeNormal(); - } - // Update gradients - if (hasGrads) - { - // Jacobian - if (isVol) - throw std::runtime_error("Line2::updateGradient(): the problem must always have a dimension less than Line2!\n"); - // Line2 is never of same dimension as Problem (surface element) - this->buildGradientSurfaceJ(); - // Length - this->buildGradientV(2); - // Normal - this->computeGradientNormal(); - } -} - -/** - * @brief Compute Jacobian determinant - * - * detJ = norm(x_i * dN_i) - */ -void Line2::buildSurfaceJ() -{ - for (size_t k = 0; k < getCache(order).getVGauss().getN(); ++k) - detJs[k] = this->buildTangents(k)[0].norm(); -} - -/** - * @brief Compute Jacobian determinant gradient with respect to each node coordinate - * - * dDetJ[l = i * 2 + j] = detJ_l * dt0_l; - */ -void Line2::buildGradientSurfaceJ() -{ - CacheLine2 &cache = getCache(order); - for (size_t k = 0; k < cache.getVGauss().getN(); ++k) - { - // Shape functions, tangent vectors and determinant - Eigen::MatrixXd const &dsf = getCache(order).getDsf(k); - Eigen::Vector3d detJ = this->buildTangents(k)[0].normalized(); - - // Jacobian gradient - gradDetJs[k].resize(2 * 2); // 2 nodes and 2 dimensions (x, y) - for (size_t i = 0; i < 2; ++i) - { - for (size_t j = 0; j < 2; ++j) - { - Eigen::Vector3d dt0 = Eigen::Vector3d::Zero(); - dt0(j) = dsf(0, i); // retain sf gradients associated to ith node for dimension j - gradDetJs[k][i * 2 + j] = detJ.dot(dt0); - } - } - } -} - -/** - * @brief Compute the element length - */ -void Line2::computeV() -{ - CacheLine2 &cache = getCache(order); - GaussLine2 &gauss = cache.gauss; - - // Gauss integration - vol = 0.0; - for (size_t k = 0; k < gauss.getN(); ++k) - vol += gauss.getW(k) * this->getDetJ(k); -} -/** - * @brief Compute length gradient with respect to each node coordinate - * - * dV[i] = w_k * dDetJ[i]_k - */ -void Line2::buildGradientV(int dim) -{ - GaussLine2 &gauss = getCache(order).gauss; - - // Gradient of volume - gradVol.resize(2 * dim, 0.); // 2 nodes - for (size_t k = 0; k < gauss.getN(); ++k) - { - double w = gauss.getW(k); // GP weight - std::vector<double> dDetJ = this->getGradDetJ(k); // gradient of Jacobian determinant - for (size_t i = 0; i < dDetJ.size(); ++i) - gradVol[i] += w * dDetJ[i]; - } -} - -/** - * @brief Compute element tangent vectors - */ -std::vector<Eigen::Vector3d> Line2::computeTangents() const -{ - return std::vector<Eigen::Vector3d>{nodes[1]->pos - nodes[0]->pos}; -} - -/** - * @brief Build element tangent vectors using shape functions at Gauss point k - */ -std::vector<Eigen::Vector3d> Line2::buildTangents(size_t k) const -{ - Eigen::MatrixXd const &dff = getCache(order).getDsf(k); - - std::vector<Eigen::Vector3d> t(1, Eigen::Vector3d::Zero()); - size_t i = 0; - for (auto it = nodes.begin(); it != nodes.end(); ++it, ++i) - { - t[0] += (*it)->pos * dff(0, i); - } - return t; -} - -/** - * @brief Compute element unit normal vector - */ -void Line2::computeNormal() -{ - Eigen::Vector3d t = this->computeTangents()[0].normalized(); - normal = Eigen::Vector3d(-t(1), t(0), 0.); -} - -/** - * @brief Compute gradient of element unit normal vector with respect to each node coordinate - */ -void Line2::computeGradientNormal() -{ - // Compute normal and norm - Eigen::Vector3d t = this->computeTangents()[0]; - Eigen::Vector3d n = Eigen::Vector3d(-t(1), t(0), 0.); - double nn = n.norm(); - - // Compute gradients - Eigen::Matrix3d inn = (Eigen::Matrix3d::Identity() - n * n.transpose() / (nn * nn)) / nn; // gradient of n/|n| - gradNormal.resize(2 * 2); // 2 nodes and 2 dimensions - gradNormal[0] = inn * Eigen::Vector3d(0, -1, 0); - gradNormal[1] = inn * Eigen::Vector3d(1, 0, 0); - gradNormal[2] = inn * Eigen::Vector3d(0, 1, 0); - gradNormal[3] = inn * Eigen::Vector3d(-1, 0, 0); // outer gradient times gradient of t (pos) wtr x -} diff --git a/tbox/src/wLine2.h b/tbox/src/wLine2.h deleted file mode 100644 index 6b076608..00000000 --- a/tbox/src/wLine2.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WLINE2_H -#define WLINE2_H - -#include "tbox.h" -#include "wLazy.h" -#include "wElement.h" -#include "wCacheLine2.h" - -namespace tbox -{ - -/** - * @brief Linear line finite element - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API Line2 : public Element -{ -#ifndef SWIG -private: - inline static CacheLine2 &getCache(int n); - -protected: - virtual void buildSurfaceJ() override; - virtual void buildGradientSurfaceJ() override; - virtual void computeV() override; - virtual void buildGradientV(int dim) override; - virtual void computeNormal() override; - virtual void computeGradientNormal() override; - virtual std::vector<Eigen::Vector3d> computeTangents() const override; - virtual std::vector<Eigen::Vector3d> buildTangents(size_t k) const override; -#endif - -public: - Line2(int n, Tag *_ptag, Tag *_etag, std::vector<Tag *> &_parts, std::vector<Node *> &nods); - virtual ~Line2() {} - virtual ELTYPE type() const override { return ELTYPE::LINE2; } - -#ifndef SWIG - virtual void initValues(bool isvol, int ordr = 2) override; - virtual void initGradients() override; - virtual void update() override; - virtual Cache &getVCache() const override; -#endif -}; - -#include "wLine2.inl" - -} // namespace tbox - -#endif //WLINE2_H diff --git a/tbox/src/wLine2.inl b/tbox/src/wLine2.inl deleted file mode 100644 index 5dc09184..00000000 --- a/tbox/src/wLine2.inl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @brief Return cache for Line2 private methods - */ -inline CacheLine2 &Line2::getCache(int n) -{ - static Lazy<CacheLine2> cache(n); - return cache.get(); -} diff --git a/tbox/src/wLinearSolver.cpp b/tbox/src/wLinearSolver.cpp deleted file mode 100644 index c483c62b..00000000 --- a/tbox/src/wLinearSolver.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wLinearSolver.h" -using namespace tbox; - -/** - * @brief Analyze the matrix pattern - */ -void LinearSolver::analyze(Eigen::SparseMatrix<double> const &A) -{ - throw std::runtime_error("tbox::LinearSolver::analyze not implemented!\n"); -} -/** - * @brief Farctorize the matrix - */ -void LinearSolver::factorize(Eigen::SparseMatrix<double> const &A) -{ - throw std::runtime_error("tbox::LinearSolver::factorize not implemented!\n"); -} -/** - * @brief Solve the set of equations - */ -void LinearSolver::solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - throw std::runtime_error("tbox::LinearSolver::solve not implemented!\n"); -} -/** - * @brief Analyze the matrix pattern, factorize it, and solve the set of equations - */ -void LinearSolver::compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - throw std::runtime_error("tbox::LinearSolver::compute not implemented!\n"); -} -/** - * @brief Get the error norm(Ax - b) - */ -double LinearSolver::getError() -{ - throw std::runtime_error("tbox::LinearSolver::getError not implemented!\n"); -} -/** - * @brief Get the number of iterations required for solving the set of equations - */ -int LinearSolver::getIterations() -{ - throw std::runtime_error("tbox::LinearSolver::getIterations not implemented!\n"); -} \ No newline at end of file diff --git a/tbox/src/wLinearSolver.h b/tbox/src/wLinearSolver.h deleted file mode 100644 index 3e93813a..00000000 --- a/tbox/src/wLinearSolver.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WLINEARSOLVER_H -#define WLINEARSOLVER_H - -#include "tbox.h" -#include "wObject.h" -#include <Eigen/Sparse> - -namespace tbox -{ - -/** - * @brief Base interface class for linear solvers - * @authors Adrien Crovato - */ -class TBOX_API LinearSolver : public fwk::wSharedObject -{ -public: - LinearSolver() {} - virtual ~LinearSolver() {} - -#ifndef SWIG - virtual void analyze(Eigen::SparseMatrix<double> const &A); - virtual void factorize(Eigen::SparseMatrix<double> const &A); - virtual void solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x); - virtual void compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x); - - virtual double getError(); - virtual int getIterations(); -#endif -}; - -} // namespace tbox - -#endif // WLINEARSOLVER_H \ No newline at end of file diff --git a/tbox/src/wLinesearch.cpp b/tbox/src/wLinesearch.cpp deleted file mode 100644 index 3bf8e330..00000000 --- a/tbox/src/wLinesearch.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wLinesearch.h" -#include <sstream> -#include <iomanip> -#include <cmath> -#include <stdexcept> - -using namespace tbox; - -LSFunction::LSFunction() : wObject() -{ -} - -double LSFunction::eval(double alpha) -{ - return 0.0; -} - -RevFunction::RevFunction(LSFunction &_f) : LSFunction(), f(_f) -{ -} - -double RevFunction::eval(double alpha) -{ - return f.eval(-alpha); -} - -// --- - -Linesearch::Linesearch(LSFunction &_fct) : fct(_fct) -{ - verbose = 0; - maxLsIt = 1000; - tol = 1e-10; - fevalIt = 0; -} - -/** - * @brief Set control parameters - */ -void Linesearch::set(int _maxLSIt, double _lSTol, bool _verbose) -{ - verbose = _verbose; - maxLsIt = _maxLSIt; - tol = _lSTol; -} - -double Linesearch::run() -{ - throw std::runtime_error("Linesearch::run() not implemented!\n"); -} - -// --- - -BacktrackLS::BacktrackLS(LSFunction &_fct) : Linesearch(_fct) -{ -} - -/** - * @brief Backtracking linesearch - */ -double BacktrackLS::run() -{ - double a = 1; - double phi0 = fct.eval(0.); - fevalIt = 1; - do - { - double phi = fct.eval(a); - fevalIt++; - if (phi > phi0) - a /= 2; - else - break; - } while (fevalIt < maxLsIt); - return a; -} - -// --- - -FleuryLS::FleuryLS(LSFunction &_fct, double _h0, double _hL, bool _revAllowed) : Linesearch(_fct), h0(_h0), hL(_hL), revAllowed(_revAllowed) -{ - hU = 10.0; - hS = h0 / 10.0; - brckIt = 0; - lsIt = 0; -} - -/** - * @brief Execute 3-points quadratic linesearch - */ -double FleuryLS::run() -{ - double h = h0; - double phi1 = fct.eval(0); - double phit = fct.eval(h); - fevalIt = 2; - - if (verbose > 2) - { - std::cout << "Starting Backeting \n"; - std::cout << "\t" << std::setprecision(16) << "phi1(" << 0 << ") = " << phi1 << '\n'; - std::cout << "\t" << std::setprecision(16) << "phit(" << h << ") = " << phit << '\n'; - } - - // Following is valid if Hessian matrix is positive definite - // -> derivative is negative at 0. - double phi2 = 0.0, phi3; - size_t nB; - if (phit < phi1) - { - for (nB = 0;; ++nB) - { - if (h > hU) - { - if (verbose > 2) - { - std::cout << "Positive slope detected (in ascending bracketing #1)!\n"; - } - - if (revAllowed) - { - if (verbose > 2) - { - std::cout << "Reverse Direction of Line Search (in ascending bracketing #1)!" - << "\n"; - } - RevFunction revfct(fct); - FleuryLS revsearch(revfct, h0, hL, false); - return revsearch.run(); - } - else - { - if (verbose > 2) - { - std::cout << "Error in ascending bracketing #1:\n" - << std::setprecision(16) << "a1=" << 0 << " a2=" << h << " a3 =" << 2.0 * h << '\n' - << std::setprecision(16) << "phi1=" << phi1 << " phi2=" << phi2 << " phit=" << phit << '\n' - << "Using default step:\n" - << std::setprecision(16) << "a=" << hS << "\n"; - } - fct.eval(hS); - fevalIt++; - brckIt = nB + 1; - return hS; - } - } - phi2 = phit; - phit = fct.eval(2 * h); - fevalIt++; - - if (verbose > 2) - { - std::cout << "Ascending bracketing iteration # " << nB << ": \n"; - std::cout << "\t" - << "a1=" << 0 << " a2=" << h << " a3 =" << 2.0 * h << '\n'; - std::cout << "\t" - << "phi1=" << phi1 << " phi2=" << phi2 << " phit=" << phit << '\n'; - } - - if (phit > phi2) - break; - h = 2 * h; - } - phi3 = phit; - } - else - { - for (nB = 0;; ++nB) - { - if (h < hL) - { - if (verbose > 2) - { - std::cout << "Positive slope detected (in descending bracketing #2)!\n"; - } - - if (revAllowed) - { - if (verbose > 2) - { - std::cout << "Reverse Direction of Line Search (in descending bracketing #2) !" - << "\n"; - } - RevFunction revfct(fct); - FleuryLS revsearch(revfct, h0, hL, false); - return revsearch.run(); - } - else - { - if (verbose > 2) - { - std::cout << "Error in descending bracketing #2:\n" - << std::setprecision(16) << "a1=" << 0 << " a2=" << h << " a3 =" << 2.0 * h << '\n' - << std::setprecision(16) << "phi1=" << phi1 << " phi2=" << phi2 << " phit=" << phit << '\n' - << "Using default step:\n" - << std::setprecision(16) << "a=" << hS << "\n"; - } - fct.eval(hS); - fevalIt++; - brckIt = nB + 1; - return hS; - } - } - phi3 = phit; - phit = fct.eval(h / 2); - fevalIt++; - if (verbose > 2) - { - std::cout << "Descending bracketing iteration # " << nB << ": \n"; - std::cout << "\t" - << "a1=" << 0 << " a3=" << h << " a2 =" << h / 2.0 << '\n'; - std::cout << "\t" - << "phi1=" << phi1 << " phi3=" << phi3 << " phit=" << phit << '\n'; - } - if (phit < phi1) - break; - h = h / 2; - } - phi2 = phit; - h = h / 2; - } - - double a1 = 0; - double a2 = h; - double a3 = 2 * h; - double a4 = h * (4 * phi2 - 3 * phi1 - phi3) / (4 * phi2 - 2 * phi1 - 2 * phi3); - - if (verbose > 2) - { - std::cout << "Backeting succeeds in " << nB << " iterations : \n"; - std::cout << "\t" << std::setprecision(16) << "phi1(" << a1 << ") = " << phi1 << '\n'; - std::cout << "\t" << std::setprecision(16) << "phi2(" << a2 << ") = " << phi2 << '\n'; - std::cout << "\t" << std::setprecision(16) << "phi3(" << a3 << ") = " << phi3 << '\n'; - } - - double phi4; - double aa = 0.0; - size_t nLS = 0; - double A = 0.; - double errorPhi; - double errorAlpha; - - for (nLS = 0;; ++nLS) - { - phi4 = fct.eval(a4); - fevalIt++; - - errorAlpha = fabs(a4 - a2); - errorPhi = fabs(phi4 - phi2); - - if (nLS == maxLsIt) - { - brckIt = nB + 1; - lsIt = nLS; - std::stringstream msg; - msg << "Line-search doesn't converge within prescribed tolerance :\n"; - msg << "a1=" << std::setprecision(16) << a1 << " a2=" << a2 << " a3=" << a3 << " a4=" << a4 << '\n'; - msg << "phi1=" << std::setprecision(16) << phi1 << " phi2=" << phi2 << " phi3=" << phi3 << " phi4=" << phi4 << '\n'; - msg << "|A| = " << std::setprecision(16) << fabs(A) << ", |phi2-phi4| = " << errorPhi << " and |a2-a4| = " << errorAlpha << '\n'; - throw std::runtime_error(msg.str()); - } - - if (verbose > 2) - { - std::cout << "Line search iteration # " << nLS << ": \n"; - std::cout << "\t" << std::setprecision(16) << "phi1(" << a1 << ") = " << phi1 << '\n'; - std::cout << "\t" << std::setprecision(16) << "phi2(" << a2 << ") = " << phi2 << '\n'; - std::cout << "\t" << std::setprecision(16) << "phi3(" << a3 << ") = " << phi3 << '\n'; - std::cout << "\t" << std::setprecision(16) << "phi4(" << a4 << ") = " << phi4 << '\n'; - std::cout << "\t" << std::setprecision(16) << "|phi2-phi4| = " << errorPhi << " and |a2-a4| = " << errorAlpha << '\n'; - } - - if (a1 <= a4 && a4 <= a2) - { - if (phi1 >= phi4 && phi4 <= phi2) - { - a3 = a2; - phi3 = phi2; - a2 = a4; - phi2 = phi4; - } - else - { - a1 = a4; - phi1 = phi4; - } - } - else - { - if (phi2 >= phi4 && phi4 <= phi3) - { - a1 = a2; - phi1 = phi2; - a2 = a4; - phi2 = phi4; - } - else - { - a3 = a4; - phi3 = phi4; - } - } - - A = (a2 - a3) * phi1 + (a3 - a1) * phi2 + (a1 - a2) * phi3; - - if (verbose > 2) - { - std::cout << "\t" << std::setprecision(16) << "|A| = " << fabs(A) << "><" << tol << '\n'; - } - // phi2 ~ phi4 and a2 ~ a4 -> algorithm converges - if (fabs(A) <= tol) - { - if (phi4 < phi2) - aa = a4; - else - aa = a2; - break; - } - - a4 = 0.5 * (((a2 * a2) - (a3 * a3)) * phi1 + ((a3 * a3) - (a1 * a1)) * phi2 + ((a1 * a1) - (a2 * a2)) * phi3) / - (A); - } - - if (verbose > 2) - { - std::cout << "Line search succeeds in " << nLS << " iterations : \n"; - std::cout << "\t" << std::setprecision(16) << "|A| = " << fabs(A) << '\n'; - std::cout << "\t" << std::setprecision(16) << "|phi4-phi2| = " << errorPhi << '\n'; - std::cout << "\t" << std::setprecision(16) << "|a4-a2| = " << errorAlpha << '\n'; - std::cout << "\t" << std::setprecision(16) << "phi1(" << a1 << ") = " << phi1 << '\n'; - std::cout << "\t" << std::setprecision(16) << "phi2(" << a2 << ") = " << phi2 << '\n'; - std::cout << "\t" << std::setprecision(16) << "phi3(" << a3 << ") = " << phi3 << '\n'; - std::cout << "\t" << std::setprecision(16) << "phi4(" << a4 << ") = " << phi4 << '\n'; - } - brckIt = nB + 1; - lsIt = nLS; - return aa; -} - -// --- - -BankRoseLS::BankRoseLS(LSFunction &_fct) : Linesearch(_fct) -{ - K = 0.; -} - -/** - * @brief Execute Bank & Rose linesearch - */ -double BankRoseLS::run() -{ - double phi0 = fct.eval(0); - fevalIt = 1; - while (1) - { - double t = 1 / (1 + K * phi0); - double phi = fct.eval(t); - fevalIt++; - if (1 / t * (1 - phi / phi0) > tol) - { - K /= 10; - return t; - } - else if (fevalIt == maxLsIt) - { - std::stringstream msg; - msg << "Line-search doesn't converge within prescribed tolerance:\n"; - msg << "iter = " << std::setprecision(16) << fevalIt << '\n'; - msg << "K = " << std::setprecision(16) << K << ", t = " << t << '\n'; - msg << "phi/phi0 = " << std::setprecision(16) << phi / phi0 << std::endl; - throw std::runtime_error(msg.str()); - } - else - { - if (K == 0.) - K = 1; - else - K *= 10; - } - } -} \ No newline at end of file diff --git a/tbox/src/wLinesearch.h b/tbox/src/wLinesearch.h deleted file mode 100644 index 729fc26f..00000000 --- a/tbox/src/wLinesearch.h +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WLINESEARCH_H -#define WLINESEARCH_H - -#include "tbox.h" -#include "wObject.h" -#include <iostream> - -#ifndef SWIG - -namespace tbox -{ - -/** - * @brief Linesearch function - * @authors Romain Boman - */ -class TBOX_API LSFunction : public fwk::wObject -{ -public: - LSFunction(); - virtual double eval(double alpha); -}; - -class TBOX_API RevFunction : public LSFunction -{ - LSFunction &f; - -public: - RevFunction(LSFunction &_f); - virtual double eval(double alpha) override; -}; - -/** - * @brief Linesearch base class - * @authors Adrien Crovato - */ -class TBOX_API Linesearch -{ -protected: - LSFunction &fct; ///< function - size_t maxLsIt; ///< max. number of iterations for linesearch - double tol; ///< tolerance for linesearch - int verbose; ///< display more info - -public: - size_t fevalIt; ///< function evaluation count - - Linesearch(LSFunction &_fct); - - virtual void set(int _maxLSIt, double _lSTol, bool _verbose); - virtual double run(); -}; - -/** - * @brief Simple backtrack linesearch - * @authors Adrien Crovato - */ -class TBOX_API BacktrackLS : public Linesearch -{ -public: - BacktrackLS(LSFunction &_fct); - - virtual double run() override; -}; - -/** - * @brief 3-points quadratic linesearch - * - * Implemented following Prof. Fleury notes, University of Liege - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API FleuryLS : public Linesearch -{ -private: - double hU; ///< upper bound value for bracketing - double hS; ///< current value for bracketing - double h0; ///< initial value for bracketing - double hL; ///< lower bound value for bracketing - bool revAllowed; ///< allow bracketing in reverse direction - -public: - size_t brckIt; ///< bracketing iteration count - size_t lsIt; ///< linesearch iteration count - - FleuryLS(LSFunction &_fct, double _h0 = 1, double _hL = 1e-10, bool _revAllowed = true); - - virtual double run() override; -}; - -/** - * @brief Bank and Rose linesearch - * - * Implemented following Bank and Rose, Global Approximate Newton Methods, Numerische Mathematik - * www.math.hcmuns.edu.vn/~tangoc//bbmot.pdf - * @authors Adrien Crovato - */ -class TBOX_API BankRoseLS : public Linesearch -{ -private: - double K; ///> damping control - -public: - BankRoseLS(LSFunction &_fct); - virtual double run() override; -}; - -} // namespace tbox - -#endif - -#endif //WLINESEARCH_H diff --git a/tbox/src/wMshConvert.cpp b/tbox/src/wMshConvert.cpp deleted file mode 100644 index 013fff0c..00000000 --- a/tbox/src/wMshConvert.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wMshConvert.h" -#include "std_extra.h" -#include <string> -#include <cstring> -#include <sstream> -#include <fstream> -#include <set> -#include <algorithm> - -using namespace tbox; - -MshConvert::MshConvert(std::shared_ptr<MshData> _msh) : wSharedObject(), msh(_msh) -{ -} - -/** - * @brief Search for a line in a code - */ -int MshConvert::searchCode(char const *code, char const *line) const -{ - return strncmp(code, line, strlen(code)); -} - -/** - * @brief Cnovert a mesh from ANSYS to gmsh format - */ -void MshConvert::ansys_gmsh(std::string const &fname1, std::string const &fname2) -{ - // Fonction a generaliser afin de: -prendre en compte les hexaedres et quadrangle. - // -prendre en compte la presence de differents materiaux. - // -prendre en compte les elements de contacts. - // -prendre en compte les elements non lineaires. - - std::cout << "converting file " << fname1 << " and save results in " << fname2 << "\n"; - - FILE *read_file = fopen(fname1.c_str(), "r"); - if (!read_file) - throw std::runtime_error("Error opening file 1 (load)"); - - //FILE *written_file = fopen(fname2.c_str(),"w"); - //if (!written_file) - // throw std::runtime_error("Error opening file 2 (load)"); - - std::ofstream written_file; - written_file.open(fname2); - - std::cout << "the files are loaded\n"; - - // first reading - // - // goals: count the number of nodes - // count the number of volume elements - // set the BC sets of nodes - bool node_line = false; - bool element_line = false; - bool component_line = false; - bool volume_line = false; - int number_of_node = 0; - int number_of_element = -4; - int number_of_element_2 = 0; - int set_index = -1; - - std::vector<std::string> sets_name; - std::vector<std::set<int>> sets_nodes; - std::vector<std::vector<std::string>> sets_elems; - - while (1) - { - // read next line - char line[128]; - if (fgets(line, sizeof line, read_file) == NULL) - break; - if (searchCode("! NODES", line) == 0) - node_line = true; - else if (line[0] != '!' && node_line == true) - { - std::istringstream input(line); - input >> number_of_node; - } - else if (searchCode("! ELEMENTS", line) == 0) - { - node_line = false; - element_line = true; - } - else if (line[0] != '!' && element_line == true) - ++number_of_element; - else if (line[0] == '!' && element_line == true && number_of_element != -4) - element_line = false; - else if (searchCode("! COMPONENTS", line) == 0) - { - component_line = true; - } - else if (line[0] == 'C' && component_line == true) - { - std::string tmp_string(line); - std::string tmp_string2 = tmp_string.substr(8, 10); - std::string::iterator end_pos = std::remove(tmp_string2.begin(), tmp_string2.end(), ' '); - tmp_string2.erase(end_pos, tmp_string2.end()); - - if (tmp_string2 == "Volume") - { - volume_line = true; - continue; - } - volume_line = false; - - ++set_index; - sets_name.push_back(tmp_string2); - std::set<int> tmp; - sets_nodes.push_back(tmp); - std::vector<std::string> tmp2; - sets_elems.push_back(tmp2); - } - else if (line[0] != '!' && line[0] != '/' && line[0] != '(' && component_line == true && volume_line == false) - { - std::istringstream input(line); - for (;;) - { - int n; - input >> n; - - if (input.eof() || input.bad()) - break; - else if (input.fail()) - { - input.clear(); // unset failbit - input.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // skip bad input - } - else - sets_nodes[set_index].insert(n); - } - } - } - fclose(read_file); - - for (auto sn : sets_name) - std::cout << sn; - std::cout << std::endl; - for (int i = 0; i <= 0; ++i) - { - std::cout << sets_nodes[i].size() << "\n"; - - std::set<int>::iterator iter; - for (iter = sets_nodes[i].begin(); iter != sets_nodes[i].end(); ++iter) - std::cout << *iter << " "; - std::cout << "\n"; - } - - FILE *read_file2 = fopen(fname1.c_str(), "r"); - if (!read_file2) - throw std::runtime_error("Error opening file 1 (load)"); - - while (1) - { - // read next line - char line[128]; - if (fgets(line, sizeof line, read_file2) == NULL) - break; - else if (searchCode("! ELEMENTS", line) == 0) - element_line = true; - else if (line[0] != '!' && element_line == true) - { - std::istringstream input(line); - - int i = 0; - - int n1 = 0, n2 = 0, n3 = 0, n4 = 0; - for (;;) - { - long double n; - input >> n; - - if (input.eof() || input.bad() || n == -1) - break; - else if (input.fail()) - { - input.clear(); // unset failbit - input.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // skip bad input - } - else if (i == 11) - n1 = static_cast<int>(n); - else if (i == 12) - n2 = static_cast<int>(n); - else if (i == 13) - n3 = static_cast<int>(n); - else if (i == 14) - n4 = static_cast<int>(n); - - ++i; - } - - for (int ii = 0; ii <= set_index; ++ii) - { - std::ostringstream output; - if (sets_nodes[ii].find(n1) != sets_nodes[ii].end() && sets_nodes[ii].find(n2) != sets_nodes[ii].end() && sets_nodes[ii].find(n3) != sets_nodes[ii].end()) - output << n1 << " " << n2 << " " << n3; - else if (sets_nodes[ii].find(n1) != sets_nodes[ii].end() && sets_nodes[ii].find(n2) != sets_nodes[ii].end() && sets_nodes[ii].find(n4) != sets_nodes[ii].end()) - output << n1 << " " << n2 << " " << n4; - else if (sets_nodes[ii].find(n1) != sets_nodes[ii].end() && sets_nodes[ii].find(n3) != sets_nodes[ii].end() && sets_nodes[ii].find(n4) != sets_nodes[ii].end()) - output << n1 << " " << n3 << " " << n4; - else if (sets_nodes[ii].find(n2) != sets_nodes[ii].end() && sets_nodes[ii].find(n3) != sets_nodes[ii].end() && sets_nodes[ii].find(n4) != sets_nodes[ii].end()) - output << n2 << " " << n3 << " " << n4; - else - continue; - - sets_elems[ii].push_back(output.str()); - //break; - } - } - } - - fclose(read_file2); - - std::cout << "------------\n"; - // update the number of elements 2 - for (int i = 0; i <= set_index; ++i) - { - number_of_element_2 += static_cast<int>(sets_elems[i].size()); - std::cout << sets_elems[i].size() << "\n"; - } - - std::cout << number_of_element << "\n"; - std::cout << number_of_element_2 << "\n"; - - FILE *read_file3 = fopen(fname1.c_str(), "r"); - if (!read_file3) - throw std::runtime_error("Error opening file 1 (load)"); - - element_line = false; - node_line = false; - bool comment_element_line = false; - - written_file << "$MeshFormat\n2.2 0 8\n$EndMeshFormat\n$PhysicalNames\n"; - written_file << set_index + 2 << "\n3 270 \"Volume\"\n"; - for (int i = 0; i <= set_index; ++i) - { - written_file << "2 " << 271 + i << " \"" << sets_name[i] << "\"\n"; - } - written_file << "$EndPhysicalNames\n"; - while (1) - { - // read next line - char line[128]; - if (fgets(line, sizeof line, read_file3) == NULL) - break; - if (searchCode("! NODES", line) == 0) - { - written_file << "$Nodes \n" - << number_of_node << "\n"; - node_line = true; - } - else if (line[0] != '!' && node_line == true) - { - std::istringstream input(line); - std::ostringstream output; - for (;;) - { - double n; - input >> n; - - if (input.eof() || input.bad()) - break; - else if (input.fail()) - { - input.clear(); // unset failbit - input.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // skip bad input - } - else - output << n << ' '; - } - if (output.str().size() != 0) - written_file << output.str() << '\n'; - } - else if (searchCode("! ELEMENTS", line) == 0) - { - written_file << "$EndNodes \n$Elements \n" - << number_of_element + number_of_element_2 << "\n"; - node_line = false; - element_line = true; - comment_element_line = true; - - int ii = 0; - for (int i = 0; i <= set_index; ++i) - for (size_t j = 0; j < sets_elems[i].size(); ++j) - written_file << ++ii << " 2 2 " << 271 + i << " " << 41 + i << " " << sets_elems[i][j] << "\n"; - } - else if (line[0] == '!' && comment_element_line == true) - comment_element_line = false; - else if (line[0] != '!' && element_line == true) - { - std::istringstream input(line); - std::ostringstream output; - - int i = 0; - for (;;) - { - long double n; - input >> n; - - if (input.eof() || input.bad() || n == -1) - break; - else if (input.fail()) - { - input.clear(); // unset failbit - input.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // skip bad input - } - else if (i == 10) - { - written_file << number_of_element_2 + n << " 4 2 270 1 "; - ++i; - } - else if (i > 10) - { - written_file << n << ' '; - ++i; - } - else - ++i; - } - if (i != 0) - written_file << '\n'; - } - else if (line[0] == '!' && comment_element_line == false && element_line == true) - { - written_file << "$EndElements \n"; - element_line = false; - } - } - fclose(read_file3); -} \ No newline at end of file diff --git a/tbox/src/wMshConvert.h b/tbox/src/wMshConvert.h deleted file mode 100644 index 193e4a8c..00000000 --- a/tbox/src/wMshConvert.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WMSHCONVERT_H -#define WMSHCONVERT_H - -#include "tbox.h" -#include "wObject.h" -#include "wMshData.h" -#include <memory> - -namespace tbox -{ - -/** - * @brief Mesh converter - * @authors Adrien Crovato, Kim Liegeois - * @todo might need cleaning - */ -class TBOX_API MshConvert : public fwk::wSharedObject -{ - int searchCode(char const *code, char const *line) const; - -public: - std::shared_ptr<MshData> msh; - - MshConvert(std::shared_ptr<MshData> _msh); - virtual ~MshConvert() {} - - void ansys_gmsh(std::string const &fname1, std::string const &fname2); -}; - -} // namespace tbox - -#endif //WMSHCONVERT_H \ No newline at end of file diff --git a/tbox/src/wMshCrack.cpp b/tbox/src/wMshCrack.cpp deleted file mode 100644 index 9e11b8a8..00000000 --- a/tbox/src/wMshCrack.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wMshCrack.h" -#include "wMshData.h" -#include "wGroup.h" -#include "wGroups.h" -#include "wTag.h" -#include "wNode.h" -#include "wElement.h" -#include "wLine2.h" -#include "wTri3.h" - -using namespace tbox; - -MshCrack::MshCrack(std::shared_ptr<MshData> _msh, int _nDim) : wSharedObject(), msh(_msh), nDim(_nDim) -{ - hasCrack = true; // so that we prevent automatic data structure creation if addCrack() is not called - crckGrp = nullptr; - exclGrp = nullptr; -} -MshCrack::~MshCrack() -{ - // Delete temporary groups - delete crckGrp; - delete exclGrp; - for (size_t i = 0; i < bndGrps.size(); ++i) - delete bndGrps[i]; - for (size_t i = 0; i < bndGrp.size(); ++i) - delete bndGrp[i]; - std::cout << "~MshCrack()\n"; -} - -/** - * @brief Create temporary group for crack - */ -void MshCrack::setCrack(std::string const &crckName) -{ - // Check if a crack needs to be made - auto it = msh->ntags.find(crckName + '_'); - if (it != msh->ntags.end()) - std::cout << "Groups " << crckName << " and " << crckName << "_ are already existing. MshCrack will not be run!\n"; - else - { - hasCrack = false; - crckGrp = new Group(msh, crckName); - } -} - -/** - * @brief Create temporary group for excluded nodes on crack - */ -void MshCrack::setExcluded(std::string const &exclName) -{ - if (!hasCrack) - exclGrp = new Group(msh, exclName); -} - -/** - * @brief Create temporary groups for crack boundaries - */ -void MshCrack::addBoundaries(std::vector<std::string> const &bndName) -{ - if (!hasCrack) - { - for (auto name : bndName) - { - // Check if the boundaries are explicitely separated... - try - { - Groups *gs = new Groups(msh, std::vector<std::string>{name, name + '_'}); - 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 (const std::out_of_range &) - { - Group *g = new Group(msh, name); - bndGrp.push_back(g); - } - } - } -} - -/** - * @brief Create the crack and save the mesh - */ -void MshCrack::run() -{ - if (hasCrack) - std::cout << "MshCrack not run!\n"; - else - { - // Check that crack is bounded - if (bndGrps.empty() && bndGrp.empty()) - throw std::runtime_error("MshCrack::run crack has no boundary (use MshCrack::addBoundary()!\n"); - // Open the crack and modify data structure - openCrack(); - modifyBoundaries_(); - modifyBoundaries(); - std::cout << "Crack added on " << *(crckGrp->tag) << "(" << crckGrp->tag->name << "_ created)" << std::endl; - } -} - -/** - * @brief Duplicate the nodes and elements on the crack and modify the mesh accordingly - */ -void MshCrack::openCrack() -{ - // Collect the nodes to be duplicated - std::vector<Node *> nodes; - for (auto e : crckGrp->tag->elems) - for (auto n : e->nodes) - nodes.push_back(n); - std::sort(nodes.begin(), nodes.end()); - auto it = std::unique(nodes.begin(), nodes.end()); - nodes.resize(std::distance(nodes.begin(), it)); - // Remove the nodes to be excluded - if (exclGrp != nullptr) - { - // Get junction nodes - std::vector<Node *> excl; - for (auto e : exclGrp->tag->elems) - for (auto n : e->nodes) - excl.push_back(n); - std::sort(excl.begin(), excl.end()); - it = std::unique(excl.begin(), excl.end()); - excl.resize(std::distance(excl.begin(), it)); - // Find the intersection and remove - std::vector<Node *>::iterator endRange; - endRange = std::set_difference(nodes.begin(), nodes.end(), - excl.begin(), excl.end(), - nodes.begin()); - nodes.erase(endRange, nodes.end()); - } - // Duplicate the nodes, modify the mesh and make a map - size_t i = msh->nodes.size(); - for (auto n : nodes) - { - Node *newNodep = new Node(static_cast<int>(i + 1), n->pos, static_cast<int>(i)); - msh->nodes.push_back(newNodep); - nodMap[n] = newNodep; - i++; - } - - // Create new tag and modify the mesh - Tag *tagp = new Tag(static_cast<int>(msh->ptags.rbegin()->first + 1), crckGrp->tag->name + "_", nDim - 1); - Tag *tage = new Tag(static_cast<int>(msh->etags.rbegin()->first + 1), crckGrp->tag->name + "_", nDim - 1); - msh->ntags[crckGrp->tag->name + "_"] = tagp; - msh->ptags[static_cast<int>(msh->ptags.rbegin()->first + 1)] = tagp; - msh->etags[static_cast<int>(msh->etags.rbegin()->first + 1)] = tage; - // Duplicate elements and modify the mesh/tag - i = msh->elems.size() + 1; - for (auto e : crckGrp->tag->elems) - { - std::vector<Node *> nods(e->nodes.size()); - for (size_t j = 0; j < nods.size(); ++j) - { - try - { - nods[j] = nodMap.at(e->nodes[e->nodes.size() - j - 1]); - } - catch (const std::out_of_range &) - { - nods[j] = e->nodes[e->nodes.size() - j - 1]; - } - } - if (e->type() == ELTYPE::LINE2 && nDim == 2) - msh->elems.push_back(new Line2(static_cast<int>(i), tagp, tage, e->parts, nods)); - else if (e->type() == ELTYPE::TRI3 && nDim == 3) - msh->elems.push_back(new Tri3(static_cast<int>(i), tagp, tage, e->parts, nods)); - else - { - std::stringstream err; - err << "Msh::Crack: could not create element of type " << e->type() << " for dimension " << nDim << "!\n"; - throw std::runtime_error(err.str()); - } - i++; - } -} - -/** - * @brief Swap the elements nodes on one side of the crack and merge physical tags - */ -void MshCrack::modifyBoundaries_() -{ - for (auto gs : bndGrps) - { - // Modify element nodes touching the crack - for (auto e : gs->groups[1]->tag->elems) - swapNodes(e); - // Merge tags - Tag *refTag = gs->groups[0]->tag; - Tag *oldTag = gs->groups[1]->tag; - // Modify element tags - for (auto e : gs->groups[1]->tag->elems) - e->ptag = refTag; - // Append elements to new tag - refTag->elems.insert(refTag->elems.end(), oldTag->elems.begin(), oldTag->elems.end()); - // Delete old tag and remove from mesh maps - msh->ptags.erase(oldTag->no); - msh->ntags.erase(oldTag->name); - delete oldTag; - } -} - -/** - * @brief Detect the elements on one side of the crack and swap their nodes - */ -void MshCrack::modifyBoundaries() -{ - // compute crack CGs and normals - std::vector<Eigen::Vector3d> crkCG(crckGrp->tag->elems.size()), crkN(crckGrp->tag->elems.size()); - for (size_t i = 0; i < crckGrp->tag->elems.size(); ++i) - { - crckGrp->tag->elems[i]->computeCg(); - crkCG[i] = crckGrp->tag->elems[i]->cg; - crckGrp->tag->elems[i]->computeNormal(); - crkN[i] = crckGrp->tag->elems[i]->normal; - } - // find elements on the opposite side of the crack and swap their nodes - for (auto g : bndGrp) - { - // find elements that have at least one node on the crack and compute their CG - std::map<Element *, Eigen::Vector3d> onCrk; - for (auto e : g->tag->elems) - { - for (auto n : e->nodes) - { - if (nodMap.find(n) != nodMap.end()) - { - //Eigen::Vector3d cg(0, 0, 0); - //for (auto n_ : e->nodes) - // cg += n_->pos; - //cg /= e->nodes.size(); - //onCrk[e] = cg; - e->computeCg(); - onCrk[e] = e->cg; - break; - } - } - } - // find closest element, check side and swap nodes - for (auto p : onCrk) - { - // find mininal distance bewteen CGs - size_t idx = 0; - std::vector<Eigen::Vector3d> deltaCG(crkCG.size()); - for (size_t i = 0; i < crkCG.size(); ++i) - { - deltaCG[i] = p.second - crkCG[i]; - if (deltaCG[i].norm() < deltaCG[idx].norm()) - idx = i; - } - // check sign of dot product - if (deltaCG[idx].dot(crkN[idx]) < 0) - swapNodes(p.first); - } - } -} - -/** - * @brief Replace nodes of elements on opposite side of crack by opposite nodes - */ -void MshCrack::swapNodes(Element *e) -{ - for (size_t i = 0; i < e->nodes.size(); ++i) - { - try - { - e->nodes[i] = nodMap.at(e->nodes[i]); - } - catch (const std::out_of_range &) - { - //std::cout << e->nodes[i]->no << "not found in map!\n"; - } - } -} - -void MshCrack::write(std::ostream &out) const -{ - out << "MshCrack on " << msh << std::endl; -} \ No newline at end of file diff --git a/tbox/src/wMshCrack.h b/tbox/src/wMshCrack.h deleted file mode 100644 index fe45c9d1..00000000 --- a/tbox/src/wMshCrack.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WMSHCRACK_H -#define WMSHCRACK_H - -#include "tbox.h" -#include "wObject.h" -#include "wMshExport.h" -#include <vector> -#include <map> -#include <memory> - -namespace tbox -{ - -/** - * @brief Duplicate nodes and elements in a physical group and make mesh consistent - * - * Similar to plugin "crack" from gmsh but allows more control. Currently coded - * only for Line2 and Tri3. - * @authors Adrien Crovato - */ -class TBOX_API MshCrack : public fwk::wSharedObject -{ -private: - bool hasCrack; ///< flag telling if mesh already has crack - std::map<Node *, Node *> nodMap; ///< map between nodes on both side of crack - Group *crckGrp; ///< physical group of crack - Group *exclGrp; ///< physical group of nodes not to be duplicated - std::vector<Groups *> bndGrps; ///< list of pair of physical groups touching crack - std::vector<Group *> bndGrp; ///< list of physical groups touching crack - - void openCrack(); - void modifyBoundaries_(); - void modifyBoundaries(); - void swapNodes(Element *e); - -public: - std::shared_ptr<MshData> msh; - int nDim; - - MshCrack(std::shared_ptr<MshData> _msh, int _nDim); - virtual ~MshCrack(); - - void setCrack(std::string const &crckName); - void addBoundaries(std::vector<std::string> const &bndName); - void setExcluded(std::string const &exclName); - void run(); - -#ifndef SWIG - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace tbox - -#endif //WMSHCRACK_H \ No newline at end of file diff --git a/tbox/src/wMshData.cpp b/tbox/src/wMshData.cpp deleted file mode 100644 index ff0c6456..00000000 --- a/tbox/src/wMshData.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wMshData.h" -#include "wNode.h" -#include "wElement.h" -#include "wTag.h" - -using namespace tbox; - -MshData::MshData() : wSharedObject(), verb(false), name("unnamed") -{ -} - -void MshData::write(std::ostream &out) const -{ - out << "MshData ['" << name << "']= \n"; - out << "\t" << nodes.size() << " nodes\n"; - out << "\t" << elems.size() << " elements\n"; - out << "\t" << ptags.size() << " physical tags\n"; - out << "\t" << etags.size() << " elementary tags\n"; - out << "\t" << parts.size() << " partitions\n"; -} - -MshData::~MshData() -{ - std::cout << "~MshData()\n"; - clear(); -} - -/** - * @brief Clear the memory - */ -void MshData::clear() -{ - for (auto n : nodes) - delete n; - nodes.clear(); - - for (auto e : elems) - delete e; - elems.clear(); - - for (auto &p : ptags) - delete p.second; - ptags.clear(); - - for (auto &p : etags) - delete p.second; - etags.clear(); - - for (auto &p : parts) - delete p.second; - parts.clear(); -} diff --git a/tbox/src/wMshData.h b/tbox/src/wMshData.h deleted file mode 100644 index d3d99f6f..00000000 --- a/tbox/src/wMshData.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WMSHDATA_H -#define WMSHDATA_H - -#include "tbox.h" -#include "wObject.h" -#include <string> -#include <vector> -#include <map> - -namespace tbox -{ - -/** - * @brief Mesh data structure - * @authors Romain Boman, Adrien Crovato, Kim Liegeois - */ -class TBOX_API MshData : public fwk::wSharedObject -{ - bool verb; - -public: - std::vector<Node *> nodes; ///< nodes - std::vector<Element *> elems; ///< elements - std::string name; ///< name - - std::map<int, Tag *> ptags; ///< physical tags - std::map<int, Tag *> etags; ///< elementary tags - std::map<int, Tag *> parts; ///< partition tags - std::map<std::string, Tag *> ntags; ///< named tags - - MshData(); - virtual ~MshData(); - - void clear(); - void debug(bool v = true) { verb = v; } - virtual void write(std::ostream &out) const override; -}; - -} // namespace tbox - -#endif //WMSHDATA_H diff --git a/tbox/src/wMshDeform.cpp b/tbox/src/wMshDeform.cpp deleted file mode 100644 index 22463cc4..00000000 --- a/tbox/src/wMshDeform.cpp +++ /dev/null @@ -1,511 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wMshDeform.h" -#include "wMshData.h" -#include "wGroup.h" -#include "wGroups.h" -#include "wTag.h" -#include "wNode.h" -#include "wElement.h" -#include "wCache.h" -#include "wGauss.h" -#include "wGmres.h" - -#include <tbb/global_control.h> -#include <tbb/parallel_for_each.h> -#include <tbb/spin_mutex.h> -#include <deque> - -using namespace tbox; - -MshDeform::MshDeform(std::shared_ptr<MshData> _msh, int _nDim) : wSharedObject(), nDim(_nDim), field(false), fixed(false), moving(false), msh(_msh) -{ - // Check problem dimension - if (nDim != 2 && nDim != 3) - throw std::runtime_error("tbox::MshDeform: nDim should be 2 or 3!\n"); - // Default - fldGrp = nullptr; - symBndGrp = nullptr; - - // Initialize multithreading - nthreads = 1; - // Get mesh size - mshSize = msh->nodes.size(); -} - -/** - * @brief Set internal field - */ -void MshDeform::setField(std::string const &fldName) -{ - // Create temporary field group - fldGrp = new Group(msh, fldName); - field = true; -} - -/** - * @brief Add fixed boundaries - */ -void MshDeform::addFixed(std::vector<std::string> const &fxdBndName) -{ - // Create temporary boundary groups - for (size_t i = 0; i < fxdBndName.size(); ++i) - { - Group *g = new Group(msh, fxdBndName[i]); - fxdBndGrp.push_back(g); - } - fixed = true; -} - -/** - * @brief Add moving boundaries - */ -void MshDeform::addMoving(std::vector<std::string> const &movBndName) -{ - // Create temporary boundary groups - for (size_t i = 0; i < movBndName.size(); ++i) - { - Group *g = new Group(msh, movBndName[i]); - movBndGrp.push_back(g); - } - moving = true; -} - -/** - * @brief Set symmetry boundary - */ -void MshDeform::setSymmetry(std::string const &symBndName, size_t _blck) -{ - // Get blocked direction - blck = _blck; - if (blck != 0 && blck != 1 && blck != 2) - throw std::runtime_error("tbox::MshDeform::setSymmetry: blck should be 0, 1 or 2 (for x, y and z direction resp.)!\n"); - // Create temporary boundary groups - symBndGrp = new Group(msh, symBndName); -} - -/** - * @brief Add internal boundaries - */ -void MshDeform::addInternal(std::vector<std::string> const &intBndName) -{ - // Create temporary internal link - if (intBndName.size() != 2) - throw std::runtime_error("MshDeform: input intBndName must be a pair of internal boundaries!\n"); - Groups *gs = new Groups(msh, intBndName); - intBndGrps.push_back(gs); -} - -/** - * @brief Initialize data structure - */ -void MshDeform::initialize() -{ - // Sanity checks - if (!field) - throw std::runtime_error("MshDeform: field has not been found! Use setField() to add a field.\n"); - else if (!fixed) - throw std::runtime_error("MshDeform: fixed boundaries have not been found! Use addFixed() to add at least one boundary.\n"); - else if (!moving) - throw std::runtime_error("MshDeform: moving boundaries have not been found! Use addMoving() to add at least one boundary.\n"); - - // Store the field elements - for (auto e : fldGrp->tag->elems) - fldElems.push_back(e); - - // Create vector of fixed boundaries nodes - for (auto bnd : fxdBndGrp) - for (auto e : bnd->tag->elems) - for (auto n : e->nodes) - fxdBndNodes.push_back(n); - uniqueSort(fxdBndNodes); - - // Create vector of moving boundaries nodes - for (auto bnd : movBndGrp) - { - for (auto e : bnd->tag->elems) - { - movBndElems.push_back(e); - for (auto n : e->nodes) - movBndNodes.push_back(n); - } - } - uniqueSort(movBndNodes); - - // Create vector of symmetry boundary nodes - if (symBndGrp) - { - for (auto e : symBndGrp->tag->elems) - { - symBndElems.push_back(e); - for (auto n : e->nodes) - symBndNodes.push_back(n); - } - uniqueSort(symBndNodes); - } - - // Create the nodes pair for internal boundaries - for (auto bnds : intBndGrps) - { - // Temporary container for internal nodes - std::vector<Node *> nodes0, nodes1; - for (auto e : bnds->groups[0]->tag->elems) - { - intBndElems.push_back(e); - for (auto n : e->nodes) - nodes0.push_back(n); - } - for (auto e : bnds->groups[1]->tag->elems) - { - intBndElems.push_back(e); - for (auto n : e->nodes) - nodes1.push_back(n); - } - uniqueSort(nodes0); - uniqueSort(nodes1); - // Create the nodes pair - if (nodes0.size() != nodes1.size()) - throw std::runtime_error("MshDeform: internal boudnaries must have the same number of nodes!"); - for (auto n0 : nodes0) - { - for (auto n1 : nodes1) - { - if ((n0->pos - n1->pos).norm() <= 1e-14 && n0 != n1) - { - intBndPair.push_back(std::pair<Node *, Node *>(n0, n1)); - break; - } - } - } - } - - // List of rows to build stiffness matrix - rows.resize(nDim * mshSize); - for (size_t i = 0; i < mshSize; ++i) - for (size_t m = 0; m < nDim; ++m) - rows[nDim * i + m] = static_cast<int>(nDim * msh->nodes[i]->row + m); - // Periodic boundary condition step 1 - // -> for each node pair(a, b): node a contributions will be added to node b rows - for (auto p : intBndPair) - for (size_t m = 0; m < nDim; ++m) - rows[nDim * (p.first->row) + m] = static_cast<int>(nDim * (p.second->row) + m); - - // Delete temporary - delete fldGrp; - for (size_t i = 0; i < fxdBndGrp.size(); ++i) - delete fxdBndGrp[i]; - for (size_t i = 0; i < movBndGrp.size(); ++i) - delete movBndGrp[i]; - delete symBndGrp; - for (size_t i = 0; i < intBndGrps.size(); ++i) - delete intBndGrps[i]; -} - -/** - * @brief Store moving nodes position before deformation - */ -void MshDeform::savePos() -{ - initPos.resize(nDim * movBndNodes.size()); - for (size_t i = 0; i < movBndNodes.size(); ++i) - for (int m = 0; m < nDim; ++m) - initPos[nDim * i + m] = movBndNodes[i]->pos(m); -} - -/** - * @brief Compute mechanical stiffness matrix for one element - * - * K_ij(6,6) = int eps_k H_ijkl eps_l dV = B(6,3)H(3,3)B(3,6) - * K_ij(12,12) = int eps_k H_ijkl eps_l dV = B(12,6)H(6,6)B(6,12) - * @todo should be in a dedicated static class - */ -Eigen::MatrixXd MshDeform::buildK(tbox::Element const &e, Eigen::MatrixXd const &H) -{ - // Get precomputed values - Cache &cache = e.getVCache(); - Gauss &gauss = cache.getVGauss(); - size_t ns = e.nodes.size(); // number of nodes - - // Elementary stiffness matrix - Eigen::MatrixXd K = Eigen::MatrixXd::Zero(nDim * ns, nDim * ns); - for (size_t k = 0; k < gauss.getN(); ++k) - { - // Jacobian inverse - Eigen::MatrixXd const &iJ = e.getJinv(k); - // Fill B matrix (shape functions) - Eigen::MatrixXd const &dff = cache.getDsf(k); - Eigen::MatrixXd B; - if (nDim == 2) - { - B = Eigen::MatrixXd::Zero(3, 2 * ns); - for (size_t i = 0; i < ns; ++i) - { - // Compute [Ni,x Ni,y] - Eigen::VectorXd dN = iJ * dff.col(i); - B(0, 2 * i) = dN(0); - B(1, 2 * i + 1) = dN(1); - B(2, 2 * i + 1) = dN(0); - B(2, 2 * i) = dN(1); - } - } - else - { - B = Eigen::MatrixXd::Zero(6, 3 * ns); - for (size_t i = 0; i < ns; ++i) - { - // Compute [Ni,x Ni,y Ni,z] - Eigen::VectorXd dN = iJ * dff.col(i); - B(0, 3 * i) = dN(0); - B(1, 3 * i + 1) = dN(1); - B(2, 3 * i + 2) = dN(2); - B(3, 3 * i + 1) = dN(2); - B(3, 3 * i + 2) = dN(1); - B(4, 3 * i) = dN(2); - B(4, 3 * i + 2) = dN(0); - B(5, 3 * i) = dN(1); - B(5, 3 * i + 1) = dN(0); - } - } - - // Compute stiffness matrix - K += B.transpose() * H * B * gauss.getW(k) * e.getDetJ(k); - } - return K; -} - -/** - * @brief Build the mesh deformation matrix using linear elasticity law - * - * Dwight RP, Robust Mesh Deformation using the Linear Elasticity Equations. - * Journal of Computational Fluid Dynamics 12: 401-406, 2009 - */ -void MshDeform::build(Eigen::SparseMatrix<double, Eigen::RowMajor> &K) -{ - // Multithread - tbb::spin_mutex mutex; - - // List of triplets to build stifness matrix - std::deque<Eigen::Triplet<double>> T; - - // Build stiffness matrix - tbb::parallel_for_each(fldElems.begin(), fldElems.end(), [&](Element *e) { - // Hooke tensor - Eigen::MatrixXd H; - if (nDim == 2) - { - H = Eigen::Matrix3d::Zero(); - double nu = 0.; // Poisson ratio [-1, 0.5] - double E = 1 / e->getVol(); // Young modulus - H(0, 0) = 1 - nu; - H(1, 1) = 1 - nu; - H(2, 2) = (1 - 2 * nu) / 2; - H(0, 1) = nu; - H(1, 0) = H(0, 1); - H *= E / ((1 + nu) * (1 - 2 * nu)); - } - else - { - H = Eigen::MatrixXd::Zero(6, 6); - double nu = 0.; // Poisson ratio [-1, 0.5] - double E = 1 / e->getVol(); // Young modulus - H(0, 0) = 1 - nu; - H(1, 1) = 1 - nu; - H(2, 2) = 1 - nu; - H(3, 3) = (1 - 2 * nu) / 2; - H(4, 4) = (1 - 2 * nu) / 2; - H(5, 5) = (1 - 2 * nu) / 2; - H(0, 1) = nu; - H(1, 0) = H(0, 1); - H(0, 2) = nu; - H(2, 0) = H(0, 2); - H(1, 2) = nu; - H(2, 1) = H(1, 2); - H *= E / ((1 + nu) * (1 - 2 * nu)); - } - // Elementary stiffness matrix - Eigen::MatrixXd Ke = this->buildK(*e, H); - // Assembly - tbb::spin_mutex::scoped_lock lock(mutex); - for (size_t i = 0; i < e->nodes.size(); ++i) - { - for (int m = 0; m < nDim; ++m) - { - size_t rowi = nDim * (e->nodes[i]->row) + m; - for (size_t j = 0; j < e->nodes.size(); ++j) - { - for (int n = 0; n < nDim; ++n) - { - int rowj = nDim * (e->nodes[j]->row) + n; - T.push_back(Eigen::Triplet<double>(rows[rowi], rowj, Ke(nDim * i + m, nDim * j + n))); - } - } - } - } - }); - // Periodic boundary condition step 2 - // -> for each node pair(a, b): write "pos_a - pos_b" = 0 on row a - for (auto p : intBndPair) - for (int m = 0; m < nDim; ++m) - { - T.push_back(Eigen::Triplet<double>(nDim * (p.first->row) + m, nDim * (p.first->row) + m, 1.)); - T.push_back(Eigen::Triplet<double>(nDim * (p.first->row) + m, nDim * (p.second->row) + m, -1.)); - } - // Build matrix without BCs - K.setFromTriplets(T.begin(), T.end()); - // Apply Dirichlet condition on fixed boundaries - for (size_t i = 0; i < fxdBndNodes.size(); i++) - { - for (int m = 0; m < nDim; ++m) - { - size_t rowi = nDim * (fxdBndNodes[i]->row) + m; - for (Eigen::SparseMatrix<double, Eigen::RowMajor>::InnerIterator it(K, rowi); it; ++it) - { - if (it.row() == it.col()) - it.valueRef() = 1.; - else - it.valueRef() = 0.; - } - } - } - // Apply Dirichlet condition on symmetry boundaries - for (size_t i = 0; i < symBndNodes.size(); i++) - { - size_t rowi = nDim * (symBndNodes[i]->row) + blck; - for (Eigen::SparseMatrix<double, Eigen::RowMajor>::InnerIterator it(K, rowi); it; ++it) - { - if (it.row() == it.col()) - it.valueRef() = 1.; - else - it.valueRef() = 0.; - } - } - // Apply Dirichlet condition on moving boundaries - for (size_t i = 0; i < movBndNodes.size(); i++) - { - for (int m = 0; m < nDim; ++m) - { - size_t rowi = nDim * (movBndNodes[i]->row) + m; - for (Eigen::SparseMatrix<double, Eigen::RowMajor>::InnerIterator it(K, rowi); it; ++it) - { - if (it.row() == it.col()) - it.valueRef() = 1.; - else - it.valueRef() = 0.; - } - } - } - // Clean matrix and turn to compressed row format - K.prune(0.); - K.makeCompressed(); -} - -/** - * @brief Build the mesh deformation force vector (B.C.) using linear elasticity law - * - * Dwight RP, Robust Mesh Deformation using the Linear Elasticity Equations. - * Journal of Computational Fluid Dynamics 12: 401-406, 2009 - */ -void MshDeform::build(Eigen::VectorXd &f) -{ - // Apply Dirichlet condition on moving boundaries - for (size_t i = 0; i < movBndNodes.size(); i++) - { - for (int m = 0; m < nDim; ++m) - { - size_t rowi = nDim * (movBndNodes[i]->row) + m; - f(rowi) = movBndNodes[i]->pos(m) - initPos[nDim * i + m]; - } - } -} - -/** - * @brief Deform the mesh following linear elasticity law - * - * Dwight RP, Robust Mesh Deformation using the Linear Elasticity Equations. - * Journal of Computational Fluid Dynamics 12: 401-406, 2009 - */ -void MshDeform::deform() -{ - // Multithread - tbb::global_control control(tbb::global_control::max_allowed_parallelism, nthreads); - - // Stiffness matrix - Eigen::SparseMatrix<double, Eigen::RowMajor> K(nDim * mshSize, nDim * mshSize); - // force (RHS) and displacement (UKN) vectors - Eigen::VectorXd f = Eigen::VectorXd::Zero(nDim * mshSize), q = Eigen::VectorXd::Zero(nDim * mshSize); - - // Build stiffness matrix and RHS - std::cout << "--- Deforming mesh using linear elasticiy equations ---\n" - << "Number of threads: " << nthreads << "\n" - << "Assembling matrices... " << std::flush; - this->build(K); - this->build(f); - std::cout << "done" << std::endl; - // Solve the SoE - std ::cout << "Solving equations... " << std::flush; - Gmres gmres; - // set the preconditioner - gmres.setFillFactor(2); - gmres.setDropTol(1e-6); - // set the gmres - gmres.setTolerance(1e-8); - gmres.setRestart(50); - gmres.setMaxIterations(500); - // solve - Eigen::Map<Eigen::VectorXd> f_(f.data(), f.size()), q_(q.data(), q.size()); - gmres.compute(K, f_, q_); - std::cout << "done (#it: " << gmres.getIterations() << ", error: " << std::scientific << gmres.getError() << std::fixed << ")" << std::endl; - - // Update position - std ::cout << "Updating mesh... " << std::flush; - for (auto n : msh->nodes) - { - for (int m = 0; m < nDim; m++) - n->pos(m) += q(nDim * (n->row) + m); - } - // Reset moving boundary position - for (auto n : movBndNodes) - { - for (int m = 0; m < nDim; m++) - n->pos(m) -= q(nDim * (n->row) + m); - } - // Update element memory - for (auto e : fldElems) - e->update(); - for (auto e : movBndElems) - e->update(); - for (auto e : symBndElems) - e->update(); - for (auto e : intBndElems) - e->update(); - std::cout << "done" << std::endl; -} - -/** - * @brief Sort a vector and remove duplicates - */ -void MshDeform::uniqueSort(std::vector<Node *> &nodes) -{ - std::sort(nodes.begin(), nodes.end()); - auto it = std::unique(nodes.begin(), nodes.end()); - nodes.resize(std::distance(nodes.begin(), it)); -} - -void MshDeform::write(std::ostream &out) const -{ - out << "MshDeform on " << msh << std::endl; -} diff --git a/tbox/src/wMshDeform.h b/tbox/src/wMshDeform.h deleted file mode 100644 index 90b661ad..00000000 --- a/tbox/src/wMshDeform.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WMSHDEFORM_H -#define WMSHDEFORM_H - -#include "tbox.h" -#include "wObject.h" -#include <vector> -#include <map> -#include <memory> -#include <Eigen/Sparse> - -namespace tbox -{ - -/** - * @brief Handle mesh deformation - * @authors Adrien Crovato - */ -class TBOX_API MshDeform : public fwk::wSharedObject -{ -private: - size_t mshSize; ///< number of nodes in the mesh - int nDim; ///< dimension of the problem (2 or 3) - std::vector<int> rows; ///< unknown local index - bool field; ///< flag to check if field has been added - bool fixed; ///< flag to check if at least one fixed boundary has been added - bool moving; ///< flag to check if at least one moving boundary has been added - Group *fldGrp; ///< temporary group for field - std::vector<Group *> fxdBndGrp; ///< temporary group for fixed boundaries - std::vector<Group *> movBndGrp; ///< temporary group for moving boundaries - Group *symBndGrp; ///< temporary group for symmetry boundary - std::vector<Groups *> intBndGrps; ///< temporary group for internal boundaries - std::vector<Element *> fldElems; ///< field elements - std::vector<Element *> movBndElems; ///< moving boundaries elements - std::vector<Element *> symBndElems; ///< symmetry boundary elements - std::vector<Element *> intBndElems; ///< internal boundaries elements - std::vector<Node *> fxdBndNodes; ///< fixed boundaries nodes - std::vector<Node *> movBndNodes; ///< moving boundaries nodes - std::vector<Node *> symBndNodes; ///< symmetry boundary nodes - size_t blck; ///< blocked dimension for symmetry B.C. - std::vector<std::pair<Node *, Node *>> intBndPair; ///< internal boundaries node pairs - std::vector<double> initPos; ///< initial positions of nodes before mesh deformation - - void uniqueSort(std::vector<Node *> &nodes); - Eigen::MatrixXd buildK(tbox::Element const &e, Eigen::MatrixXd const &H); - -public: - std::shared_ptr<MshData> msh; - int nthreads; - - MshDeform(std::shared_ptr<MshData> _msh, int _nDim); - virtual ~MshDeform() { std::cout << "~MshDeform()\n"; } - - void setField(std::string const &fldName); - void addMoving(std::vector<std::string> const &fxdBndName); - void addFixed(std::vector<std::string> const &movBndName); - void setSymmetry(std::string const &symBndName, size_t _blck); - void addInternal(std::vector<std::string> const &intBndName); - void initialize(); - - void savePos(); - void build(Eigen::SparseMatrix<double, Eigen::RowMajor> &K); - void build(Eigen::VectorXd &f); - void deform(); -#ifndef SWIG - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace tbox - -#endif //WMSHDEFORM_H \ No newline at end of file diff --git a/tbox/src/wMshExport.cpp b/tbox/src/wMshExport.cpp deleted file mode 100644 index 3eca1043..00000000 --- a/tbox/src/wMshExport.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wMshExport.h" - -using namespace tbox; - -MshExport::MshExport(std::shared_ptr<MshData> _msh) : wSharedObject(), - msh(_msh), binary(true), - verb(false) -{ -} - -void MshExport::save(std::string const &fname) const -{ - throw std::runtime_error("tbox::MshExport::save not implemented!\n"); -} -void MshExport::save(std::string const &fname, Results const &r) const -{ - throw std::runtime_error("tbox::MshExport::save not implemented!\n"); -} diff --git a/tbox/src/wMshExport.h b/tbox/src/wMshExport.h deleted file mode 100644 index 50627aa1..00000000 --- a/tbox/src/wMshExport.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WMSHEXPORT_H -#define WMSHEXPORT_H - -#include "tbox.h" -#include "wObject.h" -#include "wMshData.h" -#include <memory> - -namespace tbox -{ - -/** - * @brief Base class to write mesh - * @authors Adrien Crovato, Romain Boman - */ -class TBOX_API MshExport : public fwk::wSharedObject -{ -public: - std::shared_ptr<MshData> msh; - bool binary; - bool verb; - - MshExport(std::shared_ptr<MshData> _msh); - virtual ~MshExport() {} - - virtual void save(std::string const &fname) const; -#ifndef SWIG - virtual void save(std::string const &fname, Results const &r) const; -#endif -}; - -} // namespace tbox - -#endif //WMSHEXPORT_H diff --git a/tbox/src/wMshImport.cpp b/tbox/src/wMshImport.cpp deleted file mode 100644 index 50eec162..00000000 --- a/tbox/src/wMshImport.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wMshImport.h" - -using namespace tbox; - -MshImport::MshImport(std::shared_ptr<MshData> _msh) : wSharedObject(), - msh(_msh), verb(false) -{ -} - -void MshImport::load(std::string const &fname, int myrank) -{ - throw std::runtime_error("tbox::MshImport::load not implemented!\n"); -} - -void MshImport::load(std::string const &fname, Results &r, int n) -{ - throw std::runtime_error("tbox::MshImport::load not implemented!\n"); -} diff --git a/tbox/src/wMshImport.h b/tbox/src/wMshImport.h deleted file mode 100644 index 07ebcf52..00000000 --- a/tbox/src/wMshImport.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WMSHIMPORT_H -#define WMSHIMPORT_H - -#include "tbox.h" -#include "wObject.h" -#include "wMshData.h" -#include <memory> - -namespace tbox -{ - -/** - * @brief Base class to read and load mesh - * @authors Adrien Crovato, Romain Boman - */ -class TBOX_API MshImport : public fwk::wSharedObject -{ -public: - std::shared_ptr<MshData> msh; - bool verb; - - MshImport(std::shared_ptr<MshData> _msh); - virtual ~MshImport() {} - - virtual void load(std::string const &fname, int myrank); - virtual void load(std::string const &fname, Results &r, int n = 0); -}; - -} // namespace tbox - -#endif //WMSHIMPORT_H diff --git a/tbox/src/wMumps.cpp b/tbox/src/wMumps.cpp deleted file mode 100644 index 4fe89818..00000000 --- a/tbox/src/wMumps.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wMumps.h" -#ifdef WAVES_USE_MUMPS - -#include <sstream> -using namespace tbox; - -// macros so that indices match documentation -#define ICNTL(I) icntl[(I)-1] -#define INFO(I) info[(I)-1] - -Mumps::Mumps() : LinearSolver() -{ - id.comm_fortran = -987654; // USE_COMM_WORLD; - id.par = 1; // host involved in factorization phase - id.sym = 0; // 0=unsymmetric, 1=symdef+, 2=symmetric - id.job = -1; // initialization phase - dmumps_c(&id); - - // Set default options (must set after id.job = -1) - // Verbosity level - id.ICNTL(1) = -1; // stream for error messages [def=6] - id.ICNTL(2) = -1; // stream for diag printing, statistics, warnings [def=0] - id.ICNTL(3) = -1; // stream for global information [def=6] - id.ICNTL(4) = 0; // level of printing [def=2] - // Matrix re-ordering - //0 : amd, 2 : amf, 3 : scotch, 4 : pord, 5 : metis, 6 :qamd, 7 : auto [def=7] - id.ICNTL(7) = 3; // defaults to scotch because mumps comes witch scotch if installed using apt - // Error analysis - id.ICNTL(11) = 0; // disabled - // Increase memory - id.ICNTL(14) = 40; - // Determinant - id.ICNTL(33) = 0; // disabled -} -Mumps::~Mumps() -{ - id.job = -2; - dmumps_c(&id); -} - -/** - * @brief Setup the matrix A - */ -void Mumps::configure(Eigen::SparseMatrix<double> const &A) -{ - // Check that matrix A is square - if (A.rows() != A.cols()) - throw std::runtime_error("tbox::Mumps::configure Matrix A is not square!\n"); - // Build data structure - // the matrix size, structure and number of nonzero entries can change at each iteration! - size_t nz = A.nonZeros(); - rows.clear(); - cols.clear(); - matx.clear(); - rows.reserve(nz); - cols.reserve(nz); - matx.reserve(nz); - // Get the nonzero indices and values - for (size_t k = 0; k < A.outerSize(); ++k) - for (Eigen::SparseMatrix<double>::InnerIterator it(A, k); it; ++it) - { - rows.push_back(static_cast<MUMPS_INT>(it.row() + 1)); - cols.push_back(static_cast<MUMPS_INT>(it.col() + 1)); - matx.push_back(it.value()); - } - // Set sizes - id.n = int(A.rows()); - id.nz = int(nz); - // Set matrix - id.a = &matx[0]; - // Set id - id.irn = &rows[0]; - id.jcn = &cols[0]; -} - -void Mumps::analyze(Eigen::SparseMatrix<double> const &A) -{ - this->configure(A); - id.job = 1; - dmumps_c(&id); -} -void Mumps::factorize(Eigen::SparseMatrix<double> const &A) -{ - this->configure(A); - id.job = 2; - dmumps_c(&id); -} -void Mumps::solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - Eigen::VectorXd vect = b; - id.rhs = vect.data(); - id.job = 3; - dmumps_c(&id); - check(); - x = vect; -} -void Mumps::compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - this->configure(A); - Eigen::VectorXd vect = b; - id.rhs = vect.data(); - id.job = 6; - dmumps_c(&id); - check(); - x = vect; -} - -/** - * @brief Check if an error occured during solve - */ -void Mumps::check() -{ - if (id.INFO(1) < 0) - { - std::stringstream err; - err << "tbox::Mumps: MUMPS failed with error " << id.INFO(1); - switch (id.INFO(1)) - { - case -2: - err << ": NZ = " << id.INFO(2) << " is out of range!\n"; - throw std::runtime_error(err.str()); - case -6: - case -10: - err << ": matrix is singular!\n"; - throw std::runtime_error(err.str()); - case -9: - err << ": increase ICNTL(14)!\n"; - throw std::runtime_error(err.str()); - case -13: - err << ": not enough memory!\n"; - throw std::runtime_error(err.str()); - default: - err << "!\n"; - throw std::runtime_error(err.str()); - } - } -} - -/** - * @brief Set option for MUMPS - */ -void Mumps::setOption(int k, int v) -{ - if (k > 0) - id.ICNTL(k) = v; - else - throw std::runtime_error("tbox::Mumps::setOption: option id 'k' must be strictly positive!\n"); -} - -void Mumps::write(std::ostream &out) const -{ - out << "MUMPS" << std::endl; -} - -#endif // WAVES_USE_MUMPS diff --git a/tbox/src/wMumps.h b/tbox/src/wMumps.h deleted file mode 100644 index 7eee1ca8..00000000 --- a/tbox/src/wMumps.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WMUMPS_H -#define WMUMPS_H - -#include "tbox.h" -#ifdef WAVES_USE_MUMPS - -#include "wLinearSolver.h" -#include <dmumps_c.h> -#include <Eigen/Sparse> -#include <limits> - -namespace tbox -{ - -/** - * @todo also output error in analyze and factorize, if any - */ - -/** - * @brief MUMPS interface - * - * Reference: https://github.com/rboman/math0471/blob/master/mumps/main.cpp - * Reference gmm_MUMPS_interface.h (old) - * @authors Adrien Crovato - */ -class TBOX_API Mumps : public LinearSolver -{ -private: - DMUMPS_STRUC_C id; ///< mumps structure - std::vector<MUMPS_INT> rows; ///< rows id - std::vector<MUMPS_INT> cols; ///< columns id - std::vector<double> matx; ///< matrix nonzero entries - - void configure(Eigen::SparseMatrix<double> const &A); - void check(); - -public: - Mumps(); - ~Mumps(); - -#ifndef SWIG - virtual void analyze(Eigen::SparseMatrix<double> const &A) override; - virtual void factorize(Eigen::SparseMatrix<double> const &A) override; - virtual void solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) override; - virtual void compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) override; - - virtual double getError() override { return std::numeric_limits<double>::epsilon(); } - virtual int getIterations() override { return 1; } - - virtual void write(std::ostream &out) const override; -#endif - void setOption(int k, int v); -}; - -} // namespace tbox - -#endif // WAVES_USE_MUMPS - -#endif // WMUMPS_H diff --git a/tbox/src/wNode.cpp b/tbox/src/wNode.cpp deleted file mode 100644 index 6c931d58..00000000 --- a/tbox/src/wNode.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wNode.h" - -using namespace tbox; - -void Node::write(std::ostream &out) const -{ - out << "node #" << no << " = " << pos.transpose() << " row=" << row; -} - -Node::Node(int n, Eigen::Vector3d const &p, int r) : wObject(), no(n), pos(p), row(r) -{ -} - -Node::Node() -{ - no = 0; - pos = Eigen::Vector3d(0., 0., 0.); - row = -1; -} diff --git a/tbox/src/wNode.h b/tbox/src/wNode.h deleted file mode 100644 index afcfd7e6..00000000 --- a/tbox/src/wNode.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WNODE_H -#define WNODE_H - -#include "tbox.h" -#include "wObject.h" -#include <vector> -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Node data structure - * @authors Romain Boman - */ -class TBOX_API Node : public fwk::wObject -{ -public: - int no; ///< node number - Eigen::Vector3d pos; ///< spatial position - int row; ///< row number in data vectors - - Node(int n, Eigen::Vector3d const &p, int r); - Node(); - -#ifndef SWIG - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace tbox - -#endif //WNODE_H diff --git a/tbox/src/wPardiso.cpp b/tbox/src/wPardiso.cpp deleted file mode 100644 index fbefb7f1..00000000 --- a/tbox/src/wPardiso.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wPardiso.h" -#ifdef WAVES_USE_MKL - -using namespace tbox; - -void Pardiso::analyze(Eigen::SparseMatrix<double> const &A) -{ - solver.analyzePattern(A); -} -void Pardiso::factorize(Eigen::SparseMatrix<double> const &A) -{ - solver.factorize(A); -} -void Pardiso::solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - x = solver.solve(b); -} -void Pardiso::compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - solver.compute(A); - x = solver.solve(b); -} - -/** - * @brief Set option for Pardiso - */ -void Pardiso::setOption(int k, int v) -{ - if (k >= 0) - solver.pardisoParameterArray()[k] = v; - else - throw std::runtime_error("tbox::Pardiso::setOption: option id 'k' must be positive!\n"); -} - -void Pardiso::write(std::ostream &out) const -{ - out << "Pardiso (MKL/Eigen)" << std::endl; -} - -#endif // WAVES_USE_MKL diff --git a/tbox/src/wPardiso.h b/tbox/src/wPardiso.h deleted file mode 100644 index a723c660..00000000 --- a/tbox/src/wPardiso.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WPARDISO_H -#define WPARDISO_H - -#include "tbox.h" -#ifdef WAVES_USE_MKL - -#include "wLinearSolver.h" -#include <Eigen/PardisoSupport> -#include <limits> - -namespace tbox -{ - -/** - * @brief Intel Pardiso interface - * @authors Adrien Crovato - */ -class TBOX_API Pardiso : public LinearSolver -{ - Eigen::PardisoLU<Eigen::SparseMatrix<double>> solver; - -public: - Pardiso() : LinearSolver() {} - virtual ~Pardiso() {} - -#ifndef SWIG - virtual void analyze(Eigen::SparseMatrix<double> const &A) override; - virtual void factorize(Eigen::SparseMatrix<double> const &A) override; - virtual void solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) override; - virtual void compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) override; - - virtual double getError() override { return std::numeric_limits<double>::epsilon(); } - virtual int getIterations() override { return 1; } - - virtual void write(std::ostream &out) const override; -#endif - void setOption(int k, int v); -}; - -} // namespace tbox - -#endif // WAVES_USE_MKL - -#endif // WPARDISO_H diff --git a/tbox/src/wPoint1.cpp b/tbox/src/wPoint1.cpp deleted file mode 100644 index e4cb27af..00000000 --- a/tbox/src/wPoint1.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wPoint1.h" -#include "wCachePoint1.h" -#include "wLazy.h" - -using namespace tbox; - -Point1::Point1(int n, Tag *_ptag, Tag *_etag, - std::vector<Tag *> &_parts, std::vector<Node *> &nods) : Element(n, _ptag, _etag, _parts, nods) -{ -} - -CachePoint1 &Point1::getCache(int n) -{ - static Lazy<CachePoint1> cache(n); - return cache.get(); -} - -Cache &Point1::getVCache() const -{ - return getCache(order); -} diff --git a/tbox/src/wPoint1.h b/tbox/src/wPoint1.h deleted file mode 100644 index fc78eb37..00000000 --- a/tbox/src/wPoint1.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WPOINT1_H -#define WPOINT1_H - -#include "tbox.h" -#include "wElement.h" - -namespace tbox -{ - -/** - * @brief Point element (0D) - * @authors Romain Boman - */ -class TBOX_API Point1 : public Element -{ -public: - Point1(int n, Tag *_ptag, Tag *_etag, std::vector<Tag *> &_parts, std::vector<Node *> &nods); - virtual ELTYPE type() const override { return ELTYPE::POINT1; } - -private: - static CachePoint1 &getCache(int n); - virtual Cache &getVCache() const override; -}; - -} // namespace tbox - -#endif //WPOINT1_H diff --git a/tbox/src/wQuad4.cpp b/tbox/src/wQuad4.cpp deleted file mode 100644 index c2ee84f6..00000000 --- a/tbox/src/wQuad4.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wQuad4.h" -#include "wSfQuad4.h" -#include "wGaussQuad4.h" -#include "wCacheQuad4.h" -#include "wNode.h" - -using namespace tbox; - -Quad4::Quad4(int n, Tag *_ptag, Tag *_etag, - std::vector<Tag *> &_parts, std::vector<Node *> &nods) : Element(n, _ptag, _etag, _parts, nods) -{ -} - -/** - * @brief Return cache holding shape functions and Gauss points for all Quad4 elements - */ -Cache &Quad4::getVCache() const -{ - return getCache(order); -} - -/** - * @brief Initialize precomputed values - */ -void Quad4::initValues(bool isvol, int ordr) -{ - // Set flags - isVol = isvol; - order = ordr; - hasVals = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - Js.resize(ngp); - iJs.resize(ngp); - detJs.resize(ngp); - this->update(); -} -/** - * @brief Initialize precomputed gradients - */ -void Quad4::initGradients() -{ - // Set flags - hasGrads = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - gradJs.resize(ngp); - gradDetJs.resize(ngp); - this->update(); -} -/** - * @brief Update precomputed values and gradients - */ -void Quad4::update() -{ - // Update values - if (hasVals) - { - // Jacobian and normal - // Quad4 is not of same dimension as Problem (surface element) - if (!isVol) - { - this->buildSurfaceJ(); - this->computeNormal(); - } - // Quad4 is of same dimension as Problem (volume element) - else - this->buildJ(); - // Volume and CG - this->computeV(); - this->computeCg(); - } - // Update gradients - if (hasGrads) - { - // Jacobian, volume and normal - // Quad4 is not of same dimension as Problem (surface element) - if (!isVol) - { - this->buildGradientSurfaceJ(); - this->buildGradientV(3); // gradient of surface - this->computeGradientNormal(); - } - // Quad4 is of same dimension as Problem (volume element) - else - { - this->buildGradientJ(); - this->buildGradientV(2); // gradient of volume - } - } -} - -/** - * @brief Compute Jacobian determinant - * - * detJ = norm(x_i dN_i,xi X x_i dN_i,eta) - */ -void Quad4::buildSurfaceJ() -{ - for (size_t k = 0; k < getCache(order).getVGauss().getN(); ++k) - { - std::vector<Eigen::Vector3d> ts = this->buildTangents(k); - detJs[k] = ts[0].cross(ts[1]).norm(); - } -} -/** - * @brief Compute Jacobian matrix, inverse and determinant at Gauss point k - * - * J_ij(2,2) = diN_n * xj_n (n is the node) - */ -void Quad4::buildJ() -{ - CacheQuad4 &cache = getCache(order); - for (size_t k = 0; k < cache.getVGauss().getN(); ++k) - { - Eigen::MatrixXd const &dff = cache.getDsf(k); - - Eigen::Matrix2d JJ = Eigen::Matrix2d::Zero(); // temporary fixed-size matrix to efficiently compute the inverse - size_t i = 0; - for (auto it = nodes.begin(); it != nodes.end(); ++it, ++i) - JJ += dff.col(i) * (*it)->pos.transpose().block<1, 2>(0, 0); - Js[k] = JJ; - iJs[k] = JJ.inverse(); - detJs[k] = JJ.determinant(); - this->checkJac(k); - } -} - -/** - * @brief Return the element surface - */ -void Quad4::computeV() -{ - CacheQuad4 &cache = getCache(order); - GaussQuad4 &gauss = cache.gauss; - - // Gauss integration - vol = 0.0; - for (size_t k = 0; k < gauss.getN(); ++k) - vol += gauss.getW(k) * this->getDetJ(k); -} - -/** - * @brief Compute element tangent vectors - */ -std::vector<Eigen::Vector3d> Quad4::computeTangents() const -{ - Eigen::Vector3d x1 = nodes[0]->pos; - Eigen::Vector3d x3 = nodes[2]->pos; - Eigen::Vector3d x4 = nodes[3]->pos; - - return std::vector<Eigen::Vector3d>{(x3 - x1), (x4 - x1)}; -} - -/** - * @brief Build element tangent vectors using shape functions at Gauss point k - */ -std::vector<Eigen::Vector3d> Quad4::buildTangents(size_t k) const -{ - Eigen::MatrixXd const &dff = getCache(order).getDsf(k); - - std::vector<Eigen::Vector3d> t(2, Eigen::Vector3d::Zero()); - size_t i = 0; - for (auto it = nodes.begin(); it != nodes.end(); ++it, ++i) - { - t[0] += (*it)->pos * dff(0, i); - t[1] += (*it)->pos * dff(1, i); - } - return t; -} - -/** - * @brief Compute element unit normal vector - */ -void Quad4::computeNormal() -{ - std::vector<Eigen::Vector3d> ts = this->computeTangents(); - normal = ts[0].cross(ts[1]).normalized(); -} diff --git a/tbox/src/wQuad4.h b/tbox/src/wQuad4.h deleted file mode 100644 index 75cde412..00000000 --- a/tbox/src/wQuad4.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WQUAD4_H -#define WQUAD4_H - -#include "tbox.h" -#include "wLazy.h" -#include "wElement.h" -#include "wCacheQuad4.h" - -namespace tbox -{ - -/** - * @brief Linear quadrangle finite element - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API Quad4 : public Element -{ -#ifndef SWIG -private: - inline static CacheQuad4 &getCache(int n); - -protected: - virtual void buildJ() override; - virtual void buildSurfaceJ() override; - virtual void computeV() override; - virtual std::vector<Eigen::Vector3d> computeTangents() const override; - virtual std::vector<Eigen::Vector3d> buildTangents(size_t k) const override; - virtual void computeNormal() override; -#endif - -public: - Quad4(int n, Tag *_ptag, Tag *_etag, std::vector<Tag *> &_parts, std::vector<Node *> &nods); - virtual ~Quad4() {} - virtual ELTYPE type() const override { return ELTYPE::QUAD4; } - -#ifndef SWIG - virtual void initValues(bool isvol, int ordr = 2) override; - virtual void initGradients() override; - virtual void update() override; - virtual Cache &getVCache() const override; -#endif -}; - -#include "wQuad4.inl" - -} // namespace tbox - -#endif //WQUAD4_H diff --git a/tbox/src/wQuad4.inl b/tbox/src/wQuad4.inl deleted file mode 100644 index e77859ff..00000000 --- a/tbox/src/wQuad4.inl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @brief Return cache for Quad4 private methods - */ -inline CacheQuad4 &Quad4::getCache(int n) -{ - static Lazy<CacheQuad4> cache(n); - return cache.get(); -} diff --git a/tbox/src/wResults.cpp b/tbox/src/wResults.cpp deleted file mode 100644 index 3cde9f46..00000000 --- a/tbox/src/wResults.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wResults.h" - -using namespace tbox; - -Results::Results() -{ - nt = 0; - time = 0.0; -} - -void Results::write(std::ostream &out) const -{ - out << "Results (nt=" << nt << ", time=" << time << ")\n"; - - if (!scalars_at_nodes.empty()) - { - out << scalars_at_nodes.size() << " scalars at nodes: "; - for (auto &p : scalars_at_nodes) - { - out << "\t'" << p.first << "' (size=" << p.second->size() << ")\n"; - } - } - if (!scalars_at_elems.empty()) - { - out << scalars_at_elems.size() << " scalars at elems: "; - for (auto &p : scalars_at_elems) - { - out << "\t'" << p.first << "' (size=" << p.second->size() << ")\n"; - } - } - if (!vectors_at_nodes.empty()) - { - out << vectors_at_nodes.size() << " vectors at nodes: "; - for (auto &p : vectors_at_nodes) - { - out << "\t'" << p.first << "' (size=" << p.second->size() << ")\n"; - } - } - if (!vectors_at_elems.empty()) - { - out << vectors_at_elems.size() << " vectors at elems: "; - for (auto &p : vectors_at_elems) - { - out << "\t'" << p.first << "' (size=" << p.second->size() << ")\n"; - } - } - if (!tensors_at_nodes.empty()) - { - out << tensors_at_nodes.size() << " tensors at nodes: "; - for (auto &p : tensors_at_nodes) - { - out << "\t'" << p.first << "' (size=" << p.second->size() << ")\n"; - } - } - if (!tensors_at_elems.empty()) - { - out << tensors_at_elems.size() << " tensors at elems: "; - for (auto &p : tensors_at_elems) - { - out << "\t'" << p.first << "' (size=" << p.second->size() << ")\n"; - } - } -} diff --git a/tbox/src/wResults.h b/tbox/src/wResults.h deleted file mode 100644 index 7ffa42f0..00000000 --- a/tbox/src/wResults.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WRESULTS_H -#define WRESULTS_H - -#include "tbox.h" -#include "wObject.h" -#include <string> -#include <vector> -#include <map> -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Results data structure - * @authors Romain Boman - */ -class TBOX_API Results : public fwk::wObject -{ -public: -#ifndef SWIG - int nt; - double time; - std::map<std::string, std::vector<double> *> scalars_at_nodes; - std::map<std::string, std::vector<double> *> scalars_at_slave_nodes; - std::map<std::string, std::vector<double> *> scalars_at_elems; - std::map<std::string, std::vector<Eigen::Vector3d> *> vectors_at_nodes; - std::map<std::string, std::vector<Eigen::Vector3d> *> vectors_at_elems; - std::map<std::string, std::vector<Eigen::MatrixXd> *> tensors_at_nodes; - std::map<std::string, std::vector<Eigen::MatrixXd> *> tensors_at_elems; -#endif - - Results(); - -#ifndef SWIG - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace tbox - -#endif //WRESULTS_H diff --git a/tbox/src/wSfHex8.cpp b/tbox/src/wSfHex8.cpp deleted file mode 100644 index efda54be..00000000 --- a/tbox/src/wSfHex8.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wSfHex8.h" - -using namespace tbox; - -void SfHex8::eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const -{ - ff.resize(8); - double x = ksi(0); - double y = ksi(1); - double z = ksi(2); - - ff(0) = 0.125 * (1.0 + x) * (1.0 + y) * (1.0 - z); - ff(1) = 0.125 * (1.0 - x) * (1.0 + y) * (1.0 - z); - ff(2) = 0.125 * (1.0 - x) * (1.0 - y) * (1.0 - z); - ff(3) = 0.125 * (1.0 + x) * (1.0 - y) * (1.0 - z); - ff(4) = 0.125 * (1.0 + x) * (1.0 + y) * (1.0 + z); - ff(5) = 0.125 * (1.0 - x) * (1.0 + y) * (1.0 + z); - ff(6) = 0.125 * (1.0 - x) * (1.0 - y) * (1.0 + z); - ff(7) = 0.125 * (1.0 + x) * (1.0 - y) * (1.0 + z); -} - -void SfHex8::evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const -{ - dff.resize(3, 8); - double x = ksi(0); - double y = ksi(1); - double z = ksi(2); - - dff(0, 0) = 0.125 * (1.0 + y) * (1.0 - z); - dff(1, 0) = 0.125 * (1.0 + x) * (1.0 - z); - dff(2, 0) = -0.125 * (1.0 + x) * (1.0 + y); - dff(0, 1) = -0.125 * (1.0 + y) * (1.0 - z); - dff(1, 1) = 0.125 * (1.0 - x) * (1.0 - z); - dff(2, 1) = -0.125 * (1.0 - x) * (1.0 + y); - dff(0, 2) = -0.125 * (1.0 - y) * (1.0 - z); - dff(1, 2) = -0.125 * (1.0 - x) * (1.0 - z); - dff(2, 2) = -0.125 * (1.0 - x) * (1.0 - y); - dff(0, 3) = 0.125 * (1.0 - y) * (1.0 - z); - dff(1, 3) = -0.125 * (1.0 + x) * (1.0 - z); - dff(2, 3) = -0.125 * (1.0 + x) * (1.0 - y); - dff(0, 4) = 0.125 * (1.0 + y) * (1.0 + z); - dff(1, 4) = 0.125 * (1.0 + x) * (1.0 + z); - dff(2, 4) = 0.125 * (1.0 + x) * (1.0 + y); - dff(0, 5) = -0.125 * (1.0 + y) * (1.0 + z); - dff(1, 5) = 0.125 * (1.0 - x) * (1.0 + z); - dff(2, 5) = 0.125 * (1.0 - x) * (1.0 + y); - dff(0, 6) = -0.125 * (1.0 - y) * (1.0 + z); - dff(1, 6) = -0.125 * (1.0 - x) * (1.0 + z); - dff(2, 6) = 0.125 * (1.0 - x) * (1.0 - y); - dff(0, 7) = 0.125 * (1.0 - y) * (1.0 + z); - dff(1, 7) = -0.125 * (1.0 + x) * (1.0 + z); - dff(2, 7) = 0.125 * (1.0 + x) * (1.0 - y); -} diff --git a/tbox/src/wSfHex8.h b/tbox/src/wSfHex8.h deleted file mode 100644 index 0e599115..00000000 --- a/tbox/src/wSfHex8.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WSFHEX8_H -#define WSFHEX8_H - -#include "tbox.h" -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Hex8 shape functions - * @authors Romain Boman - */ -class TBOX_API SfHex8 -{ -public: - SfHex8() {} - void eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const; - void evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const; -}; - -} // namespace tbox - -#endif //WSFHEX8_H diff --git a/tbox/src/wSfLine2.cpp b/tbox/src/wSfLine2.cpp deleted file mode 100644 index 7f99efd6..00000000 --- a/tbox/src/wSfLine2.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wSfLine2.h" - -using namespace tbox; - -void SfLine2::eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const -{ - ff.resize(2); - double x = ksi(0); - - ff(0) = 0.5 * (1.0 + x); - ff(1) = 0.5 * (1.0 - x); -} - -void SfLine2::evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const -{ - dff.resize(1, 2); - - dff(0, 0) = 0.5; - dff(0, 1) = -0.5; -} diff --git a/tbox/src/wSfLine2.h b/tbox/src/wSfLine2.h deleted file mode 100644 index d29ad34f..00000000 --- a/tbox/src/wSfLine2.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WSFLINE2_H -#define WSFLINE2_H - -#include "tbox.h" -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Line2 shape functions - * @authors Romain Boman - */ -class TBOX_API SfLine2 -{ -public: - SfLine2() {} - void eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const; - void evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const; -}; - -} // namespace tbox - -#endif //WSFLINE2_H diff --git a/tbox/src/wSfQuad4.cpp b/tbox/src/wSfQuad4.cpp deleted file mode 100644 index da595381..00000000 --- a/tbox/src/wSfQuad4.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wSfQuad4.h" - -using namespace tbox; - -void SfQuad4::eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const -{ - ff.resize(4); - double x = ksi(0); - double y = ksi(1); - - ff(0) = 0.250 * (1.0 + x) * (1.0 + y); - ff(1) = 0.250 * (1.0 - x) * (1.0 + y); - ff(2) = 0.250 * (1.0 - x) * (1.0 - y); - ff(3) = 0.250 * (1.0 + x) * (1.0 - y); -} - -void SfQuad4::evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const -{ - dff.resize(2, 4); - double x = ksi(0); - double y = ksi(1); - - dff(0, 0) = 0.250 * (1.0 + y); - dff(1, 0) = 0.250 * (1.0 + x); - dff(0, 1) = -0.250 * (1.0 + y); - dff(1, 1) = 0.250 * (1.0 - x); - dff(0, 2) = -0.250 * (1.0 - y); - dff(1, 2) = -0.250 * (1.0 - x); - dff(0, 3) = 0.250 * (1.0 - y); - dff(1, 3) = -0.250 * (1.0 + x); -} diff --git a/tbox/src/wSfQuad4.h b/tbox/src/wSfQuad4.h deleted file mode 100644 index 93ef0dab..00000000 --- a/tbox/src/wSfQuad4.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WSFQUAD4_H -#define WSFQUAD4_H - -#include "tbox.h" -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Quad4 shape functions - * @authors Romain Boman - */ -class TBOX_API SfQuad4 -{ -public: - SfQuad4() {} - void eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const; - void evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const; -}; - -} // namespace tbox - -#endif //WSFQUAD4_H diff --git a/tbox/src/wSfTetra4.cpp b/tbox/src/wSfTetra4.cpp deleted file mode 100644 index 322e5ccd..00000000 --- a/tbox/src/wSfTetra4.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wSfTetra4.h" - -using namespace tbox; - -void SfTetra4::eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const -{ - ff.resize(4); - double x = ksi(0); - double y = ksi(1); - double z = ksi(2); - - ff(0) = 1.0 - x - y - z; - ff(1) = x; - ff(2) = y; - ff(3) = z; -} - -void SfTetra4::evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const -{ - dff.resize(3, 4); - - dff(0, 0) = -1.0; - dff(1, 0) = -1.0; - dff(2, 0) = -1.0; - dff(0, 1) = 1.0; - dff(1, 1) = 0.0; - dff(2, 1) = 0.0; - dff(0, 2) = 0.0; - dff(1, 2) = 1.0; - dff(2, 2) = 0.0; - dff(0, 3) = 0.0; - dff(1, 3) = 0.0; - dff(2, 3) = 1.0; -} diff --git a/tbox/src/wSfTetra4.h b/tbox/src/wSfTetra4.h deleted file mode 100644 index f40e8323..00000000 --- a/tbox/src/wSfTetra4.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WSFTETRA4_H -#define WSFTETRA4_H - -#include "tbox.h" -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Tetra4 shape functions - * @authors Romain Boman - */ -class TBOX_API SfTetra4 -{ -public: - SfTetra4() {} - void eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const; - void evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const; -}; - -} // namespace tbox - -#endif //WSFTETRA4_H diff --git a/tbox/src/wSfTri3.cpp b/tbox/src/wSfTri3.cpp deleted file mode 100644 index ff79cda4..00000000 --- a/tbox/src/wSfTri3.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wSfTri3.h" - -using namespace tbox; - -void SfTri3::eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const -{ - ff.resize(3); - double x = ksi(0); - double y = ksi(1); - - ff(0) = 1.0 - x - y; - ff(1) = x; - ff(2) = y; -} - -void SfTri3::evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const -{ - dff.resize(2, 3); - - dff(0, 0) = -1.0; - dff(1, 0) = -1.0; - dff(0, 1) = 1.0; - dff(1, 1) = 0.0; - dff(0, 2) = 0.0; - dff(1, 2) = 1.0; -} diff --git a/tbox/src/wSfTri3.h b/tbox/src/wSfTri3.h deleted file mode 100644 index 5e8f2286..00000000 --- a/tbox/src/wSfTri3.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WSFTRI3_H -#define WSFTRI3_H - -#include "tbox.h" -#include <Eigen/Dense> - -namespace tbox -{ - -/** - * @brief Tri3 shape functions - * @authors Romain Boman - */ -class TBOX_API SfTri3 -{ -public: - SfTri3() {} - void eval(Eigen::Vector3d const &ksi, Eigen::VectorXd &ff) const; - void evalD(Eigen::Vector3d const &ksi, Eigen::MatrixXd &dff) const; -}; - -} // namespace tbox - -#endif //WSFTRI3_H diff --git a/tbox/src/wSparseLu.cpp b/tbox/src/wSparseLu.cpp deleted file mode 100644 index e22a5271..00000000 --- a/tbox/src/wSparseLu.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wSparseLu.h" -using namespace tbox; - -void SparseLu::analyze(Eigen::SparseMatrix<double> const &A) -{ - solver.analyzePattern(A); -} -void SparseLu::factorize(Eigen::SparseMatrix<double> const &A) -{ - solver.factorize(A); -} -void SparseLu::solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - x = solver.solve(b); -} -void SparseLu::compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) -{ - solver.compute(A); - x = solver.solve(b); -} - -void SparseLu::write(std::ostream &out) const -{ - out << "SparseLU (Eigen)" << std::endl; -} diff --git a/tbox/src/wSparseLu.h b/tbox/src/wSparseLu.h deleted file mode 100644 index 323a5d62..00000000 --- a/tbox/src/wSparseLu.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WSPARSELU_H -#define WSPARSELU_H - -#include "tbox.h" -#include "wLinearSolver.h" -#include <Eigen/Sparse> -#include <limits> - -namespace tbox -{ - -/** - * @brief SparseLU interface - * - * Note that SparseLU should be used with ColMajor matrices - * @authors Adrien Crovato - */ -class TBOX_API SparseLu : public LinearSolver -{ - Eigen::SparseLU<Eigen::SparseMatrix<double>> solver; - -public: - SparseLu() : LinearSolver() {} - virtual ~SparseLu() {} - -#ifndef SWIG - virtual void analyze(Eigen::SparseMatrix<double> const &A) override; - virtual void factorize(Eigen::SparseMatrix<double> const &A) override; - virtual void solve(Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) override; - virtual void compute(Eigen::SparseMatrix<double> const &A, Eigen::Map<Eigen::VectorXd> const &b, Eigen::Map<Eigen::VectorXd> &x) override; - - virtual double getError() override { return std::numeric_limits<double>::epsilon(); } - virtual int getIterations() override { return 1; } - - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace tbox - -#endif // WSPARSELU_H diff --git a/tbox/src/wTag.cpp b/tbox/src/wTag.cpp deleted file mode 100644 index e0089e79..00000000 --- a/tbox/src/wTag.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wTag.h" -#include "wElement.h" -#include <map> - -using namespace tbox; - -void Tag::write(std::ostream &out) const -{ - out << "Tag #" << no << " (" << dim; - out << "D) named \"" << name << "\" (" << elems.size() << " elements) "; - - // count each type - std::map<ELTYPE, int> types; - for (auto e : elems) - types[e->type()] += 1; - - // display - for (auto &p : types) - out << p.first << ":" << p.second << " "; -} diff --git a/tbox/src/wTag.h b/tbox/src/wTag.h deleted file mode 100644 index 0c264e62..00000000 --- a/tbox/src/wTag.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WTAG_H -#define WTAG_H - -#include "tbox.h" -#include "wObject.h" -#include <string> -#include <vector> - -namespace tbox -{ - -/** - * @brief a Tag is a named group of 1D, 2D or 3D elements - * - * The label related to: - * - the underlying geometrical entity of the elements - * - a (named) "physical entity" - * - a mesh partition - * @authors Romain Boman - */ - -class TBOX_API Tag : public fwk::wObject -{ -public: - int no; ///< label - int dim; ///< dimension (1, 2 or 3 for 1D, 2D or 3D - see .msh) - std::string name; ///< name given in gmsh - std::vector<Element *> elems; ///< list of elements with this tag - - Tag(int _no, std::string const &_name = Tag::defaultName(), int _dim = 0) : wObject(), no(_no), dim(_dim), name(_name) {} - static const std::string &defaultName() - { - static const std::string name("---"); - return name; - } - -#ifndef SWIG - virtual void write(std::ostream &out) const override; -#endif -}; - -} // namespace tbox - -#endif //WTAG_H diff --git a/tbox/src/wTetra4.cpp b/tbox/src/wTetra4.cpp deleted file mode 100644 index 8c1b42ab..00000000 --- a/tbox/src/wTetra4.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wTetra4.h" -#include "wSfTetra4.h" -#include "wGaussTetra4.h" -#include "wCacheTetra4.h" -#include "wNode.h" - -using namespace tbox; - -Tetra4::Tetra4(int n, Tag *_ptag, Tag *_etag, - std::vector<Tag *> &_parts, std::vector<Node *> &nods) : Element(n, _ptag, _etag, _parts, nods) -{ -} - -/** - * @brief Return cache handling shape functions and Gauss points for all Tetra4 elements - */ -Cache &Tetra4::getVCache() const -{ - return getCache(order); -} - -/** - * @brief Initialize precomputed values - */ -void Tetra4::initValues(bool isvol, int ordr) -{ - // Set flags - isVol = isvol; - order = ordr; - hasVals = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - Js.resize(ngp); - iJs.resize(ngp); - detJs.resize(ngp); - this->update(); -} -/** - * @brief Initialize precomputed gradients - */ -void Tetra4::initGradients() -{ - // Set flags - hasGrads = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - gradJs.resize(ngp); - gradDetJs.resize(ngp); - this->update(); -} -/** - * @brief Update precomputed values and gradients - */ -void Tetra4::update() -{ - // Update gradients - if (hasVals) - { - // Jacobian - if (!isVol) - throw std::runtime_error("Tetra4::update(): the problem must always have the same dimension as Tetra4!\n"); - // Tetra4 is always of same dimension as Problem (volume element) - this->buildJ(); - // Volume and CG - this->computeV(); - this->computeCg(); - } - // Update gradients - if (hasGrads) - { - // Jacobian - if (!isVol) - throw std::runtime_error("Tetra4::updateGradients(): the problem must always have the same dimension as Tetra4!\n"); - // Tetra4 is always of same dimension as Problem (volume element) - this->buildGradientJ(); - // Volume - this->buildGradientV(3); - } -} - -/** - * @brief Compute Jacobian matrix, inverse and determinant - * - * J_ij(3,3) = diN_n * xj_n (n is the node) - */ -void Tetra4::buildJ() -{ - CacheTetra4 &cache = getCache(order); - for (size_t k = 0; k < cache.getVGauss().getN(); ++k) - { - Eigen::MatrixXd const &dff = cache.getDsf(k); - - Eigen::Matrix3d JJ = Eigen::Matrix3d::Zero(); // temporary fixed-size matrix to efficiently compute the inverse - size_t i = 0; - for (auto it = nodes.begin(); it != nodes.end(); ++it, ++i) - JJ += dff.col(i) * ((*it)->pos).transpose(); - Js[k] = JJ; - iJs[k] = JJ.inverse(); - detJs[k] = JJ.determinant(); - this->checkJac(k); - } -} - -/** - * @brief Compute Jacobian matrix and determinant gradient with respect to each node coordinate - * - * dJ[l = i * 3 + j](3,3) = dN_i(3,1) * dxy_i(1,3)/dx_l (for node i and dimension j) - */ -void Tetra4::buildGradientJ() -{ - CacheTetra4 &cache = getCache(order); - for (size_t k = 0; k < cache.getVGauss().getN(); ++k) - { - Eigen::MatrixXd const &dsf = getCache(order).getDsf(k); - - // Jacobian - gradJs[k].resize(4 * 3); // 4 nodes and 3 dimensions (x, y, z) - for (size_t i = 0; i < 4; ++i) - { - for (size_t j = 0; j < 3; ++j) - { - gradJs[k][i * 3 + j] = Eigen::Matrix3d::Zero(); - gradJs[k][i * 3 + j].col(j) = dsf.col(i); // retain sf gradients associated to ith node for dimension j - } - } - // Determinant - double detJ = this->getDetJ(k); - Eigen::MatrixXd const &iJ = this->getJinv(k); - gradDetJs[k].resize(4 * 3); - for (size_t i = 0; i < 4 * 3; ++i) - gradDetJs[k][i] = detJ * (iJ * gradJs[k][i]).trace(); - } -} - -/** - * @brief Return the element volume - */ -void Tetra4::computeV() -{ - CacheTetra4 &cache = getCache(order); - GaussTetra4 &gauss = cache.gauss; - - // Gauss integration - vol = 0.0; - for (size_t k = 0; k < gauss.getN(); ++k) - vol += gauss.getW(k) * this->getDetJ(k); -} -/** - * @brief Compute volume gradient with respect to each node coordinate - * - * dV[i] = w_k * dDetJ[i]_k - */ -void Tetra4::buildGradientV(int dim) -{ - GaussTetra4 &gauss = getCache(order).gauss; - - // Gradient of volume - gradVol.resize(4 * dim, 0.); // 4 nodes - for (size_t k = 0; k < gauss.getN(); ++k) - { - double w = gauss.getW(k); // GP weight - std::vector<double> dDetJ = this->getGradDetJ(k); // gradient of Jacobian determinant - for (size_t i = 0; i < dDetJ.size(); ++i) - gradVol[i] += w * dDetJ[i]; - } -} - -/** - * @brief Compute gradient of a scalar field at Gauss point k - */ -Eigen::VectorXd Tetra4::computeGradient(std::vector<double> const &u, size_t k) const -{ - // Solution vector - Eigen::Vector4d ue; - for (size_t i = 0; i < nodes.size(); ++i) - ue(i) = u[nodes[i]->row]; - // gradient in global axis: inv(J)_ij * d_jN_i * ue_i - return this->getJinv(k) * getCache(order).getDsf(k) * ue; -} diff --git a/tbox/src/wTetra4.h b/tbox/src/wTetra4.h deleted file mode 100644 index 371dcba8..00000000 --- a/tbox/src/wTetra4.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WTETRA4_H -#define WTETRA4_H - -#include "tbox.h" -#include "wLazy.h" -#include "wElement.h" -#include "wCacheTetra4.h" - -namespace tbox -{ - -/** - * @brief Linear tetrahedron finite element - * @authors Kim Liegeois, Romain Boman, Adrien Crovato - */ -class TBOX_API Tetra4 : public Element -{ -#ifndef SWIG -private: - inline static CacheTetra4 &getCache(int n); - -protected: - virtual void buildJ() override; - virtual void buildGradientJ() override; - virtual void computeV() override; - virtual void buildGradientV(int dim) override; -#endif - -public: - Tetra4(int n, Tag *_ptag, Tag *_etag, std::vector<Tag *> &_parts, std::vector<Node *> &nods); - virtual ~Tetra4() {} - virtual ELTYPE type() const override { return ELTYPE::TETRA4; } - -#ifndef SWIG - virtual void initValues(bool isvol, int ordr = 2) override; - virtual void initGradients() override; - virtual void update() override; - virtual Cache &getVCache() const override; - virtual Eigen::VectorXd computeGradient(std::vector<double> const &u, size_t k) const override; -#endif -}; - -#include "wTetra4.inl" - -} // namespace tbox - -#endif //WTETRA4_H diff --git a/tbox/src/wTetra4.inl b/tbox/src/wTetra4.inl deleted file mode 100644 index 64d5d52a..00000000 --- a/tbox/src/wTetra4.inl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @brief Return cache for Tetra4 private methods - */ -inline CacheTetra4 &Tetra4::getCache(int n) -{ - static Lazy<CacheTetra4> cache(n); - return cache.get(); -} diff --git a/tbox/src/wTri3.cpp b/tbox/src/wTri3.cpp deleted file mode 100644 index ea16dd09..00000000 --- a/tbox/src/wTri3.cpp +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wTri3.h" -#include "wSfTri3.h" -#include "wGaussTri3.h" -#include "wCacheTri3.h" -#include "wNode.h" - -using namespace tbox; - -Tri3::Tri3(int n, Tag *_ptag, Tag *_etag, - std::vector<Tag *> &_parts, std::vector<Node *> &nods) : Element(n, _ptag, _etag, _parts, nods) -{ -} - -/** - * @brief Return cache holding shape functions and Gauss points for all Tri3 elements - */ -Cache &Tri3::getVCache() const -{ - return getCache(order); -} - -/** - * @brief Initialize precomputed values - */ -void Tri3::initValues(bool isvol, int ordr) -{ - // Set flags - isVol = isvol; - order = ordr; - hasVals = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - Js.resize(ngp); - iJs.resize(ngp); - detJs.resize(ngp); - this->update(); -} -/** - * @brief Initialize precomputed gradients - */ -void Tri3::initGradients() -{ - // Set flags - hasGrads = true; - // Update values - size_t ngp = getCache(order).getVGauss().getN(); - gradJs.resize(ngp); - gradDetJs.resize(ngp); - this->update(); -} -/** - * @brief Update precomputed values and gradients - */ -void Tri3::update() -{ - // Update values - if (hasVals) - { - // Jacobian and normal - // Tri3 is not of same dimension as Problem (surface element) - if (!isVol) - { - this->buildSurfaceJ(); - this->computeNormal(); - } - // Tri3 is of same dimension as Problem (volume element) - else - this->buildJ(); - // Volume and CG - this->computeV(); - this->computeCg(); - } - // Update gradients - if (hasGrads) - { - // Jacobian, volume and normal - // Tri3 is not of same dimension as Problem (surface element) - if (!isVol) - { - this->buildGradientSurfaceJ(); - this->buildGradientV(3); - this->computeGradientNormal(); - } - // Tri3 is of same dimension as Problem (volume element) - else - { - this->buildGradientJ(); - this->buildGradientV(2); - } - } -} - -/** - * @brief Compute Jacobian determinant - * - * detJ = norm(x_i dN_i,xi X x_i dN_i,eta) - */ -void Tri3::buildSurfaceJ() -{ - for (size_t k = 0; k < getCache(order).getVGauss().getN(); ++k) - { - std::vector<Eigen::Vector3d> ts = this->buildTangents(k); - detJs[k] = ts[0].cross(ts[1]).norm(); - } -} -/** - * @brief Compute Jacobian matrix, inverse and determinant - * - * J_ij(2,2) = diN_n * xj_n (n is the node) - */ -void Tri3::buildJ() -{ - CacheTri3 &cache = getCache(order); - for (size_t k = 0; k < cache.getVGauss().getN(); ++k) - { - Eigen::MatrixXd const &dff = getCache(order).getDsf(k); - - Eigen::Matrix2d JJ = Eigen::Matrix2d::Zero(); // temporary fixed-size matrix to efficiently compute the inverse - size_t i = 0; - for (auto it = nodes.begin(); it != nodes.end(); ++it, ++i) - JJ += dff.col(i) * (*it)->pos.transpose().block<1, 2>(0, 0); - Js[k] = JJ; - iJs[k] = JJ.inverse(); - detJs[k] = JJ.determinant(); - this->checkJac(k); - } -} - -/** - * @brief Compute Jacobian determinant gradient with respect to each node coordinate - * - * dDetJ[l = i * 3 + j] = detJ_l * (dt0 \cross t1 + t0 \cross dt1)_l; - */ -void Tri3::buildGradientSurfaceJ() -{ - CacheTri3 &cache = getCache(order); - for (size_t k = 0; k < getCache(order).getVGauss().getN(); ++k) - { - // Shape functions, tangent vectors and determinant - Eigen::MatrixXd const &dsf = cache.getDsf(k); - std::vector<Eigen::Vector3d> ts = this->buildTangents(k); - Eigen::Vector3d detJ = ts[0].cross(ts[1]).normalized(); - - // Jacobian gradient - gradDetJs[k].resize(3 * 3); // 3 nodes and 3 dimensions (x, y, z) - for (size_t i = 0; i < 3; ++i) - { - for (size_t j = 0; j < 3; ++j) - { - Eigen::Vector3d dt0 = Eigen::Vector3d::Zero(), dt1 = Eigen::Vector3d::Zero(); - dt0(j) = dsf(0, i); - dt1(j) = dsf(1, i); // retain sf gradients associated to ith node for dimension j - gradDetJs[k][i * 3 + j] = detJ.dot(dt0.cross(ts[1]) + ts[0].cross(dt1)); - } - } - } -} -/** - * @brief Compute Jacobian matrix gradient with respect to each node coordinate - * - * dJ[l = i * 2 + j](2,2) = dN_i(2,1) * dxy_i(1,2)/dx_l (for node i and dimension j) - */ -void Tri3::buildGradientJ() -{ - CacheTri3 &cache = getCache(order); - for (size_t k = 0; k < cache.getVGauss().getN(); ++k) - { - Eigen::MatrixXd const &dsf = cache.getDsf(k); - - // Jacobian - gradJs[k].resize(3 * 2); // 3 nodes and 2 dimensions (x, y) - for (size_t i = 0; i < 3; ++i) - { - for (size_t j = 0; j < 2; ++j) - { - gradJs[k][i * 2 + j] = Eigen::Matrix2d::Zero(); - gradJs[k][i * 2 + j].col(j) = dsf.col(i); // retain sf gradients associated to ith node for dimension j - } - } - // Determinant - double detJ = this->getDetJ(k); - Eigen::MatrixXd const &iJ = this->getJinv(k); - gradDetJs[k].resize(3 * 2); - for (size_t i = 0; i < 3 * 2; ++i) - gradDetJs[k][i] = detJ * (iJ * gradJs[k][i]).trace(); - } -} - -/** - * @brief Return the element surface - */ -void Tri3::computeV() -{ - CacheTri3 &cache = getCache(order); - GaussTri3 &gauss = cache.gauss; - - // Gauss integration - vol = 0.0; - for (size_t k = 0; k < gauss.getN(); ++k) - vol += gauss.getW(k) * this->getDetJ(k); -} -/** - * @brief Compute volume gradient with respect to each node coordinate - * - * dV[i] = w_k * dDetJ[i]_k - */ -void Tri3::buildGradientV(int dim) -{ - GaussTri3 &gauss = getCache(order).gauss; - - // Gradient of volume - gradVol.resize(3 * dim, 0.); // 3 nodes - for (size_t k = 0; k < gauss.getN(); ++k) - { - double w = gauss.getW(k); // GP weight - std::vector<double> dDetJ = this->getGradDetJ(k); // gradient of Jacobian determinant - for (size_t i = 0; i < dDetJ.size(); ++i) - gradVol[i] += w * dDetJ[i]; - } -} - -/** - * @brief Compute element tangent vectors - */ -std::vector<Eigen::Vector3d> Tri3::computeTangents() const -{ - Eigen::Vector3d x1 = nodes[0]->pos; - Eigen::Vector3d x2 = nodes[1]->pos; - Eigen::Vector3d x3 = nodes[2]->pos; - - return std::vector<Eigen::Vector3d>{(x2 - x1), (x3 - x1)}; -} - -/** - * @brief Build element tangent vectors using shape functions at Gauss point k - */ -std::vector<Eigen::Vector3d> Tri3::buildTangents(size_t k) const -{ - Eigen::MatrixXd const &dff = getCache(order).getDsf(k); - - std::vector<Eigen::Vector3d> t(2, Eigen::Vector3d::Zero()); - size_t i = 0; - for (auto it = nodes.begin(); it != nodes.end(); ++it, ++i) - { - t[0] += (*it)->pos * dff(0, i); - t[1] += (*it)->pos * dff(1, i); - } - return t; -} - -/** - * @brief Compute element unit normal vector - */ -void Tri3::computeNormal() -{ - std::vector<Eigen::Vector3d> ts = this->computeTangents(); - normal = ts[0].cross(ts[1]).normalized(); -} - -/** - * @brief Compute gradient of element unit normal vector with respect to each node coordinate - */ -void Tri3::computeGradientNormal() -{ - // Compute normal and norm - std::vector<Eigen::Vector3d> ts = this->computeTangents(); - Eigen::Vector3d n = ts[0].cross(ts[1]); - double nn = n.norm(); - - // Compute gradients - Eigen::Matrix3d inn = (Eigen::Matrix3d::Identity() - n * n.transpose() / (nn * nn)) / nn; // gradient of n/|n| - gradNormal.resize(3 * 3); // 3 nodes and 3 dimensions - for (size_t i = 0; i < 3; ++i) - { - for (size_t j = 0; j < 3; ++j) - { - Eigen::Matrix3d dx = Eigen::Matrix3d::Zero(); - dx(j, i) = 1; // dpos_i / dx_j - gradNormal[i * 3 + j] = inn * ((dx.col(1) - dx.col(0)).cross(ts[1]) + (ts[0]).cross(dx.col(2) - dx.col(0))); // outer gradient times gradient of cross product - } - } -} - -/** - * @brief Compute gradient of a scalar field at Gauss point k - */ -Eigen::VectorXd Tri3::computeGradient(std::vector<double> const &u, size_t k) const -{ - // Solution vector - Eigen::Vector3d ue; - for (size_t i = 0; i < nodes.size(); ++i) - ue(i) = u[nodes[i]->row]; - // Gradient in global axis: inv(J)_ij * d_jN_i * ue_i - return this->getJinv(k) * getCache(order).getDsf(k) * ue; -} diff --git a/tbox/src/wTri3.h b/tbox/src/wTri3.h deleted file mode 100644 index c042c4c5..00000000 --- a/tbox/src/wTri3.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WTRI3_H -#define WTRI3_H - -#include "tbox.h" -#include "wLazy.h" -#include "wElement.h" -#include "wCacheTri3.h" - -namespace tbox -{ - -/** - * @brief Linear triangle finite element - * @authors Romain Boman, Adrien Crovato - */ -class TBOX_API Tri3 : public Element -{ -#ifndef SWIG -private: - inline static CacheTri3 &getCache(int order); - -protected: - virtual void buildJ() override; - virtual void buildSurfaceJ() override; - virtual void buildGradientJ() override; - virtual void buildGradientSurfaceJ() override; - virtual void computeV() override; - virtual void buildGradientV(int dim) override; - virtual void computeNormal() override; - virtual void computeGradientNormal() override; - virtual std::vector<Eigen::Vector3d> computeTangents() const override; - virtual std::vector<Eigen::Vector3d> buildTangents(size_t k) const override; -#endif - -public: - Tri3(int n, Tag *_ptag, Tag *_etag, std::vector<Tag *> &_parts, std::vector<Node *> &nods); - virtual ~Tri3() {} - virtual ELTYPE type() const override { return ELTYPE::TRI3; } - -#ifndef SWIG - virtual void initValues(bool isvol, int ordr = 2) override; - virtual void initGradients() override; - virtual void update() override; - virtual Cache &getVCache() const override; - virtual Eigen::VectorXd computeGradient(std::vector<double> const &u, size_t k) const override; -#endif -}; - -#include "wTri3.inl" - -} // namespace tbox - -#endif //WTRI3_H diff --git a/tbox/src/wTri3.inl b/tbox/src/wTri3.inl deleted file mode 100644 index 57f12736..00000000 --- a/tbox/src/wTri3.inl +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @brief Return cache for Tri3 private methods - */ -inline CacheTri3 &Tri3::getCache(int n) -{ - static Lazy<CacheTri3> cache(n); - return cache.get(); -} diff --git a/tbox/src/wUnitTest.cpp b/tbox/src/wUnitTest.cpp deleted file mode 100644 index 7b886c29..00000000 --- a/tbox/src/wUnitTest.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wUnitTest.h" -#include "wMshData.h" -#include "wNode.h" -#include "wElement.h" -#include "wGmshImport.h" -#include "wGmshExport.h" -#include "wResults.h" -#include "wMshDeform.h" -#include <Eigen/Dense> - -using namespace tbox; - -/** - * @brief Write and read results to/from disk - */ -void UnitTest::gmshIO(GmshExport *writer, GmshImport *reader) -{ - // Mesh - auto mesh = writer->msh; // should be the same than in reader->msh - - // Variables to be written then read - std::vector<double> x(mesh->nodes.size(), 0), type(mesh->elems.size(), 0); // x-position, element type - std::vector<Eigen::Vector3d> xyz(mesh->nodes.size(), Eigen::Vector3d::Zero()); // x,y,z-position - - // Temporary results container - Results res; - res.scalars_at_nodes["x"] = &x; - res.vectors_at_nodes["xyz"] = &xyz; - res.scalars_at_elems["type"] = &type; - - // Fill the variables and write them to disk - for (size_t i = 0; i < mesh->nodes.size(); ++i) - { - x[i] = mesh->nodes[i]->pos(0); - xyz[i] = mesh->nodes[i]->pos; - } - for (size_t i = 0; i < mesh->elems.size(); ++i) - type[i] = static_cast<double>(mesh->elems[i]->type()); - writer->binary = false; // because we cannot read files in bin format yet... - writer->save(mesh->name, res); - - // Clear the variables and read them from disk - std::fill(x.begin(), x.end(), 0); - std::fill(xyz.begin(), xyz.end(), Eigen::Vector3d::Zero()); - std::fill(type.begin(), type.end(), 0); - reader->load(mesh->name + ".pos", res, 0); - - // Test that the variables have the required value - for (size_t i = 0; i < x.size(); ++i) - if (x[i] != mesh->nodes[i]->pos(0)) - this->error("gmshIO", std::to_string(x[i]), std::to_string(mesh->nodes[i]->pos(0))); - for (size_t i = 0; i < xyz.size(); ++i) - if (xyz[i] != mesh->nodes[i]->pos) - this->error("gmshIO", - "(" + std::to_string(xyz[i](0)) + "," + std::to_string(xyz[i](1)) + "," + std::to_string(xyz[i](2)) + ")", - "(" + std::to_string(mesh->nodes[i]->pos(0)) + "," + std::to_string(mesh->nodes[i]->pos(1)) + "," + std::to_string(mesh->nodes[i]->pos(2)) + ")"); - for (size_t i = 0; i < type.size(); ++i) - if (type[i] != static_cast<double>(mesh->elems[i]->type())) - this->error("gmshIO", std::to_string(type[i]), std::to_string(static_cast<double>(mesh->elems[i]->type()))); -} - -/** - * @brief Deform a mesh of dimension d - */ -void UnitTest::mshDeform(MshDeform *mshDef, int d) -{ - // Initialize memory (volume element only) - for (auto e : mshDef->msh->elems) - if ((d == 2 && e->type() == ELTYPE::TRI3) || (d == 3 && e->type() == ELTYPE::TETRA4)) - e->initValues(true); - // Call deform - mshDef->deform(); -} - -/** - * @brief Print error on failure - */ -void UnitTest::error(std::string const &name, std::string const &computed, std::string const &expected) -{ - std::string message = "tbox::UnitTest::" + name + " failed! Computed: " + computed + " but expected: " + expected + ".\n"; - throw std::runtime_error(message); -} diff --git a/tbox/src/wUnitTest.h b/tbox/src/wUnitTest.h deleted file mode 100644 index 4a515676..00000000 --- a/tbox/src/wUnitTest.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WUNITTEST_H -#define WUNITTEST_H - -#include "tbox.h" -#include "wObject.h" - -namespace tbox -{ - -/** - * @brief Tests for tbox - * @authors Adrien Crovato - */ -class TBOX_API UnitTest : public fwk::wObject -{ - void error(std::string const &name, std::string const &computed, std::string const &expected); - -public: - UnitTest() : wObject() {} - virtual ~UnitTest() {} - - void gmshIO(GmshExport *writer, GmshImport *reader); - void mshDeform(MshDeform *mshDef, int d); -}; - -} // namespace tbox - -#endif //WUNITTEST_H diff --git a/tbox/tests/basicops.py b/tbox/tests/basicops.py deleted file mode 100644 index 0d1fb9c9..00000000 --- a/tbox/tests/basicops.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import tbox - -def main(): - - print("creating a Point") - p1 = tbox.Vector3d(0., 0., 0.) - print(p1) - print("creating a Node") - n1 = tbox.Node(1, p1, 0) - print(n1) - print("accessing Node position") - pos = n1.pos - print(pos) - -if __name__ == "__main__": - main() - diff --git a/tbox/tests/fem/elem1s.py b/tbox/tests/fem/elem1s.py deleted file mode 100644 index a14f11b9..00000000 --- a/tbox/tests/fem/elem1s.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# basic tests on single finite elements - -import tbox -import tbox.gmsh as gmsh - -def main(**d): - - # 1 triangle - print('='*80+'\nTesting Tri\n'+'='*80) - msh = gmsh.MeshLoader('tri1.geo',__file__).execute() - - el = msh.ntags['S1'].elems[0] - print(el) - - # 1 hex - print('='*80+'\nTesting Hex\n'+'='*80) - msh = gmsh.MeshLoader('hex1.geo',__file__).execute() - - el = msh.ntags['Volume'].elems[0] - print(el) - - # 1 quad - print('='*80+'\nTesting Quad\n'+'='*80) - - msh = gmsh.MeshLoader('quad1.geo',__file__).execute() - - el = msh.ntags['S1'].elems[0] - print(el) - - -if __name__ == "__main__": - main() diff --git a/tbox/tests/fem/hex1.geo b/tbox/tests/fem/hex1.geo deleted file mode 100644 index 6926b5ed..00000000 --- a/tbox/tests/fem/hex1.geo +++ /dev/null @@ -1,49 +0,0 @@ -// a cube meshed with hex - -DefineConstant[ Lx = { 1, Min 5, Max 20, Step 1, Name "Lengths/Lx" } ]; -DefineConstant[ Ly = { 1, Min 5, Max 20, Step 1, Name "Lengths/Ly" } ]; -DefineConstant[ Lz = { 1, Min 1, Max 2, Step 1, Name "Lengths/Lz" } ]; - -DefineConstant[ Nx = { 1, Min 1, Max 200, Step 10, Name "Mesh/Nx" } ]; -DefineConstant[ Ny = { 1, Min 1, Max 200, Step 10, Name "Mesh/Ny" } ]; -DefineConstant[ Nz = { 1, Min 1, Max 200, Step 10, Name "Mesh/Nz" } ]; - -lc = 1; // useless -Point(1) = { 0, 0, 0, lc}; -Point(2) = { Lx, 0, 0, lc}; -Point(3) = { Lx, Ly, 0, lc}; -Point(4) = { 0, Ly, 0, lc}; - -Line(1) = {1, 2}; -Line(2) = {2, 3}; -Line(3) = {3, 4}; -Line(4) = {4, 1}; - -Line Loop(5) = {1, 2, 3, 4}; - -Plane Surface(6) = {5}; - -Transfinite Line {1, 3} = Nx+1 Using Progression 1; -Transfinite Line {4, 2} = Ny+1 Using Progression 1; - -Transfinite Surface {6}; -Recombine Surface {6}; -Extrude {0, 0, Lz} { - Surface{6}; Layers{Nz}; Recombine; -} -Physical Volume("Volume") = {1}; - -Physical Surface("FaceZ0") = {6}; -Physical Surface("FaceZ1") = {28}; -Physical Surface("FaceY0") = {15}; -Physical Surface("FaceX1") = {19}; -Physical Surface("FaceY1") = {23}; -Physical Surface("FaceX0") = {27}; - -Physical Line("Line1") = {13}; -Physical Line("Line2") = {14}; -Physical Line("Line3") = {18}; -Physical Line("Line4") = {22}; - - - diff --git a/tbox/tests/fem/quad1.geo b/tbox/tests/fem/quad1.geo deleted file mode 100644 index 4aac824c..00000000 --- a/tbox/tests/fem/quad1.geo +++ /dev/null @@ -1,36 +0,0 @@ -// a square meshed with quads - -DefineConstant[ Lx = { 1, Min 5, Max 20, Step 1, Name "Lengths/Lx" } ]; -DefineConstant[ Ly = { 1, Min 5, Max 20, Step 1, Name "Lengths/Ly" } ]; - -DefineConstant[ Nx = { 1, Min 1, Max 200, Step 10, Name "Mesh/Nx" } ]; -DefineConstant[ Ny = { 1, Min 1, Max 200, Step 10, Name "Mesh/Ny" } ]; - -lc = 1; // useless -Point(1) = { 0, 0, 0, lc}; -Point(2) = { Lx, 0, 0, lc}; -Point(3) = { Lx, Ly, 0, lc}; -Point(4) = { 0, Ly, 0, lc}; - -Line(1) = {1, 2}; -Line(2) = {2, 3}; -Line(3) = {3, 4}; -Line(4) = {4, 1}; - -Line Loop(1) = {1, 2, 3, 4}; -Plane Surface(1) = {1}; - -Transfinite Line {1, 3} = Nx+1 Using Progression 1; -Transfinite Line {2, 4} = Ny+1 Using Progression 1; -Recombine Surface {1}; - -Physical Point("P1") = {1}; -Physical Point("P2") = {2}; -Physical Point("P3") = {3}; -Physical Point("P4") = {4}; -Physical Line("Bottom") = {1}; -Physical Line("Right") = {2}; -Physical Line("Top") = {3}; -Physical Line("Left") = {4}; -Physical Surface("S1") = {1}; - diff --git a/tbox/tests/fem/tri1.geo b/tbox/tests/fem/tri1.geo deleted file mode 100644 index eef7a140..00000000 --- a/tbox/tests/fem/tri1.geo +++ /dev/null @@ -1,21 +0,0 @@ -// a triangle - -Point(1) = { 0, 0, 0, 2}; -Point(2) = { 1, 0, 0, 2}; -Point(3) = { 0, 1, 0, 2}; - -Line(1) = {1, 2}; -Line(2) = {2, 3}; -Line(3) = {3, 1}; - -Line Loop(1) = {1, 2, 3}; -Plane Surface(1) = {1}; - -Physical Point("P1") = {1}; -Physical Point("P2") = {2}; -Physical Point("P3") = {3}; -Physical Line("L1") = {1}; -Physical Line("L2") = {2}; -Physical Line("L3") = {3}; -Physical Surface("S1") = {1}; - diff --git a/tbox/tests/gmshio.py b/tbox/tests/gmshio.py deleted file mode 100755 index 6e876a86..00000000 --- a/tbox/tests/gmshio.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import tbox -import tbox.gmsh as gmsh - -def main(): - # test read/write mesh - msh = gmsh.MeshLoader("models/model.geo",__file__).execute() - printtags(msh) - - gmshWriter = tbox.GmshExport(msh) - print(gmshWriter) - gmshWriter.save(msh.name) - - gmshReader = tbox.GmshImport(msh) # could be reused from gmsh.MeshLoader - print(gmshReader) - - # test read/write results - test = tbox.UnitTest() - test.gmshIO(gmshWriter, gmshReader) - -def printtags(mshdata): - print("\n-ptags:") - for t in list(mshdata.ptags.items()): - print(t[1]) - print("\n-etags:") - for t in list(mshdata.etags.items()): - print(t[1]) - print("\n-partitions:") - for t in list(mshdata.parts.items()): - print(t[1]) - -if __name__ == "__main__": - main() - diff --git a/tbox/tests/helloworld.slurm.sh b/tbox/tests/helloworld.slurm.sh deleted file mode 100755 index fd76eec2..00000000 --- a/tbox/tests/helloworld.slurm.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -# Submission script for NIC4 -#SBATCH --job-name=helloworld -#SBATCH --time=00:00:10 # hh:mm:ss -# -#SBATCH --ntasks=2 -#SBATCH --mem-per-cpu=200 # megabytes -#SBATCH --partition=defq -# -#SBATCH --mail-user=rboman -#SBATCH --mail-type=ALL -# -#SBATCH --comment=math0471 - -. ~/.bash_profile master2 - -module list -mpirun python-mpi helloworld.py diff --git a/tbox/tests/meshDeformation.py b/tbox/tests/meshDeformation.py deleted file mode 100644 index a1870488..00000000 --- a/tbox/tests/meshDeformation.py +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# Test mesh deformation - -import numpy as np -import tbox -import tbox.gmsh as gmsh -import fwk -from fwk.wutils import parseargs - -def main(): - - # timer - tms = fwk.Timers() - tms["total"].start() - - # parameters for mesh deformation - dx = 0.1 - dy = -0.6 - - # mesh an beam - pars = {} - msh = gmsh.MeshLoader("models/beam.geo",__file__).execute(**pars) - gmshWriter = tbox.GmshExport(msh) - # create mesh deformation handler - mshDef = tbox.MshDeform(msh, 2) - mshDef.setField("internalField") - mshDef.addFixed(["clamp"]) - mshDef.addMoving(["tip"]) - mshDef.initialize() - args = parseargs() - mshDef.nthreads = args.k - - # deform the mesh (dummy translation of "tip" nodes) - mshDef.savePos() - msh.nodes[1].pos[0] += dx - msh.nodes[1].pos[1] += dy - msh.nodes[2].pos[0] += dx - msh.nodes[2].pos[1] += dy - - # deform the mesh - test = tbox.UnitTest() - tms["deform"].start() - test.mshDeform(mshDef, 2) - tms["deform"].stop() - gmshWriter.save("beam_def") - - # display timers - tms["total"].stop() - print("CPU statistics") - print(tms) - - # eof - print('') - -if __name__ == "__main__": - main() diff --git a/tbox/tests/meshDeformation3.py b/tbox/tests/meshDeformation3.py deleted file mode 100644 index 9fe169ee..00000000 --- a/tbox/tests/meshDeformation3.py +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# Test mesh deformation - -import numpy as np -import tbox -import tbox.gmsh as gmsh -import fwk -from fwk.wutils import parseargs - -def main(): - - # timer - tms = fwk.Timers() - tms["total"].start() - - # parameters for mesh deformation - dz = 1.5 - - # mesh an beam - pars = {} - msh = gmsh.MeshLoader("models/beam3.geo",__file__).execute(**pars) - gmshWriter = tbox.GmshExport(msh) - # create mesh deformation handler - mshDef = tbox.MshDeform(msh, 3) - mshDef.setField("field") - mshDef.addFixed(["clamp"]) - mshDef.addMoving(["tip"]) - mshDef.initialize() - args = parseargs() - mshDef.nthreads = args.k - - # deform the mesh (dummy translation of "tip" nodes) - mshDef.savePos() - msh.nodes[4].pos[2] += dz - msh.nodes[5].pos[2] += dz - msh.nodes[6].pos[2] += dz - msh.nodes[7].pos[2] += dz - - # deform the mesh - test = tbox.UnitTest() - tms["deform"].start() - test.mshDeform(mshDef, 3) - tms["deform"].stop() - gmshWriter.save(msh.name+"_def") - - # display timers - tms["total"].stop() - print("CPU statistics") - print(tms) - - # eof - print('') - -if __name__ == "__main__": - main() diff --git a/tbox/tests/models/beam.geo b/tbox/tests/models/beam.geo deleted file mode 100644 index c67ef26a..00000000 --- a/tbox/tests/models/beam.geo +++ /dev/null @@ -1,21 +0,0 @@ -Point(1) = {0 ,0,0}; -Point(2) = {10,0,0}; -Point(3) = {10,1,0}; -Point(4) = {0 ,1,0}; - -Line(1) = {1,2}; -Line(2) = {2,3}; -Line(3) = {3,4}; -Line(4) = {4,1}; - -Line Loop(1) = {1,2,3,4}; -Surface(1) = {1}; - -Transfinite Line{1, 3} = 10+1; -Transfinite Line{2, 4} = 1+1; - -Transfinite Surface{1} = {1, 2, 3, 4}; - -Physical Surface("internalField", 10) = {1}; -Physical Line("clamp", 11) = {4}; -Physical Line("tip", 12) = {2}; diff --git a/tbox/tests/models/beam3.geo b/tbox/tests/models/beam3.geo deleted file mode 100644 index 23d5d9a1..00000000 --- a/tbox/tests/models/beam3.geo +++ /dev/null @@ -1,47 +0,0 @@ -Point(1) = {0 ,0,0,1}; -Point(2) = {1 ,0,0,1}; -Point(3) = {1 ,0,2,1}; -Point(4) = {0 ,0,2,1}; -Point(5) = {0 ,10,0,1}; -Point(6) = {1 ,10,0,1}; -Point(7) = {1 ,10,2,1}; -Point(8) = {0 ,10,2,1}; - - -Line(1) = {1,2}; -Line(2) = {2,3}; -Line(3) = {3,4}; -Line(4) = {4,1}; -Line(5) = {5,6}; -Line(6) = {6,7}; -Line(7) = {7,8}; -Line(8) = {8,5}; -Line(9) = {1,5}; -Line(10) = {2,6}; -Line(11) = {3,7}; -Line(12) = {4,8}; - -Line Loop(1) = {1,2,3,4}; -Surface(1) = {-1}; -Line Loop(2) = {5,6,7,8}; -Surface(2) = {2}; -Line Loop(3) = {1,10,-5,-9}; -Surface(3) = {3}; -Line Loop(4) = {2,11,-6,-10}; -Surface(4) = {4}; -Line Loop(5) = {3,12,-7,-11}; -Surface(5) = {5}; -Line Loop(6) = {4,9,-8,-12}; -Surface(6) = {6}; - -Surface Loop(1) = {1,2,3,4,5,6}; -Volume(1) = (1); - -Transfinite Line{1,2,3,4,5,6,7,8} = 1+1; -Transfinite Line{9,10,11,12} = 10+1; -Transfinite Surface{1,2,3,4,5,6}; - -Physical Volume("field") = {1}; -Physical Surface("clamp") = {1}; -Physical Surface("tip") = {2}; -Physical Surface("side") = {3,4,5,6}; diff --git a/tbox/tests/models/model.geo b/tbox/tests/models/model.geo deleted file mode 100644 index 2543d346..00000000 --- a/tbox/tests/models/model.geo +++ /dev/null @@ -1,14 +0,0 @@ -Point(1) = { 0, 0, 0, 0.1}; -Point(2) = { 1, 0, 0, 0.2}; -Point(3) = { 1, 1, 0, 0.3}; -Point(4) = { 0, 1, 0, 0.1}; - -Line(1) = {1, 2}; -Line(2) = {2, 3}; -Line(3) = {3, 4}; -Line(4) = {4, 1}; - -Line Loop(1) = {1, 2, 3, 4}; -Plane Surface(1) = {1}; - - diff --git a/tbox/tests/mpi/helloworld.py b/tbox/tests/mpi/helloworld.py deleted file mode 100644 index 1a247750..00000000 --- a/tbox/tests/mpi/helloworld.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -""" -Parallel Hello World -""" - -from mpi4py import MPI -import sys - -size = MPI.COMM_WORLD.Get_size() -rank = MPI.COMM_WORLD.Get_rank() -name = MPI.Get_processor_name() - -sys.stdout.write( - "Hello, World! I am process %d of %d on %s.\n" - % (rank, size, name)) diff --git a/tbox/utils.py b/tbox/utils.py deleted file mode 100644 index 7d32f8dc..00000000 --- a/tbox/utils.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -"""@package docstring -Utilities for tbox -Adrien Crovato -""" - -def myrange(start, stop, step): - """Extended range with custom step - Adrien Crovato - """ - vec = [] - i = start - while i <= stop: - vec.append(i) - i += step - return vec - -def plot(x, y, xlbl, ylbl, title, invert=False): - """Plot using matplotlib - Adrien Crovato - @todo extend to pass unlimited number of arguments - """ - from fwk.wutils import parseargs - args = parseargs() - if not args.nogui: - import matplotlib.pyplot as plt - # define font - font = {'family': 'serif', - 'color': 'darkred', - 'weight': 'normal', - 'size': 16,} - # plot results - plt.plot(x, y, 'b-',lw=2) - plt.xlabel(xlbl, fontdict=font) - plt.ylabel(ylbl, fontdict=font) - plt.title(title, fontdict=font) - if invert: - plt.gca().invert_yaxis() - #plt.grid(True) - plt.show() - -def sort(id, data): - """Sort data array against id (line connectivity list) - Adrien Crovato - """ - import numpy as np - # sort id vector - id = id[id[:,0].argsort(),:] - # deep copy of data - _data = np.zeros((data.shape[0], data.shape[1])) - _data[:] = data - # sort data against id - _max = np.argmax(data[:,0]) - data[0,:] = _data[_max,:] - nextId = id[np.where(id[:, 0]==_max)[0][0], 0] - for i in range(1, id.shape[0]): - data[i,:] = _data[id[nextId,1],:] - nextId = id[nextId,1] - -def read(filename): - """Read from file and store in data array - Adrien Croavto - """ - import io - import numpy as np - # read file - fl = io.open(filename, 'r') - label = fl.readline().split(',') - fl.close() - data = np.loadtxt(filename, delimiter=',', skiprows=1) - return data - -def write(data, name, frmt, dlm, hdr, cmts): - """Write data array to file - Adrien Crovato - """ - import numpy as np - print('writing data file ' + name + '.') - np.savetxt(name, data, fmt=frmt, delimiter=dlm, header=hdr, comments=cmts) diff --git a/tbox/viewer.py b/tbox/viewer.py deleted file mode 100644 index ddabbc90..00000000 --- a/tbox/viewer.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import os, os.path - -class GUI: - """Default GUI for gmsh - Romain Boman - """ - def __init__(self): - pass - def open(self,prefix): - mshfile = prefix+".msh" - if not os.path.isfile(mshfile): - raise Exception("file not found %s" % mshfile) - posfile = prefix+".pos" - if not os.path.isfile(posfile): - raise Exception("file not found %s" % posfile) - optfile = prefix+".opt" - if not os.path.isfile(optfile): - self.defopt(optfile) - cmd="gmsh %s %s %s" % (mshfile, posfile, optfile) - os.system(cmd) - - def defopt(self,fname='defaultflowOpt.opt'): - f = open(fname,'w') - f.write("General.Orthographic = 0;\n") - f.close() - diff --git a/tboxVtk/CMakeLists.txt b/tboxVtk/CMakeLists.txt deleted file mode 100644 index 156e07c4..00000000 --- a/tboxVtk/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Add source dir -ADD_SUBDIRECTORY( src ) -ADD_SUBDIRECTORY( _src ) - -# Add test dir -MACRO_AddTest(${CMAKE_CURRENT_SOURCE_DIR}/tests) diff --git a/tboxVtk/__init__.py b/tboxVtk/__init__.py deleted file mode 100644 index d687db1b..00000000 --- a/tboxVtk/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -# -*- coding: utf-8 -*- -# tboxVtk MODULE initialization file - -# Copyright 2018 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import fwk -from tboxVtkw import * - diff --git a/tboxVtk/_src/CMakeLists.txt b/tboxVtk/_src/CMakeLists.txt deleted file mode 100644 index dbf06c35..00000000 --- a/tboxVtk/_src/CMakeLists.txt +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake file for the SWIG interface of tboxVtk.so - -INCLUDE(${SWIG_USE_FILE}) - -FILE(GLOB SRCS *.h *.cpp *.inl *.swg) -FILE(GLOB ISRCS *.i) - -SET(CMAKE_SWIG_FLAGS "") -SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES CPLUSPLUS ON) - -SET(SWINCFLAGS --I${PROJECT_SOURCE_DIR}/tboxVtk/src --I${PROJECT_SOURCE_DIR}/tbox/src --I${PROJECT_SOURCE_DIR}/tbox/_src --I${PROJECT_SOURCE_DIR}/fwk/src --I${PROJECT_SOURCE_DIR}/fwk/_src -) -SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES SWIG_FLAGS "${SWINCFLAGS}") - -if (${CMAKE_VERSION} VERSION_LESS "3.8.0") - SWIG_ADD_MODULE(tboxVtkw python ${ISRCS} ${SRCS}) -else() - SWIG_ADD_LIBRARY(tboxVtkw LANGUAGE python SOURCES ${ISRCS} ${SRCS}) -endif() -MACRO_DebugPostfix(_tboxVtkw) - -TARGET_INCLUDE_DIRECTORIES(_tboxVtkw PRIVATE ${PROJECT_SOURCE_DIR}/tboxVtk/_src - ${PROJECT_SOURCE_DIR}/fwk/_src - ${PROJECT_SOURCE_DIR}/tbox/_src - ${PYTHON_INCLUDE_PATH} -) - -SWIG_LINK_LIBRARIES(tboxVtkw - tboxVtk tbox fwk ${PYTHON_LIBRARIES} -) diff --git a/tboxVtk/_src/tboxVtkw.h b/tboxVtk/_src/tboxVtkw.h deleted file mode 100644 index f1349687..00000000 --- a/tboxVtk/_src/tboxVtkw.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wVtkExport.h" diff --git a/tboxVtk/_src/tboxVtkw.i b/tboxVtk/_src/tboxVtkw.i deleted file mode 100644 index 2a7ec115..00000000 --- a/tboxVtk/_src/tboxVtkw.i +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// tboxVtk.i: SWIG input file of the tboxVtk python interface - -%feature("autodoc","1"); - -%module(docstring= -"'tboxVtkw' module: Vtk for shared tools -(c) ULg - A&M", -directors="1", -threads="1" -) tboxVtkw -%{ - -//#if defined(_WIN32) && defined(__GNUC__) -#undef _hypot -#include <cmath> -//#endif - -#include <memory> -#include <string> -#include <sstream> -#include <typeinfo> -#include "tboxVtk.h" - -#include "fwkw.h" -#include "tboxw.h" -#include "tboxVtkw.h" - -%} - -%include "fwkw.swg" - -// ----------- MODULES UTILISES ------------ -%import "tboxw.i" - -// ----------- TBOXVTK CLASSES ---------------- -%include "tboxVtk.h" - -%shared_ptr(tboxVtk::VtkExport) -%include "wVtkExport.h" diff --git a/tboxVtk/cutter.py b/tboxVtk/cutter.py deleted file mode 100644 index f0dc2260..00000000 --- a/tboxVtk/cutter.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# @brief VTK cut plane post-processing -# @authors Adrien Crovato, Kim Liegeois - -try: - import vtk -except: - raise Exception('VTK not found. Aborting!\n') - -class Cutter: - def __init__(self, _grid): - self.grid = _grid - - def cut(self, tag, cutO, cutN, tag_name="tag"): - ''' - Cut the physical group ided "tag" with a plane defined by point "cutO" and normal "cutN" - ''' - import numpy as np - # create a threshold containing the physical group (tag) to cut - thresh = vtk.vtkThreshold() - thresh.ThresholdBetween(tag,tag) - thresh.SetInputConnection(self.grid) - thresh.SetInputArrayToProcess(0, 0, 0, vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS, tag_name) # "tag" is the default name set in tboxVtk::VtkExport::save - thresh.Update() - # create cutting plane - plane = vtk.vtkPlane() - plane.SetOrigin(cutO[0], cutO[1], cutO[2]) - plane.SetNormal(cutN[0], cutN[1], cutN[2]) - # cut the threshold and get data - cutter = vtk.vtkCutter() - cutter.SetCutFunction(plane) - cutter.SetInputConnection(thresh.GetOutputPort()) - cutter.Update() - return cutter.GetOutput() - - def extract(self, cutData, tagDim, vname, atPoint = True): - ''' - Extract points "pts", connectivity list "elems" and data "vals" named "vname" from cutting plane data "cutData". - The physical group dimension is given by "tagDim" and "atPoint" is True if vname is defined at points. - ''' - import numpy as np - # transfer point coordinates - _pts = cutData.GetPoints() - pts = np.zeros((_pts.GetNumberOfPoints(), 3)) - for i in range(0, pts.shape[0]): - for j in range(0, 3): - pts[i][j] = _pts.GetPoint(i)[j] - # transfer connectivity - if tagDim == 3: - _elems = cutData.GetPolys().GetData() - nV = 3 # assumes that all Poly(gon)s are triangles - elif tagDim == 2: - _elems = cutData.GetLines().GetData() - nV = 2 - else: - raise Exception('tagDim can only be 2 or 3 but ' + tagDim + ' was given!\n') - elems = np.zeros((_elems.GetNumberOfTuples() // (nV+1), nV), dtype=int) - for i in range(0, elems.shape[0]): - for j in range(0, nV): - elems[i][j] = _elems.GetTuple((nV+1)*i+j+1)[0] - # transfer variables - vals = {} - for name in vname: - if atPoint: # data at points - _vals = cutData.GetPointData().GetArray(name) - else: # data at elements - _vals = cutData.GetCellData().GetArray(name) - vals[name] = np.zeros((_vals.GetNumberOfTuples(), _vals.GetNumberOfComponents())) - for i in range(0, vals[name].shape[0]): - for j in range(0, vals[name].shape[1]): - vals[name][i][j] = _vals.GetTuple(i)[j] - return pts, elems, vals diff --git a/tboxVtk/lineExtractor.py b/tboxVtk/lineExtractor.py deleted file mode 100644 index df305b5c..00000000 --- a/tboxVtk/lineExtractor.py +++ /dev/null @@ -1,153 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# @brief VTK cut plane post-processing -# @authors Adrien Crovato, Kim Liegeois - -try: - import vtk -except: - raise Exception('VTK not found. Aborting!\n') - -class LineExtractor: - def __init__(self, _grid): - self.grid = _grid - - def cut(self, tag, p1, p2, tag_name="tag"): - ''' - Cut the physical group ided tag_name="tag" with a line defined by point "p1" and normal "p2" - ''' - import numpy as np - self.p1 = np.zeros((3,)) - self.p2 = np.zeros((3,)) - for j in range(0, 3): - self.p1[j] = p1[j] - self.p2[j] = p2[j] - - p12 = self.p2-self.p1 - - v1 = np.zeros((3,)) - v1[0] = 1 - - if np.linalg.norm(np.cross(v1,p12)) != 0: - v1 = np.cross(v1, p12) - v2 = np.cross(v1, p12) - else: - v1[0] = 0 - v1[1] = 1 - v2 = np.zeros((3,)) - v2[2] = 1 - - # create a threshold containing the physical group (tag) to cut - thresh = vtk.vtkThreshold() - thresh.ThresholdBetween(tag,tag) - thresh.SetInputConnection(self.grid) - thresh.SetInputArrayToProcess(0, 0, 0, vtk.vtkDataObject.FIELD_ASSOCIATION_CELLS, tag_name) # "tag" is the default name set in tboxVtk::VtkExport::save - thresh.Update() - # create the first cutting plane - plane1 = vtk.vtkPlane() - plane1.SetOrigin(p1[0], p1[1], p1[2]) - plane1.SetNormal(v1[0], v1[1], v1[2]) - plane2 = vtk.vtkPlane() - plane2.SetOrigin(p1[0], p1[1], p1[2]) - plane2.SetNormal(v2[0], v2[1], v2[2]) - # cut the threshold and get data - cutter1 = vtk.vtkFiltersCorePython.vtkCutter() - cutter1.SetCutFunction(plane1) - cutter1.SetInputConnection(thresh.GetOutputPort()) - cutter1.Update() - - cutter2 = vtk.vtkFiltersCorePython.vtkCutter() - cutter2.SetCutFunction(plane2) - cutter2.SetInputConnection(cutter1.GetOutputPort()) - cutter2.Update() - - return cutter2.GetOutput() - - def extract(self, cutData, vname, atPoint = True): - ''' - Extract points "pts", connectivity list "elems" and data "vals" named "vname" from cutting plane data "cutData". - The physical group dimension is given by "tagDim" and "atPoint" is True if vname is defined at points. - ''' - import numpy as np - # transfer point coordinates - norm_p1p2 = np.linalg.norm(self.p2-self.p1) - _pts = cutData.GetPoints() - pts = np.zeros((_pts.GetNumberOfPoints(), )) - for i in range(0, len(pts)): - tmp = np.zeros((3,)) - for j in range(0, 3): - tmp[j] = _pts.GetPoint(i)[j] - pts[i] = np.inner(self.p2-self.p1,tmp-self.p1) / norm_p1p2 - indices_tmp = np.argsort(pts) - pts = pts - pts_res = pts[indices_tmp] - indices_2 = np.argwhere((pts_res >= 0) & (pts_res <= norm_p1p2)) - pts_res = pts_res[indices_2] - # transfer connectivity - _elems = cutData.GetLines().GetData() - nV = 2 - max_nb_elems = _elems.GetNumberOfTuples() // (nV+1) - current_nb_elems = 0 - indices_elems = np.zeros((max_nb_elems,), dtype=int) - for i in range(0, max_nb_elems): - has_to_be_kept = True - for j in range(0, nV): - node_id = int(_elems.GetTuple((nV+1)*i+j+1)[0]) - if pts[node_id] < 0 or pts[node_id] > norm_p1p2: - has_to_be_kept = False - break - if has_to_be_kept: - current_nb_elems = current_nb_elems + 1 - indices_elems[i] = 1 - indices_elems_2 = np.zeros((current_nb_elems,), dtype=int) - elems = np.zeros((current_nb_elems, nV), dtype=int) - mean_per_elems = np.zeros((current_nb_elems,)) - current_i = -1 - for i in range(0, max_nb_elems): - if indices_elems[i]: - current_i = current_i + 1 - indices_elems_2[current_i] = i - for j in range(0, nV): - node_id = int(_elems.GetTuple((nV+1)*i+j+1)[0]) - elems[current_i][j] = np.argwhere(pts[node_id] == pts_res)[0][0] - mean_per_elems[current_i] = mean_per_elems[current_i] + 0.5*pts[node_id] - indices_elems_3 = np.argsort(mean_per_elems) - elems = elems[indices_elems_3][:] - # transfer variables - vals = {} - for name in vname: - if atPoint: # data at points - _vals = cutData.GetPointData().GetArray(name) - else: # data at elements - _vals = cutData.GetCellData().GetArray(name) - vals[name] = np.zeros((_vals.GetNumberOfTuples(), _vals.GetNumberOfComponents())) - for i in range(0, vals[name].shape[0]): - for j in range(0, vals[name].shape[1]): - if atPoint: - vals[name][i][j] = _vals.GetTuple(i)[j] - else: - vals[name][i][j] = _vals.GetTuple(i)[j] - if atPoint: - tmp = vals[name][indices_tmp][:] - vals[name] = tmp[indices_2][:] - else: - tmp = vals[name][indices_elems_2][:] - vals[name] = tmp[indices_elems_3][:] - - return pts_res, elems, vals diff --git a/tboxVtk/qt5vtk6/QVTKRenderWindowInteractor.py b/tboxVtk/qt5vtk6/QVTKRenderWindowInteractor.py deleted file mode 100644 index 09c5e3da..00000000 --- a/tboxVtk/qt5vtk6/QVTKRenderWindowInteractor.py +++ /dev/null @@ -1,644 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -""" -A simple VTK widget for PyQt or PySide. -See http://www.trolltech.com for Qt documentation, -http://www.riverbankcomputing.co.uk for PyQt, and -http://pyside.github.io for PySide. - -This class is based on the vtkGenericRenderWindowInteractor and is -therefore fairly powerful. It should also play nicely with the -vtk3DWidget code. - -Created by Prabhu Ramachandran, May 2002 -Based on David Gobbi's QVTKRenderWidget.py - -Changes by Gerard Vermeulen Feb. 2003 - Win32 support. - -Changes by Gerard Vermeulen, May 2003 - Bug fixes and better integration with the Qt framework. - -Changes by Phil Thompson, Nov. 2006 - Ported to PyQt v4. - Added support for wheel events. - -Changes by Phil Thompson, Oct. 2007 - Bug fixes. - -Changes by Phil Thompson, Mar. 2008 - Added cursor support. - -Changes by Rodrigo Mologni, Sep. 2013 (Credit to Daniele Esposti) - Bug fix to PySide: Converts PyCObject to void pointer. - -Changes by Greg Schussman, Aug. 2014 - The keyPressEvent function now passes keysym instead of None. - -Changes by Alex Tsui, Apr. 2015 - Port from PyQt4 to PyQt5. - -Changes by Fabian Wenzel, Jan. 2016 - Support for Python3 -""" - - - - -import vtk # added by RoBo -PyQtImpl = None # added by RoBo - -# Check whether a specific PyQt implementation was chosen -try: - import vtk.qt - PyQtImpl = vtk.qt.PyQtImpl -except ImportError: - pass - -# Check whether a specific QVTKRenderWindowInteractor base -# class was chosen, can be set to "QGLWidget" -QVTKRWIBase = "QWidget" -try: - import vtk.qt - QVTKRWIBase = vtk.qt.QVTKRWIBase -except ImportError: - pass - -if PyQtImpl is None: - # Autodetect the PyQt implementation to use - try: - import PyQt5 - PyQtImpl = "PyQt5" - except ImportError: - try: - import PyQt4 - PyQtImpl = "PyQt4" - except ImportError: - try: - import PySide - PyQtImpl = "PySide" - except ImportError: - raise ImportError("Cannot load either PyQt or PySide") - -if PyQtImpl == "PyQt5": - if QVTKRWIBase == "QGLWidget": - from PyQt5.QtOpenGL import QGLWidget - from PyQt5.QtWidgets import QWidget - from PyQt5.QtWidgets import QSizePolicy - from PyQt5.QtWidgets import QApplication - from PyQt5.QtCore import Qt - from PyQt5.QtCore import QTimer - from PyQt5.QtCore import QObject - from PyQt5.QtCore import QSize - from PyQt5.QtCore import QEvent -elif PyQtImpl == "PyQt4": - if QVTKRWIBase == "QGLWidget": - from PyQt4.QtOpenGL import QGLWidget - from PyQt4.QtGui import QWidget - from PyQt4.QtGui import QSizePolicy - from PyQt4.QtGui import QApplication - from PyQt4.QtCore import Qt - from PyQt4.QtCore import QTimer - from PyQt4.QtCore import QObject - from PyQt4.QtCore import QSize - from PyQt4.QtCore import QEvent -elif PyQtImpl == "PySide": - if QVTKRWIBase == "QGLWidget": - from PySide.QtOpenGL import QGLWidget - from PySide.QtGui import QWidget - from PySide.QtGui import QSizePolicy - from PySide.QtGui import QApplication - from PySide.QtCore import Qt - from PySide.QtCore import QTimer - from PySide.QtCore import QObject - from PySide.QtCore import QSize - from PySide.QtCore import QEvent -else: - raise ImportError("Unknown PyQt implementation " + repr(PyQtImpl)) - -# Define types for base class, based on string -if QVTKRWIBase == "QWidget": - QVTKRWIBaseClass = QWidget -elif QVTKRWIBase == "QGLWidget": - QVTKRWIBaseClass = QGLWidget -else: - raise ImportError("Unknown base class for QVTKRenderWindowInteractor " + QVTKRWIBase) - -class QVTKRenderWindowInteractor(QVTKRWIBaseClass): - - """ A QVTKRenderWindowInteractor for Python and Qt. Uses a - vtkGenericRenderWindowInteractor to handle the interactions. Use - GetRenderWindow() to get the vtkRenderWindow. Create with the - keyword stereo=1 in order to generate a stereo-capable window. - - The user interface is summarized in vtkInteractorStyle.h: - - - Keypress j / Keypress t: toggle between joystick (position - sensitive) and trackball (motion sensitive) styles. In joystick - style, motion occurs continuously as long as a mouse button is - pressed. In trackball style, motion occurs when the mouse button - is pressed and the mouse pointer moves. - - - Keypress c / Keypress o: toggle between camera and object - (actor) modes. In camera mode, mouse events affect the camera - position and focal point. In object mode, mouse events affect - the actor that is under the mouse pointer. - - - Button 1: rotate the camera around its focal point (if camera - mode) or rotate the actor around its origin (if actor mode). The - rotation is in the direction defined from the center of the - renderer's viewport towards the mouse position. In joystick mode, - the magnitude of the rotation is determined by the distance the - mouse is from the center of the render window. - - - Button 2: pan the camera (if camera mode) or translate the actor - (if object mode). In joystick mode, the direction of pan or - translation is from the center of the viewport towards the mouse - position. In trackball mode, the direction of motion is the - direction the mouse moves. (Note: with 2-button mice, pan is - defined as <Shift>-Button 1.) - - - Button 3: zoom the camera (if camera mode) or scale the actor - (if object mode). Zoom in/increase scale if the mouse position is - in the top half of the viewport; zoom out/decrease scale if the - mouse position is in the bottom half. In joystick mode, the amount - of zoom is controlled by the distance of the mouse pointer from - the horizontal centerline of the window. - - - Keypress 3: toggle the render window into and out of stereo - mode. By default, red-blue stereo pairs are created. Some systems - support Crystal Eyes LCD stereo glasses; you have to invoke - SetStereoTypeToCrystalEyes() on the rendering window. Note: to - use stereo you also need to pass a stereo=1 keyword argument to - the constructor. - - - Keypress e: exit the application. - - - Keypress f: fly to the picked point - - - Keypress p: perform a pick operation. The render window interactor - has an internal instance of vtkCellPicker that it uses to pick. - - - Keypress r: reset the camera view along the current view - direction. Centers the actors and moves the camera so that all actors - are visible. - - - Keypress s: modify the representation of all actors so that they - are surfaces. - - - Keypress u: invoke the user-defined function. Typically, this - keypress will bring up an interactor that you can type commands in. - - - Keypress w: modify the representation of all actors so that they - are wireframe. - """ - - # Map between VTK and Qt cursors. - _CURSOR_MAP = { - 0: Qt.ArrowCursor, # VTK_CURSOR_DEFAULT - 1: Qt.ArrowCursor, # VTK_CURSOR_ARROW - 2: Qt.SizeBDiagCursor, # VTK_CURSOR_SIZENE - 3: Qt.SizeFDiagCursor, # VTK_CURSOR_SIZENWSE - 4: Qt.SizeBDiagCursor, # VTK_CURSOR_SIZESW - 5: Qt.SizeFDiagCursor, # VTK_CURSOR_SIZESE - 6: Qt.SizeVerCursor, # VTK_CURSOR_SIZENS - 7: Qt.SizeHorCursor, # VTK_CURSOR_SIZEWE - 8: Qt.SizeAllCursor, # VTK_CURSOR_SIZEALL - 9: Qt.PointingHandCursor, # VTK_CURSOR_HAND - 10: Qt.CrossCursor, # VTK_CURSOR_CROSSHAIR - } - - def __init__(self, parent=None, **kw): - # the current button - self._ActiveButton = Qt.NoButton - - # private attributes - self.__saveX = 0 - self.__saveY = 0 - self.__saveModifiers = Qt.NoModifier - self.__saveButtons = Qt.NoButton - self.__wheelDelta = 0 - - # do special handling of some keywords: - # stereo, rw - - try: - stereo = bool(kw['stereo']) - except KeyError: - stereo = False - - try: - rw = kw['rw'] - except KeyError: - rw = None - - # create base qt-level widget - if QVTKRWIBase == "QWidget": - if "wflags" in kw: - wflags = kw['wflags'] - else: - wflags = Qt.WindowFlags() - QWidget.__init__(self, parent, wflags | Qt.MSWindowsOwnDC) - elif QVTKRWIBase == "QGLWidget": - QGLWidget.__init__(self, parent) - - if rw: # user-supplied render window - self._RenderWindow = rw - else: - self._RenderWindow = vtk.vtkRenderWindow() - - WId = self.winId() - - # Python2 - if type(WId).__name__ == 'PyCObject': - from ctypes import pythonapi, c_void_p, py_object - - pythonapi.PyCObject_AsVoidPtr.restype = c_void_p - pythonapi.PyCObject_AsVoidPtr.argtypes = [py_object] - - WId = pythonapi.PyCObject_AsVoidPtr(WId) - - # Python3 - elif type(WId).__name__ == 'PyCapsule': - from ctypes import pythonapi, c_void_p, py_object, c_char_p - - pythonapi.PyCapsule_GetName.restype = c_char_p - pythonapi.PyCapsule_GetName.argtypes = [py_object] - - name = pythonapi.PyCapsule_GetName(WId) - - pythonapi.PyCapsule_GetPointer.restype = c_void_p - pythonapi.PyCapsule_GetPointer.argtypes = [py_object, c_char_p] - - WId = pythonapi.PyCapsule_GetPointer(WId, name) - - self._RenderWindow.SetWindowInfo(str(int(WId))) - - if stereo: # stereo mode - self._RenderWindow.StereoCapableWindowOn() - self._RenderWindow.SetStereoTypeToCrystalEyes() - - try: - self._Iren = kw['iren'] - except KeyError: - self._Iren = vtk.vtkGenericRenderWindowInteractor() - self._Iren.SetRenderWindow(self._RenderWindow) - - # do all the necessary qt setup - self.setAttribute(Qt.WA_OpaquePaintEvent) - self.setAttribute(Qt.WA_PaintOnScreen) - self.setMouseTracking(True) # get all mouse events - self.setFocusPolicy(Qt.WheelFocus) - self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) - - self._Timer = QTimer(self) - self._Timer.timeout.connect(self.TimerEvent) - - self._Iren.AddObserver('CreateTimerEvent', self.CreateTimer) - self._Iren.AddObserver('DestroyTimerEvent', self.DestroyTimer) - self._Iren.GetRenderWindow().AddObserver('CursorChangedEvent', - self.CursorChangedEvent) - - #Create a hidden child widget and connect its destroyed signal to its - #parent ``Finalize`` slot. The hidden children will be destroyed before - #its parent thus allowing cleanup of VTK elements. - self._hidden = QWidget(self) - self._hidden.hide() - self._hidden.destroyed.connect(self.Finalize) - - def __getattr__(self, attr): - """Makes the object behave like a vtkGenericRenderWindowInteractor""" - if attr == '__vtk__': - return lambda t=self._Iren: t - elif hasattr(self._Iren, attr): - return getattr(self._Iren, attr) - else: - raise AttributeError(self.__class__.__name__ + - " has no attribute named " + attr) - - def Finalize(self): - ''' - Call internal cleanup method on VTK objects - ''' - self._RenderWindow.Finalize() - - def CreateTimer(self, obj, evt): - self._Timer.start(10) - - def DestroyTimer(self, obj, evt): - self._Timer.stop() - return 1 - - def TimerEvent(self): - self._Iren.TimerEvent() - - def CursorChangedEvent(self, obj, evt): - """Called when the CursorChangedEvent fires on the render window.""" - # This indirection is needed since when the event fires, the current - # cursor is not yet set so we defer this by which time the current - # cursor should have been set. - QTimer.singleShot(0, self.ShowCursor) - - def HideCursor(self): - """Hides the cursor.""" - self.setCursor(Qt.BlankCursor) - - def ShowCursor(self): - """Shows the cursor.""" - vtk_cursor = self._Iren.GetRenderWindow().GetCurrentCursor() - qt_cursor = self._CURSOR_MAP.get(vtk_cursor, Qt.ArrowCursor) - self.setCursor(qt_cursor) - - def closeEvent(self, evt): - self.Finalize() - - def sizeHint(self): - return QSize(400, 400) - - def paintEngine(self): - return None - - def paintEvent(self, ev): - self._Iren.Render() - - def resizeEvent(self, ev): - w = self.width() - h = self.height() - vtk.vtkRenderWindow.SetSize(self._RenderWindow, w, h) - self._Iren.SetSize(w, h) - self._Iren.ConfigureEvent() - self.update() - - def _GetCtrlShift(self, ev): - ctrl = shift = False - - if hasattr(ev, 'modifiers'): - if ev.modifiers() & Qt.ShiftModifier: - shift = True - if ev.modifiers() & Qt.ControlModifier: - ctrl = True - else: - if self.__saveModifiers & Qt.ShiftModifier: - shift = True - if self.__saveModifiers & Qt.ControlModifier: - ctrl = True - - return ctrl, shift - - def enterEvent(self, ev): - ctrl, shift = self._GetCtrlShift(ev) - self._Iren.SetEventInformationFlipY(self.__saveX, self.__saveY, - ctrl, shift, chr(0), 0, None) - self._Iren.EnterEvent() - - def leaveEvent(self, ev): - ctrl, shift = self._GetCtrlShift(ev) - self._Iren.SetEventInformationFlipY(self.__saveX, self.__saveY, - ctrl, shift, chr(0), 0, None) - self._Iren.LeaveEvent() - - def mousePressEvent(self, ev): - ctrl, shift = self._GetCtrlShift(ev) - repeat = 0 - if ev.type() == QEvent.MouseButtonDblClick: - repeat = 1 - self._Iren.SetEventInformationFlipY(ev.x(), ev.y(), - ctrl, shift, chr(0), repeat, None) - - self._ActiveButton = ev.button() - - if self._ActiveButton == Qt.LeftButton: - self._Iren.LeftButtonPressEvent() - elif self._ActiveButton == Qt.RightButton: - self._Iren.RightButtonPressEvent() - elif self._ActiveButton == Qt.MidButton: - self._Iren.MiddleButtonPressEvent() - - def mouseReleaseEvent(self, ev): - ctrl, shift = self._GetCtrlShift(ev) - self._Iren.SetEventInformationFlipY(ev.x(), ev.y(), - ctrl, shift, chr(0), 0, None) - - if self._ActiveButton == Qt.LeftButton: - self._Iren.LeftButtonReleaseEvent() - elif self._ActiveButton == Qt.RightButton: - self._Iren.RightButtonReleaseEvent() - elif self._ActiveButton == Qt.MidButton: - self._Iren.MiddleButtonReleaseEvent() - - def mouseMoveEvent(self, ev): - self.__saveModifiers = ev.modifiers() - self.__saveButtons = ev.buttons() - self.__saveX = ev.x() - self.__saveY = ev.y() - - ctrl, shift = self._GetCtrlShift(ev) - self._Iren.SetEventInformationFlipY(ev.x(), ev.y(), - ctrl, shift, chr(0), 0, None) - self._Iren.MouseMoveEvent() - - def keyPressEvent(self, ev): - ctrl, shift = self._GetCtrlShift(ev) - if ev.key() < 256: - key = str(ev.text()) - else: - key = chr(0) - - keySym = _qt_key_to_key_sym(ev.key()) - if shift and len(keySym) == 1 and keySym.isalpha(): - keySym = keySym.upper() - - self._Iren.SetEventInformationFlipY(self.__saveX, self.__saveY, - ctrl, shift, key, 0, keySym) - self._Iren.KeyPressEvent() - self._Iren.CharEvent() - - def keyReleaseEvent(self, ev): - ctrl, shift = self._GetCtrlShift(ev) - if ev.key() < 256: - key = chr(ev.key()) - else: - key = chr(0) - - self._Iren.SetEventInformationFlipY(self.__saveX, self.__saveY, - ctrl, shift, key, 0, None) - self._Iren.KeyReleaseEvent() - - def wheelEvent(self, ev): - if hasattr(ev, 'delta'): - self.__wheelDelta += ev.delta() - else: - self.__wheelDelta += ev.angleDelta().y() - - if self.__wheelDelta >= 120: - self._Iren.MouseWheelForwardEvent() - self.__wheelDelta = 0 - elif self.__wheelDelta <= -120: - self._Iren.MouseWheelBackwardEvent() - self.__wheelDelta = 0 - - def GetRenderWindow(self): - return self._RenderWindow - - def Render(self): - self.update() - - -def QVTKRenderWidgetConeExample(): - """A simple example that uses the QVTKRenderWindowInteractor class.""" - - # every QT app needs an app - app = QApplication(['QVTKRenderWindowInteractor']) - - # create the widget - widget = QVTKRenderWindowInteractor() - widget.Initialize() - widget.Start() - # if you dont want the 'q' key to exit comment this. - widget.AddObserver("ExitEvent", lambda o, e, a=app: a.quit()) - - ren = vtk.vtkRenderer() - widget.GetRenderWindow().AddRenderer(ren) - - cone = vtk.vtkConeSource() - cone.SetResolution(8) - - coneMapper = vtk.vtkPolyDataMapper() - coneMapper.SetInputConnection(cone.GetOutputPort()) - - coneActor = vtk.vtkActor() - coneActor.SetMapper(coneMapper) - - ren.AddActor(coneActor) - - # show the widget - widget.show() - # start event processing - app.exec_() - - -_keysyms = { - Qt.Key_Backspace: 'BackSpace', - Qt.Key_Tab: 'Tab', - Qt.Key_Backtab: 'Tab', - # Qt.Key_Clear : 'Clear', - Qt.Key_Return: 'Return', - Qt.Key_Enter: 'Return', - Qt.Key_Shift: 'Shift_L', - Qt.Key_Control: 'Control_L', - Qt.Key_Alt: 'Alt_L', - Qt.Key_Pause: 'Pause', - Qt.Key_CapsLock: 'Caps_Lock', - Qt.Key_Escape: 'Escape', - Qt.Key_Space: 'space', - # Qt.Key_Prior : 'Prior', - # Qt.Key_Next : 'Next', - Qt.Key_End: 'End', - Qt.Key_Home: 'Home', - Qt.Key_Left: 'Left', - Qt.Key_Up: 'Up', - Qt.Key_Right: 'Right', - Qt.Key_Down: 'Down', - Qt.Key_SysReq: 'Snapshot', - Qt.Key_Insert: 'Insert', - Qt.Key_Delete: 'Delete', - Qt.Key_Help: 'Help', - Qt.Key_0: '0', - Qt.Key_1: '1', - Qt.Key_2: '2', - Qt.Key_3: '3', - Qt.Key_4: '4', - Qt.Key_5: '5', - Qt.Key_6: '6', - Qt.Key_7: '7', - Qt.Key_8: '8', - Qt.Key_9: '9', - Qt.Key_A: 'a', - Qt.Key_B: 'b', - Qt.Key_C: 'c', - Qt.Key_D: 'd', - Qt.Key_E: 'e', - Qt.Key_F: 'f', - Qt.Key_G: 'g', - Qt.Key_H: 'h', - Qt.Key_I: 'i', - Qt.Key_J: 'j', - Qt.Key_K: 'k', - Qt.Key_L: 'l', - Qt.Key_M: 'm', - Qt.Key_N: 'n', - Qt.Key_O: 'o', - Qt.Key_P: 'p', - Qt.Key_Q: 'q', - Qt.Key_R: 'r', - Qt.Key_S: 's', - Qt.Key_T: 't', - Qt.Key_U: 'u', - Qt.Key_V: 'v', - Qt.Key_W: 'w', - Qt.Key_X: 'x', - Qt.Key_Y: 'y', - Qt.Key_Z: 'z', - Qt.Key_Asterisk: 'asterisk', - Qt.Key_Plus: 'plus', - Qt.Key_Minus: 'minus', - Qt.Key_Period: 'period', - Qt.Key_Slash: 'slash', - Qt.Key_F1: 'F1', - Qt.Key_F2: 'F2', - Qt.Key_F3: 'F3', - Qt.Key_F4: 'F4', - Qt.Key_F5: 'F5', - Qt.Key_F6: 'F6', - Qt.Key_F7: 'F7', - Qt.Key_F8: 'F8', - Qt.Key_F9: 'F9', - Qt.Key_F10: 'F10', - Qt.Key_F11: 'F11', - Qt.Key_F12: 'F12', - Qt.Key_F13: 'F13', - Qt.Key_F14: 'F14', - Qt.Key_F15: 'F15', - Qt.Key_F16: 'F16', - Qt.Key_F17: 'F17', - Qt.Key_F18: 'F18', - Qt.Key_F19: 'F19', - Qt.Key_F20: 'F20', - Qt.Key_F21: 'F21', - Qt.Key_F22: 'F22', - Qt.Key_F23: 'F23', - Qt.Key_F24: 'F24', - Qt.Key_NumLock: 'Num_Lock', - Qt.Key_ScrollLock: 'Scroll_Lock', - } - -def _qt_key_to_key_sym(key): - """ Convert a Qt key into a vtk keysym. - - This is essentially copied from the c++ implementation in - GUISupport/Qt/QVTKInteractorAdapter.cxx. - """ - - if key not in _keysyms: - return None - - return _keysyms[key] - - -if __name__ == "__main__": - print(PyQtImpl) - QVTKRenderWidgetConeExample() diff --git a/tboxVtk/qt5vtk6/README.txt b/tboxVtk/qt5vtk6/README.txt deleted file mode 100644 index 2671b8f9..00000000 --- a/tboxVtk/qt5vtk6/README.txt +++ /dev/null @@ -1,4 +0,0 @@ -Interface PyQt5 / vtk -===================== -This file is missing in vtk6.3.0 -location (in vtk7): python-2.7.12\Lib\site-packages\vtk\qt5 \ No newline at end of file diff --git a/tboxVtk/qt5vtk6/__init__.py b/tboxVtk/qt5vtk6/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/tboxVtk/reader.py b/tboxVtk/reader.py deleted file mode 100644 index 41227027..00000000 --- a/tboxVtk/reader.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -# @brief VTK Reader -# @authors Adrien Crovato - -try: - import vtk -except: - raise Exception('VTK not found. Aborting!\n') - -class Reader: - def __init__(self): - self.reader = vtk.vtkXMLUnstructuredGridReader() - - def open(self, fname): - import os.path - extensions = ['.pvtu','.vtu','.vtk'] - extension = None - for extension_tmp in extensions: - if os.path.isfile(fname+extension_tmp): - extension = extension_tmp - break - if extension is None: raise Exception("file %s.pvtu/.vtu/.vtk not found!\n" %fname) - self.reader.SetFileName(fname+extension) - self.reader.Update() - - def close(self): - print('No need to do that apparently...\n') - #self.reader.CloseFile() diff --git a/tboxVtk/src/CMakeLists.txt b/tboxVtk/src/CMakeLists.txt deleted file mode 100644 index e2e639b5..00000000 --- a/tboxVtk/src/CMakeLists.txt +++ /dev/null @@ -1,66 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# CMake input file of tboxw.so - -FILE(GLOB SRCS *.h *.cpp *.inl *.hpp) - -ADD_LIBRARY(tboxVtk SHARED ${SRCS}) -MACRO_DebugPostfix(tboxVtk) - -TARGET_INCLUDE_DIRECTORIES(tboxVtk PUBLIC ${PROJECT_SOURCE_DIR}/tboxVtk/src) - -# ------------------------------------------------------------------------ -# "new" way to link against VTK >=6 using COMPONENTS -# https://vtk.org/Wiki/VTK/Build_System_Migration - - -# 1. first, look for all available VTK libraries -FIND_PACKAGE(VTK REQUIRED NO_MODULE) -IF(${VTK_VERSION} VERSION_LESS 6.0) - MESSAGE(FATAL_ERROR "VTK>=6 required!") -ENDIF() -MESSAGE(STATUS "VTK_LIBRARIES1 = ${VTK_LIBRARIES}") # display all VTK libs - -# list of required components -SET(REQVTKCMP vtkIOXML) - -# check whether MPI has been compiled -IF(TARGET vtkParallelMPI) # NOTE: this test also works with a previous single-COMPONENT search - SET(REQVTKCMP ${REQVTKCMP} vtkParallelMPI vtkIOParallelXML) - TARGET_COMPILE_DEFINITIONS(tboxVtk PUBLIC "-DVTK_HAS_MPI") - MESSAGE(STATUS "vtkParallelMPI available!") -ELSE() - MESSAGE(STATUS "vtkParallelMPI NOT available!") -ENDIF() - -# 2. second, perform a new search with a limited number of components -# NOTE: you may just disable the following line to link against ALL vtk libraries! -FIND_PACKAGE(VTK REQUIRED COMPONENTS ${REQVTKCMP} NO_MODULE) - -# debug -MESSAGE(STATUS "VTK_DEFINITIONS = ${VTK_DEFINITIONS}") -MESSAGE(STATUS "VTK_REQUIRED_CXX_FLAGS = ${VTK_REQUIRED_CXX_FLAGS}") -MESSAGE(STATUS "VTK_REQUIRED_EXE_LINKER_FLAGS = ${VTK_REQUIRED_EXE_LINKER_FLAGS}") -MESSAGE(STATUS "VTK_REQUIRED_SHARED_LINKER_FLAGS = ${VTK_REQUIRED_SHARED_LINKER_FLAGS}") -MESSAGE(STATUS "VTK_USE_FILE = ${VTK_USE_FILE}") -MESSAGE(STATUS "VTK_INCLUDE_DIR = ${VTK_INCLUDE_DIR}") -MESSAGE(STATUS "VTK_LIBRARIES = ${VTK_LIBRARIES}") - -TARGET_INCLUDE_DIRECTORIES(tboxVtk PUBLIC ${VTK_INCLUDE_DIRS}) -TARGET_COMPILE_DEFINITIONS(tboxVtk PUBLIC ${VTK_DEFINITIONS}) -TARGET_LINK_LIBRARIES(tboxVtk ${VTK_LIBRARIES} tbox) - -SOURCE_GROUP(base REGULAR_EXPRESSION ".*\\.(cpp|inl|hpp|h)") - diff --git a/tboxVtk/src/tboxVtk.h b/tboxVtk/src/tboxVtk.h deleted file mode 100644 index 3146b3a5..00000000 --- a/tboxVtk/src/tboxVtk.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// global header of the "tboxVtk" module - -#ifndef TBOXVTK_H -#define TBOXVTK_H - -#if defined(WIN32) -#ifdef tboxVtk_EXPORTS -#define TBOXVTK_API __declspec(dllexport) -#else -#define TBOXVTK_API __declspec(dllimport) -#endif -#else -#define TBOXVTK_API -#endif - -#include "tbox.h" - -/** - * @brief Namespace for tboxVtk module - */ -namespace tboxVtk -{ -// Msh utilities -class vtkExport; - -// Kim's old classes (to be cleaned) -class vtkExport_KIM2CLEAN; -} // namespace tboxVtk - -#endif //TBOXVTK_H diff --git a/tboxVtk/src/wVtkExport.cpp b/tboxVtk/src/wVtkExport.cpp deleted file mode 100644 index 322eff82..00000000 --- a/tboxVtk/src/wVtkExport.cpp +++ /dev/null @@ -1,260 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "wVtkExport.h" -#include "wNode.h" -#include "wElement.h" -#include "wResults.h" -#include "wTag.h" - -#include <vtkSmartPointer.h> -#include <vtkUnstructuredGrid.h> -#include <vtkXMLUnstructuredGridWriter.h> -#include <vtkPoints.h> -#include <vtkHexahedron.h> -#include <vtkTetra.h> -#include <vtkQuad.h> -#include <vtkTriangle.h> -#include <vtkLine.h> -#include <vtkVertex.h> -#include <vtkDoubleArray.h> -#include <vtkIntArray.h> -#include <vtkPointData.h> -#include <vtkCellData.h> - -using namespace tbox; -using namespace tboxVtk; - -using vtkWriterP = vtkSmartPointer<vtkXMLUnstructuredGridWriter>; -using vtkPtsP = vtkSmartPointer<vtkPoints>; -using vtkHexaP = vtkSmartPointer<vtkHexahedron>; -using vtkTetraP = vtkSmartPointer<vtkTetra>; -using vtkQuadP = vtkSmartPointer<vtkQuad>; -using vtkTriP = vtkSmartPointer<vtkTriangle>; -using vtkLineP = vtkSmartPointer<vtkLine>; -using vtkVtxP = vtkSmartPointer<vtkVertex>; -using vtkDblArrP = vtkSmartPointer<vtkDoubleArray>; -using vtkIntArrP = vtkSmartPointer<vtkIntArray>; - -VtkExport::VtkExport(std::shared_ptr<MshData> _msh) : MshExport(_msh) -{ - grid = vtkSmartPointer<vtkUnstructuredGrid>::New(); - create(); -} - -VtkExport::~VtkExport() -{ - std::cout << "~VtkExport()\n"; -} - -/** - * @brief Save mesh on disk - * @authors Adrien Crovato - */ -void VtkExport::save(std::string const &fname) const -{ - // Update point position - grid->GetPoints()->Reset(); - for (auto n : msh->nodes) - grid->GetPoints()->InsertPoint(n->no - 1, n->pos(0), n->pos(1), n->pos(2)); - grid->GetPoints()->Modified(); - - // Define writer - std::string wname = fname + ".vtu"; - vtkWriterP writer = vtkWriterP::New(); - writer->SetFileName(wname.c_str()); - writer->SetInputData(grid); - // Write binary or ascii - if (binary) - { - std::cout << "writing binary file: " << wname << "... " << std::flush; - writer->SetDataModeToBinary(); - } - else - { - std::cout << "writing ascii file: " << wname << "... " << std::flush; - writer->SetDataModeToAscii(); - } - writer->Write(); - std::cout << "done!" << std::endl; -} - -/** - * @brief Save mesh and results on disk - * @authors Adrien Crovato, Kim Liegeois - */ -void VtkExport::save(std::string const &fname, Results const &r) const -{ - // Create scalar field (at nodes) - for (auto &p : r.scalars_at_nodes) - { - vtkDblArrP data = vtkDblArrP::New(); - data->SetNumberOfComponents(1); - data->SetNumberOfTuples(msh->nodes.size()); - data->SetName(p.first.c_str()); - for (size_t i = 0; i < msh->nodes.size(); ++i) - data->SetValue(msh->nodes[i]->no - 1, (*(p.second))[i]); - grid->GetPointData()->AddArray(data); - } - // Create vector field (at nodes) - for (auto &p : r.vectors_at_nodes) - { - vtkDblArrP data = vtkDblArrP::New(); - data->SetNumberOfComponents(3); - data->SetNumberOfTuples(msh->nodes.size()); - data->SetName(p.first.c_str()); - for (size_t i = 0; i < msh->nodes.size(); ++i) - data->SetTuple3(msh->nodes[i]->no - 1, (*(p.second))[i](0), (*(p.second))[i](1), (*(p.second))[i](2)); - grid->GetPointData()->AddArray(data); - } - // Create tensor field (at nodes) - for (auto &p : r.tensors_at_nodes) - { - vtkDblArrP data = vtkDblArrP::New(); - data->SetNumberOfComponents(9); - data->SetNumberOfTuples(msh->nodes.size()); - data->SetName(p.first.c_str()); - for (size_t i = 0; i < msh->nodes.size(); ++i) - data->SetTuple9(msh->nodes[i]->no - 1, (*(p.second))[i](0, 0), (*(p.second))[i](0, 1), (*(p.second))[i](0, 2), - (*(p.second))[i](1, 0), (*(p.second))[i](1, 1), (*(p.second))[i](1, 2), - (*(p.second))[i](2, 0), (*(p.second))[i](2, 1), (*(p.second))[i](2, 2)); - grid->GetPointData()->AddArray(data); - } - - // Create scalar field (at elements) - for (auto &p : r.scalars_at_elems) - { - vtkDblArrP data = vtkDblArrP::New(); - data->SetNumberOfComponents(1); - data->SetNumberOfTuples(msh->elems.size()); - data->SetName(p.first.c_str()); - for (size_t i = 0; i < msh->elems.size(); ++i) - data->SetValue(msh->elems[i]->no - 1, (*(p.second))[i]); - grid->GetCellData()->AddArray(data); - } - // Create vector field (at elems) - for (auto &p : r.vectors_at_elems) - { - vtkDblArrP data = vtkDblArrP::New(); - data->SetNumberOfComponents(3); - data->SetNumberOfTuples(msh->elems.size()); - data->SetName(p.first.c_str()); - for (size_t i = 0; i < msh->elems.size(); ++i) - data->SetTuple3(msh->elems[i]->no - 1, (*(p.second))[i](0), (*(p.second))[i](1), (*(p.second))[i](2)); - grid->GetCellData()->AddArray(data); - } - // Create tensor field (at elems) - for (auto &p : r.tensors_at_elems) - { - vtkDblArrP data = vtkDblArrP::New(); - data->SetNumberOfComponents(9); - data->SetNumberOfTuples(msh->elems.size()); - data->SetName(p.first.c_str()); - for (size_t i = 0; i < msh->elems.size(); ++i) - data->SetTuple9(msh->elems[i]->no - 1, (*(p.second))[i](0, 0), (*(p.second))[i](0, 1), (*(p.second))[i](0, 2), - (*(p.second))[i](1, 0), (*(p.second))[i](1, 1), (*(p.second))[i](1, 2), - (*(p.second))[i](2, 0), (*(p.second))[i](2, 1), (*(p.second))[i](2, 2)); - grid->GetCellData()->AddArray(data); - } - - // Write to file - save(fname); -} - -/** - * @brief Create data structure - * @authors Adrien Crovato, Romain Boman - */ -void VtkExport::create() -{ - // Create points - vtkPtsP points = vtkPtsP::New(); - points->SetNumberOfPoints(msh->nodes.size()); - for (auto n : msh->nodes) - points->InsertPoint(n->no - 1, n->pos(0), n->pos(1), n->pos(2)); - grid->SetPoints(points); - - // Create elements - for (auto e : msh->elems) - { - if (e->type() == ELTYPE::HEX8) - { - vtkHexaP cell = vtkHexaP::New(); - for (size_t i = 0; i < e->nodes.size(); ++i) - cell->GetPointIds()->SetId(i, e->nodes[i]->no - 1); - grid->InsertNextCell(cell->GetCellType(), cell->GetPointIds()); - } - else if (e->type() == ELTYPE::TETRA4) - { - vtkTetraP cell = vtkTetraP::New(); - for (size_t i = 0; i < e->nodes.size(); ++i) - cell->GetPointIds()->SetId(i, e->nodes[i]->no - 1); - grid->InsertNextCell(cell->GetCellType(), cell->GetPointIds()); - } - else if (e->type() == ELTYPE::QUAD4) - { - vtkQuadP cell = vtkQuadP::New(); - for (size_t i = 0; i < e->nodes.size(); ++i) - cell->GetPointIds()->SetId(i, e->nodes[i]->no - 1); - grid->InsertNextCell(cell->GetCellType(), cell->GetPointIds()); - } - else if (e->type() == ELTYPE::TRI3) - { - vtkTriP cell = vtkTriP::New(); - for (size_t i = 0; i < e->nodes.size(); ++i) - cell->GetPointIds()->SetId(i, e->nodes[i]->no - 1); - grid->InsertNextCell(cell->GetCellType(), cell->GetPointIds()); - } - else if (e->type() == ELTYPE::LINE2) - { - vtkLineP cell = vtkLineP::New(); - for (size_t i = 0; i < e->nodes.size(); ++i) - cell->GetPointIds()->SetId(i, e->nodes[i]->no - 1); - grid->InsertNextCell(cell->GetCellType(), cell->GetPointIds()); - } - else if (e->type() == ELTYPE::POINT1) - { - vtkVtxP cell = vtkVtxP::New(); - for (size_t i = 0; i < e->nodes.size(); ++i) - cell->GetPointIds()->SetId(i, e->nodes[i]->no - 1); - grid->InsertNextCell(cell->GetCellType(), cell->GetPointIds()); - } - else - { - std::stringstream err; - err << "tboxVtk::create: translation to VTK for element type " - << e->type() << " is not supported yet!\n"; - throw std::runtime_error(err.str()); - } - } - - // Create tags - vtkIntArrP tag = vtkIntArrP::New(); - tag->SetName("tag"); - tag->SetNumberOfComponents(1); - tag->SetNumberOfTuples(msh->elems.size()); - for (auto &ptag : msh->ptags) - { - for (size_t i = 0; i < ptag.second->elems.size(); ++i) - tag->SetValue(ptag.second->elems[i]->no - 1, ptag.second->no); - } - grid->GetCellData()->AddArray(tag); -} - -void VtkExport::write(std::ostream &out) const -{ - out << "VtkExport on " << *msh << std::endl; -} \ No newline at end of file diff --git a/tboxVtk/src/wVtkExport.h b/tboxVtk/src/wVtkExport.h deleted file mode 100644 index 8dea4d0f..00000000 --- a/tboxVtk/src/wVtkExport.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2020 University of Liège - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef WVTKEXPORT_H -#define WVTKEXPORT_H - -#include "tboxVtk.h" -#include "wMshExport.h" -#include <vector> -#include <map> -#include <vtkSmartPointer.h> -#include <vtkUnstructuredGrid.h> - -namespace tboxVtk -{ - -/** - * @todo [Long-term] implement a way to automatically update vtk data structure (grid) if internal data structure (msh) changes. - * For now, the points and the data are always updated at each save operation. - */ - -/** - * @brief Write mesh in VTK format - * @authors Adrien Crovato, Romain Boman - */ -class TBOXVTK_API VtkExport : public tbox::MshExport -{ - vtkSmartPointer<vtkUnstructuredGrid> grid; - void create(); - -public: - VtkExport(std::shared_ptr<tbox::MshData> _msh); - virtual ~VtkExport(); - - virtual void save(std::string const &fname) const override; -#ifndef SWIG - virtual void save(std::string const &fname, tbox::Results const &r) const override; -#endif - - virtual void write(std::ostream &out) const override; -}; - -} // namespace tboxVtk - -#endif //WGMSHUTILS_H diff --git a/tboxVtk/tests/models/model.geo b/tboxVtk/tests/models/model.geo deleted file mode 100644 index 2543d346..00000000 --- a/tboxVtk/tests/models/model.geo +++ /dev/null @@ -1,14 +0,0 @@ -Point(1) = { 0, 0, 0, 0.1}; -Point(2) = { 1, 0, 0, 0.2}; -Point(3) = { 1, 1, 0, 0.3}; -Point(4) = { 0, 1, 0, 0.1}; - -Line(1) = {1, 2}; -Line(2) = {2, 3}; -Line(3) = {3, 4}; -Line(4) = {4, 1}; - -Line Loop(1) = {1, 2, 3, 4}; -Plane Surface(1) = {1}; - - diff --git a/tboxVtk/tests/vtkio.py b/tboxVtk/tests/vtkio.py deleted file mode 100755 index 81a49b2d..00000000 --- a/tboxVtk/tests/vtkio.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- - -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import tboxVtk -import tbox.gmsh as gmsh - -def main(): - msh = gmsh.MeshLoader("models/model.geo",__file__).execute() - printtags(msh) - - vtkWriter = tboxVtk.VtkExport(msh) - print(vtkWriter) - vtkWriter.binary = False - vtkWriter.save(msh.name) - -def printtags(mshdata): - print("\n-ptags:") - for t in list(mshdata.ptags.items()): - print(t[1]) - print("\n-etags:") - for t in list(mshdata.etags.items()): - print(t[1]) - print("\n-partitions:") - for t in list(mshdata.parts.items()): - print(t[1]) - -if __name__ == "__main__": - main() - diff --git a/tlnos/_src/CMakeLists.txt b/tlnos/_src/CMakeLists.txt index 1baf919b..32cc0790 100644 --- a/tlnos/_src/CMakeLists.txt +++ b/tlnos/_src/CMakeLists.txt @@ -12,10 +12,10 @@ SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES CPLUSPLUS ON) SET(SWINCFLAGS -I${PROJECT_SOURCE_DIR}/tlnos/src --I${PROJECT_SOURCE_DIR}/tbox/src --I${PROJECT_SOURCE_DIR}/tbox/_src --I${PROJECT_SOURCE_DIR}/fwk/src --I${PROJECT_SOURCE_DIR}/fwk/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src ) SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES SWIG_FLAGS "${SWINCFLAGS}") @@ -30,10 +30,10 @@ MACRO_DebugPostfix(_tlnosw) FIND_PACKAGE(Trilinos REQUIRED) INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/tlnos/src - ${PROJECT_SOURCE_DIR}/tbox/src - ${PROJECT_SOURCE_DIR}/fwk/src - ${PROJECT_SOURCE_DIR}/fwk/_src - ${PROJECT_SOURCE_DIR}/tbox/_src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src + ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src + ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src ${Trilinos_INCLUDE_DIRS} ${Trilinos_TPL_INCLUDE_DIRS} ${MPI_INCLUDE_PATH}) @@ -42,3 +42,5 @@ SWIG_LINK_LIBRARIES(tlnosw tlnos tbox fwk ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES} ${PYTHON_LIBRARIES} ) +INSTALL(FILES ${CMAKE_SWIG_OUTDIR}/tlnosw.py DESTINATION ${CMAKE_INSTALL_PREFIX}) +INSTALL(TARGETS _tlnosw DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/tlnos/src/CMakeLists.txt b/tlnos/src/CMakeLists.txt index 34b13919..ca02962e 100644 --- a/tlnos/src/CMakeLists.txt +++ b/tlnos/src/CMakeLists.txt @@ -77,5 +77,4 @@ LINK_DIRECTORIES (${Trilinos_LIBRARY_DIRS} ${Trilinos_TPL_LIBRARY_DIRS}) TARGET_LINK_LIBRARIES(tlnos tbox fwk ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES} ${MPI_LIBRARIES}) -#SOURCE_GROUP(base REGULAR_EXPRESSION ".*\\.(cpp|inl|hpp|h)") - +INSTALL(TARGETS tlnos DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/waves-config.cmake.in b/waves-config.cmake.in deleted file mode 100644 index ffac3e3f..00000000 --- a/waves-config.cmake.in +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright 2020 University of Liège -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Config file generator for the waves package -# waves-config.cmake - find fwk and tbox modules given the location of waves -# ---------------------------------------------------------------------------- -# output: -# WAVES_FOUND : TRUE/FALSE -# WAVES_INCLUDE_DIRS : where the Waves/*.h are [cached] -# WAVES_SWIG_DIRS : where the Waves/*.i are [cached] -# WAVES_LIBRARIES : where the Waves/*.so are [cached] -# ---------------------------------------------------------------------------- - -# Includes -SET(WAVES_INCLUDE_DIRS "@WAVES_INCLUDE_DIRS@" CACHE STRING "Waves headers") -SET(WAVES_SWIG_DIRS "@WAVES_SWIG_DIRS@" CACHE STRING "Waves swig interface") - -# These are IMPORTED targets created by wavesTargets.cmake -GET_FILENAME_COMPONENT(WAVES_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) -INCLUDE("${WAVES_CMAKE_DIR}/wavesTargets.cmake") -SET(WAVES_LIBRARIES "@WAVES_LIBRARIES@" CACHE STRING "Waves libs") -SET_TARGET_PROPERTIES(${WAVES_LIBRARIES} PROPERTIES IMPORTED_GLOBAL TRUE) - -# handle the QUIETLY and REQUIRED arguments and set WAVES_FOUND to TRUE -# if all listed variables are TRUE -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAVES - REQUIRED_VARS WAVES_INCLUDE_DIRS WAVES_SWIG_DIRS WAVES_LIBRARIES) diff --git a/waves/CMakeLists.txt b/waves/CMakeLists.txt index 6190a51e..3e2df53e 100644 --- a/waves/CMakeLists.txt +++ b/waves/CMakeLists.txt @@ -20,3 +20,14 @@ ADD_SUBDIRECTORY( _src ) # Add test dir MACRO_AddTest(${CMAKE_CURRENT_SOURCE_DIR}/tests) + +# Add to install +INSTALL(FILES ${CMAKE_CURRENT_LIST_DIR}/__init__.py + ${CMAKE_CURRENT_LIST_DIR}/srcs.py + ${CMAKE_CURRENT_LIST_DIR}/utils.py + ${CMAKE_CURRENT_LIST_DIR}/viewer.py + DESTINATION waves) +INSTALL(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/tests + ${CMAKE_CURRENT_LIST_DIR}/models + DESTINATION waves) + \ No newline at end of file diff --git a/waves/_src/CMakeLists.txt b/waves/_src/CMakeLists.txt index 0373de8d..666aa00d 100644 --- a/waves/_src/CMakeLists.txt +++ b/waves/_src/CMakeLists.txt @@ -25,10 +25,10 @@ SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES CPLUSPLUS ON) SET(SWINCFLAGS -I${PROJECT_SOURCE_DIR}/waves/src --I${PROJECT_SOURCE_DIR}/tbox/src --I${PROJECT_SOURCE_DIR}/tbox/_src --I${PROJECT_SOURCE_DIR}/fwk/src --I${PROJECT_SOURCE_DIR}/fwk/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/src +-I${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src ) SET_SOURCE_FILES_PROPERTIES(${ISRCS} PROPERTIES SWIG_FLAGS "${SWINCFLAGS}") @@ -39,11 +39,14 @@ else() endif() MACRO_DebugPostfix(_wavesw) -TARGET_INCLUDE_DIRECTORIES(_wavesw PRIVATE ${PROJECT_SOURCE_DIR}/fwk/_src - ${PROJECT_SOURCE_DIR}/tbox/_src +TARGET_INCLUDE_DIRECTORIES(_wavesw PRIVATE ${PROJECT_SOURCE_DIR}/ext/amfe/fwk/_src + ${PROJECT_SOURCE_DIR}/ext/amfe/tbox/_src ${PYTHON_INCLUDE_PATH} ) SWIG_LINK_LIBRARIES(wavesw waves tbox fwk ${PYTHON_LIBRARIES} ) + +INSTALL(FILES ${CMAKE_SWIG_OUTDIR}/wavesw.py DESTINATION ${CMAKE_INSTALL_PREFIX}) +INSTALL(TARGETS _wavesw DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/waves/exe/CMakeLists.txt b/waves/exe/CMakeLists.txt index 4c8eadd1..00d9f3d2 100644 --- a/waves/exe/CMakeLists.txt +++ b/waves/exe/CMakeLists.txt @@ -17,4 +17,4 @@ FILE(GLOB SRCS *.h *.cpp *.inl *.hpp) ADD_EXECUTABLE(waves1 ${SRCS}) MACRO_DebugPostfix(waves1) -TARGET_LINK_LIBRARIES(waves1 waves) # tbox) +TARGET_LINK_LIBRARIES(waves1 waves) diff --git a/waves/src/CMakeLists.txt b/waves/src/CMakeLists.txt index fd1745ca..9216fd83 100644 --- a/waves/src/CMakeLists.txt +++ b/waves/src/CMakeLists.txt @@ -22,5 +22,7 @@ TARGET_INCLUDE_DIRECTORIES(waves PUBLIC ${PROJECT_SOURCE_DIR}/waves/src) TARGET_LINK_LIBRARIES(waves tbox fwk) +INSTALL(TARGETS waves DESTINATION ${CMAKE_INSTALL_PREFIX}) + SOURCE_GROUP(base REGULAR_EXPRESSION ".*\\.(cpp|inl|hpp|h)") SOURCE_GROUP(schemes REGULAR_EXPRESSION ".+(TimeIntegration|Runge|Euler|Newmark).+") diff --git a/waves_config.h.in b/waves_config.h.in deleted file mode 100644 index a37b9446..00000000 --- a/waves_config.h.in +++ /dev/null @@ -1,2 +0,0 @@ -#cmakedefine WAVES_USE_MKL -#cmakedefine WAVES_USE_MUMPS -- GitLab