From 7ba2efedadc1b2726f8b9b3ca0b3d39c56f9574d Mon Sep 17 00:00:00 2001 From: dcodoni Date: Tue, 14 May 2024 10:57:30 -0700 Subject: [PATCH 1/6] Dockerfiles are created to build containers with precompiled PETSc and Trilinos libraries. A workflow file was created to tests the PETSc and Trilinos interfaces for some fluid and fsi problems. --- .github/workflows/test_ubuntu.yml | 60 + .github/workflows/test_ubuntu20.yml | 25 - .github/workflows/test_ubuntu22.yml | 38 - Code/Source/svFSI/CMakeLists.txt | 95 +- Code/Source/svFSI/ComMod.h | 64 +- Code/Source/svFSI/FsilsLinearAlgebra.cpp | 149 ++ Code/Source/svFSI/FsilsLinearAlgebra.h | 60 + Code/Source/svFSI/LinearAlgebra.cpp | 92 ++ Code/Source/svFSI/LinearAlgebra.h | 73 + Code/Source/svFSI/Parameters.cpp | 153 +- Code/Source/svFSI/Parameters.h | 30 +- Code/Source/svFSI/PetscLinearAlgebra.cpp | 167 +++ Code/Source/svFSI/PetscLinearAlgebra.h | 65 + Code/Source/svFSI/Simulation.cpp | 8 - Code/Source/svFSI/Simulation.h | 3 + Code/Source/svFSI/TrilinosLinearAlgebra.cpp | 205 +++ Code/Source/svFSI/TrilinosLinearAlgebra.h | 66 + Code/Source/svFSI/all_fun.cpp | 198 +-- Code/Source/svFSI/all_fun.h | 11 +- Code/Source/svFSI/baf_ini.cpp | 10 +- Code/Source/svFSI/bf.cpp | 21 +- Code/Source/svFSI/cep.cpp | 14 +- Code/Source/svFSI/cmm.cpp | 43 +- Code/Source/svFSI/consts.cpp | 75 +- Code/Source/svFSI/consts.h | 35 +- Code/Source/svFSI/distribute.cpp | 44 +- Code/Source/svFSI/eq_assem.cpp | 129 +- Code/Source/svFSI/eq_assem.h | 4 +- Code/Source/svFSI/fluid.cpp | 26 +- Code/Source/svFSI/fsi.cpp | 27 +- Code/Source/svFSI/heatf.cpp | 17 +- Code/Source/svFSI/heats.cpp | 16 +- Code/Source/svFSI/initialize.cpp | 49 +- Code/Source/svFSI/l_elas.cpp | 16 +- Code/Source/svFSI/lhsa.cpp | 10 +- Code/Source/svFSI/load_msh.cpp | 3 - Code/Source/svFSI/ls.cpp | 168 +-- Code/Source/svFSI/ls.h | 4 + Code/Source/svFSI/main.cpp | 122 +- Code/Source/svFSI/mat_models.cpp | 4 +- Code/Source/svFSI/mesh.cpp | 17 +- Code/Source/svFSI/nn.cpp | 41 +- Code/Source/svFSI/nn.h | 3 +- Code/Source/svFSI/petsc_impl.cpp | 1107 ++++++++++++++ Code/Source/svFSI/petsc_impl.h | 132 ++ Code/Source/svFSI/pic.cpp | 38 +- Code/Source/svFSI/read_files.cpp | 74 +- Code/Source/svFSI/set_bc.cpp | 263 +--- Code/Source/svFSI/set_equation_props.h | 6 +- Code/Source/svFSI/shells.cpp | 36 +- Code/Source/svFSI/stokes.cpp | 17 +- Code/Source/svFSI/sv_struct.cpp | 43 +- Code/Source/svFSI/trilinos_impl.cpp | 1327 +++++++++++++++++ Code/Source/svFSI/trilinos_impl.h | 245 +++ Code/Source/svFSI/ustruct.cpp | 33 +- Code/Source/svFSI/vtk_xml.cpp | 76 +- Code/Source/svFSI/vtk_xml.h | 2 - Code/Source/svFSI/vtk_xml_parser.cpp | 75 - Code/Source/svFSI/vtk_xml_parser.h | 1 - Code/Source/svFSILS/add_bc_mul.cpp | 28 +- Code/Source/svFSILS/bc.cpp | 57 +- Code/Source/svFSILS/fsils_api.hpp | 2 - tests/cases/cep/cable_TTP_1d/result_001.vtu | 4 +- tests/cases/cep/cable_TTP_1d/svFSI.xml | 9 +- .../result_BICG_CN_epicardium_BO_001.vtu | 4 +- .../result_CG_RK4_myocardium_BO_001.vtu | 4 +- .../result_GMRES_FE_epicardium_TTP_001.vtu | 4 +- .../result_GMRES_FE_pfib_AP_001.vtu | 4 +- .../svFSI_BICG_CN_epicardium_BO.xml | 7 +- .../svFSI_CG_RK4_myocardium_BO.xml | 8 +- .../svFSI_GMRES_FE_epicardium_TTP.xml | 7 +- .../svFSI_GMRES_FE_pfib_AP.xml | 7 +- tests/cases/cep/purkinje/result_001.vtu | 4 +- tests/cases/cep/purkinje/svFSI.xml | 9 +- tests/cases/cep/spiral_BO_2d/result_001.vtu | 4 +- tests/cases/cep/spiral_BO_2d/svFSI.xml | 10 +- tests/cases/cep/square_AP_2d/result_001.vtu | 4 +- tests/cases/cep/square_AP_2d/svFSI.xml | 10 +- .../1-rigid-solution/svFSI.xml | 3 + .../2-inflate/svFSI.xml | 6 +- .../3-inflate-cmm/svFSI.xml | 5 +- .../cmm/pipe_3d/1-rigid-solution/svFSI.xml | 3 + tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml | 3 + .../cases/cmm/pipe_3d/2b-prestress/svFSI.xml | 3 + .../cmm/pipe_3d/3a-inflate-cmm/svFSI.xml | 5 +- .../cmm/pipe_3d/3b-prestress-cmm/svFSI.xml | 4 +- tests/cases/fluid/carreau_yasuda/svFSI.xml | 4 +- tests/cases/fluid/casson/svFSI.xml | 4 +- tests/cases/fluid/driven_cavity_2d/svFSI.xml | 4 +- tests/cases/fluid/dye_AD/svFSI.xml | 8 +- tests/cases/fluid/iliac_artery/svFSI.xml | 3 + tests/cases/fluid/newtonian/svFSI.xml | 4 +- tests/cases/fluid/pipe_RCR_3d/svFSI.xml | 4 +- .../fluid/pipe_RCR_3d_bj_trilinos/README.md | 71 + .../pipe_RCR_3d_bj_trilinos/lumen_inlet.fcs | 21 + .../pipe_RCR_3d_bj_trilinos/lumen_inlet.flow | 34 + .../mesh/mesh-complete.mesh.vtu | 3 + .../mesh/mesh-surfaces/lumen_inlet.vtp | 3 + .../mesh/mesh-surfaces/lumen_outlet.vtp | 3 + .../mesh/mesh-surfaces/lumen_wall.vtp | 3 + .../pipe_RCR_3d_bj_trilinos/result_002.vtu | 3 + .../fluid/pipe_RCR_3d_bj_trilinos/svFSI.xml | 104 ++ .../fluid/pipe_RCR_3d_ilut_trilinos/README.md | 71 + .../pipe_RCR_3d_ilut_trilinos/lumen_inlet.fcs | 21 + .../lumen_inlet.flow | 34 + .../mesh/mesh-complete.mesh.vtu | 3 + .../mesh/mesh-surfaces/lumen_inlet.vtp | 3 + .../mesh/mesh-surfaces/lumen_outlet.vtp | 3 + .../mesh/mesh-surfaces/lumen_wall.vtp | 3 + .../pipe_RCR_3d_ilut_trilinos/result_002.vtu | 3 + .../fluid/pipe_RCR_3d_ilut_trilinos/svFSI.xml | 104 ++ tests/cases/fluid/pipe_RCR_3d_petsc/README.md | 71 + .../fluid/pipe_RCR_3d_petsc/lumen_inlet.fcs | 21 + .../fluid/pipe_RCR_3d_petsc/lumen_inlet.flow | 34 + .../mesh/mesh-complete.mesh.vtu | 3 + .../mesh/mesh-surfaces/lumen_inlet.vtp | 3 + .../mesh/mesh-surfaces/lumen_outlet.vtp | 3 + .../mesh/mesh-surfaces/lumen_wall.vtp | 3 + .../fluid/pipe_RCR_3d_petsc/result_002.vtu | 3 + tests/cases/fluid/pipe_RCR_3d_petsc/svFSI.xml | 104 ++ tests/cases/fsi/pipe_3d/svFSI.xml | 14 +- tests/cases/fsi/pipe_3d_bj_trilinos/README.md | 23 + .../fsi/pipe_3d_bj_trilinos/configuration.png | 3 + .../mesh/fluid/mesh-complete.mesh.vtu | 3 + .../mesh/fluid/mesh-surfaces/end.vtp | 3 + .../mesh/fluid/mesh-surfaces/interface.vtp | 3 + .../mesh/fluid/mesh-surfaces/start.vtp | 3 + .../mesh/solid/mesh-complete.mesh.vtu | 3 + .../mesh/solid/mesh-surfaces/end.vtp | 3 + .../mesh/solid/mesh-surfaces/interface.vtp | 3 + .../mesh/solid/mesh-surfaces/outside.vtp | 3 + .../mesh/solid/mesh-surfaces/start.vtp | 3 + .../fsi/pipe_3d_bj_trilinos/result_005.vtu | 3 + .../cases/fsi/pipe_3d_bj_trilinos/results.gif | 3 + tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml | 157 ++ tests/cases/fsi/pipe_3d_ml_trilinos/README.md | 23 + .../fsi/pipe_3d_ml_trilinos/configuration.png | 3 + .../mesh/fluid/mesh-complete.mesh.vtu | 3 + .../mesh/fluid/mesh-surfaces/end.vtp | 3 + .../mesh/fluid/mesh-surfaces/interface.vtp | 3 + .../mesh/fluid/mesh-surfaces/start.vtp | 3 + .../mesh/solid/mesh-complete.mesh.vtu | 3 + .../mesh/solid/mesh-surfaces/end.vtp | 3 + .../mesh/solid/mesh-surfaces/interface.vtp | 3 + .../mesh/solid/mesh-surfaces/outside.vtp | 3 + .../mesh/solid/mesh-surfaces/start.vtp | 3 + .../fsi/pipe_3d_ml_trilinos/result_005.vtu | 3 + .../cases/fsi/pipe_3d_ml_trilinos/results.gif | 3 + tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml | 157 ++ tests/cases/fsi/pipe_3d_petsc/README.md | 23 + .../cases/fsi/pipe_3d_petsc/configuration.png | 3 + .../mesh/fluid/mesh-complete.mesh.vtu | 3 + .../mesh/fluid/mesh-surfaces/end.vtp | 3 + .../mesh/fluid/mesh-surfaces/interface.vtp | 3 + .../mesh/fluid/mesh-surfaces/start.vtp | 3 + .../mesh/solid/mesh-complete.mesh.vtu | 3 + .../mesh/solid/mesh-surfaces/end.vtp | 3 + .../mesh/solid/mesh-surfaces/interface.vtp | 3 + .../mesh/solid/mesh-surfaces/outside.vtp | 3 + .../mesh/solid/mesh-surfaces/start.vtp | 3 + tests/cases/fsi/pipe_3d_petsc/result_005.vtu | 3 + tests/cases/fsi/pipe_3d_petsc/results.gif | 3 + tests/cases/fsi/pipe_3d_petsc/svFSI.xml | 157 ++ .../diffusion_line_source/svFSI_BICG.xml | 3 + .../heats/diffusion_line_source/svFSI_CG.xml | 4 +- .../diffusion_line_source/svFSI_GMRES.xml | 4 +- tests/cases/shell/plate/svFSI.xml | 3 + tests/cases/shell/valve/svFSI.xml | 3 + .../manufactured_solution/P1P1/N004/svFSI.xml | 4 +- .../manufactured_solution/P1P1/N008/svFSI.xml | 4 +- .../manufactured_solution/P1P1/N016/svFSI.xml | 5 +- .../manufactured_solution/P1P1/N032/svFSI.xml | 4 +- .../manufactured_solution/P1P1/N064/svFSI.xml | 4 +- .../manufactured_solution/P1P1/N128/svFSI.xml | 5 +- .../manufactured_solution/P1P1/N256/svFSI.xml | 5 +- .../manufactured_solution/P2P1/N004/svFSI.xml | 5 +- .../manufactured_solution/P2P1/N008/svFSI.xml | 5 +- .../manufactured_solution/P2P1/N016/svFSI.xml | 5 +- .../manufactured_solution/P2P1/N032/svFSI.xml | 6 +- .../manufactured_solution/P2P1/N064/svFSI.xml | 4 +- .../manufactured_solution/P2P1/N128/svFSI.xml | 4 +- .../struct/LV_Guccione_passive/svFSI.xml | 6 +- .../struct/LV_Holzapfel_passive/svFSI.xml | 20 +- .../cases/struct/block_compression/svFSI.xml | 4 +- tests/cases/struct/robin/svFSI.xml | 4 +- .../ustruct/LV_Guccione_active/result_001.vtu | 4 +- .../ustruct/LV_Guccione_active/svFSI.xml | 4 +- .../block_compression/P1P1_VMS/svFSI.xml | 4 +- .../ustruct/tensile_adventitia_HGO/svFSI.xml | 4 +- tests/conftest.py | 70 +- tests/test_fluid.py | 17 +- tests/test_fsi.py | 15 + tests/test_struct.py | 26 +- tests/test_ustruct.py | 20 - 194 files changed, 5954 insertions(+), 1902 deletions(-) create mode 100644 .github/workflows/test_ubuntu.yml delete mode 100644 .github/workflows/test_ubuntu20.yml delete mode 100644 .github/workflows/test_ubuntu22.yml create mode 100644 Code/Source/svFSI/FsilsLinearAlgebra.cpp create mode 100644 Code/Source/svFSI/FsilsLinearAlgebra.h create mode 100644 Code/Source/svFSI/LinearAlgebra.cpp create mode 100644 Code/Source/svFSI/LinearAlgebra.h create mode 100644 Code/Source/svFSI/PetscLinearAlgebra.cpp create mode 100644 Code/Source/svFSI/PetscLinearAlgebra.h create mode 100644 Code/Source/svFSI/TrilinosLinearAlgebra.cpp create mode 100644 Code/Source/svFSI/TrilinosLinearAlgebra.h create mode 100644 Code/Source/svFSI/petsc_impl.cpp create mode 100644 Code/Source/svFSI/petsc_impl.h create mode 100644 Code/Source/svFSI/trilinos_impl.cpp create mode 100644 Code/Source/svFSI/trilinos_impl.h create mode 100755 tests/cases/fluid/pipe_RCR_3d_bj_trilinos/README.md create mode 100755 tests/cases/fluid/pipe_RCR_3d_bj_trilinos/lumen_inlet.fcs create mode 100755 tests/cases/fluid/pipe_RCR_3d_bj_trilinos/lumen_inlet.flow create mode 100644 tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-complete.mesh.vtu create mode 100644 tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_inlet.vtp create mode 100644 tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_outlet.vtp create mode 100644 tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_wall.vtp create mode 100644 tests/cases/fluid/pipe_RCR_3d_bj_trilinos/result_002.vtu create mode 100755 tests/cases/fluid/pipe_RCR_3d_bj_trilinos/svFSI.xml create mode 100755 tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/README.md create mode 100755 tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/lumen_inlet.fcs create mode 100755 tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/lumen_inlet.flow create mode 100644 tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-complete.mesh.vtu create mode 100644 tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_inlet.vtp create mode 100644 tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_outlet.vtp create mode 100644 tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_wall.vtp create mode 100644 tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/result_002.vtu create mode 100755 tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/svFSI.xml create mode 100755 tests/cases/fluid/pipe_RCR_3d_petsc/README.md create mode 100755 tests/cases/fluid/pipe_RCR_3d_petsc/lumen_inlet.fcs create mode 100755 tests/cases/fluid/pipe_RCR_3d_petsc/lumen_inlet.flow create mode 100644 tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-complete.mesh.vtu create mode 100644 tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_inlet.vtp create mode 100644 tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_outlet.vtp create mode 100644 tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_wall.vtp create mode 100644 tests/cases/fluid/pipe_RCR_3d_petsc/result_002.vtu create mode 100755 tests/cases/fluid/pipe_RCR_3d_petsc/svFSI.xml create mode 100755 tests/cases/fsi/pipe_3d_bj_trilinos/README.md create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/configuration.png create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-complete.mesh.vtu create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/end.vtp create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/interface.vtp create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/start.vtp create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-complete.mesh.vtu create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/end.vtp create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/interface.vtp create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/outside.vtp create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/start.vtp create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/result_005.vtu create mode 100644 tests/cases/fsi/pipe_3d_bj_trilinos/results.gif create mode 100755 tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml create mode 100755 tests/cases/fsi/pipe_3d_ml_trilinos/README.md create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/configuration.png create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-complete.mesh.vtu create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/end.vtp create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/interface.vtp create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/start.vtp create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-complete.mesh.vtu create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/end.vtp create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/interface.vtp create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/outside.vtp create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/start.vtp create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/result_005.vtu create mode 100644 tests/cases/fsi/pipe_3d_ml_trilinos/results.gif create mode 100755 tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml create mode 100755 tests/cases/fsi/pipe_3d_petsc/README.md create mode 100644 tests/cases/fsi/pipe_3d_petsc/configuration.png create mode 100644 tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-complete.mesh.vtu create mode 100644 tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/end.vtp create mode 100644 tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/interface.vtp create mode 100644 tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/start.vtp create mode 100644 tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-complete.mesh.vtu create mode 100644 tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/end.vtp create mode 100644 tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/interface.vtp create mode 100644 tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/outside.vtp create mode 100644 tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/start.vtp create mode 100644 tests/cases/fsi/pipe_3d_petsc/result_005.vtu create mode 100644 tests/cases/fsi/pipe_3d_petsc/results.gif create mode 100755 tests/cases/fsi/pipe_3d_petsc/svFSI.xml diff --git a/.github/workflows/test_ubuntu.yml b/.github/workflows/test_ubuntu.yml new file mode 100644 index 00000000..d9c9ec83 --- /dev/null +++ b/.github/workflows/test_ubuntu.yml @@ -0,0 +1,60 @@ +name: test Ubuntu +on: [push, pull_request] +jobs: + test: + strategy: + matrix: + os: + - name: Ubuntu-20.04 + version: ubuntu-20.04 + image: ubuntu20 + - name: Ubuntu-22.04 + version: ubuntu-22.04 + image: ubuntu22 + runs-on: ${{ matrix.os.version }} + container: dcodoni/lib:${{ matrix.os.image }} + steps: + - uses: actions/checkout@v3 + - name: Build svFSIplus + run: | + mkdir build + cd build + cmake -DENABLE_COVERAGE=ON -DENABLE_ARRAY_INDEX_CHECKING=ON -DENABLE_UNIT_TEST=ON -DSV_USE_TRILINOS:BOOL=ON .. + make -j2 + cd .. + - name: Build svFSIplus (PETSc) + run: | + if [ -d "build-petsc" ]; then + rm -rf "build-petsc" + fi + mkdir build-petsc + cd build-petsc + cmake -DENABLE_COVERAGE=ON -DENABLE_ARRAY_INDEX_CHECKING=ON -DENABLE_UNIT_TEST=ON -DSV_PETSC_DIR:STRING=/petsc .. + make -j2 + cd .. + - name: Run integration tests + run: | + git config --global --add safe.directory /__w/svFSIplus/svFSIplus + git lfs pull + cd tests + conda run -n svfsiplus pytest -rPv --durations=0 + - name: Run unit tests + run: | + cd build/svFSI-build/Source/svFSI + ctest --verbose + - name: Generate code coverage + run: | + cd build/svFSI-build + make coverage + - name: Save coverage report + uses: actions/upload-artifact@v3 + with: + name: coverage_report + path: build/svFSI-build/coverage + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v3 + env: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + + + \ No newline at end of file diff --git a/.github/workflows/test_ubuntu20.yml b/.github/workflows/test_ubuntu20.yml deleted file mode 100644 index df42574e..00000000 --- a/.github/workflows/test_ubuntu20.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Ubuntu 20.04 -on: [push, pull_request] -jobs: - test: - runs-on: ubuntu-20.04 - container: msalvad/ubuntu20_vtk9:v1 - steps: - - uses: actions/checkout@v3 - - name: Build svFSIplus - run: | - mkdir build - cd build - cmake -DENABLE_COVERAGE=ON -DENABLE_ARRAY_INDEX_CHECKING=ON -DENABLE_UNIT_TEST=ON .. - make -j2 - cd .. - - name: Run integration tests - run: | - git config --global --add safe.directory /__w/svFSIplus/svFSIplus - git lfs pull - cd tests - conda run -n svfsiplus pytest -rPv --durations=0 - - name: Run unit tests - run: | - cd build/svFSI-build/Source/svFSI - ctest --verbose \ No newline at end of file diff --git a/.github/workflows/test_ubuntu22.yml b/.github/workflows/test_ubuntu22.yml deleted file mode 100644 index 86d0a8ed..00000000 --- a/.github/workflows/test_ubuntu22.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Ubuntu 22.04 -on: [push, pull_request] -jobs: - test: - runs-on: ubuntu-22.04 - container: msalvad/ubuntu22_vtk9:v1 - steps: - - uses: actions/checkout@v3 - - name: Build svFSIplus - run: | - mkdir build - cd build - cmake -DENABLE_COVERAGE=ON -DENABLE_ARRAY_INDEX_CHECKING=ON -DENABLE_UNIT_TEST=ON .. - make -j2 - cd .. - - name: Run integration tests - run: | - git config --global --add safe.directory /__w/svFSIplus/svFSIplus - git lfs pull - cd tests - conda run -n svfsiplus pytest -rPv --durations=0 - - name: Run unit tests - run: | - cd build/svFSI-build/Source/svFSI - ctest --verbose - - name: Generate code coverage - run: | - cd build/svFSI-build - make coverage - - name: Save coverage report - uses: actions/upload-artifact@v3 - with: - name: coverage_report - path: build/svFSI-build/coverage - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v3 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file diff --git a/Code/Source/svFSI/CMakeLists.txt b/Code/Source/svFSI/CMakeLists.txt index 00e7ccdc..5661ab92 100644 --- a/Code/Source/svFSI/CMakeLists.txt +++ b/Code/Source/svFSI/CMakeLists.txt @@ -1,3 +1,27 @@ +# Copyright (c) 2014-2015 The Regents of the University of California. +# All Rights Reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject +# to the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER +# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -84,11 +108,12 @@ if(NOT "${SV_PETSC_DIR}" STREQUAL "") message(" PETSC_LIBRARY_DIRS = ${PETSC_LIBRARY_DIRS}") message(" PETSC_INCLUDE_DIRS = ${PETSC_INCLUDE_DIRS}") - # Set PETSc include directory. + # Set PETSc include and library directories. include_directories(${PETSC_INCLUDE_DIRS}) + #link_directories(${PETSC_LIBRARY_DIRS}) - # Set C++ directive to use PETSc in svFSIplus code. - ADD_DEFINITIONS(-DWITH_PETSC) + # Set C++ directive to use PETSc. + ADD_DEFINITIONS(-DUSE_PETSC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -std=c99") set(USE_PETSC 1) @@ -123,6 +148,10 @@ set(lib ${SV_LIB_SVFSI_NAME}) set(CSRCS Array3.h Array3.cpp Array.h Array.cpp + LinearAlgebra.h LinearAlgebra.cpp + FsilsLinearAlgebra.h FsilsLinearAlgebra.cpp + PetscLinearAlgebra.h PetscLinearAlgebra.cpp + TrilinosLinearAlgebra.h TrilinosLinearAlgebra.cpp Tensor4.h Tensor4.cpp Vector.h Vector.cpp @@ -192,12 +221,12 @@ set(CSRCS ) # Set PETSc interace code. - if(USE_PETSC) - #set(CSRCS ${CSRCS} petsc_linear_solver.c) - endif() + #if(USE_PETSC) + # set(CSRCS ${CSRCS} petsc_linear_solver.h petsc_linear_solver.c) + #endif() if(USE_TRILINOS) - set(CSRCS ${CSRCS} trilinos_linear_solver.cpp) + #set(CSRCS ${CSRCS} trilinos_linear_solver.cpp) # trilinos directories and libraries include_directories(${Trilinos_TPL_INCLUDE_DIRS}) @@ -260,56 +289,4 @@ if(ENABLE_COVERAGE) WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) endif() -# unit tests and Google Test -if(ENABLE_UNIT_TEST) - - # link pthread on ubuntu20 - find_package(Threads REQUIRED) - - # install Google Test - include(FetchContent) - FetchContent_Declare( - googletest - URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip - ) - FetchContent_MakeAvailable(googletest) - enable_testing() - include(GoogleTest) - - # add test.cpp for unit test - - # remove the main.cpp and add test.cpp - list(APPEND CSRCS "../../../tests/unitTests/test.cpp") - list(REMOVE_ITEM CSRCS "main.cpp") - - # include source files (same as what svFSI does except for main.cpp) - add_executable(run_all_unit_tests ${CSRCS}) - - # libraries - target_link_libraries(run_all_unit_tests - ${GLOBAL_LIBRARIES} - ${INTELRUNTIME_LIBRARIES} - ${ZLIB_LIBRARY} - ${BLAS_LIBRARIES} - ${LAPACK_LIBRARIES} - ${METIS_SVFSI_LIBRARY_NAME} - ${PARMETIS_SVFSI_LIBRARY_NAME} - ${TETGEN_LIBRARY_NAME} - ${TINYXML_LIBRARY_NAME} - ${SV_LIB_SVFSILS_NAME}${SV_MPI_NAME_EXT} - ${VTK_LIBRARIES} - ) - - # link Google Test - target_link_libraries( - run_all_unit_tests - gtest - GTest::gtest_main - pthread # link pthread on ubuntu20 - ) - - # gtest_discover_tests(runUnitTest) - add_test(NAME all_unit_tests COMMAND run_all_unit_tests) - -endif() diff --git a/Code/Source/svFSI/ComMod.h b/Code/Source/svFSI/ComMod.h index dcd0536d..ed1399f5 100644 --- a/Code/Source/svFSI/ComMod.h +++ b/Code/Source/svFSI/ComMod.h @@ -56,6 +56,8 @@ #include #include +class LinearAlgebra; + /// @brief Fourier coefficients that are used to specify unsteady BCs // class fcType @@ -613,7 +615,6 @@ class outputType std::string name; }; - /// @brief Linear system of equations solver type // class lsType @@ -623,9 +624,6 @@ class lsType /// @brief LS solver (IN) consts::SolverType LS_type = consts::SolverType::lSolver_NA; - /// @brief Preconditioner (IN) - consts::PreconditionerType PREC_Type = consts::PreconditionerType::PREC_NONE; - /// @brief Successful solving (OUT) bool suc = false; @@ -667,6 +665,9 @@ class lsType /// @brief Calling duration (OUT) double callD = 0.0; + + //@brief Configuration file for linear solvers (Trilinos, PETSc) + std::string config; }; @@ -937,10 +938,6 @@ class mshType /// davep double Nxx(:,:,:) Array3 Nxx; - /// @brief Solution field (displacement, velocity, pressure, etc.) for a known, potentially - /// time-varying, quantity of interest across a mesh - Array3 Ys; - /// @brief Mesh Name std::string name; @@ -1071,6 +1068,18 @@ class eqType /// @brief type of linear solver lsType ls; + /// @brief The type of interface to a numerical linear algebra library. + consts::LinearAlgebraType linear_algebra_type; + + /// @brief The type of assembly interface to a numerical linear algebra library. + consts::LinearAlgebraType linear_algebra_assembly_type; + + /// @brief The type of preconditioner used by the interface to a numerical linear algebra library. + consts::PreconditionerType linear_algebra_preconditioner = consts::PreconditionerType::PREC_FSILS; + + /// @brief Interface to a numerical linear algebra library. + LinearAlgebra* linear_algebra = nullptr; + /// @brief FSILS type of linear solver fsi_linear_solver::FSILS_lsType FSILS; @@ -1289,23 +1298,6 @@ class ibType ibCommType cm; }; -/// @brief Data type for Trilinos Linear Solver related arrays -// -class tlsType -{ - public: - - /// @brief Local to global mapping - Vector ltg; - - /// @brief Factor for Dirichlet BCs - Array W; - - /// @brief Residual - Array R; -}; - - /// @brief The ComMod class duplicates the data structures in the Fortran COMMOD module /// defined in MOD.f. /// @@ -1376,8 +1368,7 @@ class ComMod { /// @brief Postprocess step - convert bin to vtk bool bin2VTK = false; - /// @brief Whether to use precomputed state-variable solutions - bool usePrecomp = false; + //----- int members -----// /// @brief Current domain @@ -1397,8 +1388,7 @@ class ComMod { /// @brief Current equation degrees of freedom int dof = 0; - /// @brief Global total number of nodes, across all meshes (total) and all - /// procs (global) + /// @brief Global total number of nodes int gtnNo = 0; /// @brief Number of equations @@ -1437,8 +1427,7 @@ class ComMod { /// @brief Total number of degrees of freedom per node int tDof = 0; - /// @brief Total number of nodes (number of nodes on current proc across - /// all meshes) + /// @brief Total number of nodes int tnNo = 0; /// @brief Restart Time Step @@ -1453,9 +1442,6 @@ class ComMod { /// @brief Time step size double dt = 0.0; - /// @brief Time step size of the precomputed state-variables - double precompDt = 0.0; - /// @brief Time double time = 0.0; @@ -1474,11 +1460,6 @@ class ComMod { /// @brief Stop_trigger file name std::string stopTrigName; - /// @brief Precomputed state-variable file name - std::string precompFileName; - - /// @brief Precomputed state-variable field name - std::string precompFieldName; // ALLOCATABLE DATA /// @brief Column pointer (for sparse LHS matrix structure) @@ -1524,7 +1505,7 @@ class ComMod { /// @brief LHS matrix Array Val; - /// @brief Position vector of mesh nodes (in ref config) + /// @brief Position vector Array x; /// @brief Old variables (velocity) @@ -1597,9 +1578,6 @@ class ComMod { /// @brief IB: Immersed boundary data structure ibType ib; - /// @brief Trilinos Linear Solver data type - tlsType tls; - bool debug_active = false; Timer timer; diff --git a/Code/Source/svFSI/FsilsLinearAlgebra.cpp b/Code/Source/svFSI/FsilsLinearAlgebra.cpp new file mode 100644 index 00000000..7cea23c6 --- /dev/null +++ b/Code/Source/svFSI/FsilsLinearAlgebra.cpp @@ -0,0 +1,149 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "FsilsLinearAlgebra.h" +#include "fsils_api.hpp" +#include "lhsa.h" +#include + +///////////////////////////////////////////////////////////////// +// F s i l s L i n e a r A l g e b r a // +///////////////////////////////////////////////////////////////// +// The following methods implement the FSILS LinearAlgebra interface. + +std::set FsilsLinearAlgebra::valid_assemblers = { + consts::LinearAlgebraType::none, + consts::LinearAlgebraType::fsils, +}; + +FsilsLinearAlgebra::FsilsLinearAlgebra() +{ + interface_type = consts::LinearAlgebraType::fsils; + assembly_type = consts::LinearAlgebraType::fsils; + preconditioner_type = consts::PreconditionerType::PREC_FSILS; +} + +/// @brief Allocate data arrays. +void FsilsLinearAlgebra::alloc(ComMod& com_mod, eqType& lEq) +{ + #define n_debug_alloc + #ifdef debug_alloc + std::cout << "[FsilsLinearAlgebra::alloc] ---------- alloc ---------- " << std::endl; + #endif + int dof = com_mod.dof; + + com_mod.Val.resize(dof*dof, com_mod.lhs.nnz); +} + +/// @brief Assemble local element arrays. +void FsilsLinearAlgebra::assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR) +{ + #define n_debug_assemble + #ifdef debug_assemble + std::cout << "[FsilsLinearAlgebra::assemble] ---------- assemble ---------- " << std::endl; + std::cout << "[FsilsLinearAlgebra::assemble] num_elem_nodes: " << num_elem_nodes << std::endl; + std::cout << "[FsilsLinearAlgebra::assemble] eqN.size(): " << eqN.size() << std::endl; + std::cout << "[FsilsLinearAlgebra::assemble] lK.size(): " << lK.size() << std::endl; + std::cout << "[FsilsLinearAlgebra::assemble] lR.size(): " << lR.size() << std::endl; + #endif + + lhsa_ns::do_assem(com_mod, num_elem_nodes, eqN, lK, lR); +} + +/// @brief Check the validity of the preconditioner and assembly types options. +void FsilsLinearAlgebra::check_options(const consts::PreconditionerType prec_cond_type, + const consts::LinearAlgebraType assembly_type) +{ + using namespace consts; + auto prec_cond_type_name = consts::preconditioner_type_to_name.at(prec_cond_type); + auto assembly_type_name = LinearAlgebra::type_to_name.at(assembly_type); + std::string error_msg; + + if (valid_assemblers.count(assembly_type) == 0) { + error_msg = "fsils linear algebra can't use '" + assembly_type_name + "' for assembly."; + } + + if (fsils_preconditioners.count(prec_cond_type) == 0) { + error_msg = "fsils linear algebra can't use '" + prec_cond_type_name + "' for a preconditioner."; + } + + if (error_msg != "") { + throw std::runtime_error("[svFSIplus] ERROR: " + error_msg); + } +} + +/// @brief Initialize framework. +void FsilsLinearAlgebra::initialize(ComMod& com_mod, eqType& lEq) +{ + // Nothing is needed to initialize FSILS. +} + +/// @brief Set the linear algebra package for assmbly. +void FsilsLinearAlgebra::set_assembly(consts::LinearAlgebraType atype) +{ + if (atype == consts::LinearAlgebraType::none) { + return; + } + + if (valid_assemblers.count(atype) == 0) { + auto str_type = LinearAlgebra::type_to_name.at(atype); + throw std::runtime_error("[FsilsLinearAlgebra] ERROR: Can't set fsils linear algebra to use '" + + str_type + "' for assembly."); + } + + assembly_type = atype; +} + +/// @brief Set the preconditioner. +void FsilsLinearAlgebra::set_preconditioner(consts::PreconditionerType prec_type) +{ + if (consts::fsils_preconditioners.count(prec_type) == 0) { + auto prec_cond_type_name = consts::preconditioner_type_to_name.at(prec_type); + throw std::runtime_error("[FsilsLinearAlgebra] ERROR: fsils linear algebra can't use '" + + prec_cond_type_name + "' for a preconditioner."); + return; + } + + preconditioner_type = prec_type; +} + +/// @brief Solve a system of linear equations. +void FsilsLinearAlgebra::solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res) +{ + auto& lhs = com_mod.lhs; + int dof = com_mod.dof; + auto& R = com_mod.R; + auto& Val = com_mod.Val; + auto preconditioner = lEq.linear_algebra_preconditioner; + + fsi_linear_solver::fsils_solve(lhs, lEq.FSILS, dof, R, Val, preconditioner, incL, res); +} + diff --git a/Code/Source/svFSI/FsilsLinearAlgebra.h b/Code/Source/svFSI/FsilsLinearAlgebra.h new file mode 100644 index 00000000..c01b5ab0 --- /dev/null +++ b/Code/Source/svFSI/FsilsLinearAlgebra.h @@ -0,0 +1,60 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FSILS_LINEAR_ALGEBRA_H +#define FSILS_LINEAR_ALGEBRA_H + +#include "LinearAlgebra.h" + +/// @brief The FsilsLinearAlgebra class implements the LinearAlgebra +/// interface for the FSILS numerical linear algebra included in svFSIplus. +/// +class FsilsLinearAlgebra : public virtual LinearAlgebra { + + public: + FsilsLinearAlgebra(); + ~FsilsLinearAlgebra() { }; + + virtual void alloc(ComMod& com_mod, eqType& lEq); + virtual void assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR); + virtual void check_options(const consts::PreconditionerType prec_cond_type, const consts::LinearAlgebraType assembly_type); + virtual void initialize(ComMod& com_mod, eqType& lEq); + virtual void solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res); + virtual void set_assembly(consts::LinearAlgebraType atype); + virtual void set_preconditioner(consts::PreconditionerType prec_type); + + private: + /// @brief A list of linear algebra interfaces that can be used for assembly. + static std::set valid_assemblers; +}; + +#endif + diff --git a/Code/Source/svFSI/LinearAlgebra.cpp b/Code/Source/svFSI/LinearAlgebra.cpp new file mode 100644 index 00000000..95d383b3 --- /dev/null +++ b/Code/Source/svFSI/LinearAlgebra.cpp @@ -0,0 +1,92 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "LinearAlgebra.h" +#include "PetscLinearAlgebra.h" +#include "FsilsLinearAlgebra.h" +#include "TrilinosLinearAlgebra.h" + +const std::map LinearAlgebra::name_to_type = { + {"none", consts::LinearAlgebraType::none}, + {"fsils", consts::LinearAlgebraType::fsils}, + {"petsc", consts::LinearAlgebraType::petsc}, + {"trilinos", consts::LinearAlgebraType::trilinos} +}; + +const std::map LinearAlgebra::type_to_name = { + {consts::LinearAlgebraType::none, "none"}, + {consts::LinearAlgebraType::fsils, "fsils"}, + {consts::LinearAlgebraType::petsc, "petsc"}, + {consts::LinearAlgebraType::trilinos, "trilinos"} +}; + +/// @brief Check that equation physics is compatible with LinearAlgebra type. +// +void LinearAlgebra::check_equation_compatibility(const consts::EquationType eq_physics, + const consts::LinearAlgebraType lin_alg_type, const consts::LinearAlgebraType assembly_type) +{ + using namespace consts; + + // ustruct physics requires fsils assembly. + // + if (eq_physics == EquationType::phys_ustruct) { + if ((lin_alg_type == LinearAlgebraType::trilinos) && + (assembly_type != LinearAlgebraType::fsils)) { + throw std::runtime_error("[svFSIplus] Equations with ustruct physics must use fsils for assembly."); + } + } +} + +LinearAlgebra::LinearAlgebra() +{ +} + +/// @brief Create objects derived from LinearAlgebra. +LinearAlgebra* LinearAlgebraFactory::create_interface(consts::LinearAlgebraType interface_type) +{ + LinearAlgebra* interface = nullptr; + + switch (interface_type) { + case consts::LinearAlgebraType::fsils: + interface = new FsilsLinearAlgebra(); + break; + + case consts::LinearAlgebraType::petsc: + interface = new PetscLinearAlgebra(); + break; + + case consts::LinearAlgebraType::trilinos: + interface = new TrilinosLinearAlgebra(); + break; + } + + return interface; +} + diff --git a/Code/Source/svFSI/LinearAlgebra.h b/Code/Source/svFSI/LinearAlgebra.h new file mode 100644 index 00000000..c1f81296 --- /dev/null +++ b/Code/Source/svFSI/LinearAlgebra.h @@ -0,0 +1,73 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef LINEAR_ALGEBRA_H +#define LINEAR_ALGEBRA_H + +#include "ComMod.h" +#include "consts.h" + +/// @brief The LinearAlgebra class provides an abstract interface to linear algebra +/// frameworks: FSILS, Trilinos, PETSc, etc. +// +class LinearAlgebra { + public: + static const std::map name_to_type; + static const std::map type_to_name; + static void check_equation_compatibility(const consts::EquationType eq_phys, + const consts::LinearAlgebraType lin_alg_type, const consts::LinearAlgebraType assembly_type); + + LinearAlgebra(); + virtual ~LinearAlgebra() { }; + virtual void alloc(ComMod& com_mod, eqType& lEq) = 0; + virtual void assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR) = 0; + virtual void check_options(const consts::PreconditionerType prec_cond_type, const consts::LinearAlgebraType assembly_type) = 0; + virtual void initialize(ComMod& com_mod, eqType& lEq) = 0; + virtual void set_assembly(consts::LinearAlgebraType assembly_type) = 0; + virtual void set_preconditioner(consts::PreconditionerType prec_type) = 0; + virtual void solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res) = 0; + + virtual consts::LinearAlgebraType get_interface_type() { return interface_type; } + + consts::LinearAlgebraType interface_type = consts::LinearAlgebraType::none; + consts::LinearAlgebraType assembly_type = consts::LinearAlgebraType::none; + consts::PreconditionerType preconditioner_type = consts::PreconditionerType::PREC_NONE; +}; + +/// @brief The LinearAlgebraFactory class provides a factory used to create objects derived from LinearAlgebra. +class LinearAlgebraFactory { + public: + static LinearAlgebra* create_interface(consts::LinearAlgebraType interface_type); +}; + + +#endif + diff --git a/Code/Source/svFSI/Parameters.cpp b/Code/Source/svFSI/Parameters.cpp index 13ed2884..05f33b10 100644 --- a/Code/Source/svFSI/Parameters.cpp +++ b/Code/Source/svFSI/Parameters.cpp @@ -61,6 +61,8 @@ // See LinearSolverParameters::set_values() for an example. // #include "Parameters.h" +#include "consts.h" +#include "LinearAlgebra.h" #include #include @@ -70,23 +72,28 @@ #include /// @brief Set paramaters using a function pointing to the 'ParameterLists::set_parameter_value' method. +// +// Subsection names given in 'sub_sections' are ignored and processed elsewhere. +// void xml_util_set_parameters( std::function fn, tinyxml2::XMLElement* xml_elem, - const std::string& error_msg) + const std::string& error_msg, std::set sub_sections = std::set()) { auto item = xml_elem->FirstChildElement(); while (item != nullptr) { auto name = std::string(item->Value()); - - if (item->GetText() != nullptr) { - auto value = item->GetText(); - try { - fn(name, value); - } catch (const std::bad_function_call& exception) { + + if (sub_sections.count(name) == 0) { + if (item->GetText() != nullptr) { + auto value = item->GetText(); + try { + fn(name, value); + } catch (const std::bad_function_call& exception) { + throw std::runtime_error(error_msg + name + "'."); + } + } else { throw std::runtime_error(error_msg + name + "'."); } - } else { - throw std::runtime_error(error_msg + name + "'."); } item = item->NextSiblingElement(); @@ -1803,12 +1810,9 @@ GeneralSimulationParameters::GeneralSimulationParameters() set_parameter("Starting time step", 0, !required, starting_time_step); set_parameter("Time_step_size", 0.0, required, time_step_size); - set_parameter("Precomputed_time_step_size", 0.0, !required, precomputed_time_step_size); + set_parameter("Verbose", false, !required, verbose); set_parameter("Warning", false, !required, warning); - set_parameter("Use_precomputed_solution", false, !required, use_precomputed_solution); - set_parameter("Precomputed_solution_file_path", "", !required, precomputed_solution_file_path); - set_parameter("Precomputed_solution_field_name", "", !required, precomputed_solution_field_name); } void GeneralSimulationParameters::print_parameters() @@ -2143,6 +2147,107 @@ void ProjectionParameters::set_values(tinyxml2::XMLElement* xml_elem) xml_util_set_parameters(ftpr, xml_elem, error_msg); } +////////////////////////////////////////////////////////// +// LinearAlgebraParameters // +////////////////////////////////////////////////////////// + +// The LinearAlgebraParameters class stores parameters for +// the 'Linear_algebra' XML element. + +/// @brief Define the XML element name for equation output parameters. +const std::string LinearAlgebraParameters::xml_element_name_ = "Linear_algebra"; + +LinearAlgebraParameters::LinearAlgebraParameters() +{ + // A parameter that must be defined. + bool required = true; + + auto alg_type = LinearAlgebra::type_to_name.at(consts::LinearAlgebraType::fsils); + type = Parameter("type", alg_type, required); + + set_parameter("Configuration_file", "", !required, configuration_file); + + auto prec_type = consts::preconditioner_type_to_name.at(consts::PreconditionerType::PREC_NONE); + set_parameter("Preconditioner", prec_type, !required, preconditioner); + + auto assemble_type = LinearAlgebra::type_to_name.at(consts::LinearAlgebraType::none); + set_parameter("Assembly", assemble_type, !required, assembly); +} + +void LinearAlgebraParameters::print_parameters() +{ + std::cout << std::endl; + std::cout << "-------------------------" << std::endl; + std::cout << "Linear Algebra Parameters" << std::endl; + std::cout << "-------------------------" << std::endl; + + std::cout << type.name() << ": " << type.value() << std::endl; + + auto params_name_value = get_parameter_list(); + for (auto& [ key, value ] : params_name_value) { + std::cout << key << ": " << value << std::endl; + } +} + +void LinearAlgebraParameters::set_values(tinyxml2::XMLElement* xml_elem) +{ + std::string error_msg = "Unknown " + xml_element_name + " XML element '"; + + // Get the 'type' from the element. + const char* stype; + auto result = xml_elem->QueryStringAttribute("type", &stype); + if (stype == nullptr) { + throw std::runtime_error("No TYPE given in the XML element."); + } + type.set(std::string(stype)); + + // Check Linear_algebra type=TYPE> element. + // + // TYPE in (fsils petsc trilinos) + // + if (LinearAlgebra::name_to_type.count(type.value()) == 0) { + std::string valid_types = ""; + std::for_each(LinearAlgebra::name_to_type.begin(), LinearAlgebra::name_to_type.end(), + [&valid_types](std::pair p) {valid_types += p.first+" ";}); + throw std::runtime_error("Unknown TYPE '" + type.value() + + "' given in the XML element.\nValid types are: " + valid_types); + } + + // Create a function pointer 'fptr' to 'LinearAlgebraParameters::set_parameter_value'. + // + using std::placeholders::_1; + using std::placeholders::_2; + std::function ftpr = + std::bind( &LinearAlgebraParameters::set_parameter_value, *this, _1, _2); + + // Parse XML and set parameter values. + xml_util_set_parameters(ftpr, xml_elem, error_msg); + + // Check preconditioner type. + if (consts::preconditioner_name_to_type.count(preconditioner.value()) == 0) { + std::string valid_types = ""; + std::for_each(consts::preconditioner_name_to_type.begin(), consts::preconditioner_name_to_type.end(), + [&valid_types](std::pair p) {valid_types += p.first+" ";}); + throw std::runtime_error("Unknown TYPE '" + preconditioner() + + "' given in the XML element.\nValid types are: " + valid_types); + } + + check_input_parameters(); + + values_set_ = true; +} + +/// @brief Check the validity of the input parameters. +void LinearAlgebraParameters::check_input_parameters() +{ + auto linear_algebra_type = LinearAlgebra::name_to_type.at(type()); + auto prec_cond_type = consts::preconditioner_name_to_type.at(preconditioner.value()); + auto assembly_type = LinearAlgebra::name_to_type.at(assembly.value()); + + auto linear_algebra = LinearAlgebraFactory::create_interface(linear_algebra_type); + linear_algebra->check_options(prec_cond_type, assembly_type); +} + ////////////////////////////////////////////////////////// // LinearSolverParameters // ////////////////////////////////////////////////////////// @@ -2172,11 +2277,9 @@ LinearSolverParameters::LinearSolverParameters() set_parameter("NS_GM_max_iterations", 1000, !required, ns_gm_max_iterations); set_parameter("NS_GM_tolerance", 1.0e-2, !required, ns_gm_tolerance); - set_parameter("Preconditioner", "", !required, preconditioner); + //set_parameter("Preconditioner", "", !required, preconditioner); set_parameter("Tolerance", 0.5, !required, tolerance); - - set_parameter("Use_trilinos_for_assembly", false, !required, use_trilinos_for_assembly); } void LinearSolverParameters::print_parameters() @@ -2192,7 +2295,6 @@ void LinearSolverParameters::print_parameters() for (auto& [ key, value ] : params_name_value) { std::cout << key << ": " << value << std::endl; } - } void LinearSolverParameters::set_values(tinyxml2::XMLElement* xml_elem) @@ -2205,6 +2307,7 @@ void LinearSolverParameters::set_values(tinyxml2::XMLElement* xml_elem) if (stype == nullptr) { throw std::runtime_error("No TYPE given in the XML element."); } + type.set(std::string(stype)); using std::placeholders::_1; @@ -2215,6 +2318,20 @@ void LinearSolverParameters::set_values(tinyxml2::XMLElement* xml_elem) std::bind( &LinearSolverParameters::set_parameter_value, *this, _1, _2); // Parse XML and set parameter values. - xml_util_set_parameters(ftpr, xml_elem, error_msg); + std::set sub_sections = {LinearAlgebraParameters::xml_element_name_}; + xml_util_set_parameters(ftpr, xml_elem, error_msg, sub_sections); + + // Set subsection values. + // + auto item = xml_elem->FirstChildElement(); + + while (item != nullptr) { + auto name = std::string(item->Value()); + if (name == LinearAlgebraParameters::xml_element_name_) { + linear_algebra.set_values(item); + } + item = item->NextSiblingElement(); + } + } diff --git a/Code/Source/svFSI/Parameters.h b/Code/Source/svFSI/Parameters.h index 697f7435..00b512b1 100644 --- a/Code/Source/svFSI/Parameters.h +++ b/Code/Source/svFSI/Parameters.h @@ -833,6 +833,26 @@ class ViscosityParameters : public ParameterLists ViscosityCassonsParameters cassons_model; }; +/// @brief The LinearAlgebraParameters class stores parameters for +/// the 'Linear_algebra' XML element. +class LinearAlgebraParameters : public ParameterLists +{ + public: + static const std::string xml_element_name_; + LinearAlgebraParameters(); + void check_input_parameters(); + void print_parameters(); + void set_values(tinyxml2::XMLElement* fsi_file); + bool defined() const { return values_set_; }; + + bool values_set_ = false; + Parameter type; + + Parameter assembly; + Parameter configuration_file; + Parameter preconditioner; +}; + /// @brief The LinearSolverParameters class stores parameters for /// the 'LS' XML element. class LinearSolverParameters : public ParameterLists @@ -856,11 +876,11 @@ class LinearSolverParameters : public ParameterLists Parameter ns_gm_max_iterations; Parameter ns_gm_tolerance; - Parameter preconditioner; + //Parameter preconditioner; Parameter tolerance; - Parameter use_trilinos_for_assembly; + LinearAlgebraParameters linear_algebra; }; /// @brief The StimulusParameters class stores parameters for @@ -1207,11 +1227,9 @@ class GeneralSimulationParameters : public ParameterLists Parameter start_averaging_from_zero; Parameter verbose; Parameter warning; - Parameter use_precomputed_solution; Parameter spectral_radius_of_infinite_time_step; Parameter time_step_size; - Parameter precomputed_time_step_size; Parameter increment_in_saving_restart_files; Parameter increment_in_saving_vtk_files; @@ -1225,9 +1243,7 @@ class GeneralSimulationParameters : public ParameterLists Parameter restart_file_name; Parameter searched_file_name_to_trigger_stop; Parameter save_results_in_folder; - Parameter simulation_initialization_file_path; - Parameter precomputed_solution_file_path; - Parameter precomputed_solution_field_name; + Parameter simulation_initialization_file_path; }; /// @brief The FaceParameters class is used to store parameters for the diff --git a/Code/Source/svFSI/PetscLinearAlgebra.cpp b/Code/Source/svFSI/PetscLinearAlgebra.cpp new file mode 100644 index 00000000..b7d00a09 --- /dev/null +++ b/Code/Source/svFSI/PetscLinearAlgebra.cpp @@ -0,0 +1,167 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "PetscLinearAlgebra.h" + +#include + +// Include PETSc-dependent data structures and functions. +// +#ifdef USE_PETSC +#include "petsc_impl.cpp" + +// If PETSc is not used then define PetscImpl with noop methods. +// +#else +class PetscLinearAlgebra::PetscImpl { + public: + PetscImpl(){}; + void initialize(ComMod& com_mod, eqType& lEq) {}; + void set_preconditioner(consts::PreconditionerType prec_type) {}; + void solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res) {}; +}; +#endif + +///////////////////////////////////////////////////////////////// +// P e t s c L i n e a r A l g e b r a // +///////////////////////////////////////////////////////////////// +// The following methods implement the LinearAlgebra interface. + +std::set PetscLinearAlgebra::valid_assemblers = { + consts::LinearAlgebraType::none, + consts::LinearAlgebraType::fsils +}; + +PetscLinearAlgebra::PetscLinearAlgebra() +{ + #ifndef USE_PETSC + throw std::runtime_error("[PetscLinearAlgebra] svFSIplus hase not been built with the PETSc package."); + #else + impl = new PetscLinearAlgebra::PetscImpl(); + interface_type = consts::LinearAlgebraType::petsc; + assembly_type = consts::LinearAlgebraType::none; + preconditioner_type = consts::PreconditionerType::PREC_PETSC_JACOBI; + #endif +} + +PetscLinearAlgebra::~PetscLinearAlgebra() +{ +} + +/// @brief Allocate data arrays. +void PetscLinearAlgebra::alloc(ComMod& com_mod, eqType& lEq) +{ + initialize_fsils(com_mod, lEq); +} + +/// @brief Assemble local element arrays. +void PetscLinearAlgebra::assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR) +{ + fsils_solver->assemble(com_mod, num_elem_nodes, eqN, lK, lR); +} + +/// @brief Check the validity of the precondition and assembly types options. +void PetscLinearAlgebra::check_options(const consts::PreconditionerType prec_cond_type, + const consts::LinearAlgebraType assembly_type) +{ + using namespace consts; + auto prec_cond_type_name = consts::preconditioner_type_to_name.at(prec_cond_type); + auto assembly_type_name = LinearAlgebra::type_to_name.at(assembly_type); + std::string error_msg; + + if (valid_assemblers.count(assembly_type) == 0) { + auto assembly_type_name = LinearAlgebra::type_to_name.at(assembly_type); + error_msg = "petsc linear algebra can't use '" + assembly_type_name + "' for assembly."; + } + + if (petsc_preconditioners.count(prec_cond_type) == 0) { + error_msg = "petsc linear algebra can't use '" + prec_cond_type_name + "' for preconditioning."; + } + + if (error_msg != "") { + throw std::runtime_error("[svFSIplus] ERROR: " + error_msg); + } +} + +/// @brief Initialize the PETSc framework. +void PetscLinearAlgebra::initialize(ComMod& com_mod, eqType& lEq) +{ + impl->initialize(com_mod, lEq); +} + +/// @brief Initialize an FsilsLinearAlgebra object used for assembly. +void PetscLinearAlgebra::initialize_fsils(ComMod& com_mod, eqType& lEq) +{ + fsils_solver = LinearAlgebraFactory::create_interface(consts::LinearAlgebraType::fsils); + fsils_solver->initialize(com_mod, lEq); + fsils_solver->alloc(com_mod, lEq); +} + +/// @brief Set the linear algebra package for assembly. +void PetscLinearAlgebra::set_assembly(consts::LinearAlgebraType atype) +{ + if (atype == consts::LinearAlgebraType::none) { + return; + } + + if (valid_assemblers.count(atype) == 0) { + auto str_type = LinearAlgebra::type_to_name.at(atype); + throw std::runtime_error("[PetscLinearAlgebra] ERROR: Can't set petsc linear algebra to use '" + + str_type + "' for assembly." + " petsc can only use 'fsils' for assembly."); + } + + assembly_type = atype; + + if (assembly_type == consts::LinearAlgebraType::fsils) { + use_fsils_assembly = true; + } +} + +/// @brief Set the proconditioner. +void PetscLinearAlgebra::set_preconditioner(consts::PreconditionerType prec_type) +{ + if (consts::petsc_preconditioners.count(prec_type) == 0) { + auto str_type = consts::preconditioner_type_to_name.at(prec_type); + throw std::runtime_error("[PetscLinearAlgebra] ERROR: petsc linear algebra can't use '" + + str_type + "' for a preconditioner."); + } + + preconditioner_type = prec_type; + impl->set_preconditioner(prec_type); +} + +/// @brief Solve a system of linear equations. +void PetscLinearAlgebra::solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res) +{ + //std::cout << "[PetscLinearAlgebra] solve" << std::endl; + impl->solve(com_mod, lEq, incL, res); +} + diff --git a/Code/Source/svFSI/PetscLinearAlgebra.h b/Code/Source/svFSI/PetscLinearAlgebra.h new file mode 100644 index 00000000..ca4fc20a --- /dev/null +++ b/Code/Source/svFSI/PetscLinearAlgebra.h @@ -0,0 +1,65 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef PETSC_LINEAR_ALGEBRA_H +#define PETSC_LINEAR_ALGEBRA_H + +#include "LinearAlgebra.h" + +/// @brief The PetscLinearAlgebra class implements the LinearAlgebra +/// interface for the PETSc numerical linear algebra package. +/// +class PetscLinearAlgebra : public virtual LinearAlgebra { + + public: + PetscLinearAlgebra(); + ~PetscLinearAlgebra(); + virtual void alloc(ComMod& com_mod, eqType& lEq); + virtual void assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR); + virtual void check_options(const consts::PreconditionerType prec_cond_type, const consts::LinearAlgebraType assembly_type); + virtual void initialize(ComMod& com_mod, eqType& lEq); + virtual void solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res); + virtual void set_assembly(consts::LinearAlgebraType assembly_type); + virtual void set_preconditioner(consts::PreconditionerType prec_type); + + private: + static std::set valid_assemblers; + void initialize_fsils(ComMod& com_mod, eqType& lEq); + /// @brief The FsilsLinearAlgebra object used to assemble local element matrices. + LinearAlgebra* fsils_solver = nullptr; + // Private class used to hide PETSc implementation details. + class PetscImpl; + PetscImpl* impl = nullptr; + bool use_fsils_assembly = false; +}; + +#endif + diff --git a/Code/Source/svFSI/Simulation.cpp b/Code/Source/svFSI/Simulation.cpp index 39d8c1e1..1e375d61 100644 --- a/Code/Source/svFSI/Simulation.cpp +++ b/Code/Source/svFSI/Simulation.cpp @@ -100,14 +100,6 @@ void Simulation::set_module_parameters() com_mod.stFileIncr = general.increment_in_saving_restart_files.value(); com_mod.rmsh.isReqd = general.simulation_requires_remeshing.value(); - com_mod.usePrecomp = general.use_precomputed_solution.value(); - com_mod.precompFileName = general.precomputed_solution_file_path.value(); - com_mod.precompFieldName = general.precomputed_solution_field_name.value(); - com_mod.precompDt = general.precomputed_time_step_size.value(); - if ((com_mod.precompDt == 0.0) && (com_mod.usePrecomp)) { - std::cout << "Precomputed time step size is zero. Setting to simulation time step size." << std::endl; - com_mod.precompDt = com_mod.dt; - } // Set simulation parameters. nTs = general.number_of_time_steps.value(); fTmp = general.simulation_initialization_file_path.value(); diff --git a/Code/Source/svFSI/Simulation.h b/Code/Source/svFSI/Simulation.h index 2f1ab3fd..25e18699 100644 --- a/Code/Source/svFSI/Simulation.h +++ b/Code/Source/svFSI/Simulation.h @@ -34,6 +34,7 @@ #include "ComMod.h" #include "Parameters.h" #include "SimulationLogger.h" +#include "LinearAlgebra.h" #include @@ -85,6 +86,8 @@ class Simulation { // Name of the history file. std::string history_file_name; + + LinearAlgebra* linear_algebra = nullptr; }; #endif diff --git a/Code/Source/svFSI/TrilinosLinearAlgebra.cpp b/Code/Source/svFSI/TrilinosLinearAlgebra.cpp new file mode 100644 index 00000000..da77d08f --- /dev/null +++ b/Code/Source/svFSI/TrilinosLinearAlgebra.cpp @@ -0,0 +1,205 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "TrilinosLinearAlgebra.h" +#include + +// Include Trilinos-dependent data structures and functions. +// +#ifdef WITH_TRILINOS +#include "trilinos_impl.cpp" + +// If Trilinos is not used then define TrilinosImpl with noop methods. +// +#else +class TrilinosLinearAlgebra::TrilinosImpl { + public: + TrilinosImpl(){}; + void alloc(ComMod& com_mod, eqType& lEq){}; + void assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR){}; + void initialize(ComMod& com_mod) {}; + void set_preconditioner(consts::PreconditionerType prec_type) {}; + void solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res) {}; + void solve_assembled(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res) {}; +}; +#endif + +///////////////////////////////////////////////////////////////// +// T r i l i n o s L i n e a r A l g e b r a // +///////////////////////////////////////////////////////////////// +// The following methods implement the Trilinos LinearAlgebra interface. + +/// Trilinos can use fsils or trilinos for assembly. +std::set TrilinosLinearAlgebra::valid_assemblers = { + consts::LinearAlgebraType::fsils, + consts::LinearAlgebraType::trilinos +}; + +TrilinosLinearAlgebra::TrilinosLinearAlgebra() +{ + #ifndef WITH_TRILINOS + throw std::runtime_error("[TrilinosLinearAlgebra] svFSIplus has not been built with Trilinos."); + #else + impl = new TrilinosLinearAlgebra::TrilinosImpl(); + interface_type = consts::LinearAlgebraType::trilinos; + assembly_type = consts::LinearAlgebraType::trilinos; + preconditioner_type = consts::PreconditionerType::PREC_TRILINOS_DIAGONAL; + #endif +} + +TrilinosLinearAlgebra::~TrilinosLinearAlgebra() +{ + if (fsils_solver != nullptr) { + delete fsils_solver; + } +} + +/// @brief Allocate data arrays. +void TrilinosLinearAlgebra::alloc(ComMod& com_mod, eqType& lEq) +{ + if (use_fsils_assembly) { + int dof = com_mod.dof; + com_mod.Val.resize(dof*dof, com_mod.lhs.nnz); + initialize_fsils(com_mod, lEq); + } + + impl->alloc(com_mod, lEq); +} + +/// @brief Assemble local element arrays. +/// +/// Assembly can be performed using fsils or trilinos. +/// +void TrilinosLinearAlgebra::assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR) +{ + if (use_fsils_assembly) { + fsils_solver->assemble(com_mod, num_elem_nodes, eqN, lK, lR); + } else { + impl->assemble(com_mod, num_elem_nodes, eqN, lK, lR); + } +} + +/// @brief Check the validity of the precondition and assembly options. +/// +/// Trilinos can use fsils or trilinos for assembly. +// +void TrilinosLinearAlgebra::check_options(const consts::PreconditionerType prec_cond_type, + const consts::LinearAlgebraType assembly_type) +{ + using namespace consts; + std::string error_msg; + + if (trilinos_preconditioners.count(prec_cond_type) == 0) { + auto prec_cond_type_name = consts::preconditioner_type_to_name.at(prec_cond_type); + error_msg = "trilinos linear algebra can't use '" + prec_cond_type_name + "' for a preconditioner."; + } + + if ((assembly_type != consts::LinearAlgebraType::none) && + (valid_assemblers.count(assembly_type) == 0)) { + auto assembly_type_name = LinearAlgebra::type_to_name.at(assembly_type); + error_msg = "trilinos linear algebra can't use '" + assembly_type_name + "' for assembly."; + } + + if (error_msg != "") { + throw std::runtime_error("[svFSIplus] ERROR: " + error_msg); + } +} + +/// @brief Initialize Trilinos framework. +void TrilinosLinearAlgebra::initialize(ComMod& com_mod, eqType& lEq) +{ + impl->initialize(com_mod); +} + +/// @brief Create an fsils linear algebra interface for assembly. +void TrilinosLinearAlgebra::initialize_fsils(ComMod& com_mod, eqType& lEq) +{ + #define n_debug_initialize_fsils + #ifdef debug_initialize_fsils + std::cout << "[TrilinosLinearAlgebra::initialize_fsils] ---------- initialize_fsils ---------- " << std::endl; + std::cout << "[TrilinosLinearAlgebra::initialize_fsils] preconditioner_type: " << preconditioner_type << std::endl; + #endif + + if (fsils_solver != nullptr) { + delete fsils_solver; + } + + fsils_solver = LinearAlgebraFactory::create_interface(consts::LinearAlgebraType::fsils); + fsils_solver->initialize(com_mod, lEq); + fsils_solver->alloc(com_mod, lEq); + fsils_solver->set_assembly(consts::LinearAlgebraType::fsils); +} + +/// @brief Set the linear algebra package for assmbly. +void TrilinosLinearAlgebra::set_assembly(consts::LinearAlgebraType atype) +{ + if (assembly_type == consts::LinearAlgebraType::none) { + return; + } + + if (valid_assemblers.count(atype) == 0) { + auto str_type = LinearAlgebra::type_to_name.at(atype); + throw std::runtime_error("[TrilinosLinearAlgebra] ERROR: Can't set Trilinos linear algebra to use '" + + str_type + "' for assembly." + " Trilinos can only use 'trilinos' for assembly."); + } + + assembly_type = atype; + + if (assembly_type == consts::LinearAlgebraType::fsils) { + use_fsils_assembly = true; + } +} + +/// @brief Set the proconditioner. +void TrilinosLinearAlgebra::set_preconditioner(consts::PreconditionerType prec_type) +{ + if (consts::trilinos_preconditioners.count(prec_type) == 0) { + auto str_type = consts::preconditioner_type_to_name.at(prec_type); + throw std::runtime_error("[TrilinosLinearAlgebra] ERROR: trilinos linear algebra can't use '" + + str_type + "' for a preconditioner."); + } + + preconditioner_type = prec_type; + impl->set_preconditioner(prec_type); +} + +/// @brief Solve a system of linear equations. +void TrilinosLinearAlgebra::solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res) +{ + //std::cout << "[TrilinosLinearAlgebra::solve] solve " << std::endl; + if (assembly_type == consts::LinearAlgebraType::trilinos) { + impl->solve_assembled(com_mod, lEq, incL, res); + } else { + impl->solve(com_mod, lEq, incL, res); + } +} + diff --git a/Code/Source/svFSI/TrilinosLinearAlgebra.h b/Code/Source/svFSI/TrilinosLinearAlgebra.h new file mode 100644 index 00000000..e145fa55 --- /dev/null +++ b/Code/Source/svFSI/TrilinosLinearAlgebra.h @@ -0,0 +1,66 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRILINOS_LINEAR_ALGEBRA_H +#define TRILINOS_LINEAR_ALGEBRA_H + +#include "LinearAlgebra.h" + +/// @brief The TrilinosLinearAlgebra class implements the LinearAlgebra +/// interface for the Trilinos numerical linear algebra package. +/// +class TrilinosLinearAlgebra : public virtual LinearAlgebra { + + public: + TrilinosLinearAlgebra(); + ~TrilinosLinearAlgebra(); + + virtual void alloc(ComMod& com_mod, eqType& lEq); + virtual void assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR); + virtual void check_options(const consts::PreconditionerType prec_cond_type, const consts::LinearAlgebraType assembly_type); + virtual void initialize(ComMod& com_mod, eqType& lEq); + virtual void set_assembly(consts::LinearAlgebraType atype); + virtual void set_preconditioner(consts::PreconditionerType prec_type); + virtual void solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res); + + private: + static std::set valid_assemblers; + void initialize_fsils(ComMod& com_mod, eqType& lEq); + bool use_fsils_assembly = false; + /// @brief The FsilsLinearAlgebra object used to assemble local element matrices. + LinearAlgebra* fsils_solver = nullptr; + // Private class used to hide Trilinos implementation details. + class TrilinosImpl; + TrilinosImpl* impl = nullptr; +}; + +#endif + diff --git a/Code/Source/svFSI/all_fun.cpp b/Code/Source/svFSI/all_fun.cpp index 89362b3f..94a02979 100644 --- a/Code/Source/svFSI/all_fun.cpp +++ b/Code/Source/svFSI/all_fun.cpp @@ -34,15 +34,12 @@ #include "mat_fun.h" #include "nn.h" #include "utils.h" -#include "consts.h" #include #include namespace all_fun { - using namespace consts; - //-------------- // aspect_ratio //-------------- @@ -295,14 +292,10 @@ global(const ComMod& com_mod, const CmMod& cm_mod, const mshType& lM, const Arra return result; } -/// @brief This routine integrated a scalar field over a particular domain. +/// @brief This routine integrate an equation over a particular domain /// /// Note that 'l' and 'u' should be 0-based and are used to index into 's'. -/// @param dId domain id -/// @param s an array containing a scalar value for each node in the mesh -/// @param l lower index of s -/// @param u upper index of s (must be equal to l) -/// @param pFlag flag for using Taylor-Hood function space for pressure +// /// Replicates 'FUNCTION vInteg(dId, s, l, u, pFlag)' defined in ALLFUN.f. // double integ(const ComMod& com_mod, const CmMod& cm_mod, int dId, const Array& s, int l, int u, bool pFlag) @@ -326,16 +319,10 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, int dId, const Array& s, bool pFlag, MechanicalConfigurationType cfg) +double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, const Vector& s, bool pFlag) { using namespace consts; #define n_debug_integ_s @@ -582,7 +564,7 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, co insd = 0; } - int nNo = s.size(); // Total number of nodes on a processor + int nNo = s.size(); #ifdef debug_integ_s dmsg << "nNo: " << nNo; dmsg << "insd: " << insd; @@ -592,16 +574,10 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, co if (nNo != com_mod.tnNo) { if (com_mod.ibFlag) { if (nNo != com_mod.ib.tnNo) { - std::string msg = "Incompatible vector size in integS on face: "; - msg += lFa.name; - msg += "\nNumber of nodes in s must be equal to total number of nodes (immersed boundary).\n"; - throw std::runtime_error(msg); + throw std::runtime_error("Incompatible vector size in Integ"); } } else { - std::string msg = "Incompatible vector size in integS on face: "; - msg += lFa.name; - msg += "\nNumber of nodes in s must be equal to total number of nodes.\n"; - throw std::runtime_error(msg); + throw std::runtime_error("Incompatible vector size in vInteg"); } } @@ -658,11 +634,8 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, co dmsg << "fs.eType: " << fs.eType; dmsg << "fs.w: " << fs.w; #endif - - // Initialize integral to 0 double result = 0.0; - // Loop over elements on face for (int e = 0; e < lFa.nEl; e++) { // [TODO:DaveP] not implemented. if (lFa.eType == ElementType::NRB) { @@ -676,19 +649,16 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, co fs.Nx = lFa.Nx; } - // Loop over the Gauss points for (int g = 0; g < fs.nG; g++) { Vector n(nsd); if (!isIB) { - // Get normal vector in cfg configuration auto Nx = fs.Nx.slice(g); - nn::gnnb(com_mod, lFa, e, g, nsd, insd, fs.eNoN, Nx, n, cfg); + nn::gnnb(com_mod, lFa, e, g, nsd, insd, fs.eNoN, Nx, n); } - // Calculating the Jacobian (encodes area of face element) double Jac = sqrt(utils::norm(n)); - // Calculating the function value at Gauss point + // Calculating the function value double sHat = 0.0; for (int a = 0; a < fs.eNoN; a++) { int Ac = lFa.IEN(a,e); @@ -700,7 +670,6 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, co } } - // If using multiple processors, add result from all processors if (com_mod.cm.seq() || isIB) { return result; } @@ -709,19 +678,11 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, co return result; } -/// @brief This routine integrates vector field s dotted with the face normal n -/// over the face lFa. For example, if s contains the velocity at each node on -/// the face, this function computed the velocity flux through the face. +/// @brief This routine integrate s over the surface faId. /// /// Reproduces 'FUNCTION IntegV(lFa, s)' -/// -/// @param lFa face type, representing a face on the computational mesh -/// @param s an array containing a vector value for each node in the mesh -/// @param pFlag flag for using Taylor-Hood function space for pressure -/// @param cfg denotes which configuration (reference/timestep 0, old/timestep n, or new/timestep n+1). Default reference. // -double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, - const Array& s, MechanicalConfigurationType cfg) +double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, const Array& s) { using namespace consts; @@ -738,16 +699,8 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, int insd = nsd - 1; int tnNo = com_mod.tnNo; - #ifdef debug_integ_V - dmsg << "s.nrows(): " << s.nrows(); - dmsg << "nsd: " << nsd; - #endif - if (s.nrows() != nsd) { - std::string msg = "Incompatible vector size in integV on face: "; - msg += lFa.name; - msg += "\nNumber of rows in s must be equal to number of spatial dimensions.\n"; - throw std::runtime_error(msg); + throw std::runtime_error("Incompatible vector size in integ"); } int nNo = s.ncols(); @@ -759,20 +712,13 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, if (nNo != tnNo) { if (com_mod.ibFlag) { if (nNo != com_mod.ib.tnNo) { - std::string msg = "Incompatible vector size in integV on face: "; - msg += lFa.name; - msg += "\nNumber of nodes in s must be equal to total number of nodes (immersed boundary).\n"; - throw std::runtime_error(msg); + throw std::runtime_error("Incompatible vector size in integ"); } } else { - std::string msg = "Incompatible vector size in integV on face: "; - msg += lFa.name; - msg += "\nNumber of nodes in s must be equal to total number of nodes.\n"; - throw std::runtime_error(msg); + throw std::runtime_error("Incompatible vector size in integ"); } } - // If using Immersed Boundary Method bool isIB = false; if (com_mod.ibFlag) { if (nNo == com_mod.ib.tnNo) { @@ -780,10 +726,8 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, } } - // Initialize integral to 0 double result = 0.0; - // Loop over elements on face for (int e = 0; e < lFa.nEl; e++) { //dmsg << "----- e " << e+1 << " -----"; // Updating the shape functions, if this is a NURB @@ -795,25 +739,23 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, } } - // Loop over the Gauss points for (int g = 0; g < lFa.nG; g++) { //dmsg << ">>> g: " << g+1; Vector n(nsd); if (!isIB) { - // Get normal vector in cfg configuration auto Nx = lFa.Nx.slice(g); - nn::gnnb(com_mod, lFa, e, g, nsd, nsd-1, lFa.eNoN, Nx, n, cfg); + nn::gnnb(com_mod, lFa, e, g, nsd, nsd-1, lFa.eNoN, Nx, n); //CALL GNNB(lFa, e, g, nsd-1, lFa.eNoN, lFa.Nx(:,:,g), n) } else { //CALL GNNIB(lFa, e, g, n) } - // Calculating the function value (s dot n)dA at this Gauss point + // Calculating the function value + // double sHat = 0.0; for (int a = 0; a < lFa.eNoN; a++) { int Ac = lFa.IEN(a,e); - // Compute s dot n for (int i = 0; i < nsd; i++) { sHat = sHat + lFa.N(a,g) * s(i,Ac) * n(i); //dmsg << "s(i,Ac): " << s(i,Ac); @@ -827,7 +769,6 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, } } - // If using multiple processors, add result from all processors if (cm.seq() || isIB) { return result; } @@ -837,25 +778,14 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, return result; } -/// @brief This routine integrate s(l:u,:) over the surface faId, where s is an -/// array of scalars or an array of nsd-vectors. This routine calls overloaded -/// functions to integrate scalars, if s is scalar (i.e. l=u), or vectors if s -/// is vector (i.e. l& s, const int l, std::optional uo, bool THflag, MechanicalConfigurationType cfg) + const Array& s, const int l, std::optional uo, bool THflag) { using namespace consts; @@ -873,8 +803,9 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, int insd = nsd - 1; int tnNo = com_mod.tnNo; - // Set u if uo is given. Else, set u = l. + // Set u if uo is given. int u{0}; + if (uo.has_value()) { u = uo.value(); } else { @@ -887,38 +818,30 @@ double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, if (nNo != tnNo) { if (com_mod.ibFlag) { if (nNo != com_mod.tnNo) { - std::string msg = "Incompatible vector size in integG on face: "; - msg += lFa.name; - msg += "\nNumber of nodes in s must be equal to total number of nodes (immersed boundary).\n"; - throw std::runtime_error(msg); + throw std::runtime_error("Incompatible vector size in integ"); } } else { - std::string msg = "Incompatible vector size in integG on face: "; - msg += lFa.name; - msg += "\nNumber of nodes in s must be equal to total number of nodes.\n"; - throw std::runtime_error(msg); + throw std::runtime_error("Incompatible vector size in integ"); } } - // Initialize integral to 0 (not strictly necessary to initialize to 0) double result = 0.0; - - // If s vector, integrate as vector (dot with surface normal) - if (u-l+1 == nsd) { + + if (u-l+1 == nsd) { Array vec(nsd,nNo); for (int a = 0; a < nNo; a++) { for (int i = l, n = 0; i <= u; i++, n++) { vec(n,a) = s(i,a); } } - result = integ(com_mod, cm_mod, lFa, vec, cfg); - // If s scalar, integrate as scalar + result = integ(com_mod, cm_mod, lFa, vec); + } else if (l == u) { Vector sclr(nNo); for (int a = 0; a < nNo; a++) { sclr(a) = s(l,a); } - result = integ(com_mod, cm_mod, lFa, sclr, flag, cfg); + result = integ(com_mod, cm_mod, lFa, sclr, flag); } else { throw std::runtime_error("Unexpected dof in integ"); } @@ -1095,67 +1018,6 @@ local(const ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, Array -local(const ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, Array3& U){ - if (com_mod.ltg.size() == 0) { - throw std::runtime_error("ltg is not set yet"); - } - - Array3 local_array; - int m; - int n; - int r; - - if (cm.mas(cm_mod)) { - m = U.nrows(); // nsd - r = U.ncols(); // tnNo - n = U.nslices(); // time - if (U.ncols() != com_mod.gtnNo) { - throw std::runtime_error("local_rv is only specified for vector with size gtnNo"); - } - } - - if (cm.seq()) { - local_array.resize(m, com_mod.gtnNo, U.nslices()); - local_array = U; - return local_array; - } - - cm.bcast(cm_mod, &m); - cm.bcast(cm_mod, &n); - cm.bcast(cm_mod, &r); - - local_array.resize(m, com_mod.tnNo, n); - Vector tmpU(m * com_mod.gtnNo * n); - - if (cm.mas(cm_mod)) { - for (int a = 0; a < com_mod.gtnNo; a++) { - int s = m * a; - for (int i = 0; i < n; i++) { - int e = i * m * (com_mod.gtnNo); - for (int j = 0; j < m; j++) { - tmpU(j+s+e) = U(j, a, i); - } - } - } - } - - cm.bcast(cm_mod, tmpU); - - for (int a = 0; a < com_mod.tnNo; a++) { - int Ac = com_mod.ltg[a]; - int s = m * Ac; - for (int i = 0; i < n; i++) { - int e = i * m * (com_mod.gtnNo); - for (int j = 0; j < m; j++) { - local_array(j, a, i) = tmpU(j+s+e); - } - } - } - - return local_array; -} - Vector mkc(const ComMod& com_mod, Vector& U) { diff --git a/Code/Source/svFSI/all_fun.h b/Code/Source/svFSI/all_fun.h index 681646d8..8f146ee4 100644 --- a/Code/Source/svFSI/all_fun.h +++ b/Code/Source/svFSI/all_fun.h @@ -31,9 +31,7 @@ #ifndef ALL_FUN_H #define ALL_FUN_H -#include "Array3.h" #include "Array.h" -#include "Vector.h" #include "ComMod.h" #include "consts.h" @@ -60,23 +58,20 @@ namespace all_fun { bool pFlag=false); double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, const Vector& s, - bool pFlag=false, consts::MechanicalConfigurationType cfg=consts::MechanicalConfigurationType::reference); + bool pFlag=false); double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, const Array& s, - const int l, std::optional uo=std::nullopt, bool THflag=false, consts::MechanicalConfigurationType cfg=consts::MechanicalConfigurationType::reference); + const int l, std::optional uo=std::nullopt, bool THflag=false); - double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, const Array& s, consts::MechanicalConfigurationType cfg=consts::MechanicalConfigurationType::reference); + double integ(const ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, const Array& s); bool is_domain(const ComMod& com_mod, const eqType& eq, const int node, const consts::EquationType phys); double jacobian(ComMod& com_mod, const int nDim, const int eNoN, const Array& x, const Array&Nxi); Vector local(const ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, Vector& u); - Array local(const ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, Array& u); - Array3 local(const ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, Array3& u); - Vector mkc(const ComMod& com_mod, Vector& U); Array mkc(const ComMod& com_mod, Array& U); diff --git a/Code/Source/svFSI/baf_ini.cpp b/Code/Source/svFSI/baf_ini.cpp index 12e215a4..b4fa389f 100644 --- a/Code/Source/svFSI/baf_ini.cpp +++ b/Code/Source/svFSI/baf_ini.cpp @@ -121,8 +121,7 @@ void baf_ini(Simulation* simulation) int iEq = 0; com_mod.cplBC.fa.resize(com_mod.cplBC.nFa); com_mod.cplBC.xn.resize(com_mod.cplBC.nX); - - // Assign cplBC internal variables + if (com_mod.cplBC.coupled) { auto& eq = com_mod.eq[iEq]; for (int iBc = 0; iBc < eq.nBc; iBc++) { @@ -140,8 +139,6 @@ void baf_ini(Simulation* simulation) } else if (utils::btest(bc.bType, iBC_Neu)) { com_mod.cplBC.fa[i].bGrp = CplBCType::cplBC_Neu; - // For implicit or semi-implicit (not explicit) Neumann 0D coupling scheme, - // set bType to resistance if (com_mod.cplBC.schm != CplBCType::cplBC_E) { bc.bType= utils::ibset(bc.bType, iBC_res); } @@ -486,7 +483,6 @@ void face_ini(Simulation* simulation, mshType& lM, faceType& lFa) dmsg << "Flag: " << flag; #endif - // Compute integral of normal vector over surface element if (!flag) { Vector nV(nsd); for (int e = 0; e < lFa.nEl; e++) { @@ -706,7 +702,6 @@ void fsi_ls_ini(ComMod& com_mod, const CmMod& cm_mod, bcType& lBc, const faceTyp Array sV(nsd,tnNo); Vector gNodes(nNo); - // Copy mesh node id corresponding to face node id to gNodes for (int a= 0; a < nNo; a++) { gNodes(a) = lFa.gN(a); } @@ -738,7 +733,6 @@ void fsi_ls_ini(ComMod& com_mod, const CmMod& cm_mod, bcType& lBc, const faceTyp } } else if (btest(lBc.bType, iBC_Neu)) { - // Compute integral of normal vector over the face (needed for resistance BC/0D-coupling) if (btest(lBc.bType, iBC_res)) { sV = 0.0; for (int e = 0; e < lFa.nEl; e++) { @@ -768,8 +762,6 @@ void fsi_ls_ini(ComMod& com_mod, const CmMod& cm_mod, bcType& lBc, const faceTyp lsPtr = lsPtr + 1; lBc.lsPtr = lsPtr; - - // Fills lhs.face(i) variables, including val is sVl exists fsils_bc_create(com_mod.lhs, lsPtr, lFa.nNo, nsd, BcType::BC_TYPE_Neu, gNodes, sVl); } else { lBc.lsPtr = -1; diff --git a/Code/Source/svFSI/bf.cpp b/Code/Source/svFSI/bf.cpp index 63f6492d..12d0c6be 100644 --- a/Code/Source/svFSI/bf.cpp +++ b/Code/Source/svFSI/bf.cpp @@ -40,10 +40,6 @@ #include "shells.h" #include "utils.h" -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace bf { /// @brief This subroutine is reached only for shell follower pressre loads @@ -112,21 +108,8 @@ void bf_construct(ComMod& com_mod, const mshType& lM, const int e, const int eNo } } - // Now doing the assembly part - -#ifdef WITH_TRILINOS - - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), const_cast(ptr.data()), lK.data(), lR.data()); - } else { - -#endif - - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); - -#ifdef WITH_TRILINOS - } -#endif + // Now doing the assembly part + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } /// @brief Modifes: com_mod.Bf, Dg diff --git a/Code/Source/svFSI/cep.cpp b/Code/Source/svFSI/cep.cpp index cf34b096..9093ad89 100644 --- a/Code/Source/svFSI/cep.cpp +++ b/Code/Source/svFSI/cep.cpp @@ -38,10 +38,6 @@ #include -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace cep { void b_cep(ComMod& com_mod, const int eNoN, const double w, const Vector& N, const double h, Array& lR) @@ -586,15 +582,7 @@ void construct_cep(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Ar } // Assembly -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), const_cast(ptr.data()), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } // Communications among processors for ECG leads computation diff --git a/Code/Source/svFSI/cmm.cpp b/Code/Source/svFSI/cmm.cpp index 9091eadb..9355ed21 100644 --- a/Code/Source/svFSI/cmm.cpp +++ b/Code/Source/svFSI/cmm.cpp @@ -40,10 +40,6 @@ #include "utils.h" #include -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace cmm { void cmm_3d(ComMod& com_mod, const int eNoN, const double w, const Vector& N, const Array& Nx, @@ -321,19 +317,9 @@ void cmm_b(ComMod& com_mod, const faceType& lFa, const int e, const Array(n), const_cast(ptr.data()), lK.data(), lR.data()); -#endif - } else { - lhsa_ns::do_assem(com_mod, 3, ptr, lK, lR); - } + eq.linear_algebra->assemble(com_mod, 3, ptr, lK, lR); } - void bcmmi(ComMod& com_mod, const int eNoN, const int idof, const double w, const Vector& N, const Array& Nxi, const Array& xl, const Array& tfl, Array& lR) { @@ -445,21 +431,9 @@ void cmmi(ComMod& com_mod, const mshType& lM, const Array& al, const Arr } } - // Now doing the assembly part -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - int numNodesPerElement = 3; - trilinos_doassem_(numNodesPerElement, const_cast(ptr.data()), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, 3, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif - + eq.linear_algebra->assemble(com_mod, 3, ptr, lK, lR); } - void cmm_mass(ComMod& com_mod, const double w, const Vector& N, const Array& al, const Array& bfl, const Vector& vwp, Array& lR, Array3& lK) { @@ -930,18 +904,7 @@ void construct_cmm(ComMod& com_mod, const mshType& lM, const Array& Ag, cmm_3d(com_mod, eNoN, w, N, Nx, al, yl, bfl, ksix, lR, lK); } - // Assembly - // -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif - + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } } } diff --git a/Code/Source/svFSI/consts.cpp b/Code/Source/svFSI/consts.cpp index a8f3fee3..0ee1f2cf 100644 --- a/Code/Source/svFSI/consts.cpp +++ b/Code/Source/svFSI/consts.cpp @@ -203,29 +203,66 @@ const std::map mesh_generator_name_to_type = { {"Meshsim", MeshGeneratorType::RMSH_MESHSIM} }; -/// @brief Map for preconditioner type string to PreconditionerType enum -// -const std::map preconditioner_name_to_type = -{ - {"fsils", std::make_pair(PreconditionerType::PREC_FSILS,false)}, - {"svfsi", std::make_pair(PreconditionerType::PREC_FSILS,false)}, - - {"rcs", std::make_pair(PreconditionerType::PREC_RCS,false)}, - {"row-column-scaling", std::make_pair(PreconditionerType::PREC_RCS,false)}, - - {"trilinos-diagonal", std::make_pair(PreconditionerType::PREC_TRILINOS_DIAGONAL,true)}, - - {"trilinos-blockjacobi", std::make_pair(PreconditionerType::PREC_TRILINOS_BLOCK_JACOBI,true)}, - {"blockjacobi", std::make_pair(PreconditionerType::PREC_TRILINOS_BLOCK_JACOBI,true)}, +/// @brief The list of Trilinos preconditioners. +const std::set trilinos_preconditioners = { + PreconditionerType::PREC_TRILINOS_DIAGONAL, + PreconditionerType::PREC_TRILINOS_BLOCK_JACOBI, + PreconditionerType::PREC_TRILINOS_ILU, + PreconditionerType::PREC_TRILINOS_ILUT, + PreconditionerType::PREC_TRILINOS_IC, + PreconditionerType::PREC_TRILINOS_ICT, + PreconditionerType::PREC_TRILINOS_ML +}; - {"trilinos-ilu", std::make_pair(PreconditionerType::PREC_TRILINOS_ILU,true)}, - {"trilinos-ilut", std::make_pair(PreconditionerType::PREC_TRILINOS_ILUT,true)}, +/// @brief The list of FSILS preconditioners. +const std::set fsils_preconditioners = { + PreconditionerType::PREC_FSILS, + PreconditionerType::PREC_RCS +}; - {"trilinos-ic", std::make_pair(PreconditionerType::PREC_TRILINOS_IC,true)}, - {"trilinos-ict", std::make_pair(PreconditionerType::PREC_TRILINOS_ICT,true)}, +/// @brief The list of PETSc preconditioners. +const std::set petsc_preconditioners = { + PreconditionerType::PREC_PETSC_JACOBI, + PreconditionerType::PREC_PETSC_RCS +}; - {"trilinos-ml", std::make_pair(PreconditionerType::PREC_TRILINOS_ML,true)} +/// @brief Map for preconditioner type string to PreconditionerType enum +// +const std::map preconditioner_name_to_type = +{ + {"none", PreconditionerType::PREC_NONE}, + + {"fsils", PreconditionerType::PREC_FSILS}, + {"rcs", PreconditionerType::PREC_RCS}, + {"row-column-scaling", PreconditionerType::PREC_RCS}, + + {"trilinos-diagonal", PreconditionerType::PREC_TRILINOS_DIAGONAL}, + {"trilinos-blockjacobi", PreconditionerType::PREC_TRILINOS_BLOCK_JACOBI}, + {"trilinos-ilu", PreconditionerType::PREC_TRILINOS_ILU}, + {"trilinos-ilut", PreconditionerType::PREC_TRILINOS_ILUT}, + {"trilinos-ic", PreconditionerType::PREC_TRILINOS_IC}, + {"trilinos-ict", PreconditionerType::PREC_TRILINOS_ICT}, + {"trilinos-ml", PreconditionerType::PREC_TRILINOS_ML}, + + {"petsc-jacobi", PreconditionerType::PREC_PETSC_JACOBI}, + {"petsc-rcs", PreconditionerType::PREC_PETSC_RCS} +}; +/// @brief Map for PreconditionerType enum to a string name. +// +const std::map preconditioner_type_to_name { + {PreconditionerType::PREC_FSILS, "fsils"}, + {PreconditionerType::PREC_NONE, "none"}, + {PreconditionerType::PREC_RCS, "row-column-scaling"}, + {PreconditionerType::PREC_TRILINOS_DIAGONAL, "trilinos-diagonal"}, + {PreconditionerType::PREC_TRILINOS_BLOCK_JACOBI, "trilinos-blockjacobi"}, + {PreconditionerType::PREC_TRILINOS_ILU, "trilinos-ilu"}, + {PreconditionerType::PREC_TRILINOS_ILUT, "trilinos-ilut"}, + {PreconditionerType::PREC_TRILINOS_IC, "trilinos-ic"}, + {PreconditionerType::PREC_TRILINOS_IC, "trilinos-ict"}, + {PreconditionerType::PREC_TRILINOS_ML, "trilinos-ml"}, + {PreconditionerType::PREC_PETSC_JACOBI, "petsc-jacobi"}, + {PreconditionerType::PREC_PETSC_RCS, "petsc-rcs"} }; /// @brief Map solver type string to SolverType enum. diff --git a/Code/Source/svFSI/consts.h b/Code/Source/svFSI/consts.h index 1e978648..61204539 100644 --- a/Code/Source/svFSI/consts.h +++ b/Code/Source/svFSI/consts.h @@ -34,7 +34,9 @@ #include #include #include +#include #include +#include // The enums here replicate the PARAMETERs defined // in CONSTS.f. @@ -422,13 +424,18 @@ enum class PreconditionerType PREC_TRILINOS_IC = 706, PREC_TRILINOS_ICT = 707, PREC_TRILINOS_ML = 708, - PREC_RCS = 709 + PREC_RCS = 709, + PREC_PETSC_JACOBI = 710, + PREC_PETSC_RCS = 711 }; -/// Map for preconditioner type string to pair (PreconditionerType enum, bool(true if Trilinos precondition)). -using PreconditionerMapType = std::pair; -//extern const std::map preconditioner_name_to_type; -extern const std::map preconditioner_name_to_type; +extern const std::set fsils_preconditioners; +extern const std::set petsc_preconditioners; +extern const std::set trilinos_preconditioners; +extern const std::map preconditioner_type_to_name; + +/// Map for preconditioner type string to PreconditionerType enum. +extern const std::map preconditioner_name_to_type; enum class SolverType { @@ -460,13 +467,19 @@ std::ostream& operator<<(typename std::enable_if::value, std::os return stream << static_cast::type>(e); } -//// Mechanical configurations -enum class MechanicalConfigurationType -{ - reference, // reference configuration - old_timestep, // old timestep (n) configuration - new_timestep // new timestep (n+1) configuration +//------------------- +// LinearAlgebraType +//------------------- +// The type of the numerical linear algebra library. +// +enum class LinearAlgebraType { + none, + fsils, + petsc, + trilinos }; + + }; #endif diff --git a/Code/Source/svFSI/distribute.cpp b/Code/Source/svFSI/distribute.cpp index c1f9bdfd..1fc16bf7 100644 --- a/Code/Source/svFSI/distribute.cpp +++ b/Code/Source/svFSI/distribute.cpp @@ -224,6 +224,7 @@ void distribute(Simulation* simulation) if (cm.seq()) { for (int iEq = 0; iEq < com_mod.nEq; iEq++) { auto& eq = com_mod.eq[iEq]; + for (int iBf = 0; iBf < eq.nBf; iBf++) { auto& bf = eq.bf[iBf]; @@ -309,7 +310,6 @@ void distribute(Simulation* simulation) cm.bcast(cm_mod, &com_mod.startTS); cm.bcast(cm_mod, &com_mod.nEq); cm.bcast(cm_mod, &com_mod.dt); - cm.bcast(cm_mod, &com_mod.precompDt); cm.bcast(cm_mod, &com_mod.zeroAve); cm.bcast(cm_mod, &com_mod.cmmInit); @@ -321,7 +321,6 @@ void distribute(Simulation* simulation) cm.bcast(cm_mod, &simulation->cep_mod.cepEq); - cm.bcast(cm_mod, &com_mod.usePrecomp); if (com_mod.rmsh.isReqd) { auto& rmsh = com_mod.rmsh; cm.bcast_enum(cm_mod, &rmsh.method); @@ -485,7 +484,8 @@ void distribute(Simulation* simulation) auto& cep_mod = simulation->cep_mod; for (int iEq = 0; iEq < com_mod.nEq; iEq++) { - dist_eq(com_mod, cm_mod, cm, tMs, gmtl, cep_mod, com_mod.eq[iEq]); + auto& eq = com_mod.eq[iEq]; + dist_eq(com_mod, cm_mod, cm, tMs, gmtl, cep_mod, eq); } // For CMM initialization @@ -928,8 +928,6 @@ void dist_bf(ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, bfType& lBf } } - - void dist_eq(ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, const std::vector& tMs, const Vector& gmtl, CepMod& cep_mod, eqType& lEq) { @@ -985,7 +983,10 @@ void dist_eq(ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, const std:: cm.bcast(cm_mod, &lEq.FSILS.CG.sD); cm.bcast_enum(cm_mod, &lEq.ls.LS_type); - cm.bcast_enum(cm_mod, &lEq.ls.PREC_Type); + + cm.bcast_enum(cm_mod, &lEq.linear_algebra_type); + cm.bcast_enum(cm_mod, &lEq.linear_algebra_preconditioner); + cm.bcast_enum(cm_mod, &lEq.linear_algebra_assembly_type); cm.bcast(cm_mod, &lEq.ls.relTol); cm.bcast(cm_mod, &lEq.ls.absTol); @@ -1146,6 +1147,7 @@ void dist_eq(ComMod& com_mod, const CmMod& cm_mod, const cmType& cm, const std:: for (int iBf = 0; iBf < lEq.nBf; iBf++) { dist_bf(com_mod, cm_mod, cm, lEq.bf[iBf]); } + } @@ -1425,13 +1427,6 @@ void part_face(Simulation* simulation, mshType& lM, faceType& lFa, faceType& gFa /// @brief Reproduces the Fortran 'PARTMSH' subroutine. -/// Parameters for the part_msh function: -/// @param[in] simulation A pointer to the simulation object. -/// @param[in] iM The mesh index. -/// @param[in] lM The local mesh data. -/// @param[in] gmtl The global to local map. -/// @param[in] nP The number of processors. -/// @param[in] wgt The weights. // void part_msh(Simulation* simulation, int iM, mshType& lM, Vector& gmtl, int nP, Vector& wgt) { @@ -2026,27 +2021,6 @@ void part_msh(Simulation* simulation, int iM, mshType& lM, Vector& gmtl, in // Now scattering the sorted lM%INN to all processors MPI_SCATTERV(tempIEN, sCount, disp, mpint, lM%INN, nEl*insd, mpint, master, cm%com(), ierr) */ - } - // If necessary, distribute precomputed state-variable data. - // - flag = (lM.Ys.size() != 0); - cm.bcast(cm_mod, &flag); - if (flag){ - #ifdef dbg_part_msh - dmsg << "Distributing precomputed state-variable data " << " ..."; - #endif - Array3 tmpYs; - int nsYs = lM.Ys.nslices(); - if (cm.mas(cm_mod)) { - tmpYs.resize(lM.Ys.nrows(), lM.Ys.ncols(), nsYs); - tmpYs = lM.Ys; - lM.Ys.clear(); - } else { - tmpYs.clear(); - } - lM.Ys.resize(com_mod.nsd, com_mod.tnNo, nsYs); - lM.Ys = all_fun::local(com_mod, cm_mod, cm, tmpYs); - tmpYs.clear(); - } + } } diff --git a/Code/Source/svFSI/eq_assem.cpp b/Code/Source/svFSI/eq_assem.cpp index fe274e30..2c4eb2df 100644 --- a/Code/Source/svFSI/eq_assem.cpp +++ b/Code/Source/svFSI/eq_assem.cpp @@ -49,14 +49,8 @@ #include "sv_struct.h" #include "ustruct.h" -#include - #include -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace eq_assem { void b_assem_neu_bc(ComMod& com_mod, const faceType& lFa, const Vector& hg, const Array& Yg) @@ -171,37 +165,21 @@ void b_assem_neu_bc(ComMod& com_mod, const faceType& lFa, const Vector& } } - // Now doing the assembly part - -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); - } else { - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); - } -#else - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } } - -/// @brief For struct/ustruct - construct follower pressure load contribution -/// to the residual vector and stiffness matrix. +/// @brief For struct/ustruct - construct follower pressure load. +/// /// We use Nanson's formula to take change in normal direction with /// deformation into account. Additional calculations based on mesh /// need to be performed. /// /// Reproduces 'SUBROUTINE BNEUFOLWP(lFa, hg, Dg)' -/// @param com_mod -/// @param lBc -/// @param lFa -/// @param hg Pressure magnitude -/// @param Dg -void b_neu_folw_p(ComMod& com_mod, const bcType& lBc, const faceType& lFa, const Vector& hg, const Array& Dg) +// +void b_neu_folw_p(ComMod& com_mod, const faceType& lFa, const Vector& hg, const Array& Dg) { using namespace consts; - using namespace utils; #define n_debug_b_neu_folw_p #ifdef debug_b_neu_folw_p @@ -284,7 +262,6 @@ void b_neu_folw_p(ComMod& com_mod, const bcType& lBc, const faceType& lFa, const nn::gnn(eNoN, nsd, nsd, Nxi, xl, Nx, Jac, ksix); } - // Get surface normal vector Vector nV(nsd); auto Nx_g = lFa.Nx.slice(g); nn::gnnb(com_mod, lFa, e, g, nsd, nsd-1, eNoNb, Nx_g, nV); @@ -292,7 +269,6 @@ void b_neu_folw_p(ComMod& com_mod, const bcType& lBc, const faceType& lFa, const nV = nV / Jac; double w = lFa.w(g)*Jac; - // Compute residual and tangent contributions if (cPhys == EquationType::phys_ustruct) { if (nsd == 3) { ustruct::b_ustruct_3d(com_mod, eNoN, w, N, Nx, dl, hl, nV, lR, lK, lKd); @@ -309,103 +285,20 @@ void b_neu_folw_p(ComMod& com_mod, const bcType& lBc, const faceType& lFa, const } } - // Now doing the assembly part - // -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), const_cast(ptr.data()), lK.data(), lR.data()); - } else { -#endif - if (cPhys == EquationType::phys_ustruct) { - ustruct::ustruct_do_assem(com_mod, eNoN, ptr, lKd, lK, lR); - } else if (cPhys == EquationType::phys_struct) { - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); - } -#ifdef WITH_TRILINOS + if (cPhys == EquationType::phys_ustruct) { + ustruct::ustruct_do_assem(com_mod, eNoN, ptr, lKd, lK, lR); + } else if (cPhys == EquationType::phys_struct) { + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } -#endif - } - - // Now update surface integrals involved in coupled/resistance BC - // contribution to stiffness matrix to reflect deformed geometry. - if (btest(lBc.bType, iBC_res)) { - fsi_ls_upd(com_mod, lBc, lFa); } } -/// @brief Update the surface integral involved in the coupled/resistance BC -/// contribution to the stiffness matrix to reflect deformed geometry, if using -/// a follower pressure load. -/// The value of this integral is stored in lhs%face%val. -/// This integral is sV = int_Gammat (Na * n_i) (See Brown et al. 2024, Eq. 56) -/// where Na is the shape function and n_i is the normal vector. -/// -/// This function updates the variable lhs%face%val with the new value, which -/// is eventually used in ADDBCMUL() in the linear solver to add the contribution -/// from the resistance BC to the matrix-vector product of the tangent matrix and -/// an arbitrary vector. -void fsi_ls_upd(ComMod& com_mod, const bcType& lBc, const faceType& lFa) -{ - using namespace consts; - using namespace utils; - using namespace fsi_linear_solver; - - #define n_debug_fsi_ls_upd - #ifdef debug_fsi_ls_upd - DebugMsg dmsg(__func__, com_mod.cm.idcm()); - dmsg.banner(); - dmsg << "lFa.name: " << lFa.name; - #endif - - auto& cm = com_mod.cm; - int nsd = com_mod.nsd; - int tnNo = com_mod.tnNo; - - int iM = lFa.iM; - int nNo = lFa.nNo; - - Array sVl(nsd,nNo); - Array sV(nsd,tnNo); - - // Updating the value of the surface integral of the normal vector - // using the deformed configuration ('n' = new = timestep n+1) - sV = 0.0; - for (int e = 0; e < lFa.nEl; e++) { - if (lFa.eType == ElementType::NRB) { - // CALL NRBNNXB(msh(iM),lFa,e) - } - for (int g = 0; g < lFa.nG; g++) { - Vector n(nsd); - auto Nx = lFa.Nx.slice(g); - - auto cfg = MechanicalConfigurationType::new_timestep; - - nn::gnnb(com_mod, lFa, e, g, nsd, nsd-1, lFa.eNoN, Nx, n, cfg); - // - for (int a = 0; a < lFa.eNoN; a++) { - int Ac = lFa.IEN(a,e); - for (int i = 0; i < nsd; i++) { - sV(i,Ac) = sV(i,Ac) + lFa.N(a,g)*lFa.w(g)*n(i); - } - } - } - } - - if (sVl.size() != 0) { - for (int a = 0; a < lFa.nNo; a++) { - int Ac = lFa.gN(a); - sVl.set_col(a, sV.col(Ac)); - } - } - // Update lhs.face(i).val with the new value of the surface integral - fsils_bc_update(com_mod.lhs, lBc.lsPtr, lFa.nNo, nsd, sVl); -}; - /// @brief This routine assembles the equation on a given mesh. /// /// Ag(tDof,tnNo), Yg(tDof,tnNo), Dg(tDof,tnNo) // -void global_eq_assem(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Array& Ag, const Array& Yg, const Array& Dg) +void global_eq_assem(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Array& Ag, + const Array& Yg, const Array& Dg) { #define n_debug_global_eq_assem #ifdef debug_global_eq_assem diff --git a/Code/Source/svFSI/eq_assem.h b/Code/Source/svFSI/eq_assem.h index a1f4a20a..55029260 100644 --- a/Code/Source/svFSI/eq_assem.h +++ b/Code/Source/svFSI/eq_assem.h @@ -38,9 +38,7 @@ namespace eq_assem { void b_assem_neu_bc(ComMod& com_mod, const faceType& lFa, const Vector& hg, const Array& Yg); -void b_neu_folw_p(ComMod& com_mod, const bcType& lBc, const faceType& lFa, const Vector& hg, const Array& Dg); - -void fsi_ls_upd(ComMod& com_mod, const bcType& lBc, const faceType& lFa); +void b_neu_folw_p(ComMod& com_mod, const faceType& lFa, const Vector& hg, const Array& Dg); void global_eq_assem(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Array& Ag, const Array& Yg, const Array& Dg); diff --git a/Code/Source/svFSI/fluid.cpp b/Code/Source/svFSI/fluid.cpp index bf640f57..604bf495 100644 --- a/Code/Source/svFSI/fluid.cpp +++ b/Code/Source/svFSI/fluid.cpp @@ -41,10 +41,6 @@ #include #include -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace fluid { void b_fluid(ComMod& com_mod, const int eNoN, const double w, const Vector& N, const Vector& y, @@ -93,7 +89,7 @@ void b_fluid(ComMod& com_mod, const int eNoN, const double w, const Vector& Ag } // g: loop - // Assembly - //dmsg << "Assembly ... "; - -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), const_cast(ptr.data()), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } - -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } // e: loop diff --git a/Code/Source/svFSI/fsi.cpp b/Code/Source/svFSI/fsi.cpp index 129ac7b9..b7010b93 100644 --- a/Code/Source/svFSI/fsi.cpp +++ b/Code/Source/svFSI/fsi.cpp @@ -43,13 +43,10 @@ #include #include -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace fsi { -void construct_fsi(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Array& Ag, const Array& Yg, const Array& Dg) +void construct_fsi(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Array& Ag, + const Array& Yg, const Array& Dg) { #define n_debug_construct_fsi #ifdef debug_construct_fsi @@ -318,24 +315,8 @@ void construct_fsi(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Ar } } // g: loop - // Assembly -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - if (cPhys == Equation_ustruct) { - throw std::runtime_error("[construct_fsi] Cannot assemble USTRUCT using Trilinos"); - } - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); - } else { -#endif - if (cPhys == Equation_ustruct) { - //CALL USTRUCT_DOASSEM(eNoN, ptr, lKd, lK, lR) - throw std::runtime_error("[construct_fsi] USTRUCT_DOASSEM not implemented"); - } else { - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); - } -#ifdef WITH_TRILINOS - } -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); + } // e: loop #ifdef debug_construct_fsi diff --git a/Code/Source/svFSI/heatf.cpp b/Code/Source/svFSI/heatf.cpp index d791ad27..86db90f9 100644 --- a/Code/Source/svFSI/heatf.cpp +++ b/Code/Source/svFSI/heatf.cpp @@ -36,10 +36,6 @@ #include "nn.h" #include "utils.h" -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - #include namespace heatf { @@ -157,20 +153,11 @@ void construct_heatf(ComMod& com_mod, const mshType& lM, const Array& Ag } } // for g = 0 - // Assembly -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), const_cast(ptr.data()), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); + } // for e = 0 } - void heatf_2d(ComMod& com_mod, const int eNoN, const double w, const Vector& N, const Array& Nx, const Array& al, const Array& yl, const Array& ksix, Array& lR, Array3& lK) { diff --git a/Code/Source/svFSI/heats.cpp b/Code/Source/svFSI/heats.cpp index 4a8f7de7..75231e53 100644 --- a/Code/Source/svFSI/heats.cpp +++ b/Code/Source/svFSI/heats.cpp @@ -36,10 +36,6 @@ #include "nn.h" #include "utils.h" -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace heats { void b_heats(ComMod& com_mod, const int eNoN, const double w, const Vector& N, const double h, Array& lR) @@ -133,20 +129,10 @@ void construct_heats(ComMod& com_mod, const mshType& lM, const Array& Ag } } - // Assembly -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), const_cast(ptr.data()), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } } - void heats_2d(ComMod& com_mod, const int eNoN, const double w, const Vector& N, const Array& Nx, const Array& al, const Array& yl, Array& lR, Array3& lK) { diff --git a/Code/Source/svFSI/initialize.cpp b/Code/Source/svFSI/initialize.cpp index a7313ddb..05e506ce 100644 --- a/Code/Source/svFSI/initialize.cpp +++ b/Code/Source/svFSI/initialize.cpp @@ -434,39 +434,16 @@ void initialize(Simulation* simulation, Vector& timeP) eq.dof = nsd; } - // This code checks to see if the heatF equation is accompanied - // by a fluid equation. If not, it adds the appropriate number of - // degrees of freedom based on the precomputed state-variable (velocity) - // data. - if (eq.phys == Equation_heatF) { - bool fflag = false; - for (int jEq = 0; jEq < com_mod.nEq; jEq++) { - if (std::set < EquationType > - {Equation_fluid, Equation_FSI, Equation_CMM, Equation_stokes}.count(com_mod.eq[jEq].phys)) { - fflag = true; - } - } - if (com_mod.usePrecomp) { - if (!fflag) { - tDof = tDof + nsd; - } - } else { - if (!fflag) { - throw std::runtime_error( - "HeatF equation must be accompanied by a fluid equation or precomputed velocity data."); - } - } - } eq.pNorm = std::numeric_limits::max(); eq.af = 1.0 / (1.0 + eq.roInf); eq.beta = 0.25 * pow((1.0 + eq.am - eq.af), 2.0); eq.gam = 0.5 + eq.am - eq.af; // These are indexes into arrays so need to be zero-based. - eq.s = tDof; eq.e = tDof + eq.dof - 1; tDof = eq.e + 1; + if (eq.useTLS) { flag = true; } @@ -573,15 +550,6 @@ void initialize(Simulation* simulation, Vector& timeP) fsi_linear_solver::fsils_lhs_create(com_mod.lhs, communicator, com_mod.gtnNo, com_mod.tnNo, nnz, com_mod.ltg, com_mod.rowPtr, com_mod.colPtr, nFacesLS); - // Initialize Trilinos data structure - // - if (flag) { - com_mod.tls.ltg.resize(com_mod.tnNo); - for (int a = 0; a < com_mod.tnNo; a++) { - com_mod.tls.ltg(com_mod.lhs.map(a)) = com_mod.ltg(a); - } - } - // Variable allocation and initialization int tnNo = com_mod.tnNo; com_mod.Ao.resize(tDof,tnNo); @@ -828,21 +796,6 @@ void zero_init(Simulation* simulation) dmsg.banner(); #endif - // Initialize precomputed state variables - // - - if (com_mod.usePrecomp) { - for (int l = 0; l < com_mod.nMsh; l++) { - auto& msh = com_mod.msh[l]; - for (int a = 0; a < com_mod.tnNo; a++) { - // In the future this should depend on the equation type. - for (int i = 0; i < nsd; i++) { - com_mod.Yo(i,a) = msh.Ys(i,a,0); - } - } - } - } - // Load any explicitly provided solution variables // if (com_mod.Vinit.size() != 0) { diff --git a/Code/Source/svFSI/l_elas.cpp b/Code/Source/svFSI/l_elas.cpp index 5b2d8d6b..853e3692 100644 --- a/Code/Source/svFSI/l_elas.cpp +++ b/Code/Source/svFSI/l_elas.cpp @@ -39,10 +39,6 @@ #include "nn.h" #include "utils.h" -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace l_elas { /// @brief This is for boundary elasticity equation @@ -168,17 +164,7 @@ void construct_l_elas(ComMod& com_mod, const mshType& lM, const Array& A } } - // Assembly - // -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } } diff --git a/Code/Source/svFSI/lhsa.cpp b/Code/Source/svFSI/lhsa.cpp index 4c69c00f..126af6a7 100644 --- a/Code/Source/svFSI/lhsa.cpp +++ b/Code/Source/svFSI/lhsa.cpp @@ -80,11 +80,10 @@ void add_col(const int tnNo, const int row, const int col, int& mnnzeic, Array& eqN, const Array3& lK, const Array& lR) { + //std::cout << "[lhs::do_assem] ======================= do_assem ==============" << std::endl; auto& R = com_mod.R; auto& Val = com_mod.Val; const auto& rowPtr = com_mod.rowPtr; const auto& colPtr = com_mod.colPtr; + //std::cout << "[lhs::do_assem] R.size(): " << R.size() << std::endl; + //std::cout << "[lhs::do_assem] Val.size(): " << Val.size() << std::endl; for (int a = 0; a < d; a++) { int rowN = eqN(a); diff --git a/Code/Source/svFSI/load_msh.cpp b/Code/Source/svFSI/load_msh.cpp index f70b6b0f..6442dc4f 100644 --- a/Code/Source/svFSI/load_msh.cpp +++ b/Code/Source/svFSI/load_msh.cpp @@ -196,9 +196,6 @@ void read_sv(Simulation* simulation, mshType& mesh, const MeshParameters* mesh_p // Note: This may change element node ordering. // auto &com_mod = simulation->get_com_mod(); - if (com_mod.usePrecomp) { - vtk_xml::read_precomputed_solution_vtu(com_mod.precompFileName, com_mod.precompFieldName, mesh); - } if (com_mod.ichckIEN) { read_msh_ns::check_ien(simulation, mesh); } diff --git a/Code/Source/svFSI/ls.cpp b/Code/Source/svFSI/ls.cpp index b3ad370a..44f7db2d 100644 --- a/Code/Source/svFSI/ls.cpp +++ b/Code/Source/svFSI/ls.cpp @@ -38,96 +38,8 @@ #include -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace ls_ns { -/// @brief Reproduces Fortran 'SUBROUTINE INIT_DIR_AND_COUPNEU_BC(incL, res)'. -// -void init_dir_and_coup_neu(ComMod& com_mod, const Vector& incL, const Vector& res) -{ - using namespace consts; - using namespace fsi_linear_solver; - - int dof = com_mod.dof; - int gtnNo = com_mod.gtnNo; - int tnNo = com_mod.tnNo; - auto& lhs = com_mod.lhs; - - if (lhs.nFaces != 0) { - for (auto& face : lhs.face) { - face.incFlag = true; - } - - for (int faIn = 0; faIn < lhs.nFaces; faIn++) { - if (incL(faIn) == 0) { - lhs.face[faIn].incFlag = false; - } - } - - for (int faIn = 0; faIn < lhs.nFaces; faIn++) { - auto& face = lhs.face[faIn]; - face.coupledFlag = false; - if (!face.incFlag) { - continue; - } - - bool flag = (face.bGrp == BcType::BC_TYPE_Neu); - if (flag && res(faIn) != 0.0) { - face.res = res(faIn); - face.coupledFlag = true; - } - } - } - - auto& tls = com_mod.tls; - tls.W = 1.0; - - for (int faIn = 0; faIn < lhs.nFaces; faIn++) { - auto& face = lhs.face[faIn]; - if (!face.incFlag) { - continue; - } - - int faDof = std::min(face.dof,dof); - - if (face.bGrp == BcType::BC_TYPE_Dir) { - for (int a = 0; a < face.nNo; a++) { - int Ac = face.glob(a); - for (int i = 0; i < faDof; i++) { - tls.W(i,Ac) = tls.W(i,Ac) * face.val(i,a); - } - } - } - } - - Array v(dof,tnNo); - bool isCoupledBC = false; - - for (int faIn = 0; faIn < lhs.nFaces; faIn++) { - auto& face = lhs.face[faIn]; - if (face.coupledFlag) { - isCoupledBC = true; - int faDof = std::min(face.dof,dof); - - for (int a = 0; a < face.nNo; a++) { - int Ac = face.glob(a); - for (int i = 0; i < faDof; i++) { - v(i,Ac) = v(i,Ac) + sqrt(fabs(res(faIn))) * face.val(i,a); - } - } - } - } - -#ifdef WITH_TRILINOS - trilinos_bc_create_(v.data(), isCoupledBC); -#endif - -} - - /// @brief Allocate com_mod.R and com_mod.Val arrays. /// /// Modifies: @@ -145,32 +57,7 @@ void ls_alloc(ComMod& com_mod, eqType& lEq) com_mod.R.resize(dof,tnNo); - if (!lEq.assmTLS) { - com_mod.Val.resize(dof*dof, com_mod.lhs.nnz); - } - -#ifdef WITH_TRILINOS - - auto& tls = com_mod.tls; - - if (lEq.useTLS) { - if (tls.W.size() != 0) { - tls.W.clear(); - tls.R.clear(); - trilinos_lhs_free_(); - } - - tls.W.resize(dof,tnNo); - tls.R.resize(dof,tnNo); - - int cpp_index = 1; - int task_id = com_mod.cm.idcm(); - - trilinos_lhs_create_(gtnNo, lhs.mynNo, tnNo, lhs.nnz, tls.ltg.data(), com_mod.ltg.data(), com_mod.rowPtr.data(), - com_mod.colPtr.data(), dof, cpp_index, task_id); - } - -#endif + lEq.linear_algebra->alloc(com_mod, lEq); } /// @brief Modifies: @@ -190,58 +77,7 @@ void ls_solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vecto dmsg << "lEq.assmTLS: " << lEq.assmTLS; #endif -#ifdef WITH_TRILINOS - - // Set up resistance/coupled-Neumann BC for Trilinos linear solver - if (lEq.useTLS) { - init_dir_and_coup_neu(com_mod, incL, res); - } - - if (lEq.assmTLS) { - lEq.FSILS.RI.suc = false; - auto& tls = com_mod.tls; - int solver_type = static_cast(lEq.ls.LS_type); - int prec_type = static_cast(lEq.ls.PREC_Type); - - trilinos_solve_(tls.R.data(), tls.W.data(), lEq.FSILS.RI.fNorm, lEq.FSILS.RI.iNorm, - lEq.FSILS.RI.itr, lEq.FSILS.RI.callD, lEq.FSILS.RI.dB, lEq.FSILS.RI.suc, - solver_type, lEq.FSILS.RI.relTol, lEq.FSILS.RI.mItr, lEq.FSILS.RI.sD, - prec_type, lEq.assmTLS); - - } else if (lEq.useTLS) { - auto& Val = com_mod.Val; - auto& R = com_mod.R; - auto& tls = com_mod.tls; - int solver_type = static_cast(lEq.ls.LS_type); - int prec_type = static_cast(lEq.ls.PREC_Type); - - trilinos_global_solve_(Val.data(), R.data(), tls.R.data(), tls.W.data(), lEq.FSILS.RI.fNorm, - lEq.FSILS.RI.iNorm, lEq.FSILS.RI.itr, lEq.FSILS.RI.callD, lEq.FSILS.RI.dB, lEq.FSILS.RI.suc, - solver_type, lEq.FSILS.RI.relTol, lEq.FSILS.RI.mItr, lEq.FSILS.RI.sD, prec_type); - - } else { - -#endif - - auto& lhs = com_mod.lhs; - int dof = com_mod.dof; - auto& R = com_mod.R; // Residual vector - auto& Val = com_mod.Val; // LHS matrix - - fsi_linear_solver::fsils_solve(lhs, lEq.FSILS, dof, R, Val, lEq.ls.PREC_Type, incL, res); - -#ifdef WITH_TRILINOS - } - - if (lEq.useTLS) { - for (int a = 0; a < com_mod.tnNo; a++) { - for (int i = 0; i < com_mod.R.nrows(); i++) { - com_mod.R(i,a) = com_mod.tls.R(i,com_mod.lhs.map(a)); - } - } - } -#endif - + lEq.linear_algebra->solve(com_mod, lEq, incL, res); } }; diff --git a/Code/Source/svFSI/ls.h b/Code/Source/svFSI/ls.h index dcac6ace..68367da9 100644 --- a/Code/Source/svFSI/ls.h +++ b/Code/Source/svFSI/ls.h @@ -40,6 +40,10 @@ void ls_alloc(ComMod& com_mod, eqType& lEq); void ls_solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res); +//void init_dir_and_coupneu_bc_petsc(ComMod& com_mod, const Vector& incL, const Vector& res); + +//void initialize_petsc(ComMod& com_mod); + }; #endif diff --git a/Code/Source/svFSI/main.cpp b/Code/Source/svFSI/main.cpp index 0ef712bb..89ba380b 100644 --- a/Code/Source/svFSI/main.cpp +++ b/Code/Source/svFSI/main.cpp @@ -57,8 +57,22 @@ #include #include #include -#include -#include + +//------------------------ +// add_eq_linear_algebra +//------------------------ +// Create a LinearAlgebra object for an equation. +// +void add_eq_linear_algebra(ComMod& com_mod, eqType& lEq) +{ + lEq.linear_algebra = LinearAlgebraFactory::create_interface(lEq.linear_algebra_type); + lEq.linear_algebra->set_preconditioner(lEq.linear_algebra_preconditioner); + lEq.linear_algebra->initialize(com_mod, lEq); + + if (lEq.linear_algebra_assembly_type != consts::LinearAlgebraType::none) { + lEq.linear_algebra->set_assembly(lEq.linear_algebra_assembly_type); + } +} /// @brief Read in a solver XML file and all mesh and BC data. // @@ -85,95 +99,9 @@ void read_files(Simulation* simulation, const std::string& file_name) } - - -/// @brief Iterate the precomputed state-variables in time using linear interpolation to the current time step size -// -void iterate_precomputed_time(Simulation* simulation) { - using namespace consts; - - auto& com_mod = simulation->com_mod; - auto& cm_mod = simulation->cm_mod; - auto& cm = com_mod.cm; - auto& cep_mod = simulation->get_cep_mod(); - - int nTS = com_mod.nTS; - int stopTS = nTS; - int tDof = com_mod.tDof; - int tnNo = com_mod.tnNo; - int nFacesLS = com_mod.nFacesLS; - int nsd = com_mod.nsd; - - auto& Ad = com_mod.Ad; // Time derivative of displacement - auto& Rd = com_mod.Rd; // Residual of the displacement equation - auto& Kd = com_mod.Kd; // LHS matrix for displacement equation - - auto& Ao = com_mod.Ao; // Old time derivative of variables (acceleration) - auto& Yo = com_mod.Yo; // Old variables (velocity) - auto& Do = com_mod.Do; // Old integrated variables (dissplacement) - - auto& An = com_mod.An; // New time derivative of variables - auto& Yn = com_mod.Yn; // New variables (velocity) - auto& Dn = com_mod.Dn; // New integrated variables - - int& cTS = com_mod.cTS; - int& nITs = com_mod.nITs; - double& dt = com_mod.dt; - - if (com_mod.usePrecomp) { -#ifdef debug_iterate_solution - dmsg << "Use precomputed values ..." << std::endl; -#endif - // This loop is used to interpolate between known time values of the precomputed - // state-variable solution - for (int l = 0; l < com_mod.nMsh; l++) { - auto lM = com_mod.msh[l]; - if (lM.Ys.nslices() > 1) { - // If there is only one temporal slice, then the solution is assumed constant - // in time and no interpolation is performed - // If there are multiple temporal slices, then the solution is linearly interpolated - // between the known time values and the current time. - double precompDt = com_mod.precompDt; - double preTT = precompDt * (lM.Ys.nslices() - 1); - double cT = cTS * dt; - double rT = std::fmod(cT, preTT); - int n1, n2; - double alpha; - if (precompDt == dt) { - alpha = 0.0; - if (cTS < lM.Ys.nslices()) { - n1 = cTS - 1; - } else { - n1 = cTS % lM.Ys.nslices() - 1; - } - } else { - n1 = static_cast(rT / precompDt) - 1; - alpha = std::fmod(rT, precompDt); - } - n2 = n1 + 1; - for (int i = 0; i < tnNo; i++) { - for (int j = 0; j < nsd; j++) { - if (alpha == 0.0) { - Yn(j, i) = lM.Ys(j, i, n2); - } else { - Yn(j, i) = (1.0 - alpha) * lM.Ys(j, i, n1) + alpha * lM.Ys(j, i, n2); - } - } - } - } else { - for (int i = 0; i < tnNo; i++) { - for (int j = 0; j < nsd; j++) { - Yn(j, i) = lM.Ys(j, i, 0); - } - } - } - } - } -} - /// @brief Iterate the simulation in time. /// -/// Reproduces the outer and inner loops in Fortan MAIN.f. +/// Reproduces the outer and inner loops in Fortan MAIN.f. // void iterate_solution(Simulation* simulation) { @@ -331,9 +259,7 @@ void iterate_solution(Simulation* simulation) set_bc::set_bc_dir(com_mod, An, Yn, Dn); - iterate_precomputed_time(simulation); - - // Inner loop for Newton iteration + // Inner loop for iteration // int inner_count = 1; int reply; @@ -372,6 +298,7 @@ void iterate_solution(Simulation* simulation) #ifdef debug_iterate_solution dmsg << "Initiator step ..." << std::endl; #endif + pic::pici(simulation, Ag, Yg, Dg); Ag.write("Ag_pic"+ istr); Yg.write("Yg_pic"+ istr); @@ -543,7 +470,6 @@ void iterate_solution(Simulation* simulation) for (int iBc = 0; iBc < eq.nBc; iBc++) { int i = eq.bc[iBc].lsPtr; if (i != -1) { - // Resistance term for coupled Neumann BC tangent contribution res(i) = eq.gam * dt * eq.bc[iBc].r; incL(i) = 1; } @@ -562,7 +488,7 @@ void iterate_solution(Simulation* simulation) com_mod.Val.write("Val_solve"+ istr); com_mod.R.write("R_solve"+ istr); - // Solution is obtained, now updating (Corrector) and check for convergence + // Solution is obtained, now updating (Corrector) // // Modifies: com_mod.An com_mod.Dn com_mod.Yn cep_mod.Xion com_mod.pS0 com_mod.pSa // com_mod.pSn com_mod.cEq eq.FSILS.RI.iNorm eq.pNorm @@ -796,7 +722,6 @@ int main(int argc, char *argv[]) #endif read_files(simulation, file_name); - // Distribute data to processors. #ifdef debug_main dmsg << "Distribute data to processors " << " ... "; @@ -812,6 +737,13 @@ int main(int argc, char *argv[]) #endif initialize(simulation, init_time); + // Create LinearAlgebra objects for each equation. + // + for (int iEq = 0; iEq < simulation->com_mod.nEq; iEq++) { + auto& eq = simulation->com_mod.eq[iEq]; + add_eq_linear_algebra(simulation->com_mod, eq); + } + #ifdef debug_main for (int iM = 0; iM < simulation->com_mod.nMsh; iM++) { dmsg << "---------- iM " << iM; diff --git a/Code/Source/svFSI/mat_models.cpp b/Code/Source/svFSI/mat_models.cpp index 4b706443..6f28fa60 100644 --- a/Code/Source/svFSI/mat_models.cpp +++ b/Code/Source/svFSI/mat_models.cpp @@ -690,10 +690,10 @@ void get_pk2cc_dev(const ComMod& com_mod, const CepMod& cep_mod, const dmnType& 2.0*g3*(Es(0,1)*RmRm.slice(3) + Es(0,2)*RmRm.slice(5)); auto CCb = 2.0*ten_dyad_prod(Sb, Sb, nsd); - Sb = Sb * r2; + Sb += Sb * r2; // Fiber reinforcement/active stress - Sb += Tfa*mat_dyad_prod(fl.col(0), fl.col(0), nsd); + Sb += Sb + Tfa*mat_dyad_prod(fl.col(0), fl.col(0), nsd); double r1 = J2d*mat_ddot(C, Sb, nsd) / nd; S = J2d*Sb - r1*Ci; diff --git a/Code/Source/svFSI/mesh.cpp b/Code/Source/svFSI/mesh.cpp index 0445475b..c6d1f95d 100644 --- a/Code/Source/svFSI/mesh.cpp +++ b/Code/Source/svFSI/mesh.cpp @@ -44,10 +44,6 @@ #include #include -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace mesh { void construct_mesh(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const Array& Ag, const Array& Dg) @@ -160,18 +156,7 @@ void construct_mesh(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const A } } - // Assembly - // -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif - + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } } diff --git a/Code/Source/svFSI/nn.cpp b/Code/Source/svFSI/nn.cpp index 2c864f27..6310a685 100644 --- a/Code/Source/svFSI/nn.cpp +++ b/Code/Source/svFSI/nn.cpp @@ -527,17 +527,14 @@ void gnn(const int eNoN, const int nsd, const int insd, Array& Nxi, Arra } } -/// @brief This routine returns a surface normal vector at element "e" and Gauss point -/// 'g' of face 'lFa' that is the normal weighted by Jac, i.e. -/// Jac = SQRT(NORM(n)), the Jacobian of the mapping from parent surface element to -/// reference/old/new configuration. -/// -/// cfg denotes which configuration (reference/timestep 0, old/timestep n, or new/timestep n+1). Default reference +/// @brief This routine returns a vector at element "e" and Gauss point +/// 'g' of face 'lFa' that is the normal weigthed by Jac, i.e. +/// Jac = SQRT(NORM(n)). /// /// Reproduce Fortran 'GNNB'. // void gnnb(const ComMod& com_mod, const faceType& lFa, const int e, const int g, const int nsd, const int insd, - const int eNoNb, const Array& Nx, Vector& n, MechanicalConfigurationType cfg) + const int eNoNb, const Array& Nx, Vector& n) { auto& cm = com_mod.cm; @@ -550,7 +547,6 @@ void gnnb(const ComMod& com_mod, const faceType& lFa, const int e, const int g, dmsg << "nsd: " << nsd; dmsg << "insd: " << insd; dmsg << "eNoNb: " << eNoNb; - dmsg << "cfg: " << cfg; #endif int iM = lFa.iM; @@ -610,42 +606,19 @@ void gnnb(const ComMod& com_mod, const faceType& lFa, const int e, const int g, } } - // Correcting the geometry if mesh is moving or if we want the - // area-weighted normal in a different configuration + // Correcting the position vector if mesh is moving // for (int a = 0; a < eNoN; a++) { int Ac = msh.IEN(a,Ec); for (int i = 0; i < lX.nrows(); i++) { - // Get position vector lX(i,a) = com_mod.x(i,Ac); } + if (com_mod.mvMsh) { for (int i = 0; i < lX.nrows(); i++) { - // Add mesh displacement lX(i,a) = lX(i,a) + com_mod.Do(i+nsd+1,Ac); } } - else { - switch (cfg) { - case MechanicalConfigurationType::reference: - // Do nothing - break; - case MechanicalConfigurationType::old_timestep: - for (int i = 0; i < lX.nrows(); i++) { - // Add displacement at timestep n - lX(i,a) = lX(i,a) + com_mod.Do(i,Ac); - } - break; - case MechanicalConfigurationType::new_timestep: - for (int i = 0; i < lX.nrows(); i++) { - // Add displacement at timestep n+1 - lX(i,a) = lX(i,a) + com_mod.Dn(i,Ac); - } - break; - default: - throw std::runtime_error("gnnb: invalid MechanicalConfigurationType provided"); - } - } } // Calculating surface deflation @@ -726,7 +699,7 @@ void gnnb(const ComMod& com_mod, const faceType& lFa, const int e, const int g, } // Changing the sign if neccessary. 'a' locates on the face and 'b' - // in the interior of the element. v points outward along ba + // outside of the face, in the parent element // a = ptr(0); int b = ptr(lFa.eNoN); diff --git a/Code/Source/svFSI/nn.h b/Code/Source/svFSI/nn.h index 43172783..d48caa94 100644 --- a/Code/Source/svFSI/nn.h +++ b/Code/Source/svFSI/nn.h @@ -33,7 +33,6 @@ #include "Simulation.h" #include "ComMod.h" -#include "consts.h" namespace nn { @@ -65,7 +64,7 @@ namespace nn { double& Jac, Array& ks); void gnnb(const ComMod& com_mod, const faceType& lFa, const int e, const int g, const int nsd, const int insd, - const int eNoNb, const Array& Nx, Vector& n, consts::MechanicalConfigurationType cfg=consts::MechanicalConfigurationType::reference); + const int eNoNb, const Array& Nx, Vector& n); void gnns(const int nsd, const int eNoN, const Array& Nxi, Array& xl, Vector& nV, Array& gCov, Array& gCnv); diff --git a/Code/Source/svFSI/petsc_impl.cpp b/Code/Source/svFSI/petsc_impl.cpp new file mode 100644 index 00000000..d84ea2dd --- /dev/null +++ b/Code/Source/svFSI/petsc_impl.cpp @@ -0,0 +1,1107 @@ + +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// This file contains PetscImpl and PETSc-dependent functions. + +#include "petsc_impl.h" +#include + +LHSCtx plhs; /* PETSc lhs */ +LSCtx *psol; /* PETSc solver */ +PetscLogStage stages[6]; /* performance tuning. */ + +/* + Nomenclature used in this file: + - global: across all MPI processes + - local: current MPI processes + - natural id: global vertex id from mesh file + - PETSc id: global vertex id used within PETSc + - O1 ordering: the local order of natural id generated by ParMetis in svFSI + - O2 ordering: reorder O1 to "(vertex shared with lower rank) + + (vertex owned exclusively by current rank) + + (vertex shared with higher rank)" + - owned vertices: "(vertex shared with lower rank) + + (vertex owned exclusively by current rank)" + forms the vertices owned by the current rank. + - ghost vertices: vertex shared with higher rank + + The mapping between different ordering is + O1 --> O2 --> PETSc ID +*/ + +// Initialize PETSc and create lhs for PETSc. +// +void petsc_initialize(const PetscInt nNo, const PetscInt mynNo, const PetscInt nnz, + const PetscInt nEq, const PetscInt *svFSI_ltg, const PetscInt *svFSI_map, + const PetscInt *svFSI_rowPtr, const PetscInt *svFSI_colPtr, char *inp) +{ + // char* in_file = rm_blank(inp); + char* in_file = inp; + if (access(in_file, F_OK) == 0) { + PetscInitialize(NULL, NULL, in_file, NULL); + PetscPrintf(MPI_COMM_WORLD, " : " + "use linear solver config. from file.\n"); + } + else { + PetscInitialize(NULL, NULL, NULL, NULL); + PetscPrintf(MPI_COMM_WORLD, " : " + "use linear solver config. from svFSI input.\n"); + } + + PetscLogStageRegister("Create LHS", &stages[0]); + PetscLogStageRegister("Create VecMat", &stages[1]); + PetscLogStageRegister("Create Solver", &stages[2]); + PetscLogStageRegister("Set Values", &stages[3]); + PetscLogStageRegister("PETSc Solve", &stages[4]); + PetscLogStageRegister("Row-Col. Sca.", &stages[5]); + + PetscLogStagePush(stages[0]); + + plhs.created = PETSC_FALSE; + petsc_create_lhs(nNo, mynNo, nnz, svFSI_ltg, svFSI_map, svFSI_rowPtr, svFSI_colPtr); + + PetscMalloc1(nEq, &psol); + + for (PetscInt i = 0; i < nEq; i++) { + psol[i].created = PETSC_FALSE; + } + + PetscLogStagePop(); +} + +/* + Create parallel vector and matrix data structures. +*/ +void petsc_create_linearsystem(const PetscInt dof, const PetscInt iEq, const PetscInt nEq, + const PetscReal *svFSI_DirBC, const PetscReal *svFSI_lpBC) +{ + // PetscInt cEq = *iEq - 1; + PetscInt cEq = iEq; // in Fortran, cEq = 1; in C++, cEq = 0; + + if (psol[cEq].created) { + return; + } + + PetscLogStagePush(stages[1]); + petsc_create_bc(dof, cEq, svFSI_DirBC, svFSI_lpBC); /* bc info is required for mat_create */ + petsc_create_vecmat(dof, cEq, nEq); + psol[cEq].created = PETSC_TRUE; + PetscLogStagePop(); +} + +/* + Create PETSc linear solver data. +*/ +void petsc_create_linearsolver(const consts::SolverType lsType, const consts::PreconditionerType pcType, + const PetscInt kSpace, const PetscInt maxIter, const PetscReal relTol, const PetscReal absTol, + const consts::EquationType phys, const PetscInt dof, const PetscInt iEq, const PetscInt nEq) +{ + using namespace consts; + + // PetscInt cEq = *iEq - 1; + PetscInt cEq = iEq; // in Fortran, cEq = 1; in C++, cEq = 0; + PC pc; + PetscBool usefieldsplit; + + PetscLogStagePush(stages[2]); + + /* Initialize equation specific prefix for vec/mat/ksp */ + switch (phys) + { + case EquationType::phys_fluid: + psol[cEq].pre = "ns_"; + break; + case EquationType::phys_struct: + psol[cEq].pre = "st_"; + break; + case EquationType::phys_heatS: + psol[cEq].pre = "hs_"; + break; + case EquationType::phys_lElas: + psol[cEq].pre = "le_"; + break; + case EquationType::phys_heatF: + psol[cEq].pre = "hf_"; + break; + case EquationType::phys_FSI: + psol[cEq].pre = "fs_"; + break; + case EquationType::phys_mesh: + psol[cEq].pre = "ms_"; + break; + case EquationType::phys_shell: + psol[cEq].pre = "sh_"; + break; + case EquationType::phys_CMM: + psol[cEq].pre = "cm_"; + break; + case EquationType::phys_CEP: + psol[cEq].pre = "ep_"; + break; + case EquationType::phys_ustruct: + psol[cEq].pre = "st_"; + break; + case EquationType::phys_stokes: + psol[cEq].pre = "ss_"; + break; + default: + PetscPrintf(MPI_COMM_WORLD, "ERROR : " + "equation type %d is not defined.\n", phys); + break; + } + + /* Initialize PETSc linear solver setting */ + KSPCreate(MPI_COMM_WORLD, &psol[cEq].ksp); + + if (nEq > 1) { + KSPSetOptionsPrefix(psol[cEq].ksp, psol[cEq].pre); + } + + KSPSetTolerances(psol[cEq].ksp, relTol, absTol, PETSC_DEFAULT, maxIter); + + // Set the linear solver. + + switch (lsType) { + case SolverType::lSolver_CG: + KSPSetType(psol[cEq].ksp, KSPCG); + break; + case SolverType::lSolver_GMRES: + KSPSetType(psol[cEq].ksp, KSPGMRES); +// KSPGMRESSetRestart(psol[cEq].ksp, *kSpace); + break; + case SolverType::lSolver_BICGS: + KSPSetType(psol[cEq].ksp, KSPBCGS); + break; + default: + PetscPrintf(MPI_COMM_WORLD, "ERROR : " + "linear solver type not supported through svFSI input file.\n" + "ERROR : " + "More linear solver types can be set through petsc_option.inp.\n"); + break; + } + + /* Set preconditioner */ + psol[cEq].rcs = PETSC_FALSE; + KSPGetPC(psol[cEq].ksp, &pc); + + switch (pcType) + { + case PreconditionerType::PREC_PETSC_JACOBI: + PCSetType(pc, PCJACOBI); + break; + + case PreconditionerType::PREC_PETSC_RCS: + psol[cEq].rcs = PETSC_TRUE; + PetscPrintf(MPI_COMM_WORLD, "WARNING : " + "precondition the linear system with RCS first.\n" + "WARNING : " + "This will NOT be overwritten by petsc_option.inp!\n"); + break; + + default: + PetscPrintf(MPI_COMM_WORLD, "ERROR : " + "preconditioner type not supported through svFSI input file.\n" + "ERROR : " + "More preconditioner options can be set through petsc_option.inp.\n"); + break; + } + + /* Run time options */ + KSPSetFromOptions(psol[cEq].ksp); + + /* Set up PCFIELDSPLIT */ + PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &usefieldsplit); + if (usefieldsplit){ + if (phys==EquationType::phys_fluid || phys==EquationType::phys_ustruct || phys==EquationType::phys_stokes ){ + petsc_set_pcfieldsplit(dof, cEq); + } + else { + PetscPrintf(MPI_COMM_WORLD, "///////////////////////////////////" + "///////////////////////////////////////////////////////////////\n"); + PetscPrintf(MPI_COMM_WORLD, "WARNING : " + "PCFIELDSPLIT is hard-coded for ustruct/stokes/NS.\n"); + PetscPrintf(MPI_COMM_WORLD, "///////////////////////////////////" + "///////////////////////////////////////////////////////////////\n"); + } + } + + PetscLogStagePop(); +} + +/* + Set up the linear system. +*/ +void petsc_set_values(const PetscInt dof, const PetscInt iEq, const PetscReal *R, + const PetscReal *Val, const PetscReal *svFSI_DirBC, const PetscReal *svFSI_lpBC) +{ + // PetscInt cEq = *iEq - 1; + PetscInt cEq = iEq; // in Fortran, cEq = 1; in C++, cEq = 0; + + /* Set values in A &b, apply Dir and Lumped parameter BC */ + PetscLogStagePush(stages[3]); + petsc_set_vec(dof, cEq, R); + petsc_set_mat(dof, cEq, Val); + petsc_set_bc(cEq, svFSI_DirBC, svFSI_lpBC); + PetscLogStagePop(); + + /* Scale A and b if RCS preconditioner is activated. */ + PetscLogStagePush(stages[5]); + if (psol[cEq].rcs){ + petsc_pc_rcs(dof, cEq); + } + PetscLogStagePop(); +} + +/* + Solve the linear system. +*/ +void petsc_solve(PetscReal *resNorm, PetscReal *initNorm, PetscReal *dB, + PetscReal *execTime, bool *converged, PetscInt *numIter, + PetscReal *R, const PetscInt maxIter, const PetscInt dof, + const PetscInt iEq) +{ + PetscReal *a, *array; + PetscInt i, j, na; + // PetscInt cEq = *iEq - 1; + PetscInt cEq = iEq; // in Fortran, cEq = 1; in C++, cEq = 0; + PetscBool usepreonly; + KSPType ksptype; + Vec lx, res; + KSPConvergedReason reason; + PetscLogDouble ts, te; + + PetscLogStagePush(stages[4]); + na = maxIter; + PetscMalloc1(na, &a); + PetscTime(&ts); + KSPSetOperators(psol[cEq].ksp, psol[cEq].A, psol[cEq].A); + + /* Calculate residual for direct solver. KSP uses preconditioned norm. */ + PetscObjectTypeCompare((PetscObject)psol[cEq].ksp, KSPPREONLY, &usepreonly); + + if (usepreonly){ + VecNorm(psol[cEq].b, NORM_2 , initNorm); + } else { + KSPSetResidualHistory(psol[cEq].ksp, a, na, PETSC_TRUE); + } + + KSPSetUp(psol[cEq].ksp); + KSPSolve(psol[cEq].ksp, psol[cEq].b, psol[cEq].b); + + /* Rescale solution for RCS preconditioner */ + if (psol[cEq].rcs){ + VecPointwiseMult(psol[cEq].b, psol[cEq].b, psol[cEq].Dc); + } + + /* Fill the ghost vertices with correct values. */ + VecGhostUpdateBegin(psol[cEq].b, INSERT_VALUES, SCATTER_FORWARD); + VecGhostUpdateEnd(psol[cEq].b, INSERT_VALUES, SCATTER_FORWARD); + + PetscTime(&te); + + /* Get convergence info. */ + if (usepreonly){ + *resNorm = __DBL_EPSILON__; + } + else { + KSPGetResidualHistory(psol[cEq].ksp, (const PetscReal **) &a, &na); + *initNorm = a[0]; + *resNorm = a[na-1]; + } + KSPGetIterationNumber(psol[cEq].ksp, numIter); + KSPGetConvergedReason(psol[cEq].ksp, &reason); + *converged = reason > 0 ? true : false; + *dB = 10.0 * log(*resNorm / *initNorm); + *execTime = te - ts; + + /* Export solution to svFSI. */ + VecGhostGetLocalForm(psol[cEq].b, &lx); + VecGetArray(lx, &array); + na = 0; + for (i = 0; i < plhs.nNo; i++) { + for (j = 0; j < dof; j++) { + R[plhs.map[i]*(dof)+j] = array[na++]; + } + } + VecRestoreArray(lx, &array); + VecGhostRestoreLocalForm(psol[cEq].b, &lx); + + PetscFree(a); + PetscLogStagePop(); +} + +/* + Clean up all petsc data. +*/ +void petsc_destroy_all(const PetscInt nEq) +{ + if (!psol==NULL){ + PetscInt cEq; + PetscErrorCode ierr; + + if (!plhs.created) { + PetscPrintf(MPI_COMM_WORLD, "ERROR : " + "lhs is not created.\n"); + ierr = PETSC_ERR_ARG_WRONGSTATE; + PETSCABORT(MPI_COMM_WORLD, ierr); + } + + plhs.nNo = 0; + plhs.mynNo = 0; + plhs.created = PETSC_FALSE; + + PetscFree (plhs.map); + PetscFree2(plhs.rowPtr, plhs.colPtr); + PetscFree2(plhs.ltg, plhs.ghostltg); + + for (cEq = 0; cEq < nEq; cEq++) + { + if (!psol[cEq].created) { + PetscPrintf(MPI_COMM_WORLD, "ERROR : " + "solver %d is not created.\n", cEq); + ierr = PETSC_ERR_ARG_WRONGSTATE; + PETSCABORT(MPI_COMM_WORLD, ierr); + } + + psol[cEq].created = PETSC_FALSE; + + psol[cEq].lpPts = 0; + PetscFree2(psol[cEq].lpBC_l, psol[cEq].lpBC_g); + + psol[cEq].DirPts = 0; + PetscFree (psol[cEq].DirBC); + + VecDestroy(&psol[cEq].b); + MatDestroy(&psol[cEq].A); + KSPDestroy(&psol[cEq].ksp); + + if (psol[cEq].rcs) { + psol[cEq].rcs = PETSC_FALSE; + VecDestroy(&psol[cEq].Dr); + VecDestroy(&psol[cEq].Dc); + } + } + PetscFree(psol); + + PetscFinalize(); + } +} + + +/* + Creating PETSc lhs data structure with svFSI info. +*/ +PetscErrorCode petsc_create_lhs(const PetscInt nNo, const PetscInt mynNo, const PetscInt nnz, \ + const PetscInt *svFSI_ltg, const PetscInt *svFSI_map, \ + const PetscInt *svFSI_rowPtr, const PetscInt *svFSI_colPtr) +{ + PetscInt i, j ; + PetscErrorCode ierr; + PetscInt *local2global, *local2local; /* local copy of svFSI ltg and map */ + PetscInt *local_ltg; /* local to global mapping of all vertices on current proc.*/ + PetscInt *owned_ltg; /* local to global mapping of owned vertices */ + PetscInt *ghost_ltg; /* local to global mapping of ghost vertices */ + PetscInt rstart; /* starting index of PETSc ordering for a processor */ + AO ao; /* Application Ordering object */ + PetscInt *pordering; /* PETSc ordering */ + PetscInt ghostnNo; /* number of ghost vertices */ + + PetscFunctionBeginUser; + + /* In cases with remeshing, lhs needs to be regenerated. */ + if (plhs.created) { + PetscPrintf(MPI_COMM_WORLD, "ERROR : \ + lhs is already created."); + ierr = PETSC_ERR_ARG_WRONGSTATE; + PETSCABORT(MPI_COMM_WORLD, ierr); + } + + plhs.nNo = nNo; + plhs.mynNo = mynNo; + plhs.created = PETSC_TRUE; + + /* Fortran index to C index (NOT apply for svFSIplus) */ + PetscCall(PetscMalloc2(nNo, &local2global, nNo, &local2local)); + for (i = 0; i < nNo; i++) { + // local2global[i] = svFSI_ltg[i] - 1; + // local2local[i] = svFSI_map[i] - 1; + local2global[i] = svFSI_ltg[i]; + local2local[i] = svFSI_map[i]; + } + + /* Create local mapping, map[O2] = O1 */ + PetscCall(PetscMalloc1(nNo, &plhs.map)); + for (i = 0; i < nNo; i++) { + plhs.map[local2local[i]] = i; + } + + /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + Create global-to-global mapping using AO: + - Global order 1 is from svFSI (ltg, i.e. O1). + - Global order 2 is for PETSc (PETSc ordering). It is: + |---- Proc 0-------| |----------- Proc 2 ------------| + 0 1 ... mynNo(0)-1 mynNo(0) ... mynNo(0)+mynNo(1)-1 + + - Note that global order 2 locally follows O2 ordering, i.e. + lower rank vtx + current rank vtx + - Vertices from higher rank are ghost vertices. + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + /* Remap svFSI ltg to svFSI lhs%map order (O2) */ + PetscCall(PetscMalloc2(mynNo, &owned_ltg, nNo, &local_ltg)); + for (i = 0; i < nNo; i++) { + j = local2local[i]; + local_ltg[j] = local2global[i]; + } + for (i = 0; i < mynNo; i++) owned_ltg[i] = local_ltg[i]; + ghostnNo = nNo - mynNo; + PetscCall(PetscMalloc1(ghostnNo, &ghost_ltg)); + for (i = 0; i < ghostnNo; i++) ghost_ltg[i] = local_ltg[i+mynNo]; + + /* Create AO object between svFSI ltg and PETSc ordering */ + PetscCallMPI(MPI_Scan(&mynNo, &rstart, 1, MPIU_INT, MPI_SUM, MPI_COMM_WORLD)); + rstart -= mynNo; + PetscCall(PetscMalloc1(mynNo, &pordering)); + for (i = 0; i < mynNo; i++) pordering[i] = rstart + i; + PetscCall(AOCreateBasic(MPI_COMM_WORLD, mynNo, owned_ltg, pordering, &ao)); + + /* + Now map the vertex id in natural ordering to PETSc ordering. + Before AOApplicationToPetsc: + local_ltg[i] = natural id, i = 0,..., nNo-1 + After AOApplicationToPetsc: + local_ltg[i] = PETSc id, i = 0,..., nNo-1 + */ + PetscCall(AOApplicationToPetsc(ao, nNo, local_ltg)); + PetscCall(AOApplicationToPetsc(ao, ghostnNo, ghost_ltg)); + PetscCall(AODestroy(&ao)); + + PetscCall(PetscMalloc2(nNo, &plhs.ltg, ghostnNo, &plhs.ghostltg)); + for (i = 0; i < nNo; i++) plhs.ltg[i] = local_ltg[i]; + for (i = 0; i < ghostnNo; i++) plhs.ghostltg[i] = ghost_ltg[i]; + + /* Adjacency info in PETSc lhs (i.e plhs.rowPtr and plhs.colPtr) is used to set values. */ + PetscCall(PetscMalloc2(2*nNo, &plhs.rowPtr, nnz, &plhs.colPtr)); + for (i=0; i < nNo; i++) { + // plhs.rowPtr[i*2] = svFSI_rowPtr[i*2] - 1; + plhs.rowPtr[i*2] = svFSI_rowPtr[i*2]; + // plhs.rowPtr[i*2+1] = svFSI_rowPtr[i*2+1]; + plhs.rowPtr[i*2+1] = svFSI_rowPtr[i*2+1]+1; + } + for (i=0; i < nnz; i++) { + // plhs.colPtr[i] = plhs.ltg[svFSI_colPtr[i] - 1]; + plhs.colPtr[i] = plhs.ltg[svFSI_colPtr[i]]; + } + + /* Deallocate memory */ + PetscCall(PetscFree2(owned_ltg, local_ltg)); + PetscCall(PetscFree2(local2global, local2local)); + PetscCall(PetscFree(ghost_ltg)); + PetscCall(PetscFree(pordering)); + + PetscFunctionReturn(PETSC_SUCCESS); +} + +/* + Creating PETSc data structure for Dirichlet and lumped parameter BC with svFSI info. +*/ +PetscErrorCode petsc_create_bc(const PetscInt dof, const PetscInt cEq, \ + const PetscReal *svFSI_DirBC, const PetscReal *svFSI_lpBC) +{ + PetscInt i, j, cc, ii; + PetscInt *row1, *row2; + PetscReal eps = 1.0e6*__DBL_EPSILON__; + + PetscFunctionBeginUser; + + /* Find PETSc global index of dofs with Dirichlet BC */ + PetscCall(PetscMalloc1(plhs.mynNo*dof, &row1)); + cc = 0; + for (i = 0; i < plhs.mynNo; i++) { + ii = i * dof; + for (j = 0; j < dof; j++) { + if ( ((int) svFSI_DirBC[ii+j]) == 0) { + row1[cc++] = plhs.ltg[i]*dof + j; + } + } + } + PetscCall(PetscMalloc1(cc, &psol[cEq].DirBC)); + psol[cEq].DirPts = cc; + for (i = 0; i < cc; i++){ + psol[cEq].DirBC[i] = row1[i]; + } + + /* Find O2 and PETSc index of dofs with lumped parameter BC */ + PetscCall(PetscMalloc1(plhs.mynNo*dof, &row2)); + cc = 0; + for (i = 0; i < plhs.mynNo; i++) { + ii = i * dof; + for (j = 0; j < dof; j++) { + if ( PetscAbsReal(svFSI_lpBC[ii+j]) > eps) { + row1[cc] = ii + j; + row2[cc] = plhs.ltg[i]*dof + j; + cc++; + } + } + } + PetscCall(PetscMalloc2(cc, &psol[cEq].lpBC_l, cc, &psol[cEq].lpBC_g)); + psol[cEq].lpPts = cc; + for (i = 0; i < cc; i++){ + psol[cEq].lpBC_l[i] = row1[i]; + psol[cEq].lpBC_g[i] = row2[i]; + } + PetscCall(PetscFree(row1)); + PetscCall(PetscFree(row2)); + + PetscFunctionReturn(PETSC_SUCCESS); +} + +/* + Create and preallocate parallel PETSC vector and matrix data structure. +*/ +PetscErrorCode petsc_create_vecmat(const PetscInt dof, const PetscInt cEq, const PetscInt nEq) +{ + PetscInt i, j, is, ie, row, col; + Mat preallocator; + PetscReal *value; + PC pc; + PetscBool usefieldsplit, useamg; + + PetscFunctionBeginUser; + + /* Create vector data structures */ + PetscCall(VecCreateGhostBlock(MPI_COMM_WORLD, dof, plhs.mynNo*dof, PETSC_DECIDE, plhs.nNo-plhs.mynNo, plhs.ghostltg, &psol[cEq].b)); + if (nEq > 1) PetscCall(VecSetOptionsPrefix(psol[cEq].b, psol[cEq].pre)); + PetscCall(VecSetFromOptions(psol[cEq].b)); + + + /* + Preallocate psol.A with the help of MATPREALLOCATOR. + Internally MatPreallocatorPreallocate() will call MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_TRUE); + */ + PetscCall(MatCreate(MPI_COMM_WORLD, &preallocator)); + PetscCall(MatSetType(preallocator, MATPREALLOCATOR)); + PetscCall(MatSetSizes(preallocator, plhs.mynNo*dof, plhs.mynNo*dof, PETSC_DECIDE, PETSC_DECIDE)); + PetscCall(MatSetBlockSize(preallocator, dof)); + PetscCall(MatSetUp(preallocator)); + PetscCall(PetscMalloc1(dof*dof, &value)); + for (i = 0; i < dof*dof; i++) value[i] = 0.0; + /* Internal points */ + for (i = 0; i < plhs.nNo; i++) { + is = plhs.rowPtr[i*2]; + ie = plhs.rowPtr[i*2+1]; + row = plhs.ltg[i]; + for (j = is; j < ie; j++) { + col = plhs.colPtr[j]; + PetscCall(MatSetValuesBlocked(preallocator, 1, &row, 1, &col, value, INSERT_VALUES)); + } + } + /* Points with lumped parameter BC */ + for (i = 0; i < psol[cEq].lpPts; i++){ + row = psol[cEq].lpBC_g[i]; + for (j = 0; j < psol[cEq].lpPts; j++){ + col = psol[cEq].lpBC_g[j]; + PetscCall(MatSetValue(preallocator, row, col, 0.0, INSERT_VALUES)); + } + } + PetscCall(MatAssemblyBegin(preallocator, MAT_FINAL_ASSEMBLY)); + PetscCall(MatAssemblyEnd(preallocator, MAT_FINAL_ASSEMBLY)); + + /* Create and preallocate matrix structure */ + KSPGetPC(psol[cEq].ksp, &pc); + PetscObjectTypeCompare((PetscObject)pc, PCFIELDSPLIT, &usefieldsplit); /* Fieldsplit only supports MATAIJ */ + PetscObjectTypeCompare((PetscObject)pc, PCGAMG, &useamg); /* GAMG only supports MATAIJ */ + PetscCall(MatCreate(MPI_COMM_WORLD, &psol[cEq].A)); + if (dof > 1 && !usefieldsplit && !useamg) { + PetscCall(MatSetType(psol[cEq].A, MATBAIJ)); + } + else { + PetscCall(MatSetType(psol[cEq].A, MATAIJ)); + } + if (nEq > 1) PetscCall(MatSetOptionsPrefix(psol[cEq].A, psol[cEq].pre)); + PetscCall(MatSetFromOptions(psol[cEq].A)); + PetscCall(MatSetSizes(psol[cEq].A, plhs.mynNo*dof, plhs.mynNo*dof, PETSC_DECIDE, PETSC_DECIDE)); + PetscCall(MatSetBlockSize(psol[cEq].A, dof)); + PetscCall(MatPreallocatorPreallocate(preallocator, PETSC_TRUE, psol[cEq].A)); + PetscCall(MatSetOption(psol[cEq].A, MAT_NEW_NONZERO_LOCATION_ERR, PETSC_TRUE)); + PetscCall(MatSetOption(psol[cEq].A, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE)); + + /* Create vector structure for RCS preconditioner */ + if (psol[cEq].rcs){ + PetscCall(VecDuplicate(psol[cEq].b, &psol[cEq].Dr)); + PetscCall(VecDuplicate(psol[cEq].b, &psol[cEq].Dc)); + } + + PetscCall(PetscFree(value)); + PetscCall(MatDestroy(&preallocator)); + + PetscFunctionReturn(PETSC_SUCCESS); +} + +/* + Set values to the rhs vector. + R is the rhs from svFSI in O1 order. +*/ +PetscErrorCode petsc_set_vec(const PetscInt dof, const PetscInt cEq, const PetscReal *R) +{ + PetscInt indx, i; + PetscInt *row; + const PetscReal *value; + + PetscFunctionBeginUser; + + /* Set the rhs vector using global index. */ + PetscCall(VecZeroEntries(psol[cEq].b)); + + for (i = 0; i < plhs.mynNo; i++) { + row = plhs.ltg+i; + indx = plhs.map[i]; + value = R + indx*dof; + PetscCall(VecSetValuesBlocked(psol[cEq].b, 1, row, value, INSERT_VALUES)); + } + PetscCall(VecAssemblyBegin(psol[cEq].b)); + PetscCall(VecAssemblyEnd(psol[cEq].b)); + + /* Fill the ghost vertices with correct values. */ + PetscCall(VecGhostUpdateBegin(psol[cEq].b, INSERT_VALUES, SCATTER_FORWARD)); + PetscCall(VecGhostUpdateEnd(psol[cEq].b, INSERT_VALUES, SCATTER_FORWARD)); + + PetscFunctionReturn(PETSC_SUCCESS); +} + +/* + Set values to the matrix. +*/ +PetscErrorCode petsc_set_mat(const PetscInt dof, const PetscInt cEq, const PetscReal *Val) +{ + PetscInt i, j, is, ie; + PetscInt *col, *row; + const PetscScalar *value; + + PetscFunctionBeginUser; + + PetscCall(MatZeroEntries(psol[cEq].A)); + for (i = 0; i < plhs.nNo; i++) { + is = plhs.rowPtr[i*2]; + ie = plhs.rowPtr[i*2+1]; + row = plhs.ltg+i; + for (j = is; j < ie; j++){ + value = Val + j*dof*dof; + col = plhs.colPtr + j; + PetscCall(MatSetValuesBlocked(psol[cEq].A, 1, row, 1, col, value, ADD_VALUES)); + } + + } + PetscCall(MatAssemblyBegin(psol[cEq].A, MAT_FLUSH_ASSEMBLY)); + PetscCall(MatAssemblyEnd(psol[cEq].A, MAT_FLUSH_ASSEMBLY)); + + PetscFunctionReturn(PETSC_SUCCESS); +} + +/* + Set up Dirichlet BC and resistance BC. +*/ +PetscErrorCode petsc_set_bc(const PetscInt cEq, const PetscReal *DirBC, const PetscReal *lpBC) +{ + Vec x; + PetscInt i, j, ii, jj, row, col; + PetscReal value; + + PetscFunctionBeginUser; + + /* Apply lumped parameter BC by augmenting the matrix A. */ + for (i = 0; i < psol[cEq].lpPts; i++){ + ii = psol[cEq].lpBC_l[i]; + row = psol[cEq].lpBC_g[i]; + for (j = 0; j < psol[cEq].lpPts; j++){ + jj = psol[cEq].lpBC_l[j]; + col = psol[cEq].lpBC_g[j]; + value = lpBC[ii] * lpBC[jj]; + PetscCall(MatSetValue(psol[cEq].A, row, col, value, ADD_VALUES)); + } + } + PetscCall(MatAssemblyBegin(psol[cEq].A, MAT_FINAL_ASSEMBLY)); + PetscCall(MatAssemblyEnd(psol[cEq].A, MAT_FINAL_ASSEMBLY)); + + /* + Apply Dirichlet BC by resetting matrix A and rhs b. + Since the BC remains the same, the matrix will retain the same nonzero structure + */ + PetscCall(VecDuplicate(psol[cEq].b, &x)); + PetscCall(VecPlaceArray(x, DirBC)); + PetscCall(MatZeroRowsColumns(psol[cEq].A, psol[cEq].DirPts, psol[cEq].DirBC, 1.0, x , psol[cEq].b)); + + PetscCall(VecDestroy(&x)); + PetscFunctionReturn(PETSC_SUCCESS); +} + +/* + Set up PCFIELDSPLIT. +*/ +PetscErrorCode petsc_set_pcfieldsplit(const PetscInt dof, const PetscInt cEq) +{ + IS isu, isp; + PetscInt i, j, ii, jj; + PetscInt *uindx, *pindx; + PC pc; + + PetscFunctionBeginUser; + + /* Create index set for velocity and pressure block */ + PetscCall(PetscMalloc2((dof-1)*plhs.mynNo, &uindx, plhs.mynNo, &pindx)); + for (i = 0; i < plhs.mynNo; i++){ + ii = (dof-1)*i; + jj = dof*plhs.ltg[i]; + for (j = 0; j < dof-1; j++){ + uindx[ii+j] = jj + j; + } + pindx[i] = jj + dof - 1; + } + PetscCall(ISCreateGeneral(MPI_COMM_WORLD, (dof-1)*plhs.mynNo, uindx, PETSC_COPY_VALUES, &isu)); + PetscCall(ISSetBlockSize(isu, dof-1)); + PetscCall(ISSort(isu)); + PetscCall(ISCreateGeneral(MPI_COMM_WORLD, plhs.mynNo, pindx, PETSC_COPY_VALUES, &isp)); + PetscCall(ISSort(isp)); + + /* Pass split information to PETSc. Velocity: block 0, pressure: block 1. */ + PetscCall(KSPGetPC(psol[cEq].ksp, &pc)); + PetscCall(PCFieldSplitSetBlockSize(pc, 2)); + PetscCall(PCFieldSplitSetIS(pc, "0", isu)); + PetscCall(PCFieldSplitSetIS(pc, "1", isp)); + + PetscCall(ISDestroy(&isu)); + PetscCall(ISDestroy(&isp)); + PetscCall(PetscFree2(uindx, pindx)); + PetscFunctionReturn(PETSC_SUCCESS); +} + +/* + Row-and-Column-Scaling preconditioner. + \hat{A} = Dr*A*Dc + \hat{b} = Dr*b +*/ +PetscErrorCode petsc_pc_rcs(const PetscInt dof, const PetscInt cEq) +{ + Vec Dr, Dc; + PetscInt numCol, *row; + PetscReal *colNorm, *value; + PetscReal tol, err1, err2; + PetscInt i, iter, maxiter; + + tol = 0.1; + maxiter = 10; + + + PetscFunctionBeginUser; + + PetscCall(VecSet(psol[cEq].Dr, 1.0)); + PetscCall(VecSet(psol[cEq].Dc, 1.0)); + PetscCall(VecDuplicate(psol[cEq].Dr, &Dr)); + PetscCall(VecDuplicate(psol[cEq].Dc, &Dc)); + + + for (iter = 0; iter < maxiter; iter++){ + /* Get infinity norm of each row */ + PetscCall(MatGetRowMaxAbs(psol[cEq].A, Dr, NULL)); + + /* Get infinity norm of each column */ + PetscCall(MatGetSize(psol[cEq].A, NULL, &numCol)); + PetscCall(PetscMalloc1(numCol, &colNorm)); + PetscCall(MatGetColumnNorms(psol[cEq].A, NORM_INFINITY, colNorm)); + for (i = 0; i < plhs.mynNo; i++) { + row = plhs.ltg+i; + value = colNorm + plhs.ltg[i]*dof; + PetscCall(VecSetValuesBlocked(Dc, 1, row, value, INSERT_VALUES)); + } + PetscCall(VecAssemblyBegin(Dc)); + PetscCall(VecAssemblyEnd(Dc)); + + /* Calculate 1/sqrt(Dr, Dc) */ + PetscCall(VecSqrtAbs(Dc)); + PetscCall(VecReciprocal(Dc)); + PetscCall(VecSqrtAbs(Dr)); + PetscCall(VecReciprocal(Dr)); + + /* Scale A matrix */ + PetscCall(MatDiagonalScale(psol[cEq].A, Dr, Dc)); + PetscCall(VecPointwiseMult(psol[cEq].Dc, psol[cEq].Dc, Dc)); + PetscCall(VecPointwiseMult(psol[cEq].Dr, psol[cEq].Dr, Dr)); + + /* Converged or not */ + PetscCall(VecShift(Dc, -1.0)); + PetscCall(VecShift(Dr, -1.0)); + PetscCall(VecNorm(Dc, NORM_INFINITY, &err1)); + PetscCall(VecNorm(Dr, NORM_INFINITY, &err2)); + if (err1 <= tol && err2 <= tol) break; + } + + if (err1 > tol || err2 > tol ) { + PetscPrintf(MPI_COMM_WORLD, "ERROR : " + "did not converge to %g in %d iterations.\n" + "ERROR : " + "err1 = %g, err2 = %g\n", tol, maxiter, err1, err2); + } + + /* Scale right hand side */ + PetscCall(VecPointwiseMult(psol[cEq].b, psol[cEq].b, psol[cEq].Dr)); + + PetscCall(PetscFree(colNorm)); + PetscCall(VecDestroy(&Dr)); + PetscCall(VecDestroy(&Dc)); + + PetscFunctionReturn(PETSC_SUCCESS); +} + + +/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + Private functions for debugging + +- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ + +/* + Debug: save vector to text file +*/ +PetscErrorCode petsc_debug_save_vec(const char *filename, Vec vec) +{ + PetscFunctionBeginUser; + + PetscViewer viewer; + PetscViewerASCIIOpen(MPI_COMM_WORLD, filename, &viewer); + PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_COMMON); + VecView(vec, viewer); + PetscViewerPopFormat(viewer); + PetscViewerDestroy(&viewer); + + PetscFunctionReturn(PETSC_SUCCESS); +} + +/* + Debug: save matrix to text file +*/ +PetscErrorCode petsc_debug_save_mat(const char *filename, Mat mat) +{ + PetscFunctionBeginUser; + + PetscViewer viewer; + PetscViewerASCIIOpen(MPI_COMM_WORLD, filename, &viewer); + PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_DENSE); + MatView(mat, viewer); + PetscViewerPopFormat(viewer); + PetscViewerDestroy(&viewer); + + PetscFunctionReturn(PETSC_SUCCESS); +} + +///////////////////////////////////////////////////////////////// +// P e t s c I m p l // +///////////////////////////////////////////////////////////////// + +//----------- +// PetscImpl +//----------- +// The PetscImpl private class hides PETSc data structures +// and functions. +// +class PetscLinearAlgebra::PetscImpl { + public: + // True if PESc has been initialized. + static bool pesc_initialized; + + PetscImpl(); + void initialize(ComMod& com_mod, eqType& lEq); + void set_preconditioner(consts::PreconditionerType prec_type); + void solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res); + void init_dir_and_coupneu_bc(ComMod& com_mod, const Vector& incL, const Vector& res); + + consts::PreconditionerType preconditioner_; + + // Local to global mapping + Vector ltg_; + + // Factor for Dirichlet BCs + Array W_; + + // Residue + Array R_; + + // Factor for Lumped Parameter BCs + Array V_; + +}; + +bool PetscLinearAlgebra::PetscImpl::pesc_initialized = false; + +PetscLinearAlgebra::PetscImpl::PetscImpl() +{ +} + +//------------------------- +// init_dir_and_coupneu_bc +//------------------------- +// +void PetscLinearAlgebra::PetscImpl::init_dir_and_coupneu_bc(ComMod& com_mod, + const Vector& incL, const Vector& res) +{ + using namespace consts; + using namespace fsi_linear_solver; + + int dof = com_mod.dof; + auto& lhs = com_mod.lhs; + + if(lhs.nFaces != 0) { + for (auto& face : lhs.face) { + face.incFlag = true; + } + + for (int faIn = 0; faIn < lhs.nFaces; faIn++) { + if (incL(faIn) == 0) { + lhs.face[faIn].incFlag = false; + } + } + + for (int faIn = 0; faIn < lhs.nFaces; faIn++) { + auto& face = lhs.face[faIn]; + face.coupledFlag = false; + if (!face.incFlag) { + continue; + } + + bool flag = (face.bGrp == BcType::BC_TYPE_Neu); + + if (flag && res(faIn) != 0.0) { + face.res = res(faIn); + face.coupledFlag = true; + } + } + } + + W_ = 1.0; + + for (int faIn = 0; faIn < lhs.nFaces; faIn++) { + auto& face = lhs.face[faIn]; + if (!face.incFlag) { + continue; + } + + int faDof = std::min(face.dof,dof); + + if (face.bGrp == BcType::BC_TYPE_Dir) { + for (int a = 0; a < face.nNo; a++) { + int Ac = face.glob(a); + for (int i = 0; i < faDof; i++) { + W_(i,Ac) = W_(i,Ac) * face.val(i,a); + } + } + } + } + + V_ = 0.0; + bool isCoupledBC = false; + + for (int faIn = 0; faIn < lhs.nFaces; faIn++) { + auto& face = lhs.face[faIn]; + if (face.coupledFlag) { + isCoupledBC = true; + int faDof = std::min(face.dof,dof); + + for (int a = 0; a < face.nNo; a++) { + int Ac = face.glob(a); + for (int i = 0; i < faDof; i++) { + V_(i,Ac) = V_(i,Ac) + sqrt(fabs(res(faIn))) * face.val(i,a); + } + } + } + } +} + +//------------ +// initialize +//------------ +// Initialize PETSc and create a linear solver. +// +void PetscLinearAlgebra::PetscImpl::initialize(ComMod& com_mod, eqType& equation) +{ + if (!pesc_initialized) { + petsc_destroy_all(com_mod.nEq); + + petsc_initialize(com_mod.lhs.nNo, com_mod.lhs.mynNo, com_mod.lhs.nnz, com_mod.nEq, + com_mod.ltg.data(), com_mod.lhs.map.data(), com_mod.lhs.rowPtr.data(), + com_mod.lhs.colPtr.data(), com_mod.eq[0].ls.config.data()); + + pesc_initialized = true; + } + + auto prec_type = preconditioner_; + auto ls_type = equation.ls.LS_type; + auto phys = equation.phys; + auto& ls = equation.ls; + + // Find the equation number of `equation` in com_mod.eq[]. + // + int eq_num = -1; + + for (int a = 0; a < com_mod.nEq; a++) { + if (std::addressof(com_mod.eq[a]) == std::addressof(equation)) { + eq_num = a; + } + } + + petsc_create_linearsolver(ls_type, prec_type, ls.sD, ls.mItr, ls.relTol, ls.absTol, + phys, equation.dof, eq_num, com_mod.nEq); +} + +void PetscLinearAlgebra::PetscImpl::set_preconditioner(consts::PreconditionerType prec_type) +{ + preconditioner_ = prec_type; +} + +//------- +// solve +//------- +// +void PetscLinearAlgebra::PetscImpl::solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res) +{ + W_.resize(com_mod.dof, com_mod.tnNo); + V_.resize(com_mod.dof, com_mod.tnNo); + + init_dir_and_coupneu_bc(com_mod, incL, res); + + // only excute once for each equation + // + petsc_create_linearsystem(com_mod.dof, com_mod.cEq, com_mod.nEq, W_.data(), V_.data()); + + petsc_set_values(com_mod.dof, com_mod.cEq, com_mod.R.data(), com_mod.Val.data(), W_.data(), V_.data()); + + petsc_solve(&lEq.FSILS.RI.fNorm, &lEq.FSILS.RI.iNorm, &lEq.FSILS.RI.dB, &lEq.FSILS.RI.callD, + &lEq.FSILS.RI.suc, &lEq.FSILS.RI.itr, com_mod.R.data(), lEq.FSILS.RI.mItr, com_mod.dof, com_mod.cEq); + +} + diff --git a/Code/Source/svFSI/petsc_impl.h b/Code/Source/svFSI/petsc_impl.h new file mode 100644 index 00000000..6528b579 --- /dev/null +++ b/Code/Source/svFSI/petsc_impl.h @@ -0,0 +1,132 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +// This file contains PETSc-dependent data structures. + +#ifndef PETSC_INTERFACE_H +#define PETSC_INTERFACE_H + +#include +#include +#include +#include + +#include "consts.h" + +//-------- +// LHSCtx +//--------- +// PETSc lhs context. +// +typedef struct { + PetscBool created; /* Whether petsc lhs is created */ + + PetscInt nNo; /* local number of vertices */ + PetscInt mynNo; /* number of owned vertices */ + + PetscInt *map; /* local to local mapping, map[O2] = O1 */ + PetscInt *ltg; /* local to global in PETSc ordering */ + PetscInt *ghostltg; /* local to global in PETSc ordering */ + PetscInt *rowPtr; /* row pointer for adjacency info */ + PetscInt *colPtr; /* column pointer for adjacency info */ +} LHSCtx; + +//------- +// LSCtx +//------- +// PETSc linear solver context. +// +typedef struct { + PetscBool created; /* Whether mat and vec is created */ + const char *pre; /* option prefix for different equations */ + + PetscInt lpPts; /* number of dofs with lumped parameter BC */ + PetscInt *lpBC_l; /* O2 index for dofs with lumped parameter BC */ + PetscInt *lpBC_g; /* PETSc index for dofs with lumped parameter BC */ + + PetscInt DirPts; /* number of dofs with Dirichlet BC */ + PetscInt *DirBC; /* PETSc index for dofs with Dirichlet BC */ + + Vec b; /* rhs/solution vector of owned vertices */ + Mat A; /* stiffness matrix */ + KSP ksp; /* linear solver context */ + + PetscBool rcs; /* whether rcs preconditioner is activated */ + Vec Dr; /* diagonal matrix from row maxabs */ + Vec Dc; /* diagonal matrix from col maxabs */ +} LSCtx; + +void petsc_initialize(const PetscInt nNo, const PetscInt mynNo, + const PetscInt nnz, const PetscInt nEq, const PetscInt *svFSI_ltg, + const PetscInt *svFSI_map, const PetscInt *svFSI_rowPtr, + const PetscInt *svFSI_colPtr, char *inp); + +void petsc_create_linearsystem(const PetscInt dof, const PetscInt iEq, const PetscInt nEq, + const PetscReal *svFSI_DirBC, const PetscReal *svFSI_lpBC); + +void petsc_create_linearsolver(const consts::PreconditionerType lsType, const consts::PreconditionerType pcType, + const PetscInt kSpace, const PetscInt maxIter, const PetscReal relTol, + const PetscReal absTol, const consts::EquationType phys, const PetscInt dof, + const PetscInt iEq, const PetscInt nEq); + +void petsc_set_values(const PetscInt dof, const PetscInt iEq, const PetscReal *R, + const PetscReal *Val, const PetscReal *svFSI_DirBC, const PetscReal *svFSI_lpBC); + +void petsc_solve(PetscReal *resNorm, PetscReal *initNorm, PetscReal *dB, + PetscReal *execTime, bool *converged, PetscInt *numIter, + PetscReal *R, const PetscInt maxIter, const PetscInt dof, + const PetscInt iEq); + +void petsc_destroy_all(const PetscInt); + +PetscErrorCode petsc_create_lhs(const PetscInt, const PetscInt, const PetscInt, + const PetscInt *, const PetscInt *, + const PetscInt *, const PetscInt *); + +PetscErrorCode petsc_create_bc(const PetscInt, const PetscInt, const PetscReal *, + const PetscReal *); + +PetscErrorCode petsc_create_vecmat(const PetscInt, const PetscInt, const PetscInt); + +PetscErrorCode petsc_set_vec(const PetscInt, const PetscInt, const PetscReal *); + +PetscErrorCode petsc_set_mat(const PetscInt, const PetscInt, const PetscReal *); + +PetscErrorCode petsc_set_bc(const PetscInt, const PetscReal *, const PetscReal *); + +PetscErrorCode petsc_set_pcfieldsplit(const PetscInt, const PetscInt); + +PetscErrorCode petsc_pc_rcs(const PetscInt, const PetscInt); + + +PetscErrorCode petsc_debug_save_vec(const char *, Vec); +PetscErrorCode petsc_debug_save_mat(const char *, Mat); + +#endif diff --git a/Code/Source/svFSI/pic.cpp b/Code/Source/svFSI/pic.cpp index 4bbcebd7..69d07e51 100644 --- a/Code/Source/svFSI/pic.cpp +++ b/Code/Source/svFSI/pic.cpp @@ -29,11 +29,6 @@ */ // The code here replicates the Fortran code in PIC.f. -// -// See the publication below, section 4.4 for theory and derivation: -// Bazilevs, et al. "Isogeometric fluid-structure interaction: -// theory, algorithms, and computations.", Computational Mechanics, -// 43 (2008): 3-37. doi: 10.1007/s00466-008-0315-x #include "pic.h" @@ -226,7 +221,6 @@ void picc(Simulation* simulation) // IB treatment //if (ibFlag) CALL IB_PICC() - // Computes norms and check for convergence of Newton iterations double eps = std::numeric_limits::epsilon(); if (utils::is_zero(eq.FSILS.RI.iNorm)) { @@ -526,32 +520,12 @@ void pici(Simulation* simulation, Array& Ag, Array& Yg, Arrayparameters.equation_parameters[0]; - auto& general_params = simulation->parameters.general_simulation_parameters; + auto& eq1_params = simulation->parameters.equation_parameters[0]; auto eq1_type = eq1_params->type.value(); - if ((eq1_type != "fluid") && (eq1_type != "FSI") && (!general_params.use_precomputed_solution.value())) { + if ((eq1_type != "fluid") && (eq1_type != "FSI")) { throw std::runtime_error("heatF equation has to be specified after fluid/FSI equation"); - } + } } if (eq.phys == EquationType::phys_mesh) { @@ -1968,6 +1967,12 @@ void read_ls(Simulation* simulation, EquationParameters* eq_params, consts::Solv using namespace consts; using namespace fsi_linear_solver; + #define n_debug_read_ls + #ifdef debug_read_ls + DebugMsg dmsg(__func__, simulation->com_mod.cm.idcm()); + dmsg.banner(); + #endif + // Map SolverType to LinearSolverType enums. static std::map solver_to_ls_map = { {SolverType::lSolver_NS, LinearSolverType::LS_TYPE_NS}, @@ -1981,6 +1986,9 @@ void read_ls(Simulation* simulation, EquationParameters* eq_params, consts::Solv SolverType solver_type; LinearSolverType FSILSType; bool solver_type_defined = eq_params->linear_solver.type.defined(); + #ifdef debug_read_ls + dmsg << "solver_type_defined: " << solver_type_defined; + #endif if (solver_type_defined) { auto solver_str = eq_params->linear_solver.type.value(); @@ -1997,6 +2005,9 @@ void read_ls(Simulation* simulation, EquationParameters* eq_params, consts::Solv FSILSType = solver_to_ls_map[solver_type]; for (auto entry : solver_name_to_type) { if (solver_type == entry.second) { + #ifdef debug_read_ls + dmsg << "solver_type: " << entry.first; + #endif break; } } @@ -2004,21 +2015,31 @@ void read_ls(Simulation* simulation, EquationParameters* eq_params, consts::Solv // Set linear solver parameters. // lEq.ls.LS_type = solver_type; - fsi_linear_solver::fsils_ls_create(lEq.FSILS, FSILSType); - // Set preconditioner type. + // Process linear_algebra parameters. // - lEq.ls.PREC_Type = PreconditionerType::PREC_FSILS; + auto& linear_algebra = eq_params->linear_solver.linear_algebra; + #ifdef debug_read_ls + dmsg << "linear_algebra.defined: " << linear_algebra.defined(); + dmsg << "linear_algebra.type: " << linear_algebra.type(); + dmsg << "linear_algebra.preconditioner: " << linear_algebra.preconditioner(); + #endif - #ifdef WITH_TRILINOS - if (FSILSType == LinearSolverType::LS_TYPE_NS) { - lEq.ls.PREC_Type = PreconditionerType::PREC_FSILS; - } else { - lEq.useTLS = true; - lEq.ls.PREC_Type = PreconditionerType::PREC_TRILINOS_DIAGONAL; + if (!linear_algebra.defined()) { + throw std::runtime_error("[svFSIplus] No section has been defined for equation '" + + eq_params->type() + "."); + } + + lEq.linear_algebra_type = LinearAlgebra::name_to_type.at(linear_algebra.type()); + auto prec_type = consts::preconditioner_name_to_type.at(linear_algebra.preconditioner()); + lEq.linear_algebra_preconditioner = consts::preconditioner_name_to_type.at(linear_algebra.preconditioner()); + lEq.linear_algebra_assembly_type = LinearAlgebra::name_to_type.at(linear_algebra.assembly()); + + // Check that equation physics is compatible with the LinearAlgebra type. + for (auto& domain : lEq.dmn) { + LinearAlgebra::check_equation_compatibility(domain.phys, lEq.linear_algebra_type, lEq.linear_algebra_assembly_type); } - #endif if (!solver_type_defined) { return; @@ -2026,27 +2047,6 @@ void read_ls(Simulation* simulation, EquationParameters* eq_params, consts::Solv auto& linear_solver = eq_params->linear_solver; - if (linear_solver.preconditioner.defined()) { - auto precon_str = linear_solver.preconditioner.value(); - std::transform(precon_str.begin(), precon_str.end(), precon_str.begin(), ::tolower); - try { - auto precon_entry = preconditioner_name_to_type.at(precon_str); - lEq.ls.PREC_Type = precon_entry.first; - lEq.useTLS = precon_entry.second; - } catch (const std::out_of_range& exception) { - throw std::runtime_error("Unknown preconditioner '" + precon_str + "."); - } - - //lEq.useTLS = use_trilinos; - } - - if (lEq.useTLS) { - lEq.assmTLS = linear_solver.use_trilinos_for_assembly.value(); - if (lEq.assmTLS && simulation->com_mod.ibFlag) { - throw std::runtime_error("Cannot assemble immersed bodies using Trilinos"); - } - } - lEq.ls.mItr = linear_solver.max_iterations.value(); lEq.FSILS.RI.mItr = lEq.ls.mItr; @@ -2076,6 +2076,10 @@ void read_ls(Simulation* simulation, EquationParameters* eq_params, consts::Solv lEq.FSILS.GM.sD = lEq.FSILS.RI.sD; } + + #ifdef debug_read_ls + dmsg << "Done " << " "; + #endif } //---------------- diff --git a/Code/Source/svFSI/set_bc.cpp b/Code/Source/svFSI/set_bc.cpp index acf0f9d1..5fc6d75a 100644 --- a/Code/Source/svFSI/set_bc.cpp +++ b/Code/Source/svFSI/set_bc.cpp @@ -44,18 +44,8 @@ #include "utils.h" #include -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace set_bc { -/// @brief This function calculates updated cplBC pressures or flowrates from 0D, -/// as well as the resistance matrix M ~ dP/dQ from 0D using finite difference. -/// Updates the pressure or flowrates stored in cplBC.fa[i].y and the resistance -/// matrix M ~ dP/dQ stored in eq.bc[iBc].r. -/// @param com_mod -/// @param cm_mod void calc_der_cpl_bc(ComMod& com_mod, const CmMod& cm_mod) { using namespace consts; @@ -74,8 +64,6 @@ void calc_der_cpl_bc(ComMod& com_mod, const CmMod& cm_mod) auto& eq = com_mod.eq[iEq]; auto& cplBC = com_mod.cplBC; - // If coupling is all with Dirichlet faces, no derivative calculation is needed - // (see Moghadam et al. 2013 Section 2.2.2) if (std::count_if(cplBC.fa.begin(),cplBC.fa.end(),[](cplFaceType& fa){return fa.bGrp == CplBCType::cplBC_Dir;}) == cplBC.fa.size()) { #ifdef debug_calc_der_cpl_bc dmsg << "all cplBC_Dir " << std::endl; @@ -84,17 +72,8 @@ void calc_der_cpl_bc(ComMod& com_mod, const CmMod& cm_mod) } // if (ALL(cplBC.fa.bGrp .EQ. cplBC_Dir)) RETURN - // Determine current physics - auto& cDmn = com_mod.cDmn; - auto cPhys = eq.dmn[cDmn].phys; - - // Mechanical configuration in which to compute flowrate - auto cfg_o = MechanicalConfigurationType::reference; - auto cfg_n = MechanicalConfigurationType::reference; - bool RCRflag = false; - // Loop over BCs for (int iBc = 0; iBc < eq.nBc; iBc++) { #ifdef debug_calc_der_cpl_bc dmsg << "----- iBc " << iBc+1 << " -----" << std::endl; @@ -117,29 +96,10 @@ void calc_der_cpl_bc(ComMod& com_mod, const CmMod& cm_mod) if (ptr != -1) { auto& fa = com_mod.msh[iM].fa[iFa]; - // Compute flowrates at 3D Neumann boundaries at timesteps n and n+1 - if (utils::btest(bc.bType, iBC_Neu)) { - // If struct or ustruct, use old and new configurations to compute flowrate integral - if ((cPhys == EquationType::phys_struct) || (cPhys == EquationType::phys_ustruct)) { - // Must use follower pressure load for 0D coupling with struct/ustruct - if (!bc.flwP) { - throw std::runtime_error("[calc_der_cpl_bc] Follower pressure load must be used for 0D coupling with struct/ustruct"); - } - cfg_o = MechanicalConfigurationType::old_timestep; - cfg_n = MechanicalConfigurationType::new_timestep; - } - // If fluid, FSI, or CMM, use reference configuration to compute flowrate integral - // Note that for FSI, mvMsh will modify geometry in gnnb() - else if ((cPhys == EquationType::phys_fluid) || (cPhys == EquationType::phys_FSI) || (cPhys == EquationType::phys_CMM)) { - cfg_o = MechanicalConfigurationType::reference; - cfg_n = MechanicalConfigurationType::reference; - } - else { - throw std::runtime_error("[calc_der_cpl_bc] Invalid physics type for 0D coupling"); - } - cplBC.fa[ptr].Qo = all_fun::integ(com_mod, cm_mod, fa, com_mod.Yo, 0, nsd-1, false, cfg_o); - cplBC.fa[ptr].Qn = all_fun::integ(com_mod, cm_mod, fa, com_mod.Yn, 0, nsd-1, false, cfg_n); + if (utils::btest(bc.bType, iBC_Neu)) { + cplBC.fa[ptr].Qo = all_fun::integ(com_mod, cm_mod, fa, com_mod.Yo, 0, nsd-1); + cplBC.fa[ptr].Qn = all_fun::integ(com_mod, cm_mod, fa, com_mod.Yn, 0, nsd-1); cplBC.fa[ptr].Po = 0.0; cplBC.fa[ptr].Pn = 0.0; #ifdef debug_calc_der_cpl_bc @@ -148,9 +108,7 @@ void calc_der_cpl_bc(ComMod& com_mod, const CmMod& cm_mod) dmsg << "cplBC.fa[ptr].Qn: " << cplBC.fa[ptr].Qn; #endif - } - // Compute avg pressures at 3D Dirichlet boundaries at timesteps n and n+1 - else if (utils::btest(bc.bType, iBC_Dir)) { + } else if (utils::btest(bc.bType, iBC_Dir)) { double area = fa.area; cplBC.fa[ptr].Po = all_fun::integ(com_mod, cm_mod, fa, com_mod.Yo, nsd) / area; cplBC.fa[ptr].Pn = all_fun::integ(com_mod, cm_mod, fa, com_mod.Yn, nsd) / area; @@ -169,15 +127,12 @@ void calc_der_cpl_bc(ComMod& com_mod, const CmMod& cm_mod) dmsg << "RCRflag: " << RCRflag; #endif - // Call genBC or cplBC to get updated pressures or flowrates. if (cplBC.useGenBC) { set_bc::genBC_Integ_X(com_mod, cm_mod, "D"); } else { set_bc::cplBC_Integ_X(com_mod, cm_mod, RCRflag); } - // Compute the epsilon parameter (diff) for the finite difference calculation - // of the resistance matrix M ~ dP/dQ. Slightly different from Eq. 30 in Moghadam et al. 2013 int j = 0; double diff = 0.0; @@ -185,7 +140,7 @@ void calc_der_cpl_bc(ComMod& com_mod, const CmMod& cm_mod) auto& bc = eq.bc[iBc]; int i = bc.cplBCptr; if (i != -1 && utils::btest(bc.bType, iBC_Neu)) { - diff = diff + (cplBC.fa[i].Qn * cplBC.fa[i].Qn); + diff = diff + (cplBC.fa[i].Qo * cplBC.fa[i].Qo); j = j + 1; } } @@ -197,39 +152,24 @@ void calc_der_cpl_bc(ComMod& com_mod, const CmMod& cm_mod) diff = diff*relTol; } - // Store the original pressures and flowrates - std::vector orgY(cplBC.fa.size()); - std::vector orgQ(cplBC.fa.size()); - - for (size_t i = 0; i < cplBC.fa.size(); i++) { - orgY[i] = cplBC.fa[i].y; - orgQ[i] = cplBC.fa[i].Qn; - } - for (int iBc = 0; iBc < eq.nBc; iBc++) { auto& bc = eq.bc[iBc]; int i = bc.cplBCptr; if (i != -1 && utils::btest(bc.bType, iBC_Neu)) { + double orgY = cplBC.fa[i].y; + double orgQ = cplBC.fa[i].Qn; + cplBC.fa[i].Qn = cplBC.fa[i].Qn + diff; - // Finite difference perturbation in flowrate - cplBC.fa[i].Qn = orgQ[i] + diff; - - // Call genBC or cplBC again with perturbed flowrate if (cplBC.useGenBC) { set_bc::genBC_Integ_X(com_mod, cm_mod, "D"); } else { set_bc::cplBC_Integ_X(com_mod, cm_mod, RCRflag); } - // Finite difference calculation of the resistance dP/dQ - bc.r = (cplBC.fa[i].y - orgY[i]) / diff; - - // Restore the original pressures and flowrates - for (size_t j = 0; j < cplBC.fa.size(); j++) { - cplBC.fa[j].y = orgY[j]; - cplBC.fa[j].Qn = orgQ[j]; -} + bc.r = (cplBC.fa[i].y - orgY) / diff; + cplBC.fa[i].y = orgY; + cplBC.fa[i].Qn = orgQ; } } } @@ -315,12 +255,9 @@ void cplBC_Integ_X(ComMod& com_mod, const CmMod& cm_mod, const bool RCRflag) } } - -//--------------- -// genBC_Integ_X -//--------------- -// Interface to call 0D code (genBC/gcode) -// +/// @brief Interface to call 0D code (genBC/gcode) +/// +/// \todo [NOTE] not fully implemented. // void genBC_Integ_X(ComMod& com_mod, const CmMod& cm_mod, const std::string& genFlag) { @@ -328,17 +265,9 @@ void genBC_Integ_X(ComMod& com_mod, const CmMod& cm_mod, const std::string& genF int nDir = 0; int nNeu = 0; - double dt = com_mod.dt; auto& cplBC = com_mod.cplBC; auto& cm = com_mod.cm; - int len = cplBC.binPath.size() + cplBC.commuName.size() + 1; - char command[len]; - strcpy(command, cplBC.binPath.c_str()); - strcat(command, " "); - strcat(command, cplBC.commuName.c_str()); - - // If this process is the master process on the communicator if (cm.mas(cm_mod)) { for (int iFa = 0; iFa < cplBC.nFa; iFa++) { auto& fa = cplBC.fa[iFa]; @@ -350,106 +279,65 @@ void genBC_Integ_X(ComMod& com_mod, const CmMod& cm_mod, const std::string& genF } } - // Write coupling info (number of Dirichlet and Neumann surfaces, pressure, - // flow rate) from 3D to cplBC communication file (for GenBC, usually - // called GenBC.int) - int int_size = sizeof(int); - int double_size = sizeof(double); - int flag_size = genFlag.length(); - - std::ofstream genBC_writer; - genBC_writer.open(cplBC.commuName, std::ios::out|std::ios::binary); - if (!genBC_writer.is_open()) { - throw std::runtime_error("Failed to open the genBC initialization file '" + cplBC.commuName + "' to write."); - } - // Flag for how genBC behaves (I: Initializing, T: Iteration loop, L: Last iteration, D: Derivative) - genBC_writer.write( (char*)&flag_size, int_size); - genBC_writer.write(genFlag.c_str(), flag_size); - genBC_writer.write( (char*)&flag_size, int_size); - - genBC_writer.write( (char*)&double_size, int_size); - genBC_writer.write( (char*)&dt, double_size); - genBC_writer.write( (char*)&double_size, int_size); - - genBC_writer.write( (char*)&int_size, int_size); - genBC_writer.write( (char*)&nDir, int_size); - genBC_writer.write( (char*)&int_size, int_size); - - genBC_writer.write( (char*)&int_size, int_size); - genBC_writer.write( (char*)&nNeu, int_size); - genBC_writer.write( (char*)&int_size, int_size); + int fid = 1; + //OPEN(fid, FILE=cplBC.commuName, FORM='UNFORMATTED') + //WRITE(fid) genFlag + //WRITE(fid) dt + //WRITE(fid) nDir + //WRITE(fid) nNeu for (int iFa = 0; iFa < cplBC.nFa; iFa++) { if (cplBC.fa[iFa].bGrp == CplBCType::cplBC_Dir) { - genBC_writer.write( (char*)&double_size, int_size); - genBC_writer.write( (char*)&cplBC.fa[iFa].Po, double_size); - genBC_writer.write( (char*)&double_size, int_size); - genBC_writer.write( (char*)&double_size, int_size); - genBC_writer.write( (char*)&cplBC.fa[iFa].Pn, double_size); - genBC_writer.write( (char*)&double_size, int_size); + //WRITE(fid) cplBC.fa(iFa).Po, cplBC.fa(iFa).Pn } } - + for (int iFa = 0; iFa < cplBC.nFa; iFa++) { if (cplBC.fa[iFa].bGrp == CplBCType::cplBC_Neu) { - genBC_writer.write( (char*)&double_size, int_size); - genBC_writer.write( (char*)&cplBC.fa[iFa].Qo, double_size); - genBC_writer.write( (char*)&double_size, int_size); - genBC_writer.write( (char*)&double_size, int_size); - genBC_writer.write( (char*)&cplBC.fa[iFa].Qn, double_size); - genBC_writer.write( (char*)&double_size, int_size); + //WRITE(fid) cplBC.fa(iFa).Qo, cplBC.fa(iFa).Qn } } - genBC_writer.close(); - - // Call genBC executable which reads the communication file GenBC.int - system(command); + //CLOSE(fid) - // Read outputs from genBC, which are in the same GenBC.int - std::ifstream genBC_reader(cplBC.commuName, std::ios::out | std::ios::binary); - if (!genBC_reader.is_open()) { - throw std::runtime_error("Failed to open the genBC interface file '" + cplBC.commuName + "' to read."); - } + //CALL SYSTEM(TRIM(cplBC.binPath)//" "//TRIM(cplBC.commuName)) - int size_buffer; + //OPEN(fid,FILE=cplBC.commuName,STATUS='OLD',FORM='UNFORMATTED') for (int iFa = 0; iFa < cplBC.nFa; iFa++) { if (cplBC.fa[iFa].bGrp == CplBCType::cplBC_Dir) { - genBC_reader.read( (char*)&size_buffer, int_size ); - genBC_reader.read( (char*)&cplBC.fa[iFa].y, size_buffer ); - genBC_reader.read( (char*)&size_buffer, int_size ); + //READ(fid) cplBC.fa(iFa).y } } for (int iFa = 0; iFa < cplBC.nFa; iFa++) { if (cplBC.fa[iFa].bGrp == CplBCType::cplBC_Neu) { - genBC_reader.read( (char*)&size_buffer, int_size ); - genBC_reader.read( (char*)&cplBC.fa[iFa].y, size_buffer ); - genBC_reader.read( (char*)&size_buffer, int_size ); + //READ(fid) cplBC.fa(iFa).y } } - - genBC_reader.close(); + //CLOSE(fid) } - // If there are multiple procs (not sequential), broadcast genBC outputs to - // follower procs if (!cm.seq()) { Vector y(cplBC.nFa); + //ALLOCATE(y(cplBC.nFa)) if (cm.mas(cm_mod)) { for (int i = 0; i < cplBC.nFa; i++) { y(i) = cplBC.fa[i].y; } + //y = cplBC.fa.y; } cm.bcast(cm_mod, y); + //CALL cm.bcast(y) if (cm.slv(cm_mod)) { for (int i = 0; i < cplBC.nFa; i++) { cplBC.fa[i].y = y(i); } + // cplBC.fa.y = y; } + //DEALLOCATE(y) } } @@ -666,8 +554,7 @@ void set_bc_cmm_l(ComMod& com_mod, const CmMod& cm_mod, const faceType& lFa, con } -/// @brief Coupled BC quantities are computed here. -/// Reproduces the Fortran 'SETBCCPL()' subrotutine. +/// @brief Reproduces the Fortran 'SETBCCPL()' subrotutine. // void set_bc_cpl(ComMod& com_mod, CmMod& cm_mod) { @@ -682,21 +569,9 @@ void set_bc_cpl(ComMod& com_mod, CmMod& cm_mod) const int iEq = 0; auto& eq = com_mod.eq[iEq]; - // Determine current physics - auto& cDmn = com_mod.cDmn; - auto cPhys = eq.dmn[cDmn].phys; - - // Configuration in which to compute flowrate - auto cfg_o = MechanicalConfigurationType::reference; - auto cfg_n = MechanicalConfigurationType::reference; - - // If coupling scheme is implicit, calculate updated pressure and flowrate - // from 0D, as well as resistance from 0D using finite difference. if (cplBC.schm == CplBCType::cplBC_I) { calc_der_cpl_bc(com_mod, cm_mod); - // If coupling scheme is semi-implicit or explicit, only calculated updated - // pressure and flowrate from 0D } else { bool RCRflag = false; @@ -714,35 +589,12 @@ void set_bc_cpl(ComMod& com_mod, CmMod& cm_mod) if (ptr != -1) { - // Compute flowrates at 3D Neumann boundaries at timesteps n and n+1 if (utils::btest(bc.bType,iBC_Neu)) { - // If struct or ustruct, use old and new configurations to compute flowrate integral - if ((cPhys == EquationType::phys_struct) || (cPhys == EquationType::phys_ustruct)) { - - // Must use follower pressure load for 0D coupling with struct/ustruct - if (!bc.flwP) { - throw std::runtime_error("[set_bc_cpl] Follower pressure load must be used for 0D coupling with struct/ustruct"); - } - cfg_o = MechanicalConfigurationType::old_timestep; - cfg_n = MechanicalConfigurationType::new_timestep; - } - // If fluid, FSI, or CMM, use reference configuration to compute flowrate integral - // Note that for FSI, mvMsh will modify geometry in gnnb() - else if ((cPhys == EquationType::phys_fluid) || (cPhys == EquationType::phys_FSI) || (cPhys == EquationType::phys_CMM)) { - cfg_o = MechanicalConfigurationType::reference; - cfg_n = MechanicalConfigurationType::reference; - } - else { - throw std::runtime_error("[set_bc_cpl] Invalid physics type for 0D coupling"); - } - - cplBC.fa[ptr].Qo = all_fun::integ(com_mod, cm_mod, com_mod.msh[iM].fa[iFa], Yo, 0, nsd-1, false, cfg_o); - cplBC.fa[ptr].Qn = all_fun::integ(com_mod, cm_mod, com_mod.msh[iM].fa[iFa], Yn, 0, nsd-1, false, cfg_n); + cplBC.fa[ptr].Qo = all_fun::integ(com_mod, cm_mod, com_mod.msh[iM].fa[iFa], Yo, 0, nsd-1); + cplBC.fa[ptr].Qn = all_fun::integ(com_mod, cm_mod, com_mod.msh[iM].fa[iFa], Yn, 0, nsd-1); cplBC.fa[ptr].Po = 0.0; cplBC.fa[ptr].Pn = 0.0; - } - // Compute avg pressures at 3D Dirichlet boundaries at timesteps n and n+1 - else if (utils::btest(bc.bType,iBC_Dir)) { + } else if (utils::btest(bc.bType,iBC_Dir)) { double area = com_mod.msh[iM].fa[iFa].area; cplBC.fa[ptr].Po = all_fun::integ(com_mod, cm_mod, com_mod.msh[iM].fa[iFa], Yo, nsd) / area; cplBC.fa[ptr].Pn = all_fun::integ(com_mod, cm_mod, com_mod.msh[iM].fa[iFa], Yn, nsd) / area; @@ -752,8 +604,6 @@ void set_bc_cpl(ComMod& com_mod, CmMod& cm_mod) } } - // Call genBC or cplBC to get updated pressures or flowrates. - // Updates pressure or flowrates stored in cplBC.fa[i].y if (cplBC.useGenBC) { set_bc::genBC_Integ_X(com_mod, cm_mod, "D"); } else { @@ -1301,14 +1151,7 @@ void set_bc_dir_wl(ComMod& com_mod, const bcType& lBc, const mshType& lM, const } } - // Now doing the assembly part - if (eq.assmTLS) { -#ifdef WITH_TRILINOS - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); -#endif - } else { - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); - } + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } } @@ -1442,10 +1285,12 @@ void set_bc_neu_l(ComMod& com_mod, const CmMod& cm_mod, const bcType& lBc, const } } - // Add Neumann BCs contribution to the residual (and tangent if flwP) + // Add Neumann BCs contribution to the LHS/RHS + // + // if follower pressure load. // if (lBc.flwP) { - eq_assem::b_neu_folw_p(com_mod, lBc, lFa, hg, Dg); + eq_assem::b_neu_folw_p(com_mod, lFa, hg, Dg); } else { eq_assem::b_assem_neu_bc(com_mod, lFa, hg, Yg); @@ -1458,7 +1303,7 @@ void set_bc_neu_l(ComMod& com_mod, const CmMod& cm_mod, const bcType& lBc, const } } -/// @brief Set Robin BC contribution to residual and tangent +/// @brief Set Robin BC // void set_bc_rbnl(ComMod& com_mod, const faceType& lFa, const double ks, const double cs, const bool isN, const Array& Yg, const Array& Dg) @@ -1663,16 +1508,10 @@ void set_bc_rbnl(ComMod& com_mod, const faceType& lFa, const double ks, const do } } - if (eq.assmTLS) { - #ifdef WITH_TRILINOS - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); - #endif + if (cPhys == EquationType::phys_ustruct) { + ustruct::ustruct_do_assem(com_mod, eNoN, ptr, lKd, lK, lR); } else { - if (cPhys == EquationType::phys_ustruct) { - ustruct::ustruct_do_assem(com_mod, eNoN, ptr, lKd, lK, lR); - } else { - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); - } + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } } // for int e = 0; e < lFa.nEl; e++ @@ -1784,13 +1623,7 @@ void set_bc_trac_l(ComMod& com_mod, const CmMod& cm_mod, const bcType& lBc, cons } } - if (eq.assmTLS) { - #ifdef WITH_TRILINOS - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); - #endif - } else { - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); - } + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } } diff --git a/Code/Source/svFSI/set_equation_props.h b/Code/Source/svFSI/set_equation_props.h index c9bc5279..56d8d3b6 100644 --- a/Code/Source/svFSI/set_equation_props.h +++ b/Code/Source/svFSI/set_equation_props.h @@ -264,10 +264,8 @@ SetEquationPropertiesMapType set_equation_props = { read_domain(simulation, eq_params, lEq, propL); - nDOP = {3,1,1,0}; - outPuts = {OutputType::out_temperature, - OutputType::out_heatFlux, - OutputType::out_velocity}; + nDOP = {2,1,1,0}; + outPuts = {OutputType::out_temperature, OutputType::out_heatFlux}; // Set solver parameters. read_ls(simulation, eq_params, SolverType::lSolver_GMRES, lEq); diff --git a/Code/Source/svFSI/shells.cpp b/Code/Source/svFSI/shells.cpp index 937ff496..01ae3de1 100644 --- a/Code/Source/svFSI/shells.cpp +++ b/Code/Source/svFSI/shells.cpp @@ -41,10 +41,6 @@ #include "nn.h" #include "utils.h" -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace shells { /// @brief This routines is for solving nonlinear shell mechanics problem @@ -186,20 +182,7 @@ void construct_shell(ComMod& com_mod, const mshType& lM, const Array& Ag } } - //if (e+1 == 19) { - //exit(0); - //} - - // Assembly -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), const_cast(ptr.data()), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } // e: loop @@ -1671,22 +1654,7 @@ void shell_cst(ComMod& com_mod, const mshType& lM, const int e, const int eNoN, } } - // Global assembly - - //std::cout << "[shell_cst] " << std::endl; - //std::cout << "[shell_cst] lR: " << lR << std::endl; - //std::cout << "[shell_cst] lK: " << lK << std::endl; - //exit(0); - -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), const_cast(ptr.data()), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } //---------- diff --git a/Code/Source/svFSI/stokes.cpp b/Code/Source/svFSI/stokes.cpp index 73997743..5b9f96ba 100644 --- a/Code/Source/svFSI/stokes.cpp +++ b/Code/Source/svFSI/stokes.cpp @@ -43,10 +43,6 @@ #include #include -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace stokes { void construct_stokes(ComMod& com_mod, const mshType& lM, const Array& Ag, const Array& Yg) @@ -230,18 +226,7 @@ void construct_stokes(ComMod& com_mod, const mshType& lM, const Array& A } // g: loop - // Assembly - -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } - -#endif + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } // e: loop diff --git a/Code/Source/svFSI/sv_struct.cpp b/Code/Source/svFSI/sv_struct.cpp index 57918d01..65672a1f 100644 --- a/Code/Source/svFSI/sv_struct.cpp +++ b/Code/Source/svFSI/sv_struct.cpp @@ -45,10 +45,6 @@ #include "nn.h" #include "utils.h" -#ifdef WITH_TRILINOS -#include "trilinos_linear_solver.h" -#endif - namespace struct_ns { void b_struct_2d(const ComMod& com_mod, const int eNoN, const double w, const Vector& N, @@ -106,17 +102,7 @@ void b_struct_2d(const ComMod& com_mod, const int eNoN, const double w, const Ve } } -/// @brief Add follower pressure load contributions to the local residual and stiffness matrix. -/// @param com_mod -/// @param eNoN -/// @param w Gauss point weight times reference configuration area -/// @param N Shape function values at the Gauss point -/// @param Nx Shape function derivatives at the Gauss point -/// @param dl Displacement vector -/// @param hl Magnitude of pressure -/// @param nV Normal vector (in reference configuration) -/// @param lR Local residual -/// @param lK Local stiffness matrix + void b_struct_3d(const ComMod& com_mod, const int eNoN, const double w, const Vector& N, const Array& Nx, const Array& dl, const Vector& hl, const Vector& nV, Array& lR, Array3& lK) @@ -154,7 +140,6 @@ void b_struct_3d(const ComMod& com_mod, const int eNoN, const double w, const Ve double h = 0.0; - // Compute deformation gradient tensor F for (int a = 0; a < eNoN; a++) { h = h + N(a)*hl(a); F(0,0) = F(0,0) + Nx(0,a)*dl(i,a); @@ -176,7 +161,7 @@ void b_struct_3d(const ComMod& com_mod, const int eNoN, const double w, const Ve NxFi(1,a) = Nx(0,a)*Fi(0,1) + Nx(1,a)*Fi(1,1) + Nx(2,a)*Fi(2,1); NxFi(2,a) = Nx(0,a)*Fi(0,2) + Nx(1,a)*Fi(1,2) + Nx(2,a)*Fi(2,2); } - // Compute N.F^-1, used for Nanson' formula da.n = J*dA*N.F^-1 + nFi(0) = nV(0)*Fi(0,0) + nV(1)*Fi(1,0) + nV(2)*Fi(2,0); nFi(1) = nV(0)*Fi(0,1) + nV(1)*Fi(1,1) + nV(2)*Fi(2,1); nFi(2) = nV(0)*Fi(0,2) + nV(1)*Fi(1,2) + nV(2)*Fi(2,2); @@ -190,7 +175,6 @@ void b_struct_3d(const ComMod& com_mod, const int eNoN, const double w, const Ve debug << "wl: " << wl; #endif - // Compute follower pressure load contributions to the local residual and stiffness matrix for (int a = 0; a < eNoN; a++) { lR(0,a) = lR(0,a) - wl*N(a)*nFi(0); lR(1,a) = lR(1,a) - wl*N(a)*nFi(1); @@ -361,28 +345,7 @@ void construct_dsolid(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const } } -#if 0 - if (e+1 == 100) { - Array3::write_enabled = true; - Array::write_enabled = true; - lR.write("lR"); - lK.write("lK"); - exit(0); - } -#endif - - // Assembly - // -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - trilinos_doassem_(const_cast(eNoN), ptr.data(), lK.data(), lR.data()); - } else { -#endif - lhsa_ns::do_assem(com_mod, eNoN, ptr, lK, lR); -#ifdef WITH_TRILINOS - } -#endif - + eq.linear_algebra->assemble(com_mod, eNoN, ptr, lK, lR); } } diff --git a/Code/Source/svFSI/trilinos_impl.cpp b/Code/Source/svFSI/trilinos_impl.cpp new file mode 100644 index 00000000..3009b90f --- /dev/null +++ b/Code/Source/svFSI/trilinos_impl.cpp @@ -0,0 +1,1327 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +//-------------------------------------------------------------------- +// +// Interface to Trilinos linear solver library. +// +//-------------------------------------------------------------------- + +/*! + \file trilinos_linear_solver.cpp + \brief wrap Trilinos solver functions +*/ + +#include "trilinos_impl.h" +#include "ComMod.h" +#define NOOUTPUT + +// --- Define global Trilinos variables to be used in below functions --------- + +/// Unique block map consisting of nodes owned by each processor +Epetra_BlockMap *Trilinos::blockMap; + +/// Global block force vector +Epetra_FEVector *Trilinos::F; + +/// Global block stiffness matrix +Epetra_FEVbrMatrix *Trilinos::K; + +/// Solution vector consisting of unique nodes owned by the processor +Epetra_Vector *Trilinos::X; + +/// Solution vector with nodes owned by processor followed by its ghost nodes +Epetra_Vector *Trilinos::ghostX; + +/// Import ghostMap into blockMap to create ghost map +Epetra_Import *Trilinos::Importer; + +/// Contribution from coupled neumann boundary conditions +Epetra_FEVector *Trilinos::bdryVec; + +Epetra_FECrsGraph *Trilinos::K_graph; + +ML_Epetra::MultiLevelPreconditioner* MLPrec = NULL; + +Ifpack_Preconditioner* ifpackPrec = NULL; + +// --- Define global variables to be shared amongst the below functions ------- + +/// Nodal degrees of freedom +int dof; + +/// Total number of nodes including the ghost nodes +int ghostAndLocalNodes; + +/// Nodes owned by processor +int localNodes; + +/// Converts local proc column indices to global indices to be inserted +std::vector globalColInd; + +/// Converts local indices to global indices in unsorted ghost node order +std::vector localToGlobalUnsorted; + +/// Stores number of nonzeros per row for the topology +std::vector nnzPerRow; + +std::vector localToGlobalSorted; + +int timecount = 0; + +bool coupledBC; + +// ---------------------------------------------------------------------------- +/** + * Define the matrix vector multiplication operation to do at each iteration + * (K + v*v') *x = K*x + v*(v'*x), v = bdryVec + * + * uses efficient vectorized operation rather than explicitly forming + * the rank 1 outer product matrix + * + * \param x vector to be applied on the operator + * \param y result of sprase matrix vector multiplication + */ +int TrilinosMatVec::Apply(const Epetra_MultiVector &x, + Epetra_MultiVector &y) const +{ + //store initial matrix vector product result in Y + Trilinos::K->Apply(x, y); //K*x + if (coupledBC) + { + //now need to add on bdry term v*(v'*x) + double *dot = new double[1]; //only 1 multivector to store result in it + + //compute dot product (v'*x) + Trilinos::bdryVec->Dot(x,dot); + + //Y = 1*Y + dot*v daxpy operation + y.Update(*dot, //scalar for v + *Trilinos::bdryVec, //FE_Vector + 1.0); ///scalar for Y + + delete[] dot; + } + return 0; +} + +// ---------------------------------------------------------------------------- +/** + * make the graph global and optimize storage on it + * this function creates the LHS structure topology and RHS vector based on the + * block map + * \param numGlobalNodes total/global number of nodes each node can have dof + * for the spatial dim + * \param numLocalNodes number of nodes owned by this proc in block coordiantes + * \param numGhostAndLocalNodes number of nodes owned and shared by this + * processor includes ghost nodes + * \param nnz number of nonzeros in LHS matrix of calling proc + * \param ltgSorted integer pointer of size numLocalNodes returns global + * node number of local node a to give blockrow + * \param ltgUnsorted unsorted/not-reordered version + * \param rowPtr CSR row ptr of size numLocalNodes + 1 to block rows + * \param colInd CSR column indices ptr (size nnz points) to block rows + * \param Dof size of each block element to give dim of each block + + */ + +void trilinos_lhs_create_(int &numGlobalNodes, int &numLocalNodes, + int &numGhostAndLocalNodes, int &nnz, const int *ltgSorted, + const int *ltgUnsorted, const int *rowPtr, const int *colInd, int &Dof, + int& cpp_index, int& proc_id) +{ + + #ifdef debug_trilinos_lhs_create + std::string msg_prefix; + msg_prefix = std::string("[trilinos_lhs_create:") + std::to_string(proc_id) + "] "; + std::cout << msg_prefix << std::endl; + std::cout << msg_prefix << "========== trilinos_lhs_create ==========" << std::endl; + std::cout << msg_prefix << "Dof: " << Dof << std::endl; + std::cout << msg_prefix << "cpp_index: " << cpp_index << std::endl; + #endif + + int indexBase = 1; //0 based indexing for C/C++ / 1 for Fortran + if (cpp_index == 1) { + indexBase = 0; + } + + dof = Dof; //constant size dof blocks + ghostAndLocalNodes = numGhostAndLocalNodes; + localNodes = numLocalNodes; + Epetra_MpiComm comm(MPI_COMM_WORLD); + + #ifdef debug_trilinos_lhs_create + std::cout << msg_prefix << "indexBase: " << indexBase << std::endl; + std::cout << msg_prefix << "dof: " << dof << std::endl; + std::cout << msg_prefix << "ghostAndLocalNodes: " << ghostAndLocalNodes << std::endl; + std::cout << msg_prefix << "localNodes: " << localNodes << std::endl; + std::cout << msg_prefix << "localToGlobalSorted.size(): " << localToGlobalSorted.size() << std::endl; + #endif + + bool new_mapping_pattern = false; //could change with remeshing + + // check if mesh was changed and vectors need to be resized + if (localToGlobalSorted.size() != numGhostAndLocalNodes) { + localToGlobalSorted.clear(); // sets size to zero + localToGlobalUnsorted.clear(); + nnzPerRow.clear(); + globalColInd.clear(); + } + + // allocate memory for vectors + if (localToGlobalSorted.size() == 0) { // vectors not allocated or cleared + localToGlobalSorted.reserve(numGhostAndLocalNodes); + localToGlobalUnsorted.reserve(numGhostAndLocalNodes); + nnzPerRow.reserve(numGhostAndLocalNodes); + globalColInd.reserve(nnz); + new_mapping_pattern = true; + } + + // Define localtoglobal to be used for unqiue partition map + //only take ltgSorted(1:numLocalNodes) since those are owned by the processor + // + if (new_mapping_pattern) { + for (unsigned i = 0; i < numLocalNodes; ++i) { + //any nodes following are ghost nodes so that subset + localToGlobalSorted.emplace_back(ltgSorted[i]); + } + } + + // Create blockmap for arbitrary distributon of constant size, dof, element + // amongst the procs. This is a non-overlapping map defining a unique partition + // localToGlobalSorted[0] contains global index value of ith owned element on + // the calling processor + // + Trilinos::blockMap = new Epetra_BlockMap(numGlobalNodes, numLocalNodes, + &localToGlobalSorted[0], dof, indexBase, comm); + + // Create blockmap which includes the ghost nodes to be imported into the + // solution vector at the end + // + int inc_ghost = -1; // since including ghost nodes sum will not equal total + Epetra_BlockMap ghostMap(inc_ghost, numGhostAndLocalNodes, ltgSorted, dof, + indexBase, comm); + + // Calculate nnzPerRow to pass into graph constructor + // + if (new_mapping_pattern) { + nnzPerRow.clear (); //destroy vector + for (unsigned i = 0; i < numLocalNodes; ++i) { + nnzPerRow.emplace_back(rowPtr[i+1] - rowPtr[i]); + } + } + + // Construct graph based on nnz per row + // + Trilinos::K_graph = new Epetra_FECrsGraph(Copy, *Trilinos::blockMap, &nnzPerRow[0]); + + unsigned nnzCount = 0; //cumulate count of block nnz per rows + + // Use unsortedltg to map local col ind to global indices + // + if (globalColInd.size() != nnz) { // only if nnz changed + globalColInd.clear(); // destroy + for (unsigned i = 0; i < nnz; ++i) { + // Convert to global indexing subtract 1 for fortran vs C array indexing + globalColInd.emplace_back(ltgUnsorted[colInd[i] - indexBase]); + //globalColInd.emplace_back(ltgUnsorted[colInd[i] - 1]); + } + } + + //loop over block rows owned by current proc using localToGlobal index pointer + for (unsigned i = 0; i < numGhostAndLocalNodes; ++i) + { + if (new_mapping_pattern && i >= numLocalNodes) + nnzPerRow.emplace_back(rowPtr[i+1] - rowPtr[i]); + int numEntries = nnzPerRow[i]; //nnz per row + int error = 0; + int num_rows_inserting = 1; //number of rows-inserting one row at a time + error = Trilinos::K_graph->InsertGlobalIndices(num_rows_inserting, + <gUnsorted[i], numEntries, &globalColInd[nnzCount]); + + //colInd is indexed by nnz per rows processed so far + if (error != 0) + { + std::cout << "ERROR: Inserting Global Indices into Map" << std::endl; + exit(1); + } + + // final result should be nnz and so will not go out of bounds on colInd + // up to nnz -1 + nnzCount += numEntries; + //store into global vector + if (new_mapping_pattern) + localToGlobalUnsorted.emplace_back(ltgUnsorted[i]); + } // for + + //by end of iterations nnzCount should equal nnz-otherwise there is an error + if (nnzCount != nnz) + { + std::cout << "Number of Entries Entered in Graph does not equal nnz " << std::endl; + exit(1); + } + + //check if trilinos methods are successful + if (Trilinos::K_graph->GlobalAssemble() != 0) //Calls FillComplete + { + std::cout << "ERROR: Calling Fill Complete on Graph" << std::endl; + exit(1); + } + + //Trilinos::K_graph->OptimizeStorage(); //TODO: that causes it to fail + + // --- Create block finite element matrix from graph with fillcomplete ------ + // construct matrix from filled graph + Trilinos::K = new Epetra_FEVbrMatrix(Copy, *Trilinos::K_graph); + //construct RHS force vector F topology + Trilinos::F = new Epetra_FEVector(*Trilinos::blockMap); + Trilinos::bdryVec = new Epetra_FEVector(*Trilinos::blockMap); + + // Initialize solution vector which is unique and does not include the ghost + // indices using the unique map + Trilinos::X = new Epetra_Vector(*Trilinos::blockMap); + //initialize vector which will import the ghost nodes using the ghost map + Trilinos::ghostX = new Epetra_Vector(ghostMap); + //Create importer of the two maps + Trilinos::Importer = new Epetra_Import(ghostMap, *Trilinos::blockMap); + //need to give v a map-same as F + if (new_mapping_pattern) + for (unsigned i = numLocalNodes; i < numGhostAndLocalNodes; ++i) + localToGlobalSorted.emplace_back(ltgSorted[i]); +} // trilinos_lhs_create_ + +// ---------------------------------------------------------------------------- +/** + * This function assembles the dense element block stiffness matrix and element + * block force vector into the global block stiffness K and global block force + * vector F. + * Happens on a single element and will be called repeatedly as we loop over + * all the elements. + * + * \param numNodesPerElement number of nodes (d) for element e + * \param eqN converts local element node number to local proc + * equation number-size is numNodesPerElement + * \param lK element local stiffness of size + * (dof*dof, numNodesPerElement, numNodesPerElement) + * \param lR element local force vector of size + * (dof, numNodesPerElement) + */ +void trilinos_doassem_(int &numNodesPerElement, const int *eqN, const double *lK, double *lR) +{ + #ifdef debug_trilinos_doassem + std::cout << "[trilinos_doassem_] ========== trilinos_doassem_ ===========" << std::endl; + std::cout << "[trilinos_doassem_] dof: " << dof << std::endl; + std::cout << "[trilinos_doassem_] numNodesPerElement: " << numNodesPerElement << std::endl; + #endif + + //dof values per global ID in the force vector + int numValuesPerID = dof; + + //converts eqN in local proc values to global values + std::vector localToGlobal(numNodesPerElement); + + for (int i = 0; i < numNodesPerElement; ++i) + localToGlobal[i] = localToGlobalUnsorted[eqN[i]]; + + //loop over local nodes on the element + for (int a = 0; a < numNodesPerElement; ++a) + { + // Sum into contributions from element node-global assemble will take those + // from shared nodes on other processors since FE routine. + int error = Trilinos::K->BeginSumIntoGlobalValues(localToGlobal[a], + numNodesPerElement, &localToGlobal[0]); + + if (error != 0) + { + std::cout << "ERROR: Setting block row and block column of summing into " + << "global values!" + << std::endl; + exit(1); + } + + //submit global F values + int num_block_rows = 1; //number of global block rows put in 1 at a time + Trilinos::F->SumIntoGlobalValues (num_block_rows, &localToGlobal[a], + &numValuesPerID, &lR[a*dof]); + + if (error != 0) //1 or more indices not associated with calling processor! + { + std::cout << error << std::endl; + std::cout << "ERROR: Summing into global vector values!" << std::endl; + exit(1); + } + + //loop over local nodes for columns + std::vector values(dof*dof); + for (int b = 0; b < numNodesPerElement; ++b) + { + //transpose block since Trilinos takes in SerialMAtrix in column major + for (int i = 0; i < dof; ++i) + { + //premult by diagonal W so W(a) multiplies row a + for (int j = 0; j < dof; ++j) + { + //taking transpose of block so flip i & j + values[i*dof + j] + = lK[b*dof*dof*numNodesPerElement + a*dof*dof + j*dof + i]; + } + } + + error = Trilinos::K->SubmitBlockEntry(&values[0], dof, dof, dof); + + if (error != 0) + { + std::cout << "ERROR: Inputting values of summing into matrix " + << "global values!" + << std::endl; + exit(1); + } + } + + //finish submitting the block entry for the current row + error = Trilinos::K->EndSubmitEntries(); + if (error != 0) + { + std::cout << "[trilinos_doassem_] ERROR: End submitting block entries!" << std::endl; + exit(1); + } + } +} // trilinos_doassem_ + +// ---------------------------------------------------------------------------- +/** + * Tthis function creates the LHS structure topology and RHS vector based on + * the block map using the global stiffness matrix and global force vector + * assuming the assembly part has been done in svFSI + * + * \param Val nonzero values of assembled global stiffness + * \param RHS global force vector + * \param x solution vector + * \param dirW gives information about the Dirichlet BC + * \param resNorm norm of solution + * \param initNorm initial norm of RHS + * \param numIters linear solver number of iterations + * \param solverTime time in linear solver + * \param dB log ratio for output + * \param converged neither or not converged in the max number of iterations + * \param lsType defines type of linear solver to use + * \param relTol default relative tolerance or as set in input file + * \param maxIters default max number of iterations for gmres per restart + * \param kspace specific for gmres dim of the stored Krylov space vectors + * \param precondType defines type of preconditioner to use + */ + +void trilinos_global_solve_(const double *Val, const double *RHS, double *x, + const double *dirW, double &resNorm, double &initNorm, int &numIters, + double &solverTime, double &dB, bool &converged, int &lsType, + double &relTol, int &maxIters, int &kspace, int &precondType) +{ + int nnzCount = 0; //cumulate count of block nnz per rows + int count = 0; + int numValuesPerID = dof; //dof values per id pointer to dof + std::vector values(dof*dof); // holds local matrix entries + + // loop over block rows owned by current proc using localToGlobal index pointer + // + for (int i = 0; i < ghostAndLocalNodes; ++i) { + int numEntries = nnzPerRow[i]; //block per of entries per row + // Copy global stiffness values + int error = Trilinos::K->BeginReplaceGlobalValues(localToGlobalUnsorted[i], + numEntries, &globalColInd[nnzCount]); + + // Need to check if globalColInd and localToGlobal equal for block diag + // + if (error != 0) { + std::cout << error << std::endl; + std::cout << "ERROR: Setting block row and block column of setting " + << "global values!" + << std::endl; + exit(1); + } + + // Copy F values-loop over dof for bool + // + int num_block_rows = 1; //number of global block rows put in 1 at a time + + error = Trilinos::F->ReplaceGlobalValues (num_block_rows, + &localToGlobalUnsorted[i], &numValuesPerID, &RHS[i*dof]); + + //check is bool true or false whether to give 0 if on diagonal 1 + if (error != 0) { + std::cout << "ERROR: Setting global vector values!" << std::endl; + exit(1); + } + + for (int j = 0; j < numEntries; ++j) { + for (int l = 0; l < dof; ++l) { //loop over dof for bool to contruct + for (int m = 0; m < dof; ++m) { + values[l*dof + m] = Val[count*dof*dof + m*dof + l]; //transpose it + } + } + + // Submit square dof*dof blocks + error = Trilinos::K->SubmitBlockEntry(&values[0], dof, dof, dof); + + if (error != 0) { + std::cout << "ERROR: Inputting values of setting matrix global " + << "values!" << std::endl; + exit(1); + } + count++; + } + + error = Trilinos::K->EndSubmitEntries(); //for current block row + + if (error != 0) { + std::cout << "ERROR: End submitting block entries!" << std::endl; + exit(1); + } + nnzCount += numEntries; + } + + // Call solver code which assembles K and F for shared processors + // + bool flagFassem = false; + + trilinos_solve_(x, dirW, resNorm, initNorm, numIters, + solverTime, dB, converged, lsType, + relTol, maxIters, kspace, precondType, flagFassem); + +} // trilinos_global_solve_ + +// ---------------------------------------------------------------------------- +/** + * This function uses the established data structure to solve the block linear + * system and passes the solution vector back to fortran with the ghost nodes + * filled in + * + * \param x solution vector + * \param dirW gives information about Dirichlet BC + * \param resNorm norm of the final residual + * \param initNorm norm of initial resiual x_init = 0 ||b|| + * \param numIters number of iterations in the linear solver + * \param solverTime time in the linear solver + * \param dB log ratio for output + * \param converged can pass in solver and preconditioner type too + * \param lsType defines type of linear solver to use + * \param relTol default relative tolerance or as set in input file + * \param maxIters default max number of iterations for gmres per restart + * \param kspace specific for gmres dim of the stored Krylov space vectors + * \param precondType defines type of preconditioner to use + * \param isFassem determines if F is already assembled at ghost nodes + */ +void trilinos_solve_(double *x, const double *dirW, double &resNorm, + double &initNorm, int &numIters, double &solverTime, double &dB, + bool &converged, int &lsType, double &relTol, int &maxIters, + int &kspace, int &precondType, bool &isFassem) +{ + #define n_debug_trilinos_solve + #ifdef debug_trilinos_solve + std::cout << "[trilinos_solve] ========== trilinos_solve ==========" << std::endl; + std::cout << "[trilinos_solve] resNorm: " << resNorm << std::endl; + std::cout << "[trilinos_solve] initNorm: " << initNorm << std::endl; + std::cout << "[trilinos_solve] lsType: " << lsType << std::endl; + std::cout << "[trilinos_solve] precondType: " << precondType << std::endl; + std::cout << "[trilinos_solve] isFassem: " << isFassem << std::endl; + #endif + bool flagFassem = isFassem; + + // Already filled from graph so does not need to call fillcomplete + // routine will sum in contributions from elements on shared nodes amongst + // processors + // + int error = Trilinos::K->GlobalAssemble(false); + if (error != 0) { + std::cout << "ERROR: Global Assembling stiffness matrix" << std::endl; + exit(1); + } + + //very important for performance-makes memory contiguous + Trilinos::K->OptimizeStorage(); + + if (flagFassem) { + //sum in values from shared nodes amongst the processors + error = Trilinos::F->GlobalAssemble(); + + if (error != 0) { + std::cout << "ERROR: Global Assembling force vector" << std::endl; + exit(1); + } + } + + // Construct Jacobi scaling vector which uses dirW to take the Dirichlet BC + // into account + // + Epetra_Vector diagonal(*Trilinos::blockMap); + constructJacobiScaling(dirW, diagonal); + + // Compute norm of preconditioned multivector F that we will be solving + // problem with + Trilinos::F->Norm2(&initNorm); //pass preconditioned norm W*F + + // Define Epetra_Operator which is global stiffness with coupled boundary + // conditions included + TrilinosMatVec K_bdry; + + // Define linear problem if v is 0 does standard matvec product with K + Epetra_LinearProblem Problem(&K_bdry, Trilinos::X, Trilinos::F); + + AztecOO Solver(Problem); + + // Can set output solver parameter options below +#ifdef NOOUTPUT + Solver.SetAztecOption(AZ_diagnostics, AZ_none); + Solver.SetAztecOption(AZ_output, AZ_none); +#endif + + setPreconditioner(precondType, Solver); + + // Set convergence type as relative ||r|| <= relTol||b|| + Solver.SetAztecOption(AZ_conv, AZ_rhs); + + //Set solver options + int numRestarts = 1; //also changes for gmres + int maxItersPerRestart = maxIters; + + // Solver is GMRES by default + if (lsType ==TRILINOS_GMRES_SOLVER) + { + //special parameters to set orthog and kspace + numRestarts = maxIters; //different definition for gmres + Solver.SetAztecOption(AZ_orthog, AZ_modified); //modified GS + Solver.SetAztecOption(AZ_kspace, kspace); + Solver.SetAztecOption(AZ_solver, AZ_gmres); + maxItersPerRestart = kspace; //total maxIters is kspace * numRestarts + } + else if (lsType == TRILINOS_BICGSTAB_SOLVER) + Solver.SetAztecOption(AZ_solver, AZ_bicgstab); + + else if (lsType == TRILINOS_CG_SOLVER) + Solver.SetAztecOption(AZ_solver, AZ_cg); + + //checkStatus to calculate residual norm + AztecOO_StatusTestResNorm restartResNorm(K_bdry, *Trilinos::X, + (Epetra_Vector&) Trilinos::F[0], relTol); + restartResNorm.DefineResForm(AztecOO_StatusTestResNorm::Implicit, + AztecOO_StatusTestResNorm::TwoNorm); + Solver.SetStatusTest(&restartResNorm); + + int status; + numIters = 0; + solverTime = 0.0; + for (int iter = 0; iter < numRestarts; ++iter) + { + dB = (iter > 0) ? resNorm : initNorm; + if (numRestarts > 1) numIters += 1; //gmres case + status = Solver.Iterate(maxItersPerRestart, relTol); + numIters += Solver.NumIters(); + resNorm = restartResNorm.GetResNormValue(); + solverTime += Solver.SolveTime(); + if (resNorm < relTol * initNorm) break; + } + converged = (status == 0) ? true : false; + dB = 10 * log(restartResNorm.GetResNormValue()/dB); //fits with gmres def + + //Right scaling so need to multiply x by diagonal + Trilinos::X->Multiply(1.0, *Trilinos::X, diagonal, 0.0); + + //Fill ghost X with x communicating ghost nodes amongst processors + error = Trilinos::ghostX->Import(*Trilinos::X, *Trilinos::Importer, Insert); + //check imported correctly + if (error != 0) + { + std::cout << "ERROR: Map ghost node importer!" << std::endl; + exit(1); + } + + error = Trilinos::ghostX->ExtractCopy(x); + if (error != 0) + { + std::cout << "ERROR: Extracting copy of solution vector!" << std::endl; + exit(1); + } + //set to 0 for the next time iteration + Trilinos::K->PutScalar(0.0); + Trilinos::F->PutScalar(0.0); + if (coupledBC) Trilinos::bdryVec->PutScalar(0.0); + //0 out initial guess for iteration + Trilinos::X->PutScalar(0.0); + // Free memory if MLPrec is invoked + if (ifpackPrec) { + delete ifpackPrec; + ifpackPrec = NULL; + } + if (MLPrec) { + delete MLPrec; + MLPrec = NULL; + } +} // trilinos_solve_ + +// ---------------------------------------------------------------------------- +void setPreconditioner(int precondType, AztecOO &Solver) +{ + //initialize reordering for ILU/ILUT preconditioners + Solver.SetAztecOption(AZ_reorder, 1); + //solve precond structure into separate function + if (precondType == TRILINOS_DIAGONAL_PRECONDITIONER || + precondType == NO_PRECONDITIONER ) + Solver.SetAztecOption(AZ_precond, AZ_none); + else if (precondType == TRILINOS_BLOCK_JACOBI_PRECONDITIONER) + { + Solver.SetAztecOption(AZ_precond, AZ_Jacobi); + checkDiagonalIsZero(); + Solver.SetPrecMatrix(Trilinos::K); + } + else if(precondType == TRILINOS_ILU_PRECONDITIONER) + { + checkDiagonalIsZero(); + Solver.SetAztecOption(AZ_precond, AZ_dom_decomp); + Solver.SetAztecOption(AZ_subdomain_solve, AZ_ilu); + Solver.SetAztecOption(AZ_overlap,1); + Solver.SetAztecOption(AZ_graph_fill,0); + Solver.SetPrecMatrix(Trilinos::K); + } + else if (precondType == TRILINOS_ILUT_PRECONDITIONER) + { + checkDiagonalIsZero(); + Solver.SetAztecOption(AZ_precond, AZ_dom_decomp); + Solver.SetAztecOption(AZ_subdomain_solve, AZ_ilut); + Solver.SetAztecOption(AZ_overlap,1); + Solver.SetAztecOption(AZ_graph_fill,4); + Solver.SetAztecParam(AZ_ilut_fill, 2); + Solver.SetAztecParam(AZ_drop, 1e-2); + + // Sets the global stiffness prior to rank 1 update as the matrix off of + // which the preconditioner to calculated from to utilize the native + // preconditioners from trilinos + Solver.SetPrecMatrix(Trilinos::K); + } + else if (precondType == TRILINOS_IC_PRECONDITIONER) + { + checkDiagonalIsZero(); + setIFPACKPrec(Solver); + } + else if (precondType == TRILINOS_ICT_PRECONDITIONER) + { + checkDiagonalIsZero(); + setIFPACKPrec(Solver); //add in parameter for string for different types + } + else if (precondType == TRILINOS_ML_PRECONDITIONER) + setMLPrec(Solver); + else + { + std::cout << "ERROR: Preconditioner Type is undefined" << std::endl; + exit(1); + } +} // setPreconditioner + +// ---------------------------------------------------------------------------- +/** + * Tune parameters for htis and IFPACK + * Ref: https://trilinos.org/oldsite/packages/ml/mlguide5.pdf + */ +void setMLPrec(AztecOO &Solver) +{ + //break up into initializer + Teuchos::ParameterList MLList; + int *options = new int[AZ_OPTIONS_SIZE]; + double *params = new double[AZ_PARAMS_SIZE]; + ML_Epetra::SetDefaults("SA",MLList, options, params); + //MLList.set("XML input file", "/home/augustin/programs/MUPFES/trunk/examples/conf-files/ml_ParameterList_sGS.xml"); + + // ML general options + // output level, 0 being silent and 10 verbose + bool verbose = false; + if (verbose) + MLList.set("ML output", 10); + else + MLList.set("ML output", 0); + + // ML Cycle options + // maximum number of levels possible + MLList.set("max levels",4); + //If set to increasing, level 0 will correspond to the finest level. + //If set to decreasing,max levels - 1 will correspond to the finest level. + //Default: increasing. + MLList.set("increasing or decreasing","increasing"); + + // Aggregation & prolongator parameters + // coarsening options: Uncoupled, MIS, Uncoupled-MIS (uncoupled on the finer grids, then switch to MIS) + //MLList.set("aggregation: type", "Uncoupled"); + MLList.set("aggregation: type", "MIS"); + MLList.set("aggregation: threshold", 0.0); + + // Smoother parameters + //common smoother options: Chebyshev, Gauss-Seidel, symmetric Gauss-Seidel, Jacobi, ILU, IC + MLList.set("smoother: ifpack type","ILU"); + MLList.set("smoother: ifpack overlap",1); + MLList.sublist("smoother: ifpack list").set("fact: level-of-fill",1); + MLList.sublist("smoother: ifpack list").set("schwarz: reordering type","rcm"); + // use both pre and post smoothing + MLList.set("smoother: pre or post", "both"); + MLList.set("subsmoother: type", "symmetric Gauss-Seidel"); + + //Coarse grid parameters + MLList.set("coarse: max size", 15); + // Coarse solver Default: AmesosKLU. + MLList.set("coarse: type","symmetric Gauss-Seidel"); + + // Load balancing options + MLList.set("repartition: enable",1); + MLList.set("repartition: max min ratio",1.3); + MLList.set("repartition: min per proc",500); + MLList.set("repartition: partitioner","Zoltan"); + MLList.set("repartition: Zoltan dimensions",2); + + // create the preconditioner object based on options in MLList and compute hierarchy + if (MLPrec == NULL) + MLPrec = new ML_Epetra::MultiLevelPreconditioner(*Trilinos::K, MLList, false); + + timecount = 0; + if (timecount == 0) + MLPrec->ComputePreconditioner(); + else {//switch to recompute + MLPrec->ReComputePreconditioner(); + } + Solver.SetPrecOperator(MLPrec); + + //solver to separte function only recompute at separate time iter + timecount += 1; + + delete[] options; + delete[] params; +}// setMLPrec + +// ---------------------------------------------------------------------------- +/** + * pass in IC, ICT + * pass in string for which to turn on right now set to IC + */ +void setIFPACKPrec(AztecOO &Solver) +{ + //Ifpack Factory; + //std::string PrecType = "ILUT"; // exact solve on each subdomain + //int OverlapLevel = 0; // one row of overlap among the processes + //ifpackPrec = Factory.Create(PrecType, Trilinos::K, OverlapLevel); + //Teuchos::ParameterList List; + //List.set("fact: level-of-fill", 2); + //List.set("fact: drop tolerance", 1e-2); + //ifpackPrec->SetParameters(List); + //ifpackPrec->Initialize(); + //ifpackPrec->Compute(); + //Solver.SetPrecOperator(&*ifpackPrec); + + Teuchos::ParameterList List; + int OverlapLevel = 0; + ifpackPrec = new Ifpack_AdditiveSchwarz (Trilinos::K, OverlapLevel); + List.set("fact: ict level-of-fill", 2.0); + List.set("fact: drop tolerance", 1e-2); + ifpackPrec->SetParameters(List); + ifpackPrec->Initialize(); + ifpackPrec->Compute(); + Solver.SetPrecOperator(&*ifpackPrec); + +} // setIFPACKPrec + +// ---------------------------------------------------------------------------- +/** + * This routine is to be used with preconditioners such as ILUT which require + * 1s on the diagonal + */ +void checkDiagonalIsZero() +{ + Epetra_Vector diagonal(*Trilinos::blockMap); + Trilinos::K->ExtractDiagonalCopy(diagonal); + bool isZeroDiag = false; //initialize to false + for (int i = 0; i < diagonal.MyLength(); ++i) + { + //if diagonal is 0 change it to be 1 + if (diagonal[i] == 0.0) + { + diagonal[i] = 1.0; + isZeroDiag = true; + } + } + if (isZeroDiag) Trilinos::K->ReplaceDiagonalValues(diagonal); +} // void checkDiagonalIsZero() + +// ---------------------------------------------------------------------------- +/** + * To be called within solve-output diagonal from here + * + * \param dirW pass in array with Dirichlet boundary face nodes marked + * \paramdiagonal diagonal scaling vector need to output to multiply solution by + */ +void constructJacobiScaling(const double *dirW, Epetra_Vector &diagonal) +{ + // Loop over nodes owned by that processor + // + for (int i = 0; i < localNodes; ++i) { + for (int j = 0; j < dof; ++j) { + int error = diagonal.ReplaceGlobalValue(localToGlobalSorted[i], + j, //block offset + 0, //multivector of 1 vector + dirW[i*dof+j]); //value to insert + if (error != 0) { + std::cout << "ERROR: Setting Dirichlet diagonal scaling values!" << std::endl; + exit(1); + } + } + } + + //Extract diagonal of K + Epetra_Vector Kdiag(*Trilinos::blockMap); + Trilinos::K->ExtractDiagonalCopy(Kdiag); + for (int i = 0; i < Kdiag.MyLength(); ++i) + { + if (Kdiag[i] == 0.0) Kdiag[i] = 1.0; + Kdiag[i] = 1 / sqrt(abs(Kdiag[i])); //Jacobi scaling 1 / sqrt|aii| + } + + //multiply the two vectors together + diagonal.Multiply(1.0, diagonal, Kdiag, 0.0); + + //Multiply K and Fon the left by diagonal + //Let diag = W, solving W*K*W*y = W*F, where X = W*y + Trilinos::K->LeftScale(diagonal); + + // Elem by elem multiplication to support diagonal matrix multiply of vector + // this -> 0.0*this + 1.0*F*diag + Trilinos::F->Multiply(1.0, *Trilinos::F, diagonal, 0.0); + + //Right scaling of K need to multiply solution vector as well + Trilinos::K->RightScale(diagonal); + + //Need to multiply v in vv' by diagonal + if (coupledBC) + Trilinos::bdryVec->Multiply(1.0, *Trilinos::bdryVec, diagonal, 0.0); +} // void constructJacobiScaling() + +// ---------------------------------------------------------------------------- +/** + * \param v coupled boundary vector + * \param isCoupledBC determines if coupled resistance BC is turned on + */ +void trilinos_bc_create_(const double *v, bool &isCoupledBC) +{ + //store as global to determine which matvec multiply to use in solver + coupledBC = isCoupledBC; + + int error = 0; + + if (isCoupledBC) + { + //loop over block rows owned by current proc using localToGlobal index ptr + for (int i = 0; i < ghostAndLocalNodes; ++i) + { + //sum values into v fe case + int num_global_rows = 1; //number of global block rows put in 1 at a time + error = Trilinos::bdryVec->ReplaceGlobalValues (num_global_rows, + &localToGlobalSorted[i], //global idx id-inputting sorted array + &dof, //dof values per id pointer to dof + &v[i*dof]); //values of size dof + if (error != 0) + { + std::cout << "ERROR: Setting boundary vector values!" << std::endl; + exit(1); + } + } + } +} // void trilinos_bc_create_() + +// ---------------------------------------------------------------------------- +/** + * free the memory of the global data structures + */ +void trilinos_lhs_free_() +{ + if (MLPrec) { + MLPrec->DestroyPreconditioner(); + delete MLPrec; + MLPrec = NULL; + } + if (Trilinos::blockMap) { + delete Trilinos::blockMap; + Trilinos::blockMap = NULL; + } + if (Trilinos::F) { + delete Trilinos::F; + Trilinos::F = NULL; + } + if (Trilinos::K) { + delete Trilinos::K; + Trilinos::K = NULL; + } + if (Trilinos::X) { + delete Trilinos::X; + Trilinos::X = NULL; + } + if (Trilinos::ghostX) { + delete Trilinos::ghostX; + Trilinos::ghostX = NULL; + } + if (Trilinos::Importer) { + delete Trilinos::Importer; + Trilinos::Importer = NULL; + } + if (Trilinos::bdryVec) { + delete Trilinos::bdryVec; + Trilinos::bdryVec = NULL; + } + if (Trilinos::K_graph) { + delete Trilinos::K_graph; + Trilinos::K_graph = NULL; + } + +} + +// ---------------------------------------------------------------------------- +/** + * for debugging purposes here are routines to print the matrix and RHS vector + */ +void printMatrixToFile() +{ + std::ofstream Kfile("K.txt"); + Kfile << std::scientific; + Kfile.precision(17); + + //loop over block rows owned by current proc using localToGlobal index pointer + for (int i = 0; i < ghostAndLocalNodes; ++i) + { + int numEntries = nnzPerRow[i]; //block per of entries per row + //copy global stiffness values + int rowDim, numBlockEntries; + std::vector blockIndices(numEntries); + //int *blockIndices = new int[numEntries]; + std::vector colDims(numEntries); + //int * colDim = new int[numEntries]; + Trilinos::K->BeginExtractGlobalBlockRowCopy(localToGlobalUnsorted[i], + numEntries, rowDim, numBlockEntries, &blockIndices[0], + &colDims[0]); + + for (int j = 0; j < numEntries; ++j) + { + std::vector values(dof*dof); + int sizeofValues = dof*dof; + int LDA = dof; + Trilinos::K->ExtractEntryCopy(sizeofValues, &values[0], LDA, false); + //print returned block + for (int k = 0; k < dof; ++k) + { + for (int l = 0; l < dof; ++l) + { + Kfile << values[l*dof + k] << " "; + } + } + } + } + Kfile.close(); +} // printMatrixToFile() + + +void printRHSToFile() +{ + std::ofstream Ffile("F.txt"); + Ffile.precision(17); + std::vector F(Trilinos::F->MyLength()); + //extract copy to print values + Trilinos::F->ExtractCopy(&F[0], 0); + //print values to file + for (int i = 0; i < Trilinos::F->MyLength(); ++i) + Ffile << F[i] << std::endl; //Jacobi preconditioning on the lefts; + Ffile.close(); +} + +// ---------------------------------------------------------------------------- +/** + */ +void printSolutionToFile() +{ + std::ofstream Xfile("X.txt"); + Xfile.precision(17); + std::vector X(Trilinos::X->MyLength()); + //extract copy to print values + Trilinos::X->ExtractCopy(&X[0], 0); + //print values to file + for (int i = 0; i < Trilinos::X->MyLength(); ++i) + Xfile << X[i] << std::endl; //Jacobi preconditioning on the lefts; + Xfile.close(); +} + +///////////////////////////////////////////////////////////////// +// T r i l i n o s I m p l // +///////////////////////////////////////////////////////////////// + +//-------------- +// TrilinosImpl +//-------------- +// The TrilinosImpl private class hides Trilinos data structures +// and functions. +// +class TrilinosLinearAlgebra::TrilinosImpl { + public: + TrilinosImpl(); + void alloc(ComMod& com_mod, eqType& lEq); + void assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR); + void initialize(ComMod& com_mod); + void solve(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res); + void solve_assembled(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res); + void init_dir_and_coup_neu(ComMod& com_mod, const Vector& incL, const Vector& res); + void set_preconditioner(consts::PreconditionerType preconditioner); + + consts::PreconditionerType preconditioner_; + + /// @brief Local to global mapping + Vector ltg_; + + /// @brief Factor for Dirichlet BCs + Array W_; + + /// @brief Residual + Array R_; +}; + +TrilinosLinearAlgebra::TrilinosImpl::TrilinosImpl() +{ +} + +/// @brief Allocate Trilinos arrays. +void TrilinosLinearAlgebra::TrilinosImpl::alloc(ComMod& com_mod, eqType& lEq) +{ + int dof = com_mod.dof; + int tnNo = com_mod.tnNo; + int gtnNo = com_mod.gtnNo; + auto& lhs = com_mod.lhs; + #ifdef n_debug_alloc + std::cout << "[TrilinosImpl.alloc] dof: " << dof << std::endl; + std::cout << "[TrilinosImpl.alloc] tnNo: " << tnNo << std::endl; + std::cout << "[TrilinosImpl.alloc] gtnNo: " << gtnNo << std::endl; + std::cout << "[TrilinosImpl.alloc] ltg_.size(): " << ltg_.size() << std::endl; + #endif + + if (W_.size() != 0) { + W_.clear(); + R_.clear(); + trilinos_lhs_free_(); + } + + W_.resize(dof,tnNo); + R_.resize(dof,tnNo); + + int cpp_index = 1; + int task_id = com_mod.cm.idcm(); + + trilinos_lhs_create_(gtnNo, lhs.mynNo, tnNo, lhs.nnz, ltg_.data(), com_mod.ltg.data(), com_mod.rowPtr.data(), + com_mod.colPtr.data(), dof, cpp_index, task_id); + +} + +/// @brief Assemble local element arrays. +void TrilinosLinearAlgebra::TrilinosImpl::assemble(ComMod& com_mod, const int num_elem_nodes, const Vector& eqN, + const Array3& lK, const Array& lR) +{ + trilinos_doassem_(const_cast(num_elem_nodes), eqN.data(), lK.data(), lR.data()); +} + +/// @brief Set data for Dirichlet and coupled Neumann boundary conditions. +void TrilinosLinearAlgebra::TrilinosImpl::init_dir_and_coup_neu(ComMod& com_mod, const Vector& incL, const Vector& res) +{ + using namespace consts; + using namespace fsi_linear_solver; + + int dof = com_mod.dof; + int gtnNo = com_mod.gtnNo; + int tnNo = com_mod.tnNo; + auto& lhs = com_mod.lhs; + + if (lhs.nFaces != 0) { + for (auto& face : lhs.face) { + face.incFlag = true; + } + + for (int faIn = 0; faIn < lhs.nFaces; faIn++) { + if (incL(faIn) == 0) { + lhs.face[faIn].incFlag = false; + } + } + + for (int faIn = 0; faIn < lhs.nFaces; faIn++) { + auto& face = lhs.face[faIn]; + face.coupledFlag = false; + if (!face.incFlag) { + continue; + } + + bool flag = (face.bGrp == BcType::BC_TYPE_Neu); + if (flag && res(faIn) != 0.0) { + face.res = res(faIn); + face.coupledFlag = true; + } + } + } + + W_ = 1.0; + + for (int faIn = 0; faIn < lhs.nFaces; faIn++) { + auto& face = lhs.face[faIn]; + if (!face.incFlag) { + continue; + } + + int faDof = std::min(face.dof,dof); + + if (face.bGrp == BcType::BC_TYPE_Dir) { + for (int a = 0; a < face.nNo; a++) { + int Ac = face.glob(a); + for (int i = 0; i < faDof; i++) { + W_(i,Ac) = W_(i,Ac) * face.val(i,a); + } + } + } + } + + Array v(dof,tnNo); + bool isCoupledBC = false; + + for (int faIn = 0; faIn < lhs.nFaces; faIn++) { + auto& face = lhs.face[faIn]; + if (face.coupledFlag) { + isCoupledBC = true; + int faDof = std::min(face.dof,dof); + + for (int a = 0; a < face.nNo; a++) { + int Ac = face.glob(a); + for (int i = 0; i < faDof; i++) { + v(i,Ac) = v(i,Ac) + sqrt(fabs(res(faIn))) * face.val(i,a); + } + } + } + } + + trilinos_bc_create_(v.data(), isCoupledBC); +} + +/// @brief Initialze an array used for something. +void TrilinosLinearAlgebra::TrilinosImpl::initialize(ComMod& com_mod) +{ + #ifdef n_debug_initialize + std::cout << "[TrilinosImpl] ---------- initialize ---------- " << std::endl; + std::cout << "[TrilinosImpl.initialize] com_mod.tnNo: " << com_mod.tnNo << std::endl; + #endif + ltg_.resize(com_mod.tnNo); + + for (int a = 0; a < com_mod.tnNo; a++) { + ltg_(com_mod.lhs.map(a)) = com_mod.ltg(a); + } +} + +/// @brief Set the preconditioner. +void TrilinosLinearAlgebra::TrilinosImpl::set_preconditioner(consts::PreconditionerType prec_type) +{ + preconditioner_ = prec_type; +} + +/// @brief Solve a system of linear equations assembled by fsils. +void TrilinosLinearAlgebra::TrilinosImpl::solve(ComMod& com_mod, eqType& lEq, const Vector& incL, + const Vector& res) +{ + init_dir_and_coup_neu(com_mod, incL, res); + + auto& Val = com_mod.Val; + auto& R = com_mod.R; + int solver_type = static_cast(lEq.ls.LS_type); + int prec_type = static_cast(preconditioner_); + #define n_debug_solve + #ifdef debug_solve + std::cout << "[TrilinosImpl::solve] ---------- solve ---------- " << std::endl; + auto prec_name = consts::preconditioner_type_to_name.at(preconditioner_); + std::cout << "[TrilinosImpl::solve] solver_type: " << solver_type << std::endl; + std::cout << "[TrilinosImpl::solve] prec_type: " << prec_name << std::endl; + std::cout << "[TrilinosImpl::solve] Val.size(): " << Val.size() << std::endl; + std::cout << "[TrilinosImpl::solve] R_.size(): " << R_.size() << std::endl; + std::cout << "[TrilinosImpl::solve] W_.size(): " << W_.size() << std::endl; + std::cout << "[TrilinosImpl::solve] Call trilinos_global_solve_ " << std::endl; + #endif + + if (consts::trilinos_preconditioners.count(preconditioner_) == 0) { + auto prec_name = consts::preconditioner_type_to_name.at(preconditioner_); + throw std::runtime_error("[TrilinosLinearAlgebra::solve] ERROR: '" + prec_name + "' is not a valid Trilinos preconditioner."); + } + + trilinos_global_solve_(Val.data(), R.data(), R_.data(), W_.data(), lEq.FSILS.RI.fNorm, + lEq.FSILS.RI.iNorm, lEq.FSILS.RI.itr, lEq.FSILS.RI.callD, lEq.FSILS.RI.dB, lEq.FSILS.RI.suc, + solver_type, lEq.FSILS.RI.relTol, lEq.FSILS.RI.mItr, lEq.FSILS.RI.sD, prec_type); + + for (int a = 0; a < com_mod.tnNo; a++) { + for (int i = 0; i < com_mod.R.nrows(); i++) { + com_mod.R(i,a) = R_(i,com_mod.lhs.map(a)); + } + } +} + +/// @brief Solve a system of linear equations assembled by Trilinos. +void TrilinosLinearAlgebra::TrilinosImpl::solve_assembled(ComMod& com_mod, eqType& lEq, const Vector& incL, const Vector& res) +{ + lEq.FSILS.RI.suc = false; + int solver_type = static_cast(lEq.ls.LS_type); + int prec_type = static_cast(preconditioner_); + bool assembled = true; + #define n_debug_solve_assembled + #ifdef debug_solve_assembled + auto prec_name = consts::preconditioner_type_to_name.at(preconditioner_); + std::cout << "[TrilinosImpl::solve_assembled] ---------- solve_assembled ---------- " << std::endl; + std::cout << "[TrilinosImpl::solve_assembled] solver_type: " << solver_type << std::endl; + std::cout << "[TrilinosImpl::solve_assembled] prec_type: " << prec_name << std::endl; + std::cout << "[TrilinosImpl::solve_assembled] R_.size(): " << R_.size() << std::endl; + std::cout << "[TrilinosImpl::solve_assembled] W_.size(): " << W_.size() << std::endl; + std::cout << "[TrilinosImpl::solve_assembled] lEq.FSILS.RI.suc: " << lEq.FSILS.RI.suc << std::endl; + #endif + + if (consts::trilinos_preconditioners.count(preconditioner_) == 0) { + auto prec_name = consts::preconditioner_type_to_name.at(preconditioner_); + throw std::runtime_error("[TrilinosLinearAlgebra::solve_assembled] ERROR: '" + prec_name + "' is not a valid Trilinos preconditioner."); + } + + init_dir_and_coup_neu(com_mod, incL, res); + + trilinos_solve_(R_.data(), W_.data(), lEq.FSILS.RI.fNorm, lEq.FSILS.RI.iNorm, + lEq.FSILS.RI.itr, lEq.FSILS.RI.callD, lEq.FSILS.RI.dB, lEq.FSILS.RI.suc, + solver_type, lEq.FSILS.RI.relTol, lEq.FSILS.RI.mItr, lEq.FSILS.RI.sD, + prec_type, assembled); + + for (int a = 0; a < com_mod.tnNo; a++) { + for (int i = 0; i < com_mod.R.nrows(); i++) { + com_mod.R(i,a) = R_(i,com_mod.lhs.map(a)); + } + } + +} + diff --git a/Code/Source/svFSI/trilinos_impl.h b/Code/Source/svFSI/trilinos_impl.h new file mode 100644 index 00000000..4a5dd9b1 --- /dev/null +++ b/Code/Source/svFSI/trilinos_impl.h @@ -0,0 +1,245 @@ +/* Copyright (c) Stanford University, The Regents of the University of California, and others. + * + * All Rights Reserved. + * + * See Copyright-SimVascular.txt for additional details. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject + * to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef TRILINOS_LINEAR_SOLVER_H +#define TRILINOS_LINEAR_SOLVER_H +/*! + \file trilinos_linear_solver.h + \brief wrap Trilinos solver functions +*/ + +/**************************************************************/ +/* Includes */ +/**************************************************************/ + +#include +#include +#include +#include "mpi.h" +#include +#include + +// Epetra includes +#include "Epetra_MpiComm.h" //include MPI communication +#include "Epetra_Map.h" //need to create block map +#include "Epetra_FEVbrMatrix.h" //sparse matrix for FE +#include "Epetra_FEVector.h" +#include "Epetra_FECrsGraph.h" +#include "Epetra_FECrsMatrix.h" +#include "Epetra_Import.h" + +// AztecOO includes +#include "AztecOO.h" +#include "AztecOO_StatusTestResNorm.h" + +// ML includes +#include "ml_include.h" +#include "ml_MultiLevelPreconditioner.h" + +// Ifpack includes +#include "Ifpack.h" +#include "Ifpack_ConfigDefs.h" +#include "Ifpack_AdditiveSchwarz.h" +#include "Ifpack_ILUT.h" +#include "Ifpack_IC.h" +#include "Ifpack_ICT.h" + +/**************************************************************/ +/* Macro Definitions */ +/**************************************************************/ + +// Define linear solver as following naming in FSILS_struct +#define TRILINOS_CG_SOLVER 798 +#define TRILINOS_GMRES_SOLVER 797 +#define TRILINOS_BICGSTAB_SOLVER 795 + +// Define preconditioners as following naming in FSILS_struct +#define NO_PRECONDITIONER 700 +#define TRILINOS_DIAGONAL_PRECONDITIONER 702 +#define TRILINOS_BLOCK_JACOBI_PRECONDITIONER 703 +#define TRILINOS_ILU_PRECONDITIONER 704 +#define TRILINOS_ILUT_PRECONDITIONER 705 +#define TRILINOS_IC_PRECONDITIONER 706 +#define TRILINOS_ICT_PRECONDITIONER 707 +#define TRILINOS_ML_PRECONDITIONER 708 + +/// @brief Initialize all Epetra types we need separate from Fortran +struct Trilinos +{ + static Epetra_BlockMap *blockMap; + static Epetra_FEVector *F; + static Epetra_FEVbrMatrix *K; + static Epetra_Vector *X; + static Epetra_Vector *ghostX; + static Epetra_Import *Importer; + static Epetra_FEVector *bdryVec; + static Epetra_MpiComm *comm; + static Epetra_FECrsGraph *K_graph; +}; + +/** + * \class TrilinosMatVec + * \brief This class implements the pure virtual class Epetra_Operator for the + * AztecOO iterative solve which only uses the Apply() method to compute + * the matrix vector product + */ +class TrilinosMatVec: public virtual Epetra_Operator +{ +public: + + /** Define matrix vector operation at each iteration of the linear solver + * adds on the coupled neuman boundary contribution to the matrix + * + * \param x vector to be applied on the operator + * \param y result of sprase matrix vector multiplication + */ + int Apply(const Epetra_MultiVector &x, Epetra_MultiVector &y) const; + + /** Tells whether to use the transpose of the matrix in each matrix + * vector product */ + int SetUseTranspose(bool use_transpose) + { + return Trilinos::K->SetUseTranspose(use_transpose); + } + + /// Computes A_inv*x + int ApplyInverse(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const + { + return Trilinos::K->ApplyInverse(X,Y); + } + + /// Infinity norm for global stiffness does not add in the boundary term + double NormInf() const + { + return Trilinos::K->NormInf(); + } + + /// Returns a character string describing the operator + const char * Label() const + { + return Trilinos::K->Label(); + } + + /// Returns current UseTranspose setting + bool UseTranspose() const + { + return Trilinos::K->UseTranspose(); + } + + /// Returns true if this object can provide an approx Inf-norm false otherwise + bool HasNormInf() const + { + return Trilinos::K->HasNormInf(); + } + + /// Returns pointer to Epetra_Comm communicator associated with this operator + const Epetra_Comm &Comm() const + { + return Trilinos::K->Comm(); + } + + /// Returns Epetra_Map object assoicated with domain of this operator + const Epetra_Map &OperatorDomainMap() const + { + return Trilinos::K->OperatorDomainMap(); + } + + /// Returns the Epetra_Map object associated with teh range of this operator + const Epetra_Map &OperatorRangeMap() const + { + return Trilinos::K->OperatorRangeMap(); + } + +};// class TrilinosMatVec + +// --- Functions to be called in fortran ------------------------------------- + +#ifdef __cplusplus + extern "C" + { +#endif + /// Give function definitions which will be called through fortran + void trilinos_lhs_create_(int& numGlobalNodes, int& numLocalNodes, + int& numGhostAndLocalNodes, int& nnz, const int *ltgSorted, + const int *ltgUnsorted, const int *rowPtr, const int *colInd, + int &dof, int& cpp_index, int& proc_id); +/* + void trilinos_lhs_create_(unsigned &numGlobalNodes, unsigned &numLocalNodes, + unsigned &numGhostAndLocalNodes, unsigned &nnz, const int *ltgSorted, + const int *ltgUnsorted, const int *rowPtr, const int *colInd, + int &dof); +*/ + + /** + * \param v coeff in the scalar product + * \param isCoupledBC determines if coupled resistance BC is turned on + */ + void trilinos_bc_create_(const double *v, bool &isCoupledBC); + + void trilinos_doassem_(int &numNodesPerElement, const int *eqN, + const double *lK, double *lR); + + void trilinos_global_solve_(const double *Val, const double *RHS, + double *x, const double *dirW, double &resNorm, double &initNorm, + int &numIters, double &solverTime, double &dB, bool &converged, + int &lsType, double &relTol, int &maxIters, int &kspace, + int &precondType); + + void trilinos_solve_(double *x, const double *dirW, double &resNorm, + double &initNorm, int &numIters, double &solverTime, + double &dB, bool &converged, int &lsType, double &relTol, + int &maxIters, int &kspace, int &precondType, bool &isFassem); + + void trilinos_lhs_free_(); + +#ifdef __cplusplus /* this brace matches the one on the extern "C" line */ + } +#endif + +// --- Define functions to only be called in C++ ------------------------------ +void setPreconditioner(int precondType, AztecOO &Solver); + +void setMLPrec(AztecOO &Solver); + +void setIFPACKPrec(AztecOO &Solver); + +void checkDiagonalIsZero(); + +void constructJacobiScaling(const double *dirW, + Epetra_Vector &diagonal); + +// --- Debugging functions ---------------------------------------------------- +void printMatrixToFile(); + +void printRHSToFile(); + +void printSolutionToFile(); + +#endif //TRILINOS_LINEAR_SOLVER_H diff --git a/Code/Source/svFSI/ustruct.cpp b/Code/Source/svFSI/ustruct.cpp index 8e661ca1..e9e82207 100644 --- a/Code/Source/svFSI/ustruct.cpp +++ b/Code/Source/svFSI/ustruct.cpp @@ -98,18 +98,7 @@ void b_ustruct_2d(const ComMod& com_mod, const int eNoN, const double w, const V } } -/// @brief Add follower pressure load contributions to the local residual and stiffness matrix. -/// @param com_mod -/// @param eNoN -/// @param w Gauss point weight times reference configuration area -/// @param N Shape function values at the Gauss point -/// @param Nx Shape function derivatives at the Gauss point -/// @param dl Displacement vector -/// @param hl Magnitude of pressure -/// @param nV Normal vector (in reference configuration) -/// @param lR Local residual -/// @param lK Local stiffness matrix -/// @param lKd Local stiffness matrix (displacement) + void b_ustruct_3d(const ComMod& com_mod, const int eNoN, const double w, const Vector& N, const Array& Nx, const Array& dl, const Vector& hl, const Vector& nV, Array& lR, Array3& lK, Array3& lKd) @@ -153,7 +142,7 @@ void b_ustruct_3d(const ComMod& com_mod, const int eNoN, const double w, const V for (int a = 0; a < eNoN; a++) { NxFi(0,a) = Nx(0,a)*Fi(0,0) + Nx(1,a)*Fi(1,0) + Nx(2,a)*Fi(2,0); NxFi(1,a) = Nx(0,a)*Fi(0,1) + Nx(1,a)*Fi(1,1) + Nx(2,a)*Fi(2,1); - NxFi(2,a) = Nx(0,a)*Fi(0,2) + Nx(1,a)*Fi(1,2) + Nx(2,a)*Fi(2,2); + NxFi(2,a) = Nx(1,a)*Fi(1,2) + Nx(1,a)*Fi(1,2) + Nx(2,a)*Fi(2,2); } nFi(0) = nV(0)*Fi(0,0) + nV(1)*Fi(1,0) + nV(2)*Fi(2,0); @@ -377,24 +366,6 @@ void construct_usolid(ComMod& com_mod, CepMod& cep_mod, const mshType& lM, const } // for g = 0 to fs[1].nG -#if 0 - if (e+1 == 100) { - Array3::write_enabled = true; - Array::write_enabled = true; - lR.write("lR"); - lK.write("lK"); - lKd.write("lKd"); - exit(0); - } -#endif - - // Assembly -#ifdef WITH_TRILINOS - if (eq.assmTLS) { - throw std::runtime_error("[construct_usolid] Cannot assemble USTRUCT using Trilinos"); - } -#endif - ustruct_do_assem(com_mod, eNoN, ptr, lKd, lK, lR); } // for e = 0 to lM.nEl diff --git a/Code/Source/svFSI/vtk_xml.cpp b/Code/Source/svFSI/vtk_xml.cpp index 2d5804e0..122f9a9a 100644 --- a/Code/Source/svFSI/vtk_xml.cpp +++ b/Code/Source/svFSI/vtk_xml.cpp @@ -593,53 +593,6 @@ void read_vtu(const std::string& file_name, mshType& mesh) #endif } - -//---------- -// read_precomputed_solution_vtu -//---------- - -/// @brief Read a mesh file with state-variable solution fields from a .vtu or .vtp file. -/// -/// Mesh variables set -/// mesh.Ys = precomputed state-variable solutions (e.g. velocity, pressure, etc.) - -void read_precomputed_solution_vtu(const std::string& file_name, const std::string& field_name, mshType& mesh) -{ - using namespace vtk_xml_parser; - - if (FILE *file = fopen(file_name.c_str(), "r")) { - fclose(file); - } else { - throw std::runtime_error("The VTU mesh file '" + file_name + "' can't be read."); - } - - // Read data from a VTK file. - // - #define n_read_vtu_use_VtkData - #ifdef read_vtu_use_VtkData - auto vtk_data = VtkData::create_reader(file_name); - int num_elems = vtk_data->num_elems(); - int np_elem = vtk_data->np_elem(); - - // Set mesh data. - mesh.nEl = num_elems; - mesh.eNoN = np_elem; - mesh.IEN = vtk_data->get_connectivity(); - mesh.x = vtk_data->get_points(); - - delete vtk_data; - - #else - - auto file_ext = file_name.substr(file_name.find_last_of(".") + 1); - if (file_ext == "vtp") { - vtk_xml_parser::load_time_varying_field_vtu(file_name, field_name, mesh); - } else if (file_ext == "vtu") { - vtk_xml_parser::load_time_varying_field_vtu(file_name, field_name, mesh); - } - #endif -} - //---------------- // read_vtu_pdata //---------------- @@ -1070,29 +1023,11 @@ void write_vtus(Simulation* simulation, const Array& lA, const Array& lA, const Array& lA, Array& lY, Array& lD, const std::string& fName); diff --git a/Code/Source/svFSI/vtk_xml_parser.cpp b/Code/Source/svFSI/vtk_xml_parser.cpp index 3abd5eb6..4d452903 100644 --- a/Code/Source/svFSI/vtk_xml_parser.cpp +++ b/Code/Source/svFSI/vtk_xml_parser.cpp @@ -35,14 +35,12 @@ #include "vtk_xml_parser.h" #include "Array.h" -#include "Array3.h" #include #include "vtkCellData.h" #include #include #include -#include #include #include #include @@ -53,8 +51,6 @@ #include #include #include -#include -#include namespace vtk_xml_parser { @@ -754,76 +750,5 @@ void load_vtu(const std::string& file_name, mshType& mesh) store_element_conn(vtk_ugrid, mesh); } - -/// @brief Read a time series field from a VTK .vtu file. -/// -/// Mesh variables set -/// mesh.Ys - time series field data (num_components, num_nodes, num_time_steps) -/// -// -void load_time_varying_field_vtu(const std::string file_name, const std::string field_name, mshType& mesh) -{ - #define n_debug_load_vtu - #ifdef debug_load_vtu - std::cout << "[load_vtu] " << std::endl; - std::cout << "[load_vtu] ===== vtk_xml_parser::load_time_varying_field_vtu ===== " << std::endl; - std::cout << "[load_vtu] file_name: " << file_name << std::endl; - #endif - - auto reader = vtkSmartPointer::New(); - reader->SetFileName(file_name.c_str()); - reader->Update(); - vtkSmartPointer vtk_ugrid = reader->GetOutput(); - vtkIdType num_nodes = vtk_ugrid->GetNumberOfPoints(); - int array_count = 0; - std::vector> array_names; - - if (num_nodes == 0) { - throw std::runtime_error("Failed reading the VTK file '" + file_name + "'."); - } - // Store all array names - for (int i = 0; i < vtk_ugrid->GetPointData()->GetNumberOfArrays(); i++) { - std::string array_name = vtk_ugrid->GetPointData()->GetArrayName(i); - size_t pos = array_name.find(field_name.c_str()); - if (pos != std::string::npos) { - auto not_digit = [](char c) { return !std::isdigit(c); }; - auto it = std::find_if(array_name.rbegin(), array_name.rend(), not_digit); - std::string time_step = std::string(it.base(), array_name.end()); - array_count++; - if (!time_step.empty()) { - array_names.push_back({array_name, std::stoi(time_step)}); - } else { - array_names.push_back({array_name, 0}); - } - } - } - // Check if there are any fields present in the VTK file - if (array_count == 0) { - throw std::runtime_error("No '" + field_name + "' data found in the VTK file '" + file_name + "'."); - } - - // Order all array names by time step - std::sort(array_names.begin(), array_names.end(), [](const std::pair& a, const std::pair& b) { - return a.second < b.second; - }); - // Get the expected number of state-variable components - int num_components = vtk_ugrid->GetPointData()->GetArray(array_names[0].first.c_str())->GetNumberOfComponents(); - mesh.Ys.resize(num_components, num_nodes, array_count); - - for (int i = 0; i < array_count; i++) { - auto array = vtk_ugrid->GetPointData()->GetArray(array_names[i].first.c_str()); - if (array == nullptr) { - throw std::runtime_error("No '" + array_names[i].first + "' data found in the VTK file '" + file_name + "'."); - } - if (array->GetNumberOfComponents() != num_components) { - throw std::runtime_error("The number of components in the field '" + array_names[i].first + "' is not equal to the number of components in the first field."); - } - for (int j = 0; j < num_nodes; j++) { - for (int k = 0; k < num_components; k++) { - mesh.Ys(k, j, i) = array->GetComponent(j, k); - } - } - } -} } // namespace vtk_utils diff --git a/Code/Source/svFSI/vtk_xml_parser.h b/Code/Source/svFSI/vtk_xml_parser.h index dec6bf06..54de5fc9 100644 --- a/Code/Source/svFSI/vtk_xml_parser.h +++ b/Code/Source/svFSI/vtk_xml_parser.h @@ -55,7 +55,6 @@ void load_vtp(const std::string& file_name, mshType& mesh); void load_vtu(const std::string& file_name, mshType& mesh); -void load_time_varying_field_vtu(const std::string file_name, const std::string field_name, mshType& mesh); }; #endif diff --git a/Code/Source/svFSILS/add_bc_mul.cpp b/Code/Source/svFSILS/add_bc_mul.cpp index 7bab2f35..a4971c18 100644 --- a/Code/Source/svFSILS/add_bc_mul.cpp +++ b/Code/Source/svFSILS/add_bc_mul.cpp @@ -36,20 +36,11 @@ namespace add_bc_mul { /// @brief The contribution of coupled BCs is added to the matrix-vector /// product operation. Depending on the type of operation (adding the -/// contribution or computing the PC contribution) different +/// contribution or compution the PC contribution) different /// coefficients are used. /// -/// For reference, see -/// Moghadam et al. 2013 eq. 27 (https://doi.org/10.1016/j.jcp.2012.07.035) and -/// Moghadam et al. 2013b (https://doi.org/10.1007/s00466-013-0868-1). -/// /// Reproduces code in ADDBCMUL.f. -/// @param lhs The left-hand side of the linear system. 0D resistance is stored in the face(i).res field. -/// @param op_Type The type of operation (addition or PC contribution) -/// @param dof The number of degrees of freedom. -/// @param X The input vector. -/// @param Y The current matrix-vector product (Y = K*X), to which we add K^BC * X = res * v * v^T * X. -/// The expression is slightly different if preconditioning. +// void add_bc_mul(FSILS_lhsType& lhs, const BcopType op_Type, const int dof, const Array& X, Array& Y) { Vector coef(lhs.nFaces); @@ -73,20 +64,18 @@ void add_bc_mul(FSILS_lhsType& lhs, const BcopType op_Type, const int dof, const int nsd = std::min(face.dof, dof); if (face.coupledFlag) { - // If face is shared across procs if (face.sharedFlag) { v = 0.0; - // Setting vector v = int{N_A n_i} dGamma + for (int a = 0; a < face.nNo; a++) { int Ac = face.glob(a); for (int i = 0; i < nsd; i++) { v(i,Ac) = face.valM(i,a); } } - // Computing S = coef * v^T * X + double S = coef(faIn) * dot::fsils_dot_v(dof, lhs.mynNo, lhs.commu, v, X); - // Computing Y = Y + v * S for (int a = 0; a < face.nNo; a++) { int Ac = face.glob(a); for (int i = 0; i < nsd; i++) { @@ -94,10 +83,7 @@ void add_bc_mul(FSILS_lhsType& lhs, const BcopType op_Type, const int dof, const } } - } - // If face is not shared across procs - else { - // Computing S = coef * v^T * X + } else { double S = 0.0; for (int a = 0; a < face.nNo; a++) { int Ac = face.glob(a); @@ -105,9 +91,9 @@ void add_bc_mul(FSILS_lhsType& lhs, const BcopType op_Type, const int dof, const S = S + face.valM(i,a)*X(i,Ac); } } + S = coef(faIn) * S; - - // Computing Y = Y + v * S + for (int a = 0; a < face.nNo; a++) { int Ac = face.glob(a); for (int i = 0; i < nsd; i++) { diff --git a/Code/Source/svFSILS/bc.cpp b/Code/Source/svFSILS/bc.cpp index 6924b5c4..119644e8 100644 --- a/Code/Source/svFSILS/bc.cpp +++ b/Code/Source/svFSILS/bc.cpp @@ -33,8 +33,7 @@ namespace fsi_linear_solver { -/// @brief Sets up 0D contribution to tangent matrix for 0D-coupled boundary condition. -/// Modifies +/// @brief Modifies: /// lhs.face[faIn].nNo /// lhs.face[faIn].dof /// lhs.face[faIn].bGrp @@ -94,7 +93,6 @@ void fsils_bc_create(FSILS_lhsType& lhs, int faIn, int nNo, int dof, BcType BC_t lhs.face[faIn].val = 0.0; } - // Synchronize val on nodes on boundary between procs if (lhs.commu.nTasks > 1) { int a = 0; @@ -138,9 +136,6 @@ void fsils_bc_create(FSILS_lhsType& lhs, int faIn, int nNo, int dof, BcType BC_t } -/// @brief Frees FSILS boundary condition structure -/// @param lhs -/// @param faIn void fsils_bc_free(FSILS_lhsType& lhs, int faIn) { //IF (.NOT.lhs%face(faIn)%foC) THEN @@ -158,53 +153,5 @@ void fsils_bc_free(FSILS_lhsType& lhs, int faIn) } -/// @brief Updates lhs.face[faIn].val with new values from 'Val' parameter. -/// Val should contain the integral of the normal vector in the current (n+1) configuration, -/// used in the tangent contribution of the 0D-coupled boundary condition. -/// Since fsils_bc_create() was already called at initialization, we don't -/// need to reallocate data structures, just update values. -/// @param lhs -/// @param faIn -/// @param nNo -/// @param dof -/// @param Val -void fsils_bc_update(FSILS_lhsType& lhs, int faIn, int nNo, int dof, const Array& Val) -{ - using namespace consts; - - // Set lhs.face[faIn].val with new values from 'Val' parameter - if (Val.size() != 0) { - for (int a = 0; a < nNo; a++) { - for (int i = 0; i < Val.nrows(); i++) { - lhs.face[faIn].val(i,a) = Val(i,a); - } - } - } else { - lhs.face[faIn].val = 0.0; - } - - // Communicate update among procs - if (lhs.face[faIn].sharedFlag){ - Array v(dof,lhs.nNo); - v = 0.0; - - for (int a = 0; a < nNo; a++) { - int Ac = lhs.face[faIn].glob(a); - for (int i = 0; i < dof; i++) { - v(i,Ac) = lhs.face[faIn].val(i,a); - } - } - - fsils_commuv(lhs, dof, v); - - for (int a = 0; a < nNo; a++) { - int Ac = lhs.face[faIn].glob(a); - for (int i = 0; i < dof; i++) { - lhs.face[faIn].val(i,a) = v(i,Ac); - } - } - } - -} +}; -}; \ No newline at end of file diff --git a/Code/Source/svFSILS/fsils_api.hpp b/Code/Source/svFSILS/fsils_api.hpp index 47bac5f0..3795dbfd 100644 --- a/Code/Source/svFSILS/fsils_api.hpp +++ b/Code/Source/svFSILS/fsils_api.hpp @@ -45,8 +45,6 @@ void fsils_bc_create(FSILS_lhsType& lhs, int faIn, int nNo, int dof, BcType BC_t void fsils_bc_free(FSILS_lhsType& lhs, int faIn); -void fsils_bc_update(FSILS_lhsType& lhs, int faIn, int nNo, int dof, const Array& Val); - void fsils_commus(const FSILS_lhsType& lhs, Vector& R); void fsils_commuv(const FSILS_lhsType& lhs, const int dof, Array& R); diff --git a/tests/cases/cep/cable_TTP_1d/result_001.vtu b/tests/cases/cep/cable_TTP_1d/result_001.vtu index e8d9f50c..a98765d8 100644 --- a/tests/cases/cep/cable_TTP_1d/result_001.vtu +++ b/tests/cases/cep/cable_TTP_1d/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8be46ee399abf9577bb89126c7d7e0bca146dac9d0c5ce10b97086abe85b078c -size 3862 +oid sha256:15a085fafbfa77ab98c969cb81495a4e2d01d22eacd39f248db78a40f3d8d714 +size 4075 diff --git a/tests/cases/cep/cable_TTP_1d/svFSI.xml b/tests/cases/cep/cable_TTP_1d/svFSI.xml index 5f0dfc95..a009a6a5 100644 --- a/tests/cases/cep/cable_TTP_1d/svFSI.xml +++ b/tests/cases/cep/cable_TTP_1d/svFSI.xml @@ -31,8 +31,8 @@ true 1 - 2 - 1e-12 + 5 + 1e-6 TTP @@ -57,8 +57,11 @@ + + fsils + 100 - 1e-12 + 1e-6 50 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu index 4e7b6e6c..03842bc3 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5ca618669a71038a1385eb16a483d0d4ac1b4213df67a15d59b0522d47f8ac71 -size 8238606 +oid sha256:6af5a1ba655072991230391acabfddff4cb3a34b0a5c81241ee4a311aa550fe3 +size 8305950 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu index 4cdc28a4..91f6d532 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94e247849b57f1feac14e3cde7c52af13b4112751a41a7320754b91da1c8f7cd -size 8282430 +oid sha256:bd7cc1fa1369a3965e615577e1f9c584cd794013794cf0d1077217a19b2ac88f +size 8279618 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu index ecd13e8b..8d8a62f7 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:862e6a065fc065f25169b9b0ca220e4e4ea70ab461d0eae68bb38435fcb8b729 -size 8224038 +oid sha256:4a3b96e0e8fad864daeda38acf5fbe46a0db55a054a60b7c28542ec94d258098 +size 8288167 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu index a7a017b4..05deeb85 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a38f51e854c188ffee9a4e893de80fc5bb617d93ac68112d587ca75aef172d38 -size 8301266 +oid sha256:d044cb38f9578ec54541e5097674dbce5b06bd7b8fd7b5f56ae36f78590c770e +size 8286611 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml index 575b28aa..f34e11b6 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-12 + 1e-6 BO @@ -104,8 +104,11 @@ + + fsils + 100 - 1e-12 + 1e-6 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml index 255f4e31..5479af77 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-12 + 1e-6 BO @@ -104,8 +104,10 @@ - svfsi - 1e-12 + + fsils + + 1e-6 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml index fe6aa6eb..b5d8fe6f 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-12 + 1e-6 TTP @@ -116,8 +116,11 @@ + + fsils + 100 - 1e-12 + 1e-6 50 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml index 31745800..3b666f2e 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-12 + 1e-6 AP @@ -104,8 +104,11 @@ + + fsils + 100 - 1e-12 + 1e-6 50 diff --git a/tests/cases/cep/purkinje/result_001.vtu b/tests/cases/cep/purkinje/result_001.vtu index 66163a3e..9fb9be7f 100644 --- a/tests/cases/cep/purkinje/result_001.vtu +++ b/tests/cases/cep/purkinje/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1bf39effdb55cf6f0ee63645720a788c869b6eeba3dc23c044cc15321e2c0eef -size 718891 +oid sha256:cd457cc3a4b72665dfbc0814b22071f7b2fbe718b0a11a3b52e32a8793ff5c84 +size 722384 diff --git a/tests/cases/cep/purkinje/svFSI.xml b/tests/cases/cep/purkinje/svFSI.xml index 0209f2ca..e6c5476b 100644 --- a/tests/cases/cep/purkinje/svFSI.xml +++ b/tests/cases/cep/purkinje/svFSI.xml @@ -39,8 +39,8 @@ true 1 - 2 - 1e-12 + 3 + 1e-6 TTP @@ -67,8 +67,11 @@ + + fsils + 100 - 1e-12 + 1e-6 50 diff --git a/tests/cases/cep/spiral_BO_2d/result_001.vtu b/tests/cases/cep/spiral_BO_2d/result_001.vtu index 9e3dab81..32fd4a4f 100644 --- a/tests/cases/cep/spiral_BO_2d/result_001.vtu +++ b/tests/cases/cep/spiral_BO_2d/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9cf7d9d6e416ac49dd62c09683677bcfa4673d0d027a33ec23f0e0b248ac144a -size 14201942 +oid sha256:6e05fcc0004f38abef3eede2d4a8e9b62f4e33269886d9f3bbcddc0d49f8ed72 +size 14228715 diff --git a/tests/cases/cep/spiral_BO_2d/svFSI.xml b/tests/cases/cep/spiral_BO_2d/svFSI.xml index ad9b3daa..2a18b3af 100644 --- a/tests/cases/cep/spiral_BO_2d/svFSI.xml +++ b/tests/cases/cep/spiral_BO_2d/svFSI.xml @@ -49,8 +49,8 @@ true 1 - 2 - 1e-12 + 5 + 1e-4 BO @@ -87,8 +87,10 @@ - rcs - 1e-12 + + rcs + + 1e-6 diff --git a/tests/cases/cep/square_AP_2d/result_001.vtu b/tests/cases/cep/square_AP_2d/result_001.vtu index 3c45cb1c..e8ff19f1 100644 --- a/tests/cases/cep/square_AP_2d/result_001.vtu +++ b/tests/cases/cep/square_AP_2d/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:61e7da67b5f90550dbbf3fbeef101f45494e5de92f0db1b536f26a92f8b3ef36 -size 2174946 +oid sha256:60bc623969a212be4f5e87be73a614329489d3f587e5c07fe1970ececee23c24 +size 2180579 diff --git a/tests/cases/cep/square_AP_2d/svFSI.xml b/tests/cases/cep/square_AP_2d/svFSI.xml index 5d48cf1d..99635666 100644 --- a/tests/cases/cep/square_AP_2d/svFSI.xml +++ b/tests/cases/cep/square_AP_2d/svFSI.xml @@ -49,8 +49,8 @@ true 1 - 2 - 1e-12 + 4 + 1e-4 AP @@ -74,8 +74,10 @@ - fsils - 1e-12 + + fsils + + 1e-6 diff --git a/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml b/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml index 152f6a75..ea9dec2c 100755 --- a/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml +++ b/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml @@ -60,6 +60,9 @@ + + fsils + 10 10 300 diff --git a/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml b/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml index b6d9a9f6..e0b4b382 100755 --- a/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml +++ b/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml @@ -48,14 +48,14 @@ + + fsils + 500 1e-12 50 - - - traction spatial diff --git a/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml b/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml index e94f1a01..bb68a5eb 100755 --- a/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml +++ b/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml @@ -79,11 +79,12 @@ - FSILS + + fsils + 100 1e-12 - Dir diff --git a/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml b/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml index df1e690a..ac825aa4 100755 --- a/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml @@ -61,6 +61,9 @@ + + fsils + 10 3 500 diff --git a/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml b/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml index 45496fdf..365ff66d 100644 --- a/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml @@ -45,6 +45,9 @@ + + fsils + 500 1e-12 diff --git a/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml b/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml index 5f115416..b6639dc4 100644 --- a/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml @@ -48,6 +48,9 @@ + + fsils + 500 1e-12 diff --git a/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml b/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml index b882537b..d7407b2a 100644 --- a/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml @@ -70,12 +70,13 @@ - FSILS + + fsils + 10 1e-12 50 - Dir diff --git a/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml b/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml index 4485f508..0ec907cb 100644 --- a/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml @@ -71,7 +71,9 @@ - FSILS + + fsils + 100 1e-12 diff --git a/tests/cases/fluid/carreau_yasuda/svFSI.xml b/tests/cases/fluid/carreau_yasuda/svFSI.xml index 9e9c313e..3432fbae 100644 --- a/tests/cases/fluid/carreau_yasuda/svFSI.xml +++ b/tests/cases/fluid/carreau_yasuda/svFSI.xml @@ -69,7 +69,9 @@ - FSILS + + fsils + 100 1e-12 diff --git a/tests/cases/fluid/casson/svFSI.xml b/tests/cases/fluid/casson/svFSI.xml index d0bec925..8856084a 100644 --- a/tests/cases/fluid/casson/svFSI.xml +++ b/tests/cases/fluid/casson/svFSI.xml @@ -67,7 +67,9 @@ - FSILS + + fsils + 100 1e-12 diff --git a/tests/cases/fluid/driven_cavity_2d/svFSI.xml b/tests/cases/fluid/driven_cavity_2d/svFSI.xml index 4cd68724..ea01561a 100755 --- a/tests/cases/fluid/driven_cavity_2d/svFSI.xml +++ b/tests/cases/fluid/driven_cavity_2d/svFSI.xml @@ -71,7 +71,9 @@ - FSILS + + fsils + 1000 1e-12 diff --git a/tests/cases/fluid/dye_AD/svFSI.xml b/tests/cases/fluid/dye_AD/svFSI.xml index 467dea3c..72938238 100644 --- a/tests/cases/fluid/dye_AD/svFSI.xml +++ b/tests/cases/fluid/dye_AD/svFSI.xml @@ -67,7 +67,9 @@ - FSILS + + fsils + 100 1e-12 @@ -118,7 +120,9 @@ - FSILS + + fsils + 1e-12 100 50 diff --git a/tests/cases/fluid/iliac_artery/svFSI.xml b/tests/cases/fluid/iliac_artery/svFSI.xml index 94320b32..06b1db1a 100644 --- a/tests/cases/fluid/iliac_artery/svFSI.xml +++ b/tests/cases/fluid/iliac_artery/svFSI.xml @@ -67,6 +67,9 @@ + + fsils + 15 10 300 diff --git a/tests/cases/fluid/newtonian/svFSI.xml b/tests/cases/fluid/newtonian/svFSI.xml index 504b25f8..4cb18417 100644 --- a/tests/cases/fluid/newtonian/svFSI.xml +++ b/tests/cases/fluid/newtonian/svFSI.xml @@ -65,7 +65,9 @@ - FSILS + + fsils + 100 1e-12 diff --git a/tests/cases/fluid/pipe_RCR_3d/svFSI.xml b/tests/cases/fluid/pipe_RCR_3d/svFSI.xml index 871b4309..9e2f9512 100755 --- a/tests/cases/fluid/pipe_RCR_3d/svFSI.xml +++ b/tests/cases/fluid/pipe_RCR_3d/svFSI.xml @@ -64,7 +64,9 @@ - FSILS + + fsils + 100 1e-12 diff --git a/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/README.md b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/README.md new file mode 100755 index 00000000..67fcc6bb --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/README.md @@ -0,0 +1,71 @@ + +# **Problem Description** + +Solve fluid flow in a cylindrical tube with resistance or RCR boundary conditions at the outlet and unsteady flow at inlet. + +The input file `svFSI.inp` follows the master input file [`svFSI_master.inp`](./svFSI_master.inp) as a template. Some specific input options are discussed below: + +## Resistance and RCR values + +If the problem is solved using resistance BC at the outlet, the following keywords are expected in `Add BC`: + +`Type: Neu + Time dependence: Resistance + Value: << resistance_value >>` + +Note that when providing resistance_value, << >> are not required. + +If the problem is solved using an RCR BC at the outlet, the following keywords are expected in `Add BC`: + +`Type: Neu + Time dependence: RCR # or Windkessel + RCR values: << (proximal_resistance, capacitance, distal_resistance) >> + Distal pressure: << distal_pressure_value >>` + +For prescribing the RCR BC, the order of the values is fixed i.e., proximal resistance followed by capacitance and the distal resistance. These values can be separated by comma or space, and should be enclosed within parentheses (), double quotes "", or <>. + +## Options for providing unsteady BCs + +This example provides two ways of specifying unsteady boundary conditions: + +(a) Providing time-dependent data as input using the keyword, + +`Temporal values file path: lumen_inlet.flow` + +(b) Providing interpolated Fourier coefficients as input using the keyword, + +`Fourier coefficients file path: lumen_inlet.fcs` + +### File format for time-dependent data + +The format for providing time-dependent data in an ASCII formatted file is: + +` number_of_time_points number_of_Fourier_modes + time_point_1 data_value_1 + time_point_2 data_value_2 + . + . + . + time_point_n data_value_n` + +### File format for Fourier coefficients + +The format for providing Fourier coefficients in an ASCII formatted file is: + +` first_time_point + last_time_point + first_data_value + first_Fourier_mode + number_of_Fourier_modes + real_Fourier_mode_1 imag_Fourier_mode_1 + real_Fourier_mode_2 imag_Fourier_mode_2 + . + . + . + real_Fourier_mode_N imag_Fourier_mode_N` + +In the above format, the first_Fourier_mode on Line 4 is to be computed as, + +```bash +first_Fourier_mode = (last_data_value - first_data_value) / (last_time_point - first_time_point) +``` diff --git a/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/lumen_inlet.fcs b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/lumen_inlet.fcs new file mode 100755 index 00000000..84448314 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/lumen_inlet.fcs @@ -0,0 +1,21 @@ + 0.0000 + 1.0000 + 0.000000E+00 + 0.000000E+00 + 16 + -6.283185E+01 0.000000E+00 + 6.263025E+01 -1.868984E-07 + -1.851028E-07 1.979808E-15 + -3.293147E-07 1.821408E-07 + 2.967629E-07 4.499564E-17 + -7.134611E-07 -1.729158E-07 + -1.667927E-07 5.199497E-16 + -1.920733E-06 1.597801E-07 + 5.066059E-08 -2.587250E-16 + 9.364629E-07 -1.435117E-07 + -1.344913E-07 8.999129E-17 + -9.410540E-07 1.250477E-07 + 1.921845E-07 2.874722E-17 + 9.540060E-07 -1.054107E-07 + -9.547580E-08 -1.106526E-16 + 1.016783E-06 8.563008E-08 diff --git a/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/lumen_inlet.flow b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/lumen_inlet.flow new file mode 100755 index 00000000..174af3c6 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/lumen_inlet.flow @@ -0,0 +1,34 @@ +33 16 +0.000000 0.000000 +0.031250 -1.207301 +0.062500 -4.782786 +0.093750 -10.589077 +0.125000 -18.403023 +0.156250 -27.924348 +0.187500 -38.787146 +0.218750 -50.573962 +0.250000 -62.83185 +0.281250 -75.089744 +0.312500 -86.876560 +0.343750 -97.739358 +0.375000 -107.260684 +0.406250 -115.074629 +0.437500 -120.880920 +0.468750 -124.456405 +0.500000 -125.663706 +0.531250 -124.456405 +0.562500 -120.880920 +0.593750 -115.074629 +0.625000 -107.260684 +0.656250 -97.739358 +0.687500 -86.876560 +0.718750 -75.089744 +0.750000 -62.831853 +0.781250 -50.573962 +0.812500 -38.787146 +0.843750 -27.924348 +0.875000 -18.403023 +0.906250 -10.589077 +0.937500 -4.782786 +0.968750 -1.207301 +1.000000 0.000000 \ No newline at end of file diff --git a/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-complete.mesh.vtu b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-complete.mesh.vtu new file mode 100644 index 00000000..36bc739d --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-complete.mesh.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75e318c829105bb00e353522f1697361444d6199f92da1dc374927f243ea7632 +size 176990 diff --git a/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_inlet.vtp b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_inlet.vtp new file mode 100644 index 00000000..6311c773 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_inlet.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b77b872930b3ff01f8bc6e3ea6e061a4df800ba3bc1f4d4bf3a275f863022cea +size 6972 diff --git a/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_outlet.vtp b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_outlet.vtp new file mode 100644 index 00000000..9aa15e6e --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_outlet.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5c16563fee4011b1e89bd3492dd2798de2185dfcfb9b60944a3155a50f13187 +size 7070 diff --git a/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_wall.vtp b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_wall.vtp new file mode 100644 index 00000000..b5f092a5 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/mesh/mesh-surfaces/lumen_wall.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e3dfb1b920d6ddb3066c84a3564069541a3c8b0c2ebedad2a58625d5369de1b +size 66024 diff --git a/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/result_002.vtu b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/result_002.vtu new file mode 100644 index 00000000..d3084268 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/result_002.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f62a5a882595c10a9675583cc7f14d401bb3c11fecd4a6593c2ba0860f1cf70c +size 544865 diff --git a/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/svFSI.xml b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/svFSI.xml new file mode 100755 index 00000000..11c6c7fd --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_bj_trilinos/svFSI.xml @@ -0,0 +1,104 @@ + + + + + + false + 3 + 2 + 0.005 + 0.50 + STOP_SIM + + 1 + result + 2 + 1 + + 100 + 0 + + 1 + 0 + 0 + + + + + + mesh/mesh-complete.mesh.vtu + + + mesh/mesh-surfaces/lumen_inlet.vtp + + + + mesh/mesh-surfaces/lumen_outlet.vtp + + + + mesh/mesh-surfaces/lumen_wall.vtp + + + + + + true + 3 + 5 + 1e-11 + 0.2 + + 1.06 + + 0.04 + + + + true + true + true + true + true + true + + + + + trilinos-blockjacobi + + 100 + 1e-12 + + + + Dir + Unsteady + lumen_inlet.flow + Parabolic + true + + + + Neu + RCR + + 1.5e-5 + 1212 + 121 + 0 + 0 + + + + + Dir + Steady + 0.0 + + + + + + + diff --git a/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/README.md b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/README.md new file mode 100755 index 00000000..67fcc6bb --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/README.md @@ -0,0 +1,71 @@ + +# **Problem Description** + +Solve fluid flow in a cylindrical tube with resistance or RCR boundary conditions at the outlet and unsteady flow at inlet. + +The input file `svFSI.inp` follows the master input file [`svFSI_master.inp`](./svFSI_master.inp) as a template. Some specific input options are discussed below: + +## Resistance and RCR values + +If the problem is solved using resistance BC at the outlet, the following keywords are expected in `Add BC`: + +`Type: Neu + Time dependence: Resistance + Value: << resistance_value >>` + +Note that when providing resistance_value, << >> are not required. + +If the problem is solved using an RCR BC at the outlet, the following keywords are expected in `Add BC`: + +`Type: Neu + Time dependence: RCR # or Windkessel + RCR values: << (proximal_resistance, capacitance, distal_resistance) >> + Distal pressure: << distal_pressure_value >>` + +For prescribing the RCR BC, the order of the values is fixed i.e., proximal resistance followed by capacitance and the distal resistance. These values can be separated by comma or space, and should be enclosed within parentheses (), double quotes "", or <>. + +## Options for providing unsteady BCs + +This example provides two ways of specifying unsteady boundary conditions: + +(a) Providing time-dependent data as input using the keyword, + +`Temporal values file path: lumen_inlet.flow` + +(b) Providing interpolated Fourier coefficients as input using the keyword, + +`Fourier coefficients file path: lumen_inlet.fcs` + +### File format for time-dependent data + +The format for providing time-dependent data in an ASCII formatted file is: + +` number_of_time_points number_of_Fourier_modes + time_point_1 data_value_1 + time_point_2 data_value_2 + . + . + . + time_point_n data_value_n` + +### File format for Fourier coefficients + +The format for providing Fourier coefficients in an ASCII formatted file is: + +` first_time_point + last_time_point + first_data_value + first_Fourier_mode + number_of_Fourier_modes + real_Fourier_mode_1 imag_Fourier_mode_1 + real_Fourier_mode_2 imag_Fourier_mode_2 + . + . + . + real_Fourier_mode_N imag_Fourier_mode_N` + +In the above format, the first_Fourier_mode on Line 4 is to be computed as, + +```bash +first_Fourier_mode = (last_data_value - first_data_value) / (last_time_point - first_time_point) +``` diff --git a/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/lumen_inlet.fcs b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/lumen_inlet.fcs new file mode 100755 index 00000000..84448314 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/lumen_inlet.fcs @@ -0,0 +1,21 @@ + 0.0000 + 1.0000 + 0.000000E+00 + 0.000000E+00 + 16 + -6.283185E+01 0.000000E+00 + 6.263025E+01 -1.868984E-07 + -1.851028E-07 1.979808E-15 + -3.293147E-07 1.821408E-07 + 2.967629E-07 4.499564E-17 + -7.134611E-07 -1.729158E-07 + -1.667927E-07 5.199497E-16 + -1.920733E-06 1.597801E-07 + 5.066059E-08 -2.587250E-16 + 9.364629E-07 -1.435117E-07 + -1.344913E-07 8.999129E-17 + -9.410540E-07 1.250477E-07 + 1.921845E-07 2.874722E-17 + 9.540060E-07 -1.054107E-07 + -9.547580E-08 -1.106526E-16 + 1.016783E-06 8.563008E-08 diff --git a/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/lumen_inlet.flow b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/lumen_inlet.flow new file mode 100755 index 00000000..174af3c6 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/lumen_inlet.flow @@ -0,0 +1,34 @@ +33 16 +0.000000 0.000000 +0.031250 -1.207301 +0.062500 -4.782786 +0.093750 -10.589077 +0.125000 -18.403023 +0.156250 -27.924348 +0.187500 -38.787146 +0.218750 -50.573962 +0.250000 -62.83185 +0.281250 -75.089744 +0.312500 -86.876560 +0.343750 -97.739358 +0.375000 -107.260684 +0.406250 -115.074629 +0.437500 -120.880920 +0.468750 -124.456405 +0.500000 -125.663706 +0.531250 -124.456405 +0.562500 -120.880920 +0.593750 -115.074629 +0.625000 -107.260684 +0.656250 -97.739358 +0.687500 -86.876560 +0.718750 -75.089744 +0.750000 -62.831853 +0.781250 -50.573962 +0.812500 -38.787146 +0.843750 -27.924348 +0.875000 -18.403023 +0.906250 -10.589077 +0.937500 -4.782786 +0.968750 -1.207301 +1.000000 0.000000 \ No newline at end of file diff --git a/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-complete.mesh.vtu b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-complete.mesh.vtu new file mode 100644 index 00000000..36bc739d --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-complete.mesh.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75e318c829105bb00e353522f1697361444d6199f92da1dc374927f243ea7632 +size 176990 diff --git a/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_inlet.vtp b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_inlet.vtp new file mode 100644 index 00000000..6311c773 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_inlet.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b77b872930b3ff01f8bc6e3ea6e061a4df800ba3bc1f4d4bf3a275f863022cea +size 6972 diff --git a/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_outlet.vtp b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_outlet.vtp new file mode 100644 index 00000000..9aa15e6e --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_outlet.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5c16563fee4011b1e89bd3492dd2798de2185dfcfb9b60944a3155a50f13187 +size 7070 diff --git a/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_wall.vtp b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_wall.vtp new file mode 100644 index 00000000..b5f092a5 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/mesh/mesh-surfaces/lumen_wall.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e3dfb1b920d6ddb3066c84a3564069541a3c8b0c2ebedad2a58625d5369de1b +size 66024 diff --git a/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/result_002.vtu b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/result_002.vtu new file mode 100644 index 00000000..d3084268 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/result_002.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f62a5a882595c10a9675583cc7f14d401bb3c11fecd4a6593c2ba0860f1cf70c +size 544865 diff --git a/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/svFSI.xml b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/svFSI.xml new file mode 100755 index 00000000..bf9eea56 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_ilut_trilinos/svFSI.xml @@ -0,0 +1,104 @@ + + + + + + false + 3 + 2 + 0.005 + 0.50 + STOP_SIM + + 1 + result + 2 + 1 + + 100 + 0 + + 1 + 0 + 0 + + + + + + mesh/mesh-complete.mesh.vtu + + + mesh/mesh-surfaces/lumen_inlet.vtp + + + + mesh/mesh-surfaces/lumen_outlet.vtp + + + + mesh/mesh-surfaces/lumen_wall.vtp + + + + + + true + 3 + 5 + 1e-11 + 0.2 + + 1.06 + + 0.04 + + + + true + true + true + true + true + true + + + + + trilinos-ilut + + 100 + 1e-12 + + + + Dir + Unsteady + lumen_inlet.flow + Parabolic + true + + + + Neu + RCR + + 1.5e-5 + 1212 + 121 + 0 + 0 + + + + + Dir + Steady + 0.0 + + + + + + + diff --git a/tests/cases/fluid/pipe_RCR_3d_petsc/README.md b/tests/cases/fluid/pipe_RCR_3d_petsc/README.md new file mode 100755 index 00000000..67fcc6bb --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_petsc/README.md @@ -0,0 +1,71 @@ + +# **Problem Description** + +Solve fluid flow in a cylindrical tube with resistance or RCR boundary conditions at the outlet and unsteady flow at inlet. + +The input file `svFSI.inp` follows the master input file [`svFSI_master.inp`](./svFSI_master.inp) as a template. Some specific input options are discussed below: + +## Resistance and RCR values + +If the problem is solved using resistance BC at the outlet, the following keywords are expected in `Add BC`: + +`Type: Neu + Time dependence: Resistance + Value: << resistance_value >>` + +Note that when providing resistance_value, << >> are not required. + +If the problem is solved using an RCR BC at the outlet, the following keywords are expected in `Add BC`: + +`Type: Neu + Time dependence: RCR # or Windkessel + RCR values: << (proximal_resistance, capacitance, distal_resistance) >> + Distal pressure: << distal_pressure_value >>` + +For prescribing the RCR BC, the order of the values is fixed i.e., proximal resistance followed by capacitance and the distal resistance. These values can be separated by comma or space, and should be enclosed within parentheses (), double quotes "", or <>. + +## Options for providing unsteady BCs + +This example provides two ways of specifying unsteady boundary conditions: + +(a) Providing time-dependent data as input using the keyword, + +`Temporal values file path: lumen_inlet.flow` + +(b) Providing interpolated Fourier coefficients as input using the keyword, + +`Fourier coefficients file path: lumen_inlet.fcs` + +### File format for time-dependent data + +The format for providing time-dependent data in an ASCII formatted file is: + +` number_of_time_points number_of_Fourier_modes + time_point_1 data_value_1 + time_point_2 data_value_2 + . + . + . + time_point_n data_value_n` + +### File format for Fourier coefficients + +The format for providing Fourier coefficients in an ASCII formatted file is: + +` first_time_point + last_time_point + first_data_value + first_Fourier_mode + number_of_Fourier_modes + real_Fourier_mode_1 imag_Fourier_mode_1 + real_Fourier_mode_2 imag_Fourier_mode_2 + . + . + . + real_Fourier_mode_N imag_Fourier_mode_N` + +In the above format, the first_Fourier_mode on Line 4 is to be computed as, + +```bash +first_Fourier_mode = (last_data_value - first_data_value) / (last_time_point - first_time_point) +``` diff --git a/tests/cases/fluid/pipe_RCR_3d_petsc/lumen_inlet.fcs b/tests/cases/fluid/pipe_RCR_3d_petsc/lumen_inlet.fcs new file mode 100755 index 00000000..84448314 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_petsc/lumen_inlet.fcs @@ -0,0 +1,21 @@ + 0.0000 + 1.0000 + 0.000000E+00 + 0.000000E+00 + 16 + -6.283185E+01 0.000000E+00 + 6.263025E+01 -1.868984E-07 + -1.851028E-07 1.979808E-15 + -3.293147E-07 1.821408E-07 + 2.967629E-07 4.499564E-17 + -7.134611E-07 -1.729158E-07 + -1.667927E-07 5.199497E-16 + -1.920733E-06 1.597801E-07 + 5.066059E-08 -2.587250E-16 + 9.364629E-07 -1.435117E-07 + -1.344913E-07 8.999129E-17 + -9.410540E-07 1.250477E-07 + 1.921845E-07 2.874722E-17 + 9.540060E-07 -1.054107E-07 + -9.547580E-08 -1.106526E-16 + 1.016783E-06 8.563008E-08 diff --git a/tests/cases/fluid/pipe_RCR_3d_petsc/lumen_inlet.flow b/tests/cases/fluid/pipe_RCR_3d_petsc/lumen_inlet.flow new file mode 100755 index 00000000..174af3c6 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_petsc/lumen_inlet.flow @@ -0,0 +1,34 @@ +33 16 +0.000000 0.000000 +0.031250 -1.207301 +0.062500 -4.782786 +0.093750 -10.589077 +0.125000 -18.403023 +0.156250 -27.924348 +0.187500 -38.787146 +0.218750 -50.573962 +0.250000 -62.83185 +0.281250 -75.089744 +0.312500 -86.876560 +0.343750 -97.739358 +0.375000 -107.260684 +0.406250 -115.074629 +0.437500 -120.880920 +0.468750 -124.456405 +0.500000 -125.663706 +0.531250 -124.456405 +0.562500 -120.880920 +0.593750 -115.074629 +0.625000 -107.260684 +0.656250 -97.739358 +0.687500 -86.876560 +0.718750 -75.089744 +0.750000 -62.831853 +0.781250 -50.573962 +0.812500 -38.787146 +0.843750 -27.924348 +0.875000 -18.403023 +0.906250 -10.589077 +0.937500 -4.782786 +0.968750 -1.207301 +1.000000 0.000000 \ No newline at end of file diff --git a/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-complete.mesh.vtu b/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-complete.mesh.vtu new file mode 100644 index 00000000..36bc739d --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-complete.mesh.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:75e318c829105bb00e353522f1697361444d6199f92da1dc374927f243ea7632 +size 176990 diff --git a/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_inlet.vtp b/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_inlet.vtp new file mode 100644 index 00000000..6311c773 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_inlet.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b77b872930b3ff01f8bc6e3ea6e061a4df800ba3bc1f4d4bf3a275f863022cea +size 6972 diff --git a/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_outlet.vtp b/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_outlet.vtp new file mode 100644 index 00000000..9aa15e6e --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_outlet.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c5c16563fee4011b1e89bd3492dd2798de2185dfcfb9b60944a3155a50f13187 +size 7070 diff --git a/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_wall.vtp b/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_wall.vtp new file mode 100644 index 00000000..b5f092a5 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_petsc/mesh/mesh-surfaces/lumen_wall.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3e3dfb1b920d6ddb3066c84a3564069541a3c8b0c2ebedad2a58625d5369de1b +size 66024 diff --git a/tests/cases/fluid/pipe_RCR_3d_petsc/result_002.vtu b/tests/cases/fluid/pipe_RCR_3d_petsc/result_002.vtu new file mode 100644 index 00000000..d3084268 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_petsc/result_002.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f62a5a882595c10a9675583cc7f14d401bb3c11fecd4a6593c2ba0860f1cf70c +size 544865 diff --git a/tests/cases/fluid/pipe_RCR_3d_petsc/svFSI.xml b/tests/cases/fluid/pipe_RCR_3d_petsc/svFSI.xml new file mode 100755 index 00000000..3d55be4f --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_petsc/svFSI.xml @@ -0,0 +1,104 @@ + + + + + + false + 3 + 2 + 0.005 + 0.50 + STOP_SIM + + 1 + result + 2 + 1 + + 100 + 0 + + 1 + 0 + 0 + + + + + + mesh/mesh-complete.mesh.vtu + + + mesh/mesh-surfaces/lumen_inlet.vtp + + + + mesh/mesh-surfaces/lumen_outlet.vtp + + + + mesh/mesh-surfaces/lumen_wall.vtp + + + + + + true + 3 + 5 + 1e-11 + 0.2 + + 1.06 + + 0.04 + + + + true + true + true + true + true + true + + + + + petsc-rcs + + 100 + 1e-12 + + + + Dir + Unsteady + lumen_inlet.flow + Parabolic + true + + + + Neu + RCR + + 1.5e-5 + 1212 + 121 + 0 + 0 + + + + + Dir + Steady + 0.0 + + + + + + + diff --git a/tests/cases/fsi/pipe_3d/svFSI.xml b/tests/cases/fsi/pipe_3d/svFSI.xml index 4befad05..61649eae 100755 --- a/tests/cases/fsi/pipe_3d/svFSI.xml +++ b/tests/cases/fsi/pipe_3d/svFSI.xml @@ -10,9 +10,9 @@ STOP_SIM true result - 1 + 5 1 - 1 + 100 0 1 0 @@ -80,8 +80,10 @@ - FSILS - + + fsils + + 1e-6 1e-12 100 50 @@ -130,7 +132,9 @@ 0.3 - FSILS + + fsils + 1e-12 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/README.md b/tests/cases/fsi/pipe_3d_bj_trilinos/README.md new file mode 100755 index 00000000..9c92f6a3 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/README.md @@ -0,0 +1,23 @@ + +# **Problem Description** + +Solve pressure wave propagation in an arterial model using the Arbitrary Lagrangian-Eulerian method [1]. The problem set-up is as follows. + +

+ +

+ +And the results are + +

+ +

+ +The input file `svFSI.xml` follows the input file format for svFSIplus. More on ALE-FSI simulations can be found here: + +- SimVascular Website: https://simvascular.github.io/docssvFSI-FSI.html +- Youtube Tutorial: https://www.youtube.com/watch?v=QIpyThIAD7k + +## Reference + +1. Liu, Ju, and Alison L. Marsden. A Unified Continuum and Variational Multiscale Formulation for Fluids, Solids, and Fluid Structure Interaction. *Computer Methods in Applied Mechanics and Engineering* 337 (August 2018): 549 97. https://doi.org/10.1016/j.cma.2018.03.045. diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/configuration.png b/tests/cases/fsi/pipe_3d_bj_trilinos/configuration.png new file mode 100644 index 00000000..47d287aa --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/configuration.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c6f4038337823c1c6ffca373eaeb737a9f7c74de3225b1021d7178608c63798 +size 679523 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..8ddb1119 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-complete.mesh.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bff21b54094fe528e6f7cd9b57dafc5863b530e112e08f8a62a04431ec14a7a3 +size 67969 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..e7c6c313 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/end.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57511367796bab30c07b3b5dbd3b6ec596e433cb1aae2afe763f05ab357655bf +size 13661 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..c52d70d2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/interface.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c4a25e331d2c3ccbfa2ffcdd52e0ebbd37a8045989bec9abd7b2c0ed775e2b8 +size 28724 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..55f41e4f --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/fluid/mesh-surfaces/start.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d90d5fb5ce21d0889b27fd0a592aafa6121d19047bebd801710caf5cba6fb48a +size 13685 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..08402c8e --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-complete.mesh.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2527472b08ece18c95175c0661ca838f90ac8b97406d0c1c77459e94df620fe7 +size 36980 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..4f2a8129 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/end.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abb10cc3c374742b481031050fd6ceb2af30b8a14bd5627d89f930a4df01708a +size 12351 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..9a8bafd8 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/interface.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9302a80f392f30ae07b98d0048cb7ad85f2fd3fcb0a86dbe50def69ba5a6cafc +size 28900 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/outside.vtp b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/outside.vtp new file mode 100644 index 00000000..1c5fbfe2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/outside.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29c18dc6c30b33a98016c3df4038433430307f05bc5fd3d2d39469b4a3d4bb63 +size 28813 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..37fd38c9 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/mesh/solid/mesh-surfaces/start.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c679e42882a1a2db6382133d896879e84468058870863e670fc31212d4e29c2 +size 12335 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/result_005.vtu b/tests/cases/fsi/pipe_3d_bj_trilinos/result_005.vtu new file mode 100644 index 00000000..b3c68f1b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/result_005.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c5e0a10e6c3f30addeb8595c27f531146fdf22e7d00e132c2b5b6cd01adfd89 +size 208368 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/results.gif b/tests/cases/fsi/pipe_3d_bj_trilinos/results.gif new file mode 100644 index 00000000..0c87216b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/results.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1f98ef6a06de4f38d40481ea5feb61f0a453cfe134b9afd1f6b04ffd3f6652d +size 3051594 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml b/tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml new file mode 100755 index 00000000..5ce9f28d --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml @@ -0,0 +1,157 @@ + + + + + 0 + 3 + 5 + 1e-4 + 0.50 + STOP_SIM + true + result + 5 + 1 + 100 + 0 + 1 + 0 + 0 + + + + mesh/fluid/mesh-complete.mesh.vtu + + mesh/fluid/mesh-surfaces/start.vtp + + + mesh/fluid/mesh-surfaces/end.vtp + + + mesh/fluid/mesh-surfaces/interface.vtp + + 0 + + + + + mesh/solid/mesh-complete.mesh.vtu + + mesh/solid/mesh-surfaces/start.vtp + + + mesh/solid/mesh-surfaces/end.vtp + + + mesh/solid/mesh-surfaces/interface.vtp + + + mesh/solid/mesh-surfaces/outside.vtp + + 1 + + + + lumen_wall + + + + true + 1 + 7 + 1e-12 + + + fluid + 1.0 + + 0.04 + + 0.2 + + + + struct + + M94 + 1.0 + 1.0e7 + 0.3 + + + + + trilinos-blockjacobi + + 1e-6 + 1e-12 + 100 + 50 + + + + true + true + true + true + + + + FS_Displacement + + + + Neu + 5.0e4 + + + + Dir + 0.0 + true + false + (0, 0, 1) + + + + Dir + 0.0 + true + false + (0, 0, 1 ) + + + + + + + true + 1 + 7 + 1e-12 + 0.3 + + + + trilinos-blockjacobi + + 1e-12 + + + + true + + + + Dir + 0.0 + + + + Dir + 0.0 + + + + + diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/README.md b/tests/cases/fsi/pipe_3d_ml_trilinos/README.md new file mode 100755 index 00000000..9c92f6a3 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/README.md @@ -0,0 +1,23 @@ + +# **Problem Description** + +Solve pressure wave propagation in an arterial model using the Arbitrary Lagrangian-Eulerian method [1]. The problem set-up is as follows. + +

+ +

+ +And the results are + +

+ +

+ +The input file `svFSI.xml` follows the input file format for svFSIplus. More on ALE-FSI simulations can be found here: + +- SimVascular Website: https://simvascular.github.io/docssvFSI-FSI.html +- Youtube Tutorial: https://www.youtube.com/watch?v=QIpyThIAD7k + +## Reference + +1. Liu, Ju, and Alison L. Marsden. A Unified Continuum and Variational Multiscale Formulation for Fluids, Solids, and Fluid Structure Interaction. *Computer Methods in Applied Mechanics and Engineering* 337 (August 2018): 549 97. https://doi.org/10.1016/j.cma.2018.03.045. diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/configuration.png b/tests/cases/fsi/pipe_3d_ml_trilinos/configuration.png new file mode 100644 index 00000000..47d287aa --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/configuration.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c6f4038337823c1c6ffca373eaeb737a9f7c74de3225b1021d7178608c63798 +size 679523 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..8ddb1119 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-complete.mesh.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bff21b54094fe528e6f7cd9b57dafc5863b530e112e08f8a62a04431ec14a7a3 +size 67969 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..e7c6c313 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/end.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57511367796bab30c07b3b5dbd3b6ec596e433cb1aae2afe763f05ab357655bf +size 13661 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..c52d70d2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/interface.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c4a25e331d2c3ccbfa2ffcdd52e0ebbd37a8045989bec9abd7b2c0ed775e2b8 +size 28724 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..55f41e4f --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/fluid/mesh-surfaces/start.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d90d5fb5ce21d0889b27fd0a592aafa6121d19047bebd801710caf5cba6fb48a +size 13685 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..08402c8e --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-complete.mesh.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2527472b08ece18c95175c0661ca838f90ac8b97406d0c1c77459e94df620fe7 +size 36980 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..4f2a8129 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/end.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abb10cc3c374742b481031050fd6ceb2af30b8a14bd5627d89f930a4df01708a +size 12351 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..9a8bafd8 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/interface.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9302a80f392f30ae07b98d0048cb7ad85f2fd3fcb0a86dbe50def69ba5a6cafc +size 28900 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/outside.vtp b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/outside.vtp new file mode 100644 index 00000000..1c5fbfe2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/outside.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29c18dc6c30b33a98016c3df4038433430307f05bc5fd3d2d39469b4a3d4bb63 +size 28813 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..37fd38c9 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/mesh/solid/mesh-surfaces/start.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c679e42882a1a2db6382133d896879e84468058870863e670fc31212d4e29c2 +size 12335 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/result_005.vtu b/tests/cases/fsi/pipe_3d_ml_trilinos/result_005.vtu new file mode 100644 index 00000000..b3c68f1b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/result_005.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c5e0a10e6c3f30addeb8595c27f531146fdf22e7d00e132c2b5b6cd01adfd89 +size 208368 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/results.gif b/tests/cases/fsi/pipe_3d_ml_trilinos/results.gif new file mode 100644 index 00000000..0c87216b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/results.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1f98ef6a06de4f38d40481ea5feb61f0a453cfe134b9afd1f6b04ffd3f6652d +size 3051594 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml b/tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml new file mode 100755 index 00000000..b8e75921 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml @@ -0,0 +1,157 @@ + + + + + 0 + 3 + 5 + 1e-4 + 0.50 + STOP_SIM + true + result + 5 + 1 + 100 + 0 + 1 + 0 + 0 + + + + mesh/fluid/mesh-complete.mesh.vtu + + mesh/fluid/mesh-surfaces/start.vtp + + + mesh/fluid/mesh-surfaces/end.vtp + + + mesh/fluid/mesh-surfaces/interface.vtp + + 0 + + + + + mesh/solid/mesh-complete.mesh.vtu + + mesh/solid/mesh-surfaces/start.vtp + + + mesh/solid/mesh-surfaces/end.vtp + + + mesh/solid/mesh-surfaces/interface.vtp + + + mesh/solid/mesh-surfaces/outside.vtp + + 1 + + + + lumen_wall + + + + true + 1 + 7 + 1e-12 + + + fluid + 1.0 + + 0.04 + + 0.2 + + + + struct + + M94 + 1.0 + 1.0e7 + 0.3 + + + + + trilinos-ml + + 1e-6 + 1e-12 + 100 + 50 + + + + true + true + true + true + + + + FS_Displacement + + + + Neu + 5.0e4 + + + + Dir + 0.0 + true + false + (0, 0, 1) + + + + Dir + 0.0 + true + false + (0, 0, 1 ) + + + + + + + true + 1 + 7 + 1e-12 + 0.3 + + + + trilinos-ml + + 1e-12 + + + + true + + + + Dir + 0.0 + + + + Dir + 0.0 + + + + + diff --git a/tests/cases/fsi/pipe_3d_petsc/README.md b/tests/cases/fsi/pipe_3d_petsc/README.md new file mode 100755 index 00000000..9c92f6a3 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/README.md @@ -0,0 +1,23 @@ + +# **Problem Description** + +Solve pressure wave propagation in an arterial model using the Arbitrary Lagrangian-Eulerian method [1]. The problem set-up is as follows. + +

+ +

+ +And the results are + +

+ +

+ +The input file `svFSI.xml` follows the input file format for svFSIplus. More on ALE-FSI simulations can be found here: + +- SimVascular Website: https://simvascular.github.io/docssvFSI-FSI.html +- Youtube Tutorial: https://www.youtube.com/watch?v=QIpyThIAD7k + +## Reference + +1. Liu, Ju, and Alison L. Marsden. A Unified Continuum and Variational Multiscale Formulation for Fluids, Solids, and Fluid Structure Interaction. *Computer Methods in Applied Mechanics and Engineering* 337 (August 2018): 549 97. https://doi.org/10.1016/j.cma.2018.03.045. diff --git a/tests/cases/fsi/pipe_3d_petsc/configuration.png b/tests/cases/fsi/pipe_3d_petsc/configuration.png new file mode 100644 index 00000000..47d287aa --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/configuration.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c6f4038337823c1c6ffca373eaeb737a9f7c74de3225b1021d7178608c63798 +size 679523 diff --git a/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..8ddb1119 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-complete.mesh.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bff21b54094fe528e6f7cd9b57dafc5863b530e112e08f8a62a04431ec14a7a3 +size 67969 diff --git a/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..e7c6c313 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/end.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:57511367796bab30c07b3b5dbd3b6ec596e433cb1aae2afe763f05ab357655bf +size 13661 diff --git a/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..c52d70d2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/interface.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4c4a25e331d2c3ccbfa2ffcdd52e0ebbd37a8045989bec9abd7b2c0ed775e2b8 +size 28724 diff --git a/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..55f41e4f --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/mesh/fluid/mesh-surfaces/start.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d90d5fb5ce21d0889b27fd0a592aafa6121d19047bebd801710caf5cba6fb48a +size 13685 diff --git a/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..08402c8e --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-complete.mesh.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2527472b08ece18c95175c0661ca838f90ac8b97406d0c1c77459e94df620fe7 +size 36980 diff --git a/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..4f2a8129 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/end.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:abb10cc3c374742b481031050fd6ceb2af30b8a14bd5627d89f930a4df01708a +size 12351 diff --git a/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..9a8bafd8 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/interface.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9302a80f392f30ae07b98d0048cb7ad85f2fd3fcb0a86dbe50def69ba5a6cafc +size 28900 diff --git a/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/outside.vtp b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/outside.vtp new file mode 100644 index 00000000..1c5fbfe2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/outside.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29c18dc6c30b33a98016c3df4038433430307f05bc5fd3d2d39469b4a3d4bb63 +size 28813 diff --git a/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..37fd38c9 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/mesh/solid/mesh-surfaces/start.vtp @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9c679e42882a1a2db6382133d896879e84468058870863e670fc31212d4e29c2 +size 12335 diff --git a/tests/cases/fsi/pipe_3d_petsc/result_005.vtu b/tests/cases/fsi/pipe_3d_petsc/result_005.vtu new file mode 100644 index 00000000..b3c68f1b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/result_005.vtu @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c5e0a10e6c3f30addeb8595c27f531146fdf22e7d00e132c2b5b6cd01adfd89 +size 208368 diff --git a/tests/cases/fsi/pipe_3d_petsc/results.gif b/tests/cases/fsi/pipe_3d_petsc/results.gif new file mode 100644 index 00000000..0c87216b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/results.gif @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1f98ef6a06de4f38d40481ea5feb61f0a453cfe134b9afd1f6b04ffd3f6652d +size 3051594 diff --git a/tests/cases/fsi/pipe_3d_petsc/svFSI.xml b/tests/cases/fsi/pipe_3d_petsc/svFSI.xml new file mode 100755 index 00000000..329e794e --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/svFSI.xml @@ -0,0 +1,157 @@ + + + + + 0 + 3 + 5 + 1e-4 + 0.50 + STOP_SIM + true + result + 5 + 1 + 100 + 0 + 1 + 0 + 0 + + + + mesh/fluid/mesh-complete.mesh.vtu + + mesh/fluid/mesh-surfaces/start.vtp + + + mesh/fluid/mesh-surfaces/end.vtp + + + mesh/fluid/mesh-surfaces/interface.vtp + + 0 + + + + + mesh/solid/mesh-complete.mesh.vtu + + mesh/solid/mesh-surfaces/start.vtp + + + mesh/solid/mesh-surfaces/end.vtp + + + mesh/solid/mesh-surfaces/interface.vtp + + + mesh/solid/mesh-surfaces/outside.vtp + + 1 + + + + lumen_wall + + + + true + 1 + 7 + 1e-12 + + + fluid + 1.0 + + 0.04 + + 0.2 + + + + struct + + M94 + 1.0 + 1.0e7 + 0.3 + + + + + petsc-jacobi + + 1e-6 + 1e-12 + 100 + 50 + + + + true + true + true + true + + + + FS_Displacement + + + + Neu + 5.0e4 + + + + Dir + 0.0 + true + false + (0, 0, 1) + + + + Dir + 0.0 + true + false + (0, 0, 1 ) + + + + + + + true + 1 + 7 + 1e-12 + 0.3 + + + + fsils + + 1e-12 + + + + true + + + + Dir + 0.0 + + + + Dir + 0.0 + + + + + diff --git a/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml b/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml index bf19dc23..917c0608 100755 --- a/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml +++ b/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml @@ -62,6 +62,9 @@ + + fsils + 100 1e-12 diff --git a/tests/cases/heats/diffusion_line_source/svFSI_CG.xml b/tests/cases/heats/diffusion_line_source/svFSI_CG.xml index 99579a64..adb0a73c 100755 --- a/tests/cases/heats/diffusion_line_source/svFSI_CG.xml +++ b/tests/cases/heats/diffusion_line_source/svFSI_CG.xml @@ -62,7 +62,9 @@ - RCS + + rcs + 1e-12 diff --git a/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml b/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml index f3f60bba..52002bd5 100755 --- a/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml +++ b/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml @@ -62,7 +62,9 @@ - FSILS + + fsils + 100 1e-12 50 diff --git a/tests/cases/shell/plate/svFSI.xml b/tests/cases/shell/plate/svFSI.xml index 9b03ff7d..12d9d47e 100644 --- a/tests/cases/shell/plate/svFSI.xml +++ b/tests/cases/shell/plate/svFSI.xml @@ -69,6 +69,9 @@ + + fsils + 1e-12 100 50 diff --git a/tests/cases/shell/valve/svFSI.xml b/tests/cases/shell/valve/svFSI.xml index a03b5554..5df6e564 100644 --- a/tests/cases/shell/valve/svFSI.xml +++ b/tests/cases/shell/valve/svFSI.xml @@ -111,6 +111,9 @@ + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml index 6f726a08..6c841099 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml @@ -54,7 +54,9 @@ 10.0 - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml index 41d99f7a..9f7c24e5 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml @@ -54,7 +54,9 @@ 10.0 - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml index 91dd1cfa..a2337808 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml @@ -54,7 +54,10 @@ 10.0 - svfsi + + fsils + + 1e-9 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml index e394d60f..77e5a9ee 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml @@ -54,7 +54,9 @@ 10.0 - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml index 321c300b..601115cb 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml @@ -60,7 +60,9 @@ 10.0 - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml index 779ed2cf..ff3cd9cc 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml @@ -60,8 +60,9 @@ 10.0 - - Trilinos-ILUT + + trilinos-ilut + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml index b822d29a..48712fbf 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml @@ -60,8 +60,9 @@ 10.0 - - Trilinos-ILUT + + trilinos-ilut + 1e-9 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml index 46c215b6..815e63f3 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml @@ -54,8 +54,9 @@ 0.0 - - Trilinos-Diagonal + + trilinos-diagnonal + 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml index b5b0d685..0238139f 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml @@ -54,8 +54,9 @@ 0.0 - - Trilinos-Diagonal + + trilinos-diagnonal + 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml index ce4617c7..54288f9b 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml @@ -54,8 +54,9 @@ 0.0 - - Trilinos-Diagonal + + trilinos-diagnonal + 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml index 0a3535cf..f2fbdd7b 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml @@ -54,9 +54,9 @@ 0.0 - - - Trilinos-Diagonal + + trilinos-diagnonal + 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml index fa557672..60fac398 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml @@ -54,7 +54,9 @@ 0.0 - RCS + + rcs + 1e-9 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml index 3efaab47..ff2a7758 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml @@ -54,7 +54,9 @@ 0.0 - RCS + + rcs + 1e-9 100 50 diff --git a/tests/cases/struct/LV_Guccione_passive/svFSI.xml b/tests/cases/struct/LV_Guccione_passive/svFSI.xml index fae73d81..4f1086c7 100644 --- a/tests/cases/struct/LV_Guccione_passive/svFSI.xml +++ b/tests/cases/struct/LV_Guccione_passive/svFSI.xml @@ -79,7 +79,9 @@ - FSILS + + fsils + 1e-14 400 @@ -99,4 +101,4 @@
- \ No newline at end of file + diff --git a/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml b/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml index e08d1e22..2253a66b 100644 --- a/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml +++ b/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml @@ -44,10 +44,10 @@ mesh/fibersLongCells.vtu mesh/fibersSheetCells.vtu - 100.0 + 100.0 - + true @@ -55,16 +55,16 @@ 4 1e-10 - 1.0 - 1.0e6 + 1.0 + 1.0e6 0.483333 0.0 - 590.0 - 8.023 + 590.0 + 8.023 184720.0 16.026 24810.0 @@ -88,7 +88,9 @@ - FSILS + + fsils + 1e-12 1000 50 @@ -96,8 +98,8 @@ Robin - 1.0e7 - 5.0e2 + 1.0e7 + 5.0e2 1 diff --git a/tests/cases/struct/block_compression/svFSI.xml b/tests/cases/struct/block_compression/svFSI.xml index 8a2536cf..8571d652 100644 --- a/tests/cases/struct/block_compression/svFSI.xml +++ b/tests/cases/struct/block_compression/svFSI.xml @@ -84,7 +84,9 @@ - FSILS + + fsils + 1e-12 600 diff --git a/tests/cases/struct/robin/svFSI.xml b/tests/cases/struct/robin/svFSI.xml index 05581f91..3ca743fd 100644 --- a/tests/cases/struct/robin/svFSI.xml +++ b/tests/cases/struct/robin/svFSI.xml @@ -71,7 +71,9 @@ - FSILS + + fsils + 1e-12 600 diff --git a/tests/cases/ustruct/LV_Guccione_active/result_001.vtu b/tests/cases/ustruct/LV_Guccione_active/result_001.vtu index 6a022183..20dc8af9 100644 --- a/tests/cases/ustruct/LV_Guccione_active/result_001.vtu +++ b/tests/cases/ustruct/LV_Guccione_active/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9a063d96839c465428d82ffc4638c16feb3a33d9ee49422353b5f300f5b79479 -size 45994 +oid sha256:e96385b077d909be53eb8db6d7b3fe23a485aa1c7183af28920474128126f622 +size 71817 diff --git a/tests/cases/ustruct/LV_Guccione_active/svFSI.xml b/tests/cases/ustruct/LV_Guccione_active/svFSI.xml index 493e198e..1589360f 100644 --- a/tests/cases/ustruct/LV_Guccione_active/svFSI.xml +++ b/tests/cases/ustruct/LV_Guccione_active/svFSI.xml @@ -75,7 +75,9 @@ - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml b/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml index 85f3e4a5..d723f84d 100644 --- a/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml +++ b/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml @@ -91,7 +91,9 @@ - svfsi + + fsils + 1e-12 100 500 diff --git a/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml b/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml index dab127b8..70c94d93 100644 --- a/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml +++ b/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml @@ -95,7 +95,9 @@ - FSILS + + fsils + 1e-12 100 50 diff --git a/tests/conftest.py b/tests/conftest.py index 4c4fd670..cde4acfa 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,18 +2,21 @@ import pytest import os -import shutil +import platform import subprocess import meshio +is_not_Darwin = True +if platform.system() == "Darwin": is_not_Darwin = False + this_file_dir = os.path.abspath(os.path.dirname(__file__)) cpp_exec = os.path.join(this_file_dir, "..", "build", "svFSI-build", "bin", "svFSI") +cpp_exec_p = os.path.join(this_file_dir, "..", "build-petsc", "svFSI-build", "bin", "svFSI") # Relative tolerances for each tested field RTOL = { "Action_potential": 1.0e-10, "Cauchy_stress": 1.0e-4, - "Concentration": 1.0e-10, "Def_grad": 1.0e-10, "Divergence": 1.0e-9, "Displacement": 1.0e-10, @@ -51,23 +54,45 @@ def run_by_name(folder, name, t_max, n_proc=1): Returns: Simulation results """ - - # remove old results folders if they exist - dir_path = os.path.join(folder, str(n_proc) + "-procs") - if os.path.exists(dir_path): - shutil.rmtree(dir_path) - # run simulation - cmd = " ".join( - [ - "mpirun", - "--oversubscribe" if n_proc > 1 else "", - "-np", - str(n_proc), - cpp_exec, - name, - ] - ) + if is_not_Darwin: + if folder.endswith("petsc"): + cmd = " ".join( + [ + "mpirun", + "--oversubscribe" if n_proc > 1 else "", + "-np", + str(n_proc), + cpp_exec_p, + name, + ] + ) + else: + cmd = " ".join( + [ + "mpirun", + "--oversubscribe" if n_proc > 1 else "", + "-np", + str(n_proc), + cpp_exec, + name, + ] + ) + else: + if folder.endswith("petsc") or folder.endswith("trilinos"): + return + else: + cmd = " ".join( + [ + "mpirun", + "--oversubscribe" if n_proc > 1 else "", + "-np", + str(n_proc), + cpp_exec, + name, + ] + ) + subprocess.call(cmd, cwd=folder, shell=True) # read results @@ -104,7 +129,14 @@ def run_with_reference( # run simulation folder = os.path.join("cases", base_folder, test_folder) - res = run_by_name(folder, name_inp, t_max, n_proc) + + if is_not_Darwin: + res = run_by_name(folder, name_inp, t_max, n_proc) + else: + if folder.endswith("petsc") or folder.endswith("trilinos"): + return + else: + res = run_by_name(folder, name_inp, t_max, n_proc) # read reference fname = os.path.join(folder, name_ref) diff --git a/tests/test_fluid.py b/tests/test_fluid.py index 7317f571..7ba8214d 100644 --- a/tests/test_fluid.py +++ b/tests/test_fluid.py @@ -12,6 +12,20 @@ def test_pipe_RCR_3d(n_proc): t_max = 2 run_with_reference(base_folder, test_folder, fields, n_proc, t_max) +def test_pipe_RCR_3d_petsc(n_proc): + test_folder = "pipe_RCR_3d_petsc" + t_max = 2 + run_with_reference(base_folder, test_folder, fields, n_proc, t_max) + +def test_pipe_RCR_3d_trilinos_ilut(n_proc): + test_folder = "pipe_RCR_3d_ilut_trilinos" + t_max = 2 + run_with_reference(base_folder, test_folder, fields, n_proc, t_max) + +def test_pipe_RCR_3d_trilinos_bj(n_proc): + test_folder = "pipe_RCR_3d_bj_trilinos" + t_max = 2 + run_with_reference(base_folder, test_folder, fields, n_proc, t_max) def test_driven_cavity_2d(n_proc): test_folder = "driven_cavity_2d" @@ -23,9 +37,6 @@ def test_dye_AD(n_proc): test_folder = "dye_AD" run_with_reference(base_folder, test_folder, fields, n_proc) -def test_precomputed_dye_AD(n_proc): - test_folder = "precomputed_dye_AD" - run_with_reference(base_folder, test_folder, ['Velocity', 'Concentration'], n_proc) def test_newtonian(n_proc): test_folder = "newtonian" diff --git a/tests/test_fsi.py b/tests/test_fsi.py index 3ce3103f..b022f363 100644 --- a/tests/test_fsi.py +++ b/tests/test_fsi.py @@ -11,3 +11,18 @@ def test_pipe_3d(n_proc): test_folder = "pipe_3d" t_max = 5 run_with_reference(base_folder, test_folder, fields, n_proc, t_max) + +def test_pipe_3d_petsc(n_proc): + test_folder = "pipe_3d_petsc" + t_max = 5 + run_with_reference(base_folder, test_folder, fields, n_proc, t_max) + +def test_pipe_3d_trilinos_bj(n_proc): + test_folder = "pipe_3d_bj_trilinos" + t_max = 5 + run_with_reference(base_folder, test_folder, fields, n_proc, t_max) + +def test_pipe_3d_trilinos_ml(n_proc): + test_folder = "pipe_3d_ml_trilinos" + t_max = 5 + run_with_reference(base_folder, test_folder, fields, n_proc, t_max) \ No newline at end of file diff --git a/tests/test_struct.py b/tests/test_struct.py index b6658479..5376207d 100644 --- a/tests/test_struct.py +++ b/tests/test_struct.py @@ -1,6 +1,4 @@ from .conftest import run_with_reference -import os -import subprocess # Common folder for all tests in this file base_folder = "struct" @@ -33,29 +31,7 @@ def test_block_compression(n_proc): test_folder = "block_compression" run_with_reference(base_folder, test_folder, fields, n_proc) + def test_robin(n_proc): test_folder = "robin" run_with_reference(base_folder, test_folder, fields, n_proc) - -def test_LV_NeoHookean_passive(n_proc): - test_folder = "LV_NeoHookean_passive" - run_with_reference(base_folder, test_folder, fields, n_proc, t_max=5) - -def test_LV_NeoHookean_passive_genBC(n_proc): - test_folder = "LV_NeoHookean_passive_genBC" - - # Remove old genBC output - os.chdir(os.path.join("cases", base_folder, test_folder)) - for name in ["AllData", "InitialData", "GenBC.int"]: - if os.path.isfile(name): - os.remove(name) - - # Compile genBC - os.chdir("genBC_svFSIplus") - subprocess.run(["make", "clean"], check=True) - subprocess.run(["make"], check=True) - - # Change back to original directory - os.chdir("../../../../") - - run_with_reference(base_folder, test_folder, fields, n_proc, t_max=3) diff --git a/tests/test_ustruct.py b/tests/test_ustruct.py index f60b853d..b276edeb 100644 --- a/tests/test_ustruct.py +++ b/tests/test_ustruct.py @@ -1,6 +1,5 @@ import os import pytest -import subprocess from .conftest import run_with_reference @@ -33,22 +32,3 @@ def test_tensile_adventitia_HGO(n_proc): def test_LV_Guccione_active(n_proc): test_folder = "LV_Guccione_active" run_with_reference(base_folder, test_folder, fields, n_proc) - -def test_LV_NeoHookean_passive_genBC(n_proc): - test_folder = "LV_NeoHookean_passive_genBC" - - # Remove old genBC output - os.chdir(os.path.join("cases", base_folder, test_folder)) - for name in ["AllData", "InitialData", "GenBC.int"]: - if os.path.isfile(name): - os.remove(name) - - # Compile genBC - os.chdir("genBC_svFSIplus") - subprocess.run(["make", "clean"], check=True) - subprocess.run(["make"], check=True) - - # Change back to original directory - os.chdir("../../../../") - - run_with_reference(base_folder, test_folder, fields, n_proc, t_max=3) From b1ef0d43b358832185c0e7f288f9eff344c2c4bf Mon Sep 17 00:00:00 2001 From: dcodoni Date: Tue, 14 May 2024 14:48:10 -0700 Subject: [PATCH 2/6] Adding Docker/ folder containing dockerfiles. --- Docker/ubuntu20-on-mac-host/dockerfile | 620 +++++++++++++++++++++++++ Docker/ubuntu20/dockerfile | 617 ++++++++++++++++++++++++ Docker/ubuntu22-on-mac-host/dockerfile | 620 +++++++++++++++++++++++++ Docker/ubuntu22/dockerfile | 618 ++++++++++++++++++++++++ 4 files changed, 2475 insertions(+) create mode 100644 Docker/ubuntu20-on-mac-host/dockerfile create mode 100644 Docker/ubuntu20/dockerfile create mode 100644 Docker/ubuntu22-on-mac-host/dockerfile create mode 100644 Docker/ubuntu22/dockerfile diff --git a/Docker/ubuntu20-on-mac-host/dockerfile b/Docker/ubuntu20-on-mac-host/dockerfile new file mode 100644 index 00000000..de5eb170 --- /dev/null +++ b/Docker/ubuntu20-on-mac-host/dockerfile @@ -0,0 +1,620 @@ +# ================================================================================ +# CMAKE +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildcmake + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting CMake version CMake installation directory +ARG CMAKE_VERSION=3.29.0 +ARG CMAKE_INSTALL_DIR=/cmake + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \ + tar -xzvf cmake-${CMAKE_VERSION}.tar.gz && \ + rm cmake-${CMAKE_VERSION}.tar.gz + +WORKDIR /cmake-${CMAKE_VERSION} +RUN ./bootstrap --prefix=${CMAKE_INSTALL_DIR} && \ + make -j6 && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /cmake-${CMAKE_VERSION} + +# ================================================================================ +# OPENMPI +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildompi + +# Copy cmake binary from buildcmake +COPY --from=buildcmake /cmake /cmake + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting OMPI version OMPI installation directory +ARG OMPI_VERSION=5.0.2 +ARG OMPI_INSTALL_DIR=/openmpi + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-${OMPI_VERSION}.tar.gz && \ + tar -xzvf openmpi-${OMPI_VERSION}.tar.gz && \ + rm openmpi-${OMPI_VERSION}.tar.gz + +WORKDIR /openmpi-${OMPI_VERSION} +RUN ./configure --prefix=${OMPI_INSTALL_DIR} && \ + make -j6 all && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /openmpi-${OMPI_VERSION} + +# ================================================================================ +# VTK +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildvtk + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting VTK version VTK installation directory +ARG VTK_VERSION=9.3.0 +ARG VTK_INSTALL_DIR=/vtk + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://www.vtk.org/files/release/9.3/VTK-${VTK_VERSION}.tar.gz && \ + tar -xzvf VTK-${VTK_VERSION}.tar.gz && \ + rm VTK-${VTK_VERSION}.tar.gz + +WORKDIR /build-vtk +RUN cmake -DBUILD_SHARED_LIBS:BOOL=OFF \ +-DCMAKE_BUILD_TYPE:STRING=RELEASE \ +-DBUILD_EXAMPLES=OFF \ +-DBUILD_TESTING=OFF \ +-DVTK_USE_SYSTEM_EXPAT:BOOL=ON \ +-DVTK_USE_SYSTEM_ZLIB:BOOL=ON \ +-DVTK_LEGACY_REMOVE=ON \ +-DVTK_Group_Rendering=OFF \ +-DVTK_Group_StandAlone=OFF \ +-DVTK_RENDERING_BACKEND=None \ +-DVTK_WRAP_PYTHON=OFF \ +-DModule_vtkChartsCore=ON \ +-DModule_vtkCommonCore=ON \ +-DModule_vtkCommonDataModel=ON \ +-DModule_vtkCommonExecutionModel=ON \ +-DModule_vtkFiltersCore=ON \ +-DModule_vtkFiltersFlowPaths=ON \ +-DModule_vtkFiltersModeling=ON \ +-DModule_vtkIOLegacy=ON \ +-DModule_vtkIOXML=ON \ +-DVTK_GROUP_ENABLE_Views=NO \ +-DVTK_GROUP_ENABLE_Web=NO \ +-DVTK_GROUP_ENABLE_Imaging=NO \ +-DVTK_GROUP_ENABLE_Qt=DONT_WANT \ +-DVTK_GROUP_ENABLE_Rendering=DONT_WANT \ +-DCMAKE_INSTALL_PREFIX=${VTK_INSTALL_DIR} /VTK-${VTK_VERSION} && \ + cmake --build . --parallel 4 && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /VTK-${VTK_VERSION} build-vtk + +# ================================================================================ +# BOOST +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildboost + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting Boost version Boost installation directory +ARG BOOST_VERSION=1_84_0 +ARG BOOST_INSTALL_DIR=/boost + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_${BOOST_VERSION}.tar.gz && \ + tar -xzvf boost_${BOOST_VERSION}.tar.gz && \ + rm boost_${BOOST_VERSION}.tar.gz + +WORKDIR /boost_${BOOST_VERSION} +RUN ./bootstrap.sh --prefix=${BOOST_INSTALL_DIR} && \ + ./b2 install + +# Cleanup +WORKDIR / +RUN rm -rf /boost_${BOOST_VERSION} + +# ================================================================================ +# LAPACK +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildlapack + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting lapack installation directory +ARG LAPACK_INSTALL_DIR=/tmp/lapack + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/Reference-LAPACK/lapack.git +WORKDIR /build +RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_LIBDIR=${LAPACK_INSTALL_DIR} ../lapack && \ + cmake --build . -j6 --target install + +# Cleanup +WORKDIR / +RUN rm -rf /build /lapack + +# ================================================================================ +# BLAS (USE FROM LAPACK INSTALLATION) +# ================================================================================ +# Use a base image for building tools and dependencise +#FROM ubuntu:20.04 AS buildblas + +# Copy cmake binary from buildcmake and set ENV +#COPY --from=buildcmake /cmake /cmake + +#ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +#ENV DEBIAN_FRONTEND=noninteractive + +# Setting blas version and installation directory +#ARG BLAS_VERSION=3.12.0 +#ARG BLAS_INSTALL_DIR=/blas + +# Create new user +#RUN useradd -ms /bin/bash luser + +# Install essentials tools +#RUN apt-get update && \ +# apt-get install -y \ +# build-essential wget git \ +# python3 gfortran default-jdk default-jre \ +# libglu1-mesa-dev freeglut3-dev mesa-common-dev \ +# openssl libssl-dev zlib1g-dev libicu-dev && \ +# apt-get clean && \ +# rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +#RUN wget http://www.netlib.org/blas/blas-${BLAS_VERSION}.tgz && \ +# tar -xvf blas-${BLAS_VERSION}.tgz && \ +# rm blas-${BLAS_VERSION}.tgz + +#WORKDIR /build +#RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${BLAS_INSTALL_DIR} ../BLAS-${BLAS_VERSION} && \ +# make && \ +# make install + +# Cleanup +#WORKDIR / +#RUN rm -rf /BLAS-${BLAS_VERSION} /build + +# ================================================================================ +# HDF5 +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildhdf5 + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi/ + +ENV PATH="/cmake/bin:/openmpi:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hdf5 installation directories +ARG HDF5_INSTALL_DIR=/hdf5 + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +WORKDIR /hdf5build + +# setting luser permission to directories and changing user to luser +# this allows the HDF5 tests to run smoothly +RUN chown -R luser:luser /hdf5build && \ + chown -R luser:luser /usr/lib/aarch64-linux-gnu + +RUN mkdir ${HDF5_INSTALL_DIR} && \ + chown -R luser:luser ${HDF5_INSTALL_DIR} + +# USER luser +RUN git clone https://github.com/HDFGroup/hdf5.git + +# Build HDF5 +WORKDIR /hdf5build + +RUN cmake -C /hdf5build/hdf5/config/cmake/cacheinit.cmake -G "Unix Makefiles" \ +-DHDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16:BOOL=OFF \ +-DHDF5_ENABLE_PARALLEL:BOOL=ON \ +-DALLOW_UNSUPPORTED:BOOL=ON \ +-DCMAKE_BUILD_TYPE=Release \ +-DCMAKE_INSTALL_PREFIX=${HDF5_INSTALL_DIR} /hdf5build/hdf5 +RUN cmake --build . && \ + make install + +# For testing +# ctest . -C --rerun-failed --output-on-failure && \ + +# Cleanup +USER root +WORKDIR / +RUN rm -rf /hdf5build + +# ================================================================================ +# HYPRE +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildhypre + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildlapack /tmp/lapack /lapack/ + +ENV PATH="/cmake/bin:/openmpi/bin:/lapack:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hypre installation directory +ARG HYPRE_INSTALL_DIR=/hypre-install + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/hypre-space/hypre.git + +WORKDIR /hypre/src/ +RUN ./configure --prefix=${HYPRE_INSTALL_DIR} && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /hypre + +# ================================================================================ +# TRILINOS +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildtrilinos + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ + +ENV PATH="/cmake/bin:/openmpi/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hypre installation directory +ARG TRILINOS_INSTALL_DIR=/trilinos + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN ln -s /usr/bin/python3 /usr/bin/python + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/trilinos/Trilinos.git +WORKDIR /Trilinos/build + +# Build trilinos +#-DTPL_ENABLE_MUMPS=ON \ +RUN cmake \ +-DCMAKE_INSTALL_PREFIX=${TRILINOS_INSTALL_DIR} \ +-DTPL_ENABLE_MPI=ON \ +-DTPL_ENABLE_Boost=ON \ +-DBoost_LIBRARY_DIRS=/boost/lib \ +-DBoost_INCLUDE_DIRS=/boost/include \ +-DTPL_ENABLE_BLAS=ON \ +-DBLAS_LIBRARY_DIRS=/lapack \ +-DTPL_ENABLE_HDF5=ON \ +-DHDF5_LIBRARY_DIRS=/hdf5/lib \ +-DHDF5_INCLUDE_DIRS=/hdf5/include \ +-DTPL_ENABLE_HYPRE=ON \ +-DHYPRE_LIBRARY_DIRS=/hypre/lib \ +-DHYPRE_INCLUDE_DIRS=/hypre/include \ +-DTPL_ENABLE_LAPACK=ON \ +-DLAPACK_LIBRARY_DIRS=/lapack \ +-DCMAKE_C_COMPILER=/openmpi/bin/mpicc \ +-DCMAKE_CXX_COMPILER=/openmpi/bin/mpicxx \ +-DCMAKE_Fortran_COMPILER=/openmpi/bin/mpif90 \ +-DTrilinos_ENABLE_Epetra=ON \ +-DTrilinos_ENABLE_AztecOO=ON \ +-DTrilinos_ENABLE_Ifpack=ON \ +-DTrilinos_ENABLE_EpetraEXT=ON \ +-DTrilinos_ENABLE_Amesos=ON \ +-DTrilinos_ENABLE_ML=ON \ +-DTrilinos_ENABLE_MueLU=ON \ +-DTrilinos_ENABLE_ROL=ON \ +-DTrilinos_ENABLE_Sacado=ON \ +-DTrilinos_ENABLE_Teuchos=ON \ +-DTrilinos_ENABLE_Zoltan=ON \ +/Trilinos && \ +make -j6 install + +# Cleanup +WORKDIR / +RUN rm -rf Trilinos + + +# ================================================================================ +# PETSC +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildpetsc + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting petsc installation directory +ARG PETSC_INSTALL_DIR=/petsc-install + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# By default the cmake is looking for python and not python3 +# The following line creates a symbolic link python->python3 +RUN ln -s /usr/bin/python3 /usr/bin/python + +# ================================================================================ +# Download and install +RUN git clone -b release https://gitlab.com/petsc/petsc.git + +# Set permission for luser +RUN chown -R luser:luser /petsc + +RUN mkdir ${PETSC_INSTALL_DIR} && \ + chown -R luser:luser ${PETSC_INSTALL_DIR} + +# Switch user (petsc should be installed by non-root) +USER luser + +WORKDIR /petsc + +# Install petsc library in $PETSC_INSTALL_DIR +# Libraries path must be set explicitly +RUN ./configure --prefix=$PETSC_INSTALL_DIR \ +--with-debugging=0 \ +--with-precision=double \ +--download-suitesparse \ +--download-mumps \ +--download-superlu \ +--download-superlu_dist \ +--download-ml \ +--download-eigen \ +--download-hypre \ +--with-mpi-dir=/openmpi \ +--with-blas-lib=/lapack/libblas.so \ +--with-lapack-lib=/lapack/liblapack.so \ +--download-scalapack \ +--download-metis \ +--download-parmetis \ +--with-strict-petscerrorcode \ +--with-mpi-compilers=1 \ +COPTFLAGS='-g -O' \ +FOPTFLAGS='-g -O' \ +CXXOPTFLAGS='-g -O' && \ +make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt all && \ +make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt install && \ +make PETSC_DIR=$PETSC_INSTALL_DIR PETSC_ARCH="" check + +# Cleanup +USER root +WORKDIR / +RUN rm -rf /petsc + + +# ================================================================================ +# FINAL IMAGE +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS final + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git git-lfs lcov \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Copy all libraries and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildvtk /vtk /vtk +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ +COPY --from=buildtrilinos /trilinos /trilinos +COPY --from=buildpetsc /petsc-install /petsc + +# ================================================================================ +# CONDA +ENV CONDA_DIR /conda +RUN ls -l /lib/ +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O /miniconda.sh && \ + /bin/bash /miniconda.sh -b -p $CONDA_DIR + +# Set conda environment +ENV PATH="${CONDA_DIR}/bin:${PATH}" + +# Create and activate Conda environment +RUN conda create -y -n svfsiplus && \ + conda run -n svfsiplus pip install pytest pytest-cov pytest-mock numpy meshio pandas + +# Set libraries environment +ENV PATH="/vtk:/openmpi/bin:/cmake/bin:/trilinos/lib/cmake/Trilinos:${PATH}" +ENV LD_LIBRARY_PATH="/petsc/lib:/lapack:$LD_LIBRARY_PATH" + +ENV OMPI_ALLOW_RUN_AS_ROOT=1 +ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/Docker/ubuntu20/dockerfile b/Docker/ubuntu20/dockerfile new file mode 100644 index 00000000..cc1dada8 --- /dev/null +++ b/Docker/ubuntu20/dockerfile @@ -0,0 +1,617 @@ +# ================================================================================ +# CMAKE +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildcmake + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting CMake version CMake installation directory +ARG CMAKE_VERSION=3.29.0 +ARG CMAKE_INSTALL_DIR=/cmake + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \ + tar -xzvf cmake-${CMAKE_VERSION}.tar.gz && \ + rm cmake-${CMAKE_VERSION}.tar.gz + +WORKDIR /cmake-${CMAKE_VERSION} +RUN ./bootstrap --prefix=${CMAKE_INSTALL_DIR} && \ + make -j6 && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /cmake-${CMAKE_VERSION} + +# ================================================================================ +# OPENMPI +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildompi + +# Copy cmake binary from buildcmake +COPY --from=buildcmake /cmake /cmake + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting OMPI version OMPI installation directory +ARG OMPI_VERSION=5.0.2 +ARG OMPI_INSTALL_DIR=/openmpi + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-${OMPI_VERSION}.tar.gz && \ + tar -xzvf openmpi-${OMPI_VERSION}.tar.gz && \ + rm openmpi-${OMPI_VERSION}.tar.gz + +WORKDIR /openmpi-${OMPI_VERSION} +RUN ./configure --prefix=${OMPI_INSTALL_DIR} && \ + make -j6 all && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /openmpi-${OMPI_VERSION} + +# ================================================================================ +# VTK +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildvtk + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting VTK version VTK installation directory +ARG VTK_VERSION=9.3.0 +ARG VTK_INSTALL_DIR=/vtk + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://www.vtk.org/files/release/9.3/VTK-${VTK_VERSION}.tar.gz && \ + tar -xzvf VTK-${VTK_VERSION}.tar.gz && \ + rm VTK-${VTK_VERSION}.tar.gz + +WORKDIR /build-vtk +RUN cmake -DBUILD_SHARED_LIBS:BOOL=OFF \ +-DCMAKE_BUILD_TYPE:STRING=RELEASE \ +-DBUILD_EXAMPLES=OFF \ +-DBUILD_TESTING=OFF \ +-DVTK_USE_SYSTEM_EXPAT:BOOL=ON \ +-DVTK_USE_SYSTEM_ZLIB:BOOL=ON \ +-DVTK_LEGACY_REMOVE=ON \ +-DVTK_Group_Rendering=OFF \ +-DVTK_Group_StandAlone=OFF \ +-DVTK_RENDERING_BACKEND=None \ +-DVTK_WRAP_PYTHON=OFF \ +-DModule_vtkChartsCore=ON \ +-DModule_vtkCommonCore=ON \ +-DModule_vtkCommonDataModel=ON \ +-DModule_vtkCommonExecutionModel=ON \ +-DModule_vtkFiltersCore=ON \ +-DModule_vtkFiltersFlowPaths=ON \ +-DModule_vtkFiltersModeling=ON \ +-DModule_vtkIOLegacy=ON \ +-DModule_vtkIOXML=ON \ +-DVTK_GROUP_ENABLE_Views=NO \ +-DVTK_GROUP_ENABLE_Web=NO \ +-DVTK_GROUP_ENABLE_Imaging=NO \ +-DVTK_GROUP_ENABLE_Qt=DONT_WANT \ +-DVTK_GROUP_ENABLE_Rendering=DONT_WANT \ +-DCMAKE_INSTALL_PREFIX=${VTK_INSTALL_DIR} /VTK-${VTK_VERSION} && \ + cmake --build . --parallel 4 && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /VTK-${VTK_VERSION} build-vtk + +# ================================================================================ +# BOOST +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildboost + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting Boost version Boost installation directory +ARG BOOST_VERSION=1_84_0 +ARG BOOST_INSTALL_DIR=/boost + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_${BOOST_VERSION}.tar.gz && \ + tar -xzvf boost_${BOOST_VERSION}.tar.gz && \ + rm boost_${BOOST_VERSION}.tar.gz + +WORKDIR /boost_${BOOST_VERSION} +RUN ./bootstrap.sh --prefix=${BOOST_INSTALL_DIR} && \ + ./b2 install + +# Cleanup +WORKDIR / +RUN rm -rf /boost_${BOOST_VERSION} + +# ================================================================================ +# LAPACK +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildlapack + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting lapack installation directory +ARG LAPACK_INSTALL_DIR=/tmp/lapack + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/Reference-LAPACK/lapack.git +WORKDIR /build +RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_LIBDIR=${LAPACK_INSTALL_DIR} ../lapack && \ + cmake --build . -j6 --target install + +# Cleanup +WORKDIR / +RUN rm -rf /build /lapack + +# ================================================================================ +# BLAS (USE FROM LAPACK INSTALLATION) +# ================================================================================ +# Use a base image for building tools and dependencise +#FROM ubuntu:20.04 AS buildblas + +# Copy cmake binary from buildcmake and set ENV +#COPY --from=buildcmake /cmake /cmake + +#ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +#ENV DEBIAN_FRONTEND=noninteractive + +# Setting blas version and installation directory +#ARG BLAS_VERSION=3.12.0 +#ARG BLAS_INSTALL_DIR=/blas + +# Create new user +#RUN useradd -ms /bin/bash luser + +# Install essentials tools +#RUN apt-get update && \ +# apt-get install -y \ +# build-essential wget git \ +# python3 gfortran default-jdk default-jre \ +# libglu1-mesa-dev freeglut3-dev mesa-common-dev \ +# openssl libssl-dev zlib1g-dev libicu-dev && \ +# apt-get clean && \ +# rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +#RUN wget http://www.netlib.org/blas/blas-${BLAS_VERSION}.tgz && \ +# tar -xvf blas-${BLAS_VERSION}.tgz && \ +# rm blas-${BLAS_VERSION}.tgz + +#WORKDIR /build +#RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${BLAS_INSTALL_DIR} ../BLAS-${BLAS_VERSION} && \ +# make && \ +# make install + +# Cleanup +#WORKDIR / +#RUN rm -rf /BLAS-${BLAS_VERSION} /build + +# ================================================================================ +# HDF5 +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildhdf5 + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi/ + +ENV PATH="/cmake/bin:/openmpi:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hdf5 installation directories +ARG HDF5_INSTALL_DIR=/hdf5 + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +WORKDIR /hdf5build + +# setting luser permission to directories and changing user to luser +# this allows the HDF5 tests to run smoothly +RUN chown -R luser:luser /hdf5build && \ + chown -R luser:luser /usr/lib/x86_64-linux-gnu/ + +RUN mkdir ${HDF5_INSTALL_DIR} && \ + chown -R luser:luser ${HDF5_INSTALL_DIR} + +USER luser +RUN git clone https://github.com/HDFGroup/hdf5.git + +# Build HDF5 +WORKDIR /hdf5build/build +RUN cmake -C /hdf5build/hdf5/config/cmake/cacheinit.cmake -G "Unix Makefiles" \ +-DHDF5_ENABLE_PARALLEL:BOOL=ON \ +-DALLOW_UNSUPPORTED:BOOL=ON \ +-DCMAKE_BUILD_TYPE=Release \ +-DCMAKE_INSTALL_PREFIX=${HDF5_INSTALL_DIR} /hdf5build/hdf5 && \ + cmake --build . && \ + make install + +# For testing +# ctest . -C --rerun-failed --output-on-failure && \ + +# Cleanup +USER root +WORKDIR / +RUN rm -rf /hdf5build + +# ================================================================================ +# HYPRE +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildhypre + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildlapack /tmp/lapack /lapack/ + +ENV PATH="/cmake/bin:/openmpi/bin:/lapack:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hypre installation directory +ARG HYPRE_INSTALL_DIR=/hypre-install + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/hypre-space/hypre.git + +WORKDIR /hypre/src/ +RUN ./configure --prefix=${HYPRE_INSTALL_DIR} && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /hypre + +# ================================================================================ +# TRILINOS +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildtrilinos + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ + +ENV PATH="/cmake/bin:/openmpi/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hypre installation directory +ARG TRILINOS_INSTALL_DIR=/trilinos + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN ln -s /usr/bin/python3 /usr/bin/python + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/trilinos/Trilinos.git +WORKDIR /Trilinos/build + +# Build trilinos +#-DTPL_ENABLE_MUMPS=ON \ +RUN cmake \ +-DCMAKE_INSTALL_PREFIX=${TRILINOS_INSTALL_DIR} \ +-DTPL_ENABLE_MPI=ON \ +-DTPL_ENABLE_Boost=ON \ +-DBoost_LIBRARY_DIRS=/boost/lib \ +-DBoost_INCLUDE_DIRS=/boost/include \ +-DTPL_ENABLE_BLAS=ON \ +-DBLAS_LIBRARY_DIRS=/lapack \ +-DTPL_ENABLE_HDF5=ON \ +-DHDF5_LIBRARY_DIRS=/hdf5/lib \ +-DHDF5_INCLUDE_DIRS=/hdf5/include \ +-DTPL_ENABLE_HYPRE=ON \ +-DHYPRE_LIBRARY_DIRS=/hypre/lib \ +-DHYPRE_INCLUDE_DIRS=/hypre/include \ +-DTPL_ENABLE_LAPACK=ON \ +-DLAPACK_LIBRARY_DIRS=/lapack \ +-DCMAKE_C_COMPILER=/openmpi/bin/mpicc \ +-DCMAKE_CXX_COMPILER=/openmpi/bin/mpicxx \ +-DCMAKE_Fortran_COMPILER=/openmpi/bin/mpif90 \ +-DTrilinos_ENABLE_Epetra=ON \ +-DTrilinos_ENABLE_AztecOO=ON \ +-DTrilinos_ENABLE_Ifpack=ON \ +-DTrilinos_ENABLE_EpetraEXT=ON \ +-DTrilinos_ENABLE_Amesos=ON \ +-DTrilinos_ENABLE_ML=ON \ +-DTrilinos_ENABLE_MueLU=ON \ +-DTrilinos_ENABLE_ROL=ON \ +-DTrilinos_ENABLE_Sacado=ON \ +-DTrilinos_ENABLE_Teuchos=ON \ +-DTrilinos_ENABLE_Zoltan=ON \ +/Trilinos && \ +make -j6 install + +# Cleanup +WORKDIR / +RUN rm -rf Trilinos + + +# ================================================================================ +# PETSC +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildpetsc + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting petsc installation directory +ARG PETSC_INSTALL_DIR=/petsc-install + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# By default the cmake is looking for python and not python3 +# The following line creates a symbolic link python->python3 +RUN ln -s /usr/bin/python3 /usr/bin/python + +# ================================================================================ +# Download and install +RUN git clone -b release https://gitlab.com/petsc/petsc.git + +# Set permission for luser +RUN chown -R luser:luser /petsc + +RUN mkdir ${PETSC_INSTALL_DIR} && \ + chown -R luser:luser ${PETSC_INSTALL_DIR} + +# Switch user (petsc should be installed by non-root) +USER luser + +WORKDIR /petsc + +# Install petsc library in $PETSC_INSTALL_DIR +# Libraries path must be set explicitly +RUN ./configure --prefix=$PETSC_INSTALL_DIR \ +--with-debugging=0 \ +--with-precision=double \ +--download-suitesparse \ +--download-mumps \ +--download-superlu \ +--download-superlu_dist \ +--download-ml \ +--download-eigen \ +--download-hypre \ +--with-mpi-dir=/openmpi \ +--with-blas-lib=/lapack/libblas.so \ +--with-lapack-lib=/lapack/liblapack.so \ +--download-scalapack \ +--download-metis \ +--download-parmetis \ +--with-strict-petscerrorcode \ +--with-mpi-compilers=1 \ +COPTFLAGS='-g -O' \ +FOPTFLAGS='-g -O' \ +CXXOPTFLAGS='-g -O' && \ +make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt all && \ +make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt install && \ +make PETSC_DIR=$PETSC_INSTALL_DIR PETSC_ARCH="" check + +# Cleanup +USER root +WORKDIR / +RUN rm -rf /petsc + + +# ================================================================================ +# FINAL IMAGE +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS final + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git git-lfs lcov \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Copy all libraries and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildvtk /vtk /vtk +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ +COPY --from=buildtrilinos /trilinos /trilinos +COPY --from=buildpetsc /petsc-install /petsc + +# ================================================================================ +# CONDA +ENV CONDA_DIR /conda +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /miniconda.sh && \ + /bin/bash /miniconda.sh -b -p $CONDA_DIR + +# Set conda environment +ENV PATH="${CONDA_DIR}/bin:${PATH}" + +# Create and activate Conda environment +RUN conda create -y -n svfsiplus && \ + conda run -n svfsiplus pip install pytest pytest-cov pytest-mock numpy meshio pandas + +# Set libraries environment +ENV PATH="/vtk:/openmpi/bin:/cmake/bin:/trilinos/lib/cmake/Trilinos:${PATH}" +ENV LD_LIBRARY_PATH="/petsc/lib:/lapack:$LD_LIBRARY_PATH" + +ENV OMPI_ALLOW_RUN_AS_ROOT=1 +ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/Docker/ubuntu22-on-mac-host/dockerfile b/Docker/ubuntu22-on-mac-host/dockerfile new file mode 100644 index 00000000..03a0ce3b --- /dev/null +++ b/Docker/ubuntu22-on-mac-host/dockerfile @@ -0,0 +1,620 @@ +# ================================================================================ +# CMAKE +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildcmake + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting CMake version CMake installation directory +ARG CMAKE_VERSION=3.29.0 +ARG CMAKE_INSTALL_DIR=/cmake + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \ + tar -xzvf cmake-${CMAKE_VERSION}.tar.gz && \ + rm cmake-${CMAKE_VERSION}.tar.gz + +WORKDIR /cmake-${CMAKE_VERSION} +RUN ./bootstrap --prefix=${CMAKE_INSTALL_DIR} && \ + make -j6 && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /cmake-${CMAKE_VERSION} + +# ================================================================================ +# OPENMPI +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildompi + +# Copy cmake binary from buildcmake +COPY --from=buildcmake /cmake /cmake + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting OMPI version OMPI installation directory +ARG OMPI_VERSION=5.0.2 +ARG OMPI_INSTALL_DIR=/openmpi + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-${OMPI_VERSION}.tar.gz && \ + tar -xzvf openmpi-${OMPI_VERSION}.tar.gz && \ + rm openmpi-${OMPI_VERSION}.tar.gz + +WORKDIR /openmpi-${OMPI_VERSION} +RUN ./configure --prefix=${OMPI_INSTALL_DIR} && \ + make -j6 all && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /openmpi-${OMPI_VERSION} + +# ================================================================================ +# VTK +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildvtk + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting VTK version VTK installation directory +ARG VTK_VERSION=9.3.0 +ARG VTK_INSTALL_DIR=/vtk + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://www.vtk.org/files/release/9.3/VTK-${VTK_VERSION}.tar.gz && \ + tar -xzvf VTK-${VTK_VERSION}.tar.gz && \ + rm VTK-${VTK_VERSION}.tar.gz + +WORKDIR /build-vtk +RUN cmake -DBUILD_SHARED_LIBS:BOOL=OFF \ +-DCMAKE_BUILD_TYPE:STRING=RELEASE \ +-DBUILD_EXAMPLES=OFF \ +-DBUILD_TESTING=OFF \ +-DVTK_USE_SYSTEM_EXPAT:BOOL=ON \ +-DVTK_USE_SYSTEM_ZLIB:BOOL=ON \ +-DVTK_LEGACY_REMOVE=ON \ +-DVTK_Group_Rendering=OFF \ +-DVTK_Group_StandAlone=OFF \ +-DVTK_RENDERING_BACKEND=None \ +-DVTK_WRAP_PYTHON=OFF \ +-DModule_vtkChartsCore=ON \ +-DModule_vtkCommonCore=ON \ +-DModule_vtkCommonDataModel=ON \ +-DModule_vtkCommonExecutionModel=ON \ +-DModule_vtkFiltersCore=ON \ +-DModule_vtkFiltersFlowPaths=ON \ +-DModule_vtkFiltersModeling=ON \ +-DModule_vtkIOLegacy=ON \ +-DModule_vtkIOXML=ON \ +-DVTK_GROUP_ENABLE_Views=NO \ +-DVTK_GROUP_ENABLE_Web=NO \ +-DVTK_GROUP_ENABLE_Imaging=NO \ +-DVTK_GROUP_ENABLE_Qt=DONT_WANT \ +-DVTK_GROUP_ENABLE_Rendering=DONT_WANT \ +-DCMAKE_INSTALL_PREFIX=${VTK_INSTALL_DIR} /VTK-${VTK_VERSION} && \ + cmake --build . --parallel 4 && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /VTK-${VTK_VERSION} build-vtk + +# ================================================================================ +# BOOST +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildboost + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting Boost version Boost installation directory +ARG BOOST_VERSION=1_84_0 +ARG BOOST_INSTALL_DIR=/boost + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_${BOOST_VERSION}.tar.gz && \ + tar -xzvf boost_${BOOST_VERSION}.tar.gz && \ + rm boost_${BOOST_VERSION}.tar.gz + +WORKDIR /boost_${BOOST_VERSION} +RUN ./bootstrap.sh --prefix=${BOOST_INSTALL_DIR} && \ + ./b2 install + +# Cleanup +WORKDIR / +RUN rm -rf /boost_${BOOST_VERSION} + +# ================================================================================ +# LAPACK +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildlapack + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting lapack installation directory +ARG LAPACK_INSTALL_DIR=/tmp/lapack + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/Reference-LAPACK/lapack.git +WORKDIR /build +RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_LIBDIR=${LAPACK_INSTALL_DIR} ../lapack && \ + cmake --build . -j6 --target install + +# Cleanup +WORKDIR / +RUN rm -rf /build /lapack + +# ================================================================================ +# BLAS (USE FROM LAPACK INSTALLATION) +# ================================================================================ +# Use a base image for building tools and dependencise +#FROM ubuntu:20.04 AS buildblas + +# Copy cmake binary from buildcmake and set ENV +#COPY --from=buildcmake /cmake /cmake + +#ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +#ENV DEBIAN_FRONTEND=noninteractive + +# Setting blas version and installation directory +#ARG BLAS_VERSION=3.12.0 +#ARG BLAS_INSTALL_DIR=/blas + +# Create new user +#RUN useradd -ms /bin/bash luser + +# Install essentials tools +#RUN apt-get update && \ +# apt-get install -y \ +# build-essential wget git \ +# python3 gfortran default-jdk default-jre \ +# libglu1-mesa-dev freeglut3-dev mesa-common-dev \ +# openssl libssl-dev zlib1g-dev libicu-dev && \ +# apt-get clean && \ +# rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +#RUN wget http://www.netlib.org/blas/blas-${BLAS_VERSION}.tgz && \ +# tar -xvf blas-${BLAS_VERSION}.tgz && \ +# rm blas-${BLAS_VERSION}.tgz + +#WORKDIR /build +#RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${BLAS_INSTALL_DIR} ../BLAS-${BLAS_VERSION} && \ +# make && \ +# make install + +# Cleanup +#WORKDIR / +#RUN rm -rf /BLAS-${BLAS_VERSION} /build + +# ================================================================================ +# HDF5 +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildhdf5 + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi/ + +ENV PATH="/cmake/bin:/openmpi:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hdf5 installation directories +ARG HDF5_INSTALL_DIR=/hdf5 + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +WORKDIR /hdf5build + +# setting luser permission to directories and changing user to luser +# this allows the HDF5 tests to run smoothly +RUN chown -R luser:luser /hdf5build && \ + chown -R luser:luser /usr/lib/aarch64-linux-gnu + +RUN mkdir ${HDF5_INSTALL_DIR} && \ + chown -R luser:luser ${HDF5_INSTALL_DIR} + +# USER luser +RUN git clone https://github.com/HDFGroup/hdf5.git + +# Build HDF5 +WORKDIR /hdf5build + +RUN cmake -C /hdf5build/hdf5/config/cmake/cacheinit.cmake -G "Unix Makefiles" \ +-DHDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16:BOOL=OFF \ +-DHDF5_ENABLE_PARALLEL:BOOL=ON \ +-DALLOW_UNSUPPORTED:BOOL=ON \ +-DCMAKE_BUILD_TYPE=Release \ +-DCMAKE_INSTALL_PREFIX=${HDF5_INSTALL_DIR} /hdf5build/hdf5 +RUN cmake --build . && \ + make install + +# For testing +# ctest . -C --rerun-failed --output-on-failure && \ + +# Cleanup +USER root +WORKDIR / +RUN rm -rf /hdf5build + +# ================================================================================ +# HYPRE +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildhypre + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildlapack /tmp/lapack /lapack/ + +ENV PATH="/cmake/bin:/openmpi/bin:/lapack:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hypre installation directory +ARG HYPRE_INSTALL_DIR=/hypre-install + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/hypre-space/hypre.git + +WORKDIR /hypre/src/ +RUN ./configure --prefix=${HYPRE_INSTALL_DIR} && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /hypre + +# ================================================================================ +# TRILINOS +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildtrilinos + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ + +ENV PATH="/cmake/bin:/openmpi/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hypre installation directory +ARG TRILINOS_INSTALL_DIR=/trilinos + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN ln -s /usr/bin/python3 /usr/bin/python + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/trilinos/Trilinos.git +WORKDIR /Trilinos/build + +# Build trilinos +#-DTPL_ENABLE_MUMPS=ON \ +RUN cmake \ +-DCMAKE_INSTALL_PREFIX=${TRILINOS_INSTALL_DIR} \ +-DTPL_ENABLE_MPI=ON \ +-DTPL_ENABLE_Boost=ON \ +-DBoost_LIBRARY_DIRS=/boost/lib \ +-DBoost_INCLUDE_DIRS=/boost/include \ +-DTPL_ENABLE_BLAS=ON \ +-DBLAS_LIBRARY_DIRS=/lapack \ +-DTPL_ENABLE_HDF5=ON \ +-DHDF5_LIBRARY_DIRS=/hdf5/lib \ +-DHDF5_INCLUDE_DIRS=/hdf5/include \ +-DTPL_ENABLE_HYPRE=ON \ +-DHYPRE_LIBRARY_DIRS=/hypre/lib \ +-DHYPRE_INCLUDE_DIRS=/hypre/include \ +-DTPL_ENABLE_LAPACK=ON \ +-DLAPACK_LIBRARY_DIRS=/lapack \ +-DCMAKE_C_COMPILER=/openmpi/bin/mpicc \ +-DCMAKE_CXX_COMPILER=/openmpi/bin/mpicxx \ +-DCMAKE_Fortran_COMPILER=/openmpi/bin/mpif90 \ +-DTrilinos_ENABLE_Epetra=ON \ +-DTrilinos_ENABLE_AztecOO=ON \ +-DTrilinos_ENABLE_Ifpack=ON \ +-DTrilinos_ENABLE_EpetraEXT=ON \ +-DTrilinos_ENABLE_Amesos=ON \ +-DTrilinos_ENABLE_ML=ON \ +-DTrilinos_ENABLE_MueLU=ON \ +-DTrilinos_ENABLE_ROL=ON \ +-DTrilinos_ENABLE_Sacado=ON \ +-DTrilinos_ENABLE_Teuchos=ON \ +-DTrilinos_ENABLE_Zoltan=ON \ +/Trilinos && \ +make -j6 install + +# Cleanup +WORKDIR / +RUN rm -rf Trilinos + + +# ================================================================================ +# PETSC +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildpetsc + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting petsc installation directory +ARG PETSC_INSTALL_DIR=/petsc-install + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# By default the cmake is looking for python and not python3 +# The following line creates a symbolic link python->python3 +RUN ln -s /usr/bin/python3 /usr/bin/python + +# ================================================================================ +# Download and install +RUN git clone -b release https://gitlab.com/petsc/petsc.git + +# Set permission for luser +RUN chown -R luser:luser /petsc + +RUN mkdir ${PETSC_INSTALL_DIR} && \ + chown -R luser:luser ${PETSC_INSTALL_DIR} + +# Switch user (petsc should be installed by non-root) +USER luser + +WORKDIR /petsc + +# Install petsc library in $PETSC_INSTALL_DIR +# Libraries path must be set explicitly +RUN ./configure --prefix=$PETSC_INSTALL_DIR \ +--with-debugging=0 \ +--with-precision=double \ +--download-suitesparse \ +--download-mumps \ +--download-superlu \ +--download-superlu_dist \ +--download-ml \ +--download-eigen \ +--download-hypre \ +--with-mpi-dir=/openmpi \ +--with-blas-lib=/lapack/libblas.so \ +--with-lapack-lib=/lapack/liblapack.so \ +--download-scalapack \ +--download-metis \ +--download-parmetis \ +--with-strict-petscerrorcode \ +--with-mpi-compilers=1 \ +COPTFLAGS='-g -O' \ +FOPTFLAGS='-g -O' \ +CXXOPTFLAGS='-g -O' && \ +make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt all && \ +make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt install && \ +make PETSC_DIR=$PETSC_INSTALL_DIR PETSC_ARCH="" check + +# Cleanup +USER root +WORKDIR / +RUN rm -rf /petsc + + +# ================================================================================ +# FINAL IMAGE +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS final + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git git-lfs lcov \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Copy all libraries and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildvtk /vtk /vtk +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ +COPY --from=buildtrilinos /trilinos /trilinos +COPY --from=buildpetsc /petsc-install /petsc + +# ================================================================================ +# CONDA +ENV CONDA_DIR /conda +RUN ls -l /lib/ +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O /miniconda.sh && \ + /bin/bash /miniconda.sh -b -p $CONDA_DIR + +# Set conda environment +ENV PATH="${CONDA_DIR}/bin:${PATH}" + +# Create and activate Conda environment +RUN conda create -y -n svfsiplus && \ + conda run -n svfsiplus pip install pytest pytest-cov pytest-mock numpy meshio pandas + +# Set libraries environment +ENV PATH="/vtk:/openmpi/bin:/cmake/bin:/trilinos/lib/cmake/Trilinos:${PATH}" +ENV LD_LIBRARY_PATH="/petsc/lib:/lapack:$LD_LIBRARY_PATH" + +ENV OMPI_ALLOW_RUN_AS_ROOT=1 +ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/Docker/ubuntu22/dockerfile b/Docker/ubuntu22/dockerfile new file mode 100644 index 00000000..c22995ee --- /dev/null +++ b/Docker/ubuntu22/dockerfile @@ -0,0 +1,618 @@ +# ================================================================================ +# CMAKE +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildcmake + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting CMake version CMake installation directory +ARG CMAKE_VERSION=3.29.0 +ARG CMAKE_INSTALL_DIR=/cmake + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \ + tar -xzvf cmake-${CMAKE_VERSION}.tar.gz && \ + rm cmake-${CMAKE_VERSION}.tar.gz + +WORKDIR /cmake-${CMAKE_VERSION} +RUN ./bootstrap --prefix=${CMAKE_INSTALL_DIR} && \ + make -j6 && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /cmake-${CMAKE_VERSION} + +# ================================================================================ +# OPENMPI +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildompi + +# Copy cmake binary from buildcmake +COPY --from=buildcmake /cmake /cmake + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting OMPI version OMPI installation directory +ARG OMPI_VERSION=5.0.2 +ARG OMPI_INSTALL_DIR=/openmpi + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-${OMPI_VERSION}.tar.gz && \ + tar -xzvf openmpi-${OMPI_VERSION}.tar.gz && \ + rm openmpi-${OMPI_VERSION}.tar.gz + +WORKDIR /openmpi-${OMPI_VERSION} +RUN ./configure --prefix=${OMPI_INSTALL_DIR} && \ + make -j6 all && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /openmpi-${OMPI_VERSION} + +# ================================================================================ +# VTK +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildvtk + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting VTK version VTK installation directory +ARG VTK_VERSION=9.3.0 +ARG VTK_INSTALL_DIR=/vtk + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://www.vtk.org/files/release/9.3/VTK-${VTK_VERSION}.tar.gz && \ + tar -xzvf VTK-${VTK_VERSION}.tar.gz && \ + rm VTK-${VTK_VERSION}.tar.gz + +WORKDIR /build-vtk +RUN cmake -DBUILD_SHARED_LIBS:BOOL=OFF \ +-DCMAKE_BUILD_TYPE:STRING=RELEASE \ +-DBUILD_EXAMPLES=OFF \ +-DBUILD_TESTING=OFF \ +-DVTK_USE_SYSTEM_EXPAT:BOOL=ON \ +-DVTK_USE_SYSTEM_ZLIB:BOOL=ON \ +-DVTK_LEGACY_REMOVE=ON \ +-DVTK_Group_Rendering=OFF \ +-DVTK_Group_StandAlone=OFF \ +-DVTK_RENDERING_BACKEND=None \ +-DVTK_WRAP_PYTHON=OFF \ +-DModule_vtkChartsCore=ON \ +-DModule_vtkCommonCore=ON \ +-DModule_vtkCommonDataModel=ON \ +-DModule_vtkCommonExecutionModel=ON \ +-DModule_vtkFiltersCore=ON \ +-DModule_vtkFiltersFlowPaths=ON \ +-DModule_vtkFiltersModeling=ON \ +-DModule_vtkIOLegacy=ON \ +-DModule_vtkIOXML=ON \ +-DVTK_GROUP_ENABLE_Views=NO \ +-DVTK_GROUP_ENABLE_Web=NO \ +-DVTK_GROUP_ENABLE_Imaging=NO \ +-DVTK_GROUP_ENABLE_Qt=DONT_WANT \ +-DVTK_GROUP_ENABLE_Rendering=DONT_WANT \ +-DCMAKE_INSTALL_PREFIX=${VTK_INSTALL_DIR} /VTK-${VTK_VERSION} && \ + cmake --build . --parallel 4 && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /VTK-${VTK_VERSION} build-vtk + +# ================================================================================ +# BOOST +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildboost + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting Boost version Boost installation directory +ARG BOOST_VERSION=1_84_0 +ARG BOOST_INSTALL_DIR=/boost + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_${BOOST_VERSION}.tar.gz && \ + tar -xzvf boost_${BOOST_VERSION}.tar.gz && \ + rm boost_${BOOST_VERSION}.tar.gz + +WORKDIR /boost_${BOOST_VERSION} +RUN ./bootstrap.sh --prefix=${BOOST_INSTALL_DIR} && \ + ./b2 install + +# Cleanup +WORKDIR / +RUN rm -rf /boost_${BOOST_VERSION} + +# ================================================================================ +# LAPACK +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildlapack + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting lapack installation directory +ARG LAPACK_INSTALL_DIR=/tmp/lapack + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/Reference-LAPACK/lapack.git +WORKDIR /build +RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_LIBDIR=${LAPACK_INSTALL_DIR} ../lapack && \ + cmake --build . -j6 --target install + +# Cleanup +WORKDIR / +RUN rm -rf /build /lapack + +# ================================================================================ +# BLAS (USE FROM LAPACK INSTALLATION) +# ================================================================================ +# Use a base image for building tools and dependencise +#FROM ubuntu:20.04 AS buildblas + +# Copy cmake binary from buildcmake and set ENV +#COPY --from=buildcmake /cmake /cmake + +#ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +#ENV DEBIAN_FRONTEND=noninteractive + +# Setting blas version and installation directory +#ARG BLAS_VERSION=3.12.0 +#ARG BLAS_INSTALL_DIR=/blas + +# Create new user +#RUN useradd -ms /bin/bash luser + +# Install essentials tools +#RUN apt-get update && \ +# apt-get install -y \ +# build-essential wget git \ +# python3 gfortran default-jdk default-jre \ +# libglu1-mesa-dev freeglut3-dev mesa-common-dev \ +# openssl libssl-dev zlib1g-dev libicu-dev && \ +# apt-get clean && \ +# rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +#RUN wget http://www.netlib.org/blas/blas-${BLAS_VERSION}.tgz && \ +# tar -xvf blas-${BLAS_VERSION}.tgz && \ +# rm blas-${BLAS_VERSION}.tgz + +#WORKDIR /build +#RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${BLAS_INSTALL_DIR} ../BLAS-${BLAS_VERSION} && \ +# make && \ +# make install + +# Cleanup +#WORKDIR / +#RUN rm -rf /BLAS-${BLAS_VERSION} /build + +# ================================================================================ +# HDF5 +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildhdf5 + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi/ + +ENV PATH="/cmake/bin:/openmpi:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hdf5 installation directories +ARG HDF5_INSTALL_DIR=/hdf5 + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +WORKDIR /hdf5build + +# setting luser permission to directories and changing user to luser +# this allows the HDF5 tests to run smoothly +RUN chown -R luser:luser /hdf5build && \ + chown -R luser:luser /usr/lib/x86_64-linux-gnu/ + +RUN mkdir ${HDF5_INSTALL_DIR} && \ + chown -R luser:luser ${HDF5_INSTALL_DIR} + +USER luser +RUN git clone https://github.com/HDFGroup/hdf5.git + +# Build HDF5 +WORKDIR /hdf5build/build +RUN cmake -C /hdf5build/hdf5/config/cmake/cacheinit.cmake -G "Unix Makefiles" \ +-DHDF5_ENABLE_PARALLEL:BOOL=ON \ +-DALLOW_UNSUPPORTED:BOOL=ON \ +-DCMAKE_BUILD_TYPE=Release \ +-DCMAKE_INSTALL_PREFIX=${HDF5_INSTALL_DIR} /hdf5build/hdf5 && \ + cmake --build . && \ + make install + +# For testing +# ctest . -C --rerun-failed --output-on-failure && \ + +# Cleanup +USER root +WORKDIR / +RUN rm -rf /hdf5build + +# ================================================================================ +# HYPRE +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildhypre + +# Copy cmake binary from buildcmake and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildlapack /tmp/lapack /lapack/ + +ENV PATH="/cmake/bin:/openmpi/bin:/lapack:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hypre installation directory +ARG HYPRE_INSTALL_DIR=/hypre-install + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/hypre-space/hypre.git + +WORKDIR /hypre/src/ +RUN ./configure --prefix=${HYPRE_INSTALL_DIR} && \ + make install + +# Cleanup +WORKDIR / +RUN rm -rf /hypre + +# ================================================================================ +# TRILINOS +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildtrilinos + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ + +ENV PATH="/cmake/bin:/openmpi/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting hypre installation directory +ARG TRILINOS_INSTALL_DIR=/trilinos + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN ln -s /usr/bin/python3 /usr/bin/python + +# ================================================================================ +# Download, extract, install +RUN git clone https://github.com/trilinos/Trilinos.git +WORKDIR /Trilinos/build + +# Build trilinos +#-DTPL_ENABLE_MUMPS=ON \ +RUN cmake \ +-DCMAKE_INSTALL_PREFIX=${TRILINOS_INSTALL_DIR} \ +-DTPL_ENABLE_MPI=ON \ +-DTPL_ENABLE_Boost=ON \ +-DBoost_LIBRARY_DIRS=/boost/lib \ +-DBoost_INCLUDE_DIRS=/boost/include \ +-DTPL_ENABLE_BLAS=ON \ +-DBLAS_LIBRARY_DIRS=/lapack \ +-DTPL_ENABLE_HDF5=ON \ +-DHDF5_LIBRARY_DIRS=/hdf5/lib \ +-DHDF5_INCLUDE_DIRS=/hdf5/include \ +-DTPL_ENABLE_HYPRE=ON \ +-DHYPRE_LIBRARY_DIRS=/hypre/lib \ +-DHYPRE_INCLUDE_DIRS=/hypre/include \ +-DTPL_ENABLE_LAPACK=ON \ +-DLAPACK_LIBRARY_DIRS=/lapack \ +-DCMAKE_C_COMPILER=/openmpi/bin/mpicc \ +-DCMAKE_CXX_COMPILER=/openmpi/bin/mpicxx \ +-DCMAKE_Fortran_COMPILER=/openmpi/bin/mpif90 \ +-DTrilinos_ENABLE_Epetra=ON \ +-DTrilinos_ENABLE_AztecOO=ON \ +-DTrilinos_ENABLE_Ifpack=ON \ +-DTrilinos_ENABLE_EpetraEXT=ON \ +-DTrilinos_ENABLE_Amesos=ON \ +-DTrilinos_ENABLE_ML=ON \ +-DTrilinos_ENABLE_MueLU=ON \ +-DTrilinos_ENABLE_ROL=ON \ +-DTrilinos_ENABLE_Sacado=ON \ +-DTrilinos_ENABLE_Teuchos=ON \ +-DTrilinos_ENABLE_Zoltan=ON \ +/Trilinos && \ +make -j6 install + +# Cleanup +WORKDIR / +RUN rm -rf Trilinos + + +# ================================================================================ +# PETSC +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildpetsc + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ + +ENV PATH="/cmake/bin:${PATH}" + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Setting petsc installation directory +ARG PETSC_INSTALL_DIR=/petsc-install + +# Create new user +RUN useradd -ms /bin/bash luser + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# By default the cmake is looking for python and not python3 +# The following line creates a symbolic link python->python3 +RUN ln -s /usr/bin/python3 /usr/bin/python + +# ================================================================================ +# Download and install +RUN git clone -b release https://gitlab.com/petsc/petsc.git + +# Set permission for luser +RUN chown -R luser:luser /petsc + +RUN mkdir ${PETSC_INSTALL_DIR} && \ + chown -R luser:luser ${PETSC_INSTALL_DIR} + +# Switch user (petsc should be installed by non-root) +USER luser + +WORKDIR /petsc + +# Install petsc library in $PETSC_INSTALL_DIR +# Libraries path must be set explicitly +RUN ./configure --prefix=$PETSC_INSTALL_DIR \ +--with-debugging=0 \ +--with-precision=double \ +--download-suitesparse \ +--download-mumps \ +--download-superlu \ +--download-superlu_dist \ +--download-ml \ +--download-eigen \ +--download-hypre \ +--with-mpi-dir=/openmpi \ +--with-blas-lib=/lapack/libblas.so \ +--with-lapack-lib=/lapack/liblapack.so \ +--download-scalapack \ +--download-metis \ +--download-parmetis \ +--with-strict-petscerrorcode \ +--with-mpi-compilers=1 \ +COPTFLAGS='-g -O' \ +FOPTFLAGS='-g -O' \ +CXXOPTFLAGS='-g -O' && \ +make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt all && \ +make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt install && \ +make PETSC_DIR=$PETSC_INSTALL_DIR PETSC_ARCH="" check + +# Cleanup +USER root +WORKDIR / +RUN rm -rf /petsc + + +# ================================================================================ +# FINAL IMAGE +# ================================================================================ + +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS final + +# Any debian-based command will not prompt user-input +ENV DEBIAN_FRONTEND=noninteractive + +# Install essentials tools +RUN apt-get update && \ + apt-get install -y \ + build-essential wget git git-lfs lcov \ + python3 gfortran default-jdk default-jre \ + libglu1-mesa-dev freeglut3-dev mesa-common-dev \ + openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# Copy all libraries and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi +COPY --from=buildvtk /vtk /vtk +COPY --from=buildboost /boost /boost +COPY --from=buildhdf5 /hdf5 /hdf5 +COPY --from=buildlapack /tmp/lapack /lapack +COPY --from=buildhypre /hypre-install /hypre/ +COPY --from=buildtrilinos /trilinos /trilinos +COPY --from=buildpetsc /petsc-install /petsc + +# ================================================================================ +# CONDA +ENV CONDA_DIR /conda +RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /miniconda.sh && \ + /bin/bash /miniconda.sh -b -p $CONDA_DIR + +# Set conda environment +ENV PATH="${CONDA_DIR}/bin:${PATH}" + +# Create and activate Conda environment +RUN conda create -y -n svfsiplus && \ + conda run -n svfsiplus pip install pytest pytest-cov pytest-mock numpy meshio pandas + +# Set libraries environment +ENV PATH="/vtk:/openmpi/bin:/cmake/bin:/trilinos/lib/cmake/Trilinos:${PATH}" +ENV LD_LIBRARY_PATH="/petsc/lib:/lapack:$LD_LIBRARY_PATH" + +ENV OMPI_ALLOW_RUN_AS_ROOT=1 +ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 + From c34db8e72e8f7de68183b7fe6446c807eb91be4e Mon Sep 17 00:00:00 2001 From: dcodoni Date: Thu, 16 May 2024 18:04:23 -0700 Subject: [PATCH 3/6] README.md file for Docker container has been added to Docker/ folder. All the tests have been included back and the tolerances set to the values from the last svFSIplus update. Unnecessary dockerfiles have been deleted. --- Docker/README.md | 33 + Docker/ubuntu20-on-mac-host/dockerfile | 620 ------------------ Docker/ubuntu22-on-mac-host/dockerfile | 620 ------------------ tests/cases/cep/cable_TTP_1d/result_001.vtu | 4 +- tests/cases/cep/cable_TTP_1d/svFSI.xml | 9 +- .../result_BICG_CN_epicardium_BO_001.vtu | 4 +- .../result_CG_RK4_myocardium_BO_001.vtu | 4 +- .../result_GMRES_FE_epicardium_TTP_001.vtu | 4 +- .../result_GMRES_FE_pfib_AP_001.vtu | 4 +- .../svFSI_BICG_CN_epicardium_BO.xml | 7 +- .../svFSI_CG_RK4_myocardium_BO.xml | 8 +- .../svFSI_GMRES_FE_epicardium_TTP.xml | 7 +- .../svFSI_GMRES_FE_pfib_AP.xml | 7 +- tests/cases/cep/purkinje/result_001.vtu | 4 +- tests/cases/cep/purkinje/svFSI.xml | 9 +- tests/cases/cep/spiral_BO_2d/result_001.vtu | 4 +- tests/cases/cep/spiral_BO_2d/svFSI.xml | 10 +- tests/cases/cep/square_AP_2d/result_001.vtu | 4 +- tests/cases/cep/square_AP_2d/svFSI.xml | 10 +- .../1-rigid-solution/svFSI.xml | 3 - .../2-inflate/svFSI.xml | 6 +- .../3-inflate-cmm/svFSI.xml | 5 +- .../cmm/pipe_3d/1-rigid-solution/svFSI.xml | 3 - tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml | 3 - .../cases/cmm/pipe_3d/2b-prestress/svFSI.xml | 3 - .../cmm/pipe_3d/3a-inflate-cmm/svFSI.xml | 5 +- .../cmm/pipe_3d/3b-prestress-cmm/svFSI.xml | 4 +- .../diffusion_line_source/svFSI_BICG.xml | 3 - .../heats/diffusion_line_source/svFSI_CG.xml | 4 +- .../diffusion_line_source/svFSI_GMRES.xml | 4 +- tests/cases/shell/plate/svFSI.xml | 3 - tests/cases/shell/valve/svFSI.xml | 3 - .../manufactured_solution/P1P1/N004/svFSI.xml | 4 +- .../manufactured_solution/P1P1/N008/svFSI.xml | 4 +- .../manufactured_solution/P1P1/N016/svFSI.xml | 5 +- .../manufactured_solution/P1P1/N032/svFSI.xml | 4 +- .../manufactured_solution/P1P1/N064/svFSI.xml | 4 +- .../manufactured_solution/P1P1/N128/svFSI.xml | 5 +- .../manufactured_solution/P1P1/N256/svFSI.xml | 5 +- .../manufactured_solution/P2P1/N004/svFSI.xml | 5 +- .../manufactured_solution/P2P1/N008/svFSI.xml | 5 +- .../manufactured_solution/P2P1/N016/svFSI.xml | 5 +- .../manufactured_solution/P2P1/N032/svFSI.xml | 6 +- .../manufactured_solution/P2P1/N064/svFSI.xml | 4 +- .../manufactured_solution/P2P1/N128/svFSI.xml | 4 +- .../struct/LV_Guccione_passive/svFSI.xml | 6 +- .../struct/LV_Holzapfel_passive/svFSI.xml | 20 +- .../cases/struct/block_compression/svFSI.xml | 4 +- tests/cases/struct/robin/svFSI.xml | 4 +- .../ustruct/LV_Guccione_active/result_001.vtu | 4 +- .../ustruct/LV_Guccione_active/svFSI.xml | 4 +- .../block_compression/P1P1_VMS/svFSI.xml | 4 +- .../ustruct/tensile_adventitia_HGO/svFSI.xml | 4 +- tests/test_struct.py | 26 +- tests/test_ustruct.py | 20 + 55 files changed, 165 insertions(+), 1412 deletions(-) create mode 100644 Docker/README.md delete mode 100644 Docker/ubuntu20-on-mac-host/dockerfile delete mode 100644 Docker/ubuntu22-on-mac-host/dockerfile diff --git a/Docker/README.md b/Docker/README.md new file mode 100644 index 00000000..c5fb7304 --- /dev/null +++ b/Docker/README.md @@ -0,0 +1,33 @@ +# Docker +In order to use the dockerfiles and/or docker containers, Docker Desktop must be installed. Docker installation is straightforward [install](https://www.docker.com/products/docker-desktop/). +Once installed, Docker engine can be started using the graphic interface of Docker. When the engine is running, the containers can be built and run using the terminal's commands. +It is suggested to change the resources that Docker engine is using, since containers may require more memory than the default allocation. In order to do this, open Docker Desktop, then click on settings->resources, adjust based on personal needs. It is also useful to change the default storage limite of the Docker Engine in settings->Docker Engine and change the builder storage default. + +## Docker containers +A container is an isolated environment based on a specific operating system (OS) (typically Linux based), in which a solver can be built. The environment created in a container includes all the dependencies of the solver that needs to be built. Once the container is created, it can be run on any machine and the solver can be built directly in this virtual environment. +In this work the containers are created using Docker software [Docker](https://www.docker.com). A Docker container is built from a dockerfile. After it is created, it is saved as an image that can be copied anywhere is needed or uploaded on the cloud DockerHub [DockerHub](https://hub.docker.com). + +## Dockerfile +In the folder Docker/ there are two subfolders ubuntu20/ and ubuntu22/ containing a dockerfile each. A dockerfile usually begins with an image import of the environment OS, which in this case is Ubuntu-20.04 and Ubuntu-22.04. +For more details about the dockerfiles created in this work, refer to the DockerHub page [personalDockerHub](https://hub.docker.com/repository/docker/dcodoni/lib/general). + +## Build a container +Once the dockerfile is created, it must be built to oget the final image of the container. This can be done by moving to the directory where dockerfile is and run the command: + +docker buildx build -t RepositoryName:tagImage . + +where -t allows the user to set the name for the image created. +If your file is not named dockerfile, then in order to build a particular file just use: + +docker buildx build -f filename -t RepositoryName:tagImage . + +## Run a container +Once the image is created, it can be run interactively by running the following command: + +docker run -it -v FolderToUpload:/NameOfFolder RepositoryName:tagImage + +In this command: +- -it: means run interactively Docker image +- -v: mounts a directory 'FolderToUpload' from the host machine in the container where the directory has the name '/NameOfFolder'. For example the directory containing the source code of the solver and all the test cases can be mounted in the container. + +When the container is running interactively, the solver can be built and the test cases can be run. When exiting the container, all the output files inside '/NameOfFolder' are not deleted and they will still be available in the host machine. diff --git a/Docker/ubuntu20-on-mac-host/dockerfile b/Docker/ubuntu20-on-mac-host/dockerfile deleted file mode 100644 index de5eb170..00000000 --- a/Docker/ubuntu20-on-mac-host/dockerfile +++ /dev/null @@ -1,620 +0,0 @@ -# ================================================================================ -# CMAKE -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS buildcmake - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting CMake version CMake installation directory -ARG CMAKE_VERSION=3.29.0 -ARG CMAKE_INSTALL_DIR=/cmake - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \ - tar -xzvf cmake-${CMAKE_VERSION}.tar.gz && \ - rm cmake-${CMAKE_VERSION}.tar.gz - -WORKDIR /cmake-${CMAKE_VERSION} -RUN ./bootstrap --prefix=${CMAKE_INSTALL_DIR} && \ - make -j6 && \ - make install - -# Cleanup -WORKDIR / -RUN rm -rf /cmake-${CMAKE_VERSION} - -# ================================================================================ -# OPENMPI -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS buildompi - -# Copy cmake binary from buildcmake -COPY --from=buildcmake /cmake /cmake - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting OMPI version OMPI installation directory -ARG OMPI_VERSION=5.0.2 -ARG OMPI_INSTALL_DIR=/openmpi - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-${OMPI_VERSION}.tar.gz && \ - tar -xzvf openmpi-${OMPI_VERSION}.tar.gz && \ - rm openmpi-${OMPI_VERSION}.tar.gz - -WORKDIR /openmpi-${OMPI_VERSION} -RUN ./configure --prefix=${OMPI_INSTALL_DIR} && \ - make -j6 all && \ - make install - -# Cleanup -WORKDIR / -RUN rm -rf /openmpi-${OMPI_VERSION} - -# ================================================================================ -# VTK -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS buildvtk - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake - -ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting VTK version VTK installation directory -ARG VTK_VERSION=9.3.0 -ARG VTK_INSTALL_DIR=/vtk - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN wget https://www.vtk.org/files/release/9.3/VTK-${VTK_VERSION}.tar.gz && \ - tar -xzvf VTK-${VTK_VERSION}.tar.gz && \ - rm VTK-${VTK_VERSION}.tar.gz - -WORKDIR /build-vtk -RUN cmake -DBUILD_SHARED_LIBS:BOOL=OFF \ --DCMAKE_BUILD_TYPE:STRING=RELEASE \ --DBUILD_EXAMPLES=OFF \ --DBUILD_TESTING=OFF \ --DVTK_USE_SYSTEM_EXPAT:BOOL=ON \ --DVTK_USE_SYSTEM_ZLIB:BOOL=ON \ --DVTK_LEGACY_REMOVE=ON \ --DVTK_Group_Rendering=OFF \ --DVTK_Group_StandAlone=OFF \ --DVTK_RENDERING_BACKEND=None \ --DVTK_WRAP_PYTHON=OFF \ --DModule_vtkChartsCore=ON \ --DModule_vtkCommonCore=ON \ --DModule_vtkCommonDataModel=ON \ --DModule_vtkCommonExecutionModel=ON \ --DModule_vtkFiltersCore=ON \ --DModule_vtkFiltersFlowPaths=ON \ --DModule_vtkFiltersModeling=ON \ --DModule_vtkIOLegacy=ON \ --DModule_vtkIOXML=ON \ --DVTK_GROUP_ENABLE_Views=NO \ --DVTK_GROUP_ENABLE_Web=NO \ --DVTK_GROUP_ENABLE_Imaging=NO \ --DVTK_GROUP_ENABLE_Qt=DONT_WANT \ --DVTK_GROUP_ENABLE_Rendering=DONT_WANT \ --DCMAKE_INSTALL_PREFIX=${VTK_INSTALL_DIR} /VTK-${VTK_VERSION} && \ - cmake --build . --parallel 4 && \ - make install - -# Cleanup -WORKDIR / -RUN rm -rf /VTK-${VTK_VERSION} build-vtk - -# ================================================================================ -# BOOST -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS buildboost - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake - -ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting Boost version Boost installation directory -ARG BOOST_VERSION=1_84_0 -ARG BOOST_INSTALL_DIR=/boost - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_${BOOST_VERSION}.tar.gz && \ - tar -xzvf boost_${BOOST_VERSION}.tar.gz && \ - rm boost_${BOOST_VERSION}.tar.gz - -WORKDIR /boost_${BOOST_VERSION} -RUN ./bootstrap.sh --prefix=${BOOST_INSTALL_DIR} && \ - ./b2 install - -# Cleanup -WORKDIR / -RUN rm -rf /boost_${BOOST_VERSION} - -# ================================================================================ -# LAPACK -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS buildlapack - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake -ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting lapack installation directory -ARG LAPACK_INSTALL_DIR=/tmp/lapack - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN git clone https://github.com/Reference-LAPACK/lapack.git -WORKDIR /build -RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_LIBDIR=${LAPACK_INSTALL_DIR} ../lapack && \ - cmake --build . -j6 --target install - -# Cleanup -WORKDIR / -RUN rm -rf /build /lapack - -# ================================================================================ -# BLAS (USE FROM LAPACK INSTALLATION) -# ================================================================================ -# Use a base image for building tools and dependencise -#FROM ubuntu:20.04 AS buildblas - -# Copy cmake binary from buildcmake and set ENV -#COPY --from=buildcmake /cmake /cmake - -#ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -#ENV DEBIAN_FRONTEND=noninteractive - -# Setting blas version and installation directory -#ARG BLAS_VERSION=3.12.0 -#ARG BLAS_INSTALL_DIR=/blas - -# Create new user -#RUN useradd -ms /bin/bash luser - -# Install essentials tools -#RUN apt-get update && \ -# apt-get install -y \ -# build-essential wget git \ -# python3 gfortran default-jdk default-jre \ -# libglu1-mesa-dev freeglut3-dev mesa-common-dev \ -# openssl libssl-dev zlib1g-dev libicu-dev && \ -# apt-get clean && \ -# rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -#RUN wget http://www.netlib.org/blas/blas-${BLAS_VERSION}.tgz && \ -# tar -xvf blas-${BLAS_VERSION}.tgz && \ -# rm blas-${BLAS_VERSION}.tgz - -#WORKDIR /build -#RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${BLAS_INSTALL_DIR} ../BLAS-${BLAS_VERSION} && \ -# make && \ -# make install - -# Cleanup -#WORKDIR / -#RUN rm -rf /BLAS-${BLAS_VERSION} /build - -# ================================================================================ -# HDF5 -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS buildhdf5 - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi/ - -ENV PATH="/cmake/bin:/openmpi:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting hdf5 installation directories -ARG HDF5_INSTALL_DIR=/hdf5 - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -WORKDIR /hdf5build - -# setting luser permission to directories and changing user to luser -# this allows the HDF5 tests to run smoothly -RUN chown -R luser:luser /hdf5build && \ - chown -R luser:luser /usr/lib/aarch64-linux-gnu - -RUN mkdir ${HDF5_INSTALL_DIR} && \ - chown -R luser:luser ${HDF5_INSTALL_DIR} - -# USER luser -RUN git clone https://github.com/HDFGroup/hdf5.git - -# Build HDF5 -WORKDIR /hdf5build - -RUN cmake -C /hdf5build/hdf5/config/cmake/cacheinit.cmake -G "Unix Makefiles" \ --DHDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16:BOOL=OFF \ --DHDF5_ENABLE_PARALLEL:BOOL=ON \ --DALLOW_UNSUPPORTED:BOOL=ON \ --DCMAKE_BUILD_TYPE=Release \ --DCMAKE_INSTALL_PREFIX=${HDF5_INSTALL_DIR} /hdf5build/hdf5 -RUN cmake --build . && \ - make install - -# For testing -# ctest . -C --rerun-failed --output-on-failure && \ - -# Cleanup -USER root -WORKDIR / -RUN rm -rf /hdf5build - -# ================================================================================ -# HYPRE -# ================================================================================ - -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS buildhypre - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi -COPY --from=buildlapack /tmp/lapack /lapack/ - -ENV PATH="/cmake/bin:/openmpi/bin:/lapack:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting hypre installation directory -ARG HYPRE_INSTALL_DIR=/hypre-install - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN git clone https://github.com/hypre-space/hypre.git - -WORKDIR /hypre/src/ -RUN ./configure --prefix=${HYPRE_INSTALL_DIR} && \ - make install - -# Cleanup -WORKDIR / -RUN rm -rf /hypre - -# ================================================================================ -# TRILINOS -# ================================================================================ - -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS buildtrilinos - -# Copy all dependencies and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi -COPY --from=buildboost /boost /boost -COPY --from=buildhdf5 /hdf5 /hdf5 -COPY --from=buildlapack /tmp/lapack /lapack -COPY --from=buildhypre /hypre-install /hypre/ - -ENV PATH="/cmake/bin:/openmpi/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting hypre installation directory -ARG TRILINOS_INSTALL_DIR=/trilinos - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -RUN ln -s /usr/bin/python3 /usr/bin/python - -# ================================================================================ -# Download, extract, install -RUN git clone https://github.com/trilinos/Trilinos.git -WORKDIR /Trilinos/build - -# Build trilinos -#-DTPL_ENABLE_MUMPS=ON \ -RUN cmake \ --DCMAKE_INSTALL_PREFIX=${TRILINOS_INSTALL_DIR} \ --DTPL_ENABLE_MPI=ON \ --DTPL_ENABLE_Boost=ON \ --DBoost_LIBRARY_DIRS=/boost/lib \ --DBoost_INCLUDE_DIRS=/boost/include \ --DTPL_ENABLE_BLAS=ON \ --DBLAS_LIBRARY_DIRS=/lapack \ --DTPL_ENABLE_HDF5=ON \ --DHDF5_LIBRARY_DIRS=/hdf5/lib \ --DHDF5_INCLUDE_DIRS=/hdf5/include \ --DTPL_ENABLE_HYPRE=ON \ --DHYPRE_LIBRARY_DIRS=/hypre/lib \ --DHYPRE_INCLUDE_DIRS=/hypre/include \ --DTPL_ENABLE_LAPACK=ON \ --DLAPACK_LIBRARY_DIRS=/lapack \ --DCMAKE_C_COMPILER=/openmpi/bin/mpicc \ --DCMAKE_CXX_COMPILER=/openmpi/bin/mpicxx \ --DCMAKE_Fortran_COMPILER=/openmpi/bin/mpif90 \ --DTrilinos_ENABLE_Epetra=ON \ --DTrilinos_ENABLE_AztecOO=ON \ --DTrilinos_ENABLE_Ifpack=ON \ --DTrilinos_ENABLE_EpetraEXT=ON \ --DTrilinos_ENABLE_Amesos=ON \ --DTrilinos_ENABLE_ML=ON \ --DTrilinos_ENABLE_MueLU=ON \ --DTrilinos_ENABLE_ROL=ON \ --DTrilinos_ENABLE_Sacado=ON \ --DTrilinos_ENABLE_Teuchos=ON \ --DTrilinos_ENABLE_Zoltan=ON \ -/Trilinos && \ -make -j6 install - -# Cleanup -WORKDIR / -RUN rm -rf Trilinos - - -# ================================================================================ -# PETSC -# ================================================================================ - -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS buildpetsc - -# Copy all dependencies and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi -COPY --from=buildboost /boost /boost -COPY --from=buildhdf5 /hdf5 /hdf5 -COPY --from=buildlapack /tmp/lapack /lapack -COPY --from=buildhypre /hypre-install /hypre/ - -ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting petsc installation directory -ARG PETSC_INSTALL_DIR=/petsc-install - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# By default the cmake is looking for python and not python3 -# The following line creates a symbolic link python->python3 -RUN ln -s /usr/bin/python3 /usr/bin/python - -# ================================================================================ -# Download and install -RUN git clone -b release https://gitlab.com/petsc/petsc.git - -# Set permission for luser -RUN chown -R luser:luser /petsc - -RUN mkdir ${PETSC_INSTALL_DIR} && \ - chown -R luser:luser ${PETSC_INSTALL_DIR} - -# Switch user (petsc should be installed by non-root) -USER luser - -WORKDIR /petsc - -# Install petsc library in $PETSC_INSTALL_DIR -# Libraries path must be set explicitly -RUN ./configure --prefix=$PETSC_INSTALL_DIR \ ---with-debugging=0 \ ---with-precision=double \ ---download-suitesparse \ ---download-mumps \ ---download-superlu \ ---download-superlu_dist \ ---download-ml \ ---download-eigen \ ---download-hypre \ ---with-mpi-dir=/openmpi \ ---with-blas-lib=/lapack/libblas.so \ ---with-lapack-lib=/lapack/liblapack.so \ ---download-scalapack \ ---download-metis \ ---download-parmetis \ ---with-strict-petscerrorcode \ ---with-mpi-compilers=1 \ -COPTFLAGS='-g -O' \ -FOPTFLAGS='-g -O' \ -CXXOPTFLAGS='-g -O' && \ -make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt all && \ -make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt install && \ -make PETSC_DIR=$PETSC_INSTALL_DIR PETSC_ARCH="" check - -# Cleanup -USER root -WORKDIR / -RUN rm -rf /petsc - - -# ================================================================================ -# FINAL IMAGE -# ================================================================================ - -# Use a base image for building tools and dependencise -FROM ubuntu:20.04 AS final - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git git-lfs lcov \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Copy all libraries and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi -COPY --from=buildvtk /vtk /vtk -COPY --from=buildboost /boost /boost -COPY --from=buildhdf5 /hdf5 /hdf5 -COPY --from=buildlapack /tmp/lapack /lapack -COPY --from=buildhypre /hypre-install /hypre/ -COPY --from=buildtrilinos /trilinos /trilinos -COPY --from=buildpetsc /petsc-install /petsc - -# ================================================================================ -# CONDA -ENV CONDA_DIR /conda -RUN ls -l /lib/ -RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O /miniconda.sh && \ - /bin/bash /miniconda.sh -b -p $CONDA_DIR - -# Set conda environment -ENV PATH="${CONDA_DIR}/bin:${PATH}" - -# Create and activate Conda environment -RUN conda create -y -n svfsiplus && \ - conda run -n svfsiplus pip install pytest pytest-cov pytest-mock numpy meshio pandas - -# Set libraries environment -ENV PATH="/vtk:/openmpi/bin:/cmake/bin:/trilinos/lib/cmake/Trilinos:${PATH}" -ENV LD_LIBRARY_PATH="/petsc/lib:/lapack:$LD_LIBRARY_PATH" - -ENV OMPI_ALLOW_RUN_AS_ROOT=1 -ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/Docker/ubuntu22-on-mac-host/dockerfile b/Docker/ubuntu22-on-mac-host/dockerfile deleted file mode 100644 index 03a0ce3b..00000000 --- a/Docker/ubuntu22-on-mac-host/dockerfile +++ /dev/null @@ -1,620 +0,0 @@ -# ================================================================================ -# CMAKE -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS buildcmake - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting CMake version CMake installation directory -ARG CMAKE_VERSION=3.29.0 -ARG CMAKE_INSTALL_DIR=/cmake - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz && \ - tar -xzvf cmake-${CMAKE_VERSION}.tar.gz && \ - rm cmake-${CMAKE_VERSION}.tar.gz - -WORKDIR /cmake-${CMAKE_VERSION} -RUN ./bootstrap --prefix=${CMAKE_INSTALL_DIR} && \ - make -j6 && \ - make install - -# Cleanup -WORKDIR / -RUN rm -rf /cmake-${CMAKE_VERSION} - -# ================================================================================ -# OPENMPI -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS buildompi - -# Copy cmake binary from buildcmake -COPY --from=buildcmake /cmake /cmake - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting OMPI version OMPI installation directory -ARG OMPI_VERSION=5.0.2 -ARG OMPI_INSTALL_DIR=/openmpi - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-${OMPI_VERSION}.tar.gz && \ - tar -xzvf openmpi-${OMPI_VERSION}.tar.gz && \ - rm openmpi-${OMPI_VERSION}.tar.gz - -WORKDIR /openmpi-${OMPI_VERSION} -RUN ./configure --prefix=${OMPI_INSTALL_DIR} && \ - make -j6 all && \ - make install - -# Cleanup -WORKDIR / -RUN rm -rf /openmpi-${OMPI_VERSION} - -# ================================================================================ -# VTK -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS buildvtk - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake - -ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting VTK version VTK installation directory -ARG VTK_VERSION=9.3.0 -ARG VTK_INSTALL_DIR=/vtk - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN wget https://www.vtk.org/files/release/9.3/VTK-${VTK_VERSION}.tar.gz && \ - tar -xzvf VTK-${VTK_VERSION}.tar.gz && \ - rm VTK-${VTK_VERSION}.tar.gz - -WORKDIR /build-vtk -RUN cmake -DBUILD_SHARED_LIBS:BOOL=OFF \ --DCMAKE_BUILD_TYPE:STRING=RELEASE \ --DBUILD_EXAMPLES=OFF \ --DBUILD_TESTING=OFF \ --DVTK_USE_SYSTEM_EXPAT:BOOL=ON \ --DVTK_USE_SYSTEM_ZLIB:BOOL=ON \ --DVTK_LEGACY_REMOVE=ON \ --DVTK_Group_Rendering=OFF \ --DVTK_Group_StandAlone=OFF \ --DVTK_RENDERING_BACKEND=None \ --DVTK_WRAP_PYTHON=OFF \ --DModule_vtkChartsCore=ON \ --DModule_vtkCommonCore=ON \ --DModule_vtkCommonDataModel=ON \ --DModule_vtkCommonExecutionModel=ON \ --DModule_vtkFiltersCore=ON \ --DModule_vtkFiltersFlowPaths=ON \ --DModule_vtkFiltersModeling=ON \ --DModule_vtkIOLegacy=ON \ --DModule_vtkIOXML=ON \ --DVTK_GROUP_ENABLE_Views=NO \ --DVTK_GROUP_ENABLE_Web=NO \ --DVTK_GROUP_ENABLE_Imaging=NO \ --DVTK_GROUP_ENABLE_Qt=DONT_WANT \ --DVTK_GROUP_ENABLE_Rendering=DONT_WANT \ --DCMAKE_INSTALL_PREFIX=${VTK_INSTALL_DIR} /VTK-${VTK_VERSION} && \ - cmake --build . --parallel 4 && \ - make install - -# Cleanup -WORKDIR / -RUN rm -rf /VTK-${VTK_VERSION} build-vtk - -# ================================================================================ -# BOOST -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS buildboost - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake - -ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting Boost version Boost installation directory -ARG BOOST_VERSION=1_84_0 -ARG BOOST_INSTALL_DIR=/boost - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN wget https://boostorg.jfrog.io/artifactory/main/release/1.84.0/source/boost_${BOOST_VERSION}.tar.gz && \ - tar -xzvf boost_${BOOST_VERSION}.tar.gz && \ - rm boost_${BOOST_VERSION}.tar.gz - -WORKDIR /boost_${BOOST_VERSION} -RUN ./bootstrap.sh --prefix=${BOOST_INSTALL_DIR} && \ - ./b2 install - -# Cleanup -WORKDIR / -RUN rm -rf /boost_${BOOST_VERSION} - -# ================================================================================ -# LAPACK -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS buildlapack - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake -ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting lapack installation directory -ARG LAPACK_INSTALL_DIR=/tmp/lapack - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN git clone https://github.com/Reference-LAPACK/lapack.git -WORKDIR /build -RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_LIBDIR=${LAPACK_INSTALL_DIR} ../lapack && \ - cmake --build . -j6 --target install - -# Cleanup -WORKDIR / -RUN rm -rf /build /lapack - -# ================================================================================ -# BLAS (USE FROM LAPACK INSTALLATION) -# ================================================================================ -# Use a base image for building tools and dependencise -#FROM ubuntu:20.04 AS buildblas - -# Copy cmake binary from buildcmake and set ENV -#COPY --from=buildcmake /cmake /cmake - -#ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -#ENV DEBIAN_FRONTEND=noninteractive - -# Setting blas version and installation directory -#ARG BLAS_VERSION=3.12.0 -#ARG BLAS_INSTALL_DIR=/blas - -# Create new user -#RUN useradd -ms /bin/bash luser - -# Install essentials tools -#RUN apt-get update && \ -# apt-get install -y \ -# build-essential wget git \ -# python3 gfortran default-jdk default-jre \ -# libglu1-mesa-dev freeglut3-dev mesa-common-dev \ -# openssl libssl-dev zlib1g-dev libicu-dev && \ -# apt-get clean && \ -# rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -#RUN wget http://www.netlib.org/blas/blas-${BLAS_VERSION}.tgz && \ -# tar -xvf blas-${BLAS_VERSION}.tgz && \ -# rm blas-${BLAS_VERSION}.tgz - -#WORKDIR /build -#RUN cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=${BLAS_INSTALL_DIR} ../BLAS-${BLAS_VERSION} && \ -# make && \ -# make install - -# Cleanup -#WORKDIR / -#RUN rm -rf /BLAS-${BLAS_VERSION} /build - -# ================================================================================ -# HDF5 -# ================================================================================ -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS buildhdf5 - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi/ - -ENV PATH="/cmake/bin:/openmpi:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting hdf5 installation directories -ARG HDF5_INSTALL_DIR=/hdf5 - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -WORKDIR /hdf5build - -# setting luser permission to directories and changing user to luser -# this allows the HDF5 tests to run smoothly -RUN chown -R luser:luser /hdf5build && \ - chown -R luser:luser /usr/lib/aarch64-linux-gnu - -RUN mkdir ${HDF5_INSTALL_DIR} && \ - chown -R luser:luser ${HDF5_INSTALL_DIR} - -# USER luser -RUN git clone https://github.com/HDFGroup/hdf5.git - -# Build HDF5 -WORKDIR /hdf5build - -RUN cmake -C /hdf5build/hdf5/config/cmake/cacheinit.cmake -G "Unix Makefiles" \ --DHDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16:BOOL=OFF \ --DHDF5_ENABLE_PARALLEL:BOOL=ON \ --DALLOW_UNSUPPORTED:BOOL=ON \ --DCMAKE_BUILD_TYPE=Release \ --DCMAKE_INSTALL_PREFIX=${HDF5_INSTALL_DIR} /hdf5build/hdf5 -RUN cmake --build . && \ - make install - -# For testing -# ctest . -C --rerun-failed --output-on-failure && \ - -# Cleanup -USER root -WORKDIR / -RUN rm -rf /hdf5build - -# ================================================================================ -# HYPRE -# ================================================================================ - -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS buildhypre - -# Copy cmake binary from buildcmake and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi -COPY --from=buildlapack /tmp/lapack /lapack/ - -ENV PATH="/cmake/bin:/openmpi/bin:/lapack:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting hypre installation directory -ARG HYPRE_INSTALL_DIR=/hypre-install - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# ================================================================================ -# Download, extract, install -RUN git clone https://github.com/hypre-space/hypre.git - -WORKDIR /hypre/src/ -RUN ./configure --prefix=${HYPRE_INSTALL_DIR} && \ - make install - -# Cleanup -WORKDIR / -RUN rm -rf /hypre - -# ================================================================================ -# TRILINOS -# ================================================================================ - -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS buildtrilinos - -# Copy all dependencies and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi -COPY --from=buildboost /boost /boost -COPY --from=buildhdf5 /hdf5 /hdf5 -COPY --from=buildlapack /tmp/lapack /lapack -COPY --from=buildhypre /hypre-install /hypre/ - -ENV PATH="/cmake/bin:/openmpi/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting hypre installation directory -ARG TRILINOS_INSTALL_DIR=/trilinos - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -RUN ln -s /usr/bin/python3 /usr/bin/python - -# ================================================================================ -# Download, extract, install -RUN git clone https://github.com/trilinos/Trilinos.git -WORKDIR /Trilinos/build - -# Build trilinos -#-DTPL_ENABLE_MUMPS=ON \ -RUN cmake \ --DCMAKE_INSTALL_PREFIX=${TRILINOS_INSTALL_DIR} \ --DTPL_ENABLE_MPI=ON \ --DTPL_ENABLE_Boost=ON \ --DBoost_LIBRARY_DIRS=/boost/lib \ --DBoost_INCLUDE_DIRS=/boost/include \ --DTPL_ENABLE_BLAS=ON \ --DBLAS_LIBRARY_DIRS=/lapack \ --DTPL_ENABLE_HDF5=ON \ --DHDF5_LIBRARY_DIRS=/hdf5/lib \ --DHDF5_INCLUDE_DIRS=/hdf5/include \ --DTPL_ENABLE_HYPRE=ON \ --DHYPRE_LIBRARY_DIRS=/hypre/lib \ --DHYPRE_INCLUDE_DIRS=/hypre/include \ --DTPL_ENABLE_LAPACK=ON \ --DLAPACK_LIBRARY_DIRS=/lapack \ --DCMAKE_C_COMPILER=/openmpi/bin/mpicc \ --DCMAKE_CXX_COMPILER=/openmpi/bin/mpicxx \ --DCMAKE_Fortran_COMPILER=/openmpi/bin/mpif90 \ --DTrilinos_ENABLE_Epetra=ON \ --DTrilinos_ENABLE_AztecOO=ON \ --DTrilinos_ENABLE_Ifpack=ON \ --DTrilinos_ENABLE_EpetraEXT=ON \ --DTrilinos_ENABLE_Amesos=ON \ --DTrilinos_ENABLE_ML=ON \ --DTrilinos_ENABLE_MueLU=ON \ --DTrilinos_ENABLE_ROL=ON \ --DTrilinos_ENABLE_Sacado=ON \ --DTrilinos_ENABLE_Teuchos=ON \ --DTrilinos_ENABLE_Zoltan=ON \ -/Trilinos && \ -make -j6 install - -# Cleanup -WORKDIR / -RUN rm -rf Trilinos - - -# ================================================================================ -# PETSC -# ================================================================================ - -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS buildpetsc - -# Copy all dependencies and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi -COPY --from=buildboost /boost /boost -COPY --from=buildhdf5 /hdf5 /hdf5 -COPY --from=buildlapack /tmp/lapack /lapack -COPY --from=buildhypre /hypre-install /hypre/ - -ENV PATH="/cmake/bin:${PATH}" - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Setting petsc installation directory -ARG PETSC_INSTALL_DIR=/petsc-install - -# Create new user -RUN useradd -ms /bin/bash luser - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# By default the cmake is looking for python and not python3 -# The following line creates a symbolic link python->python3 -RUN ln -s /usr/bin/python3 /usr/bin/python - -# ================================================================================ -# Download and install -RUN git clone -b release https://gitlab.com/petsc/petsc.git - -# Set permission for luser -RUN chown -R luser:luser /petsc - -RUN mkdir ${PETSC_INSTALL_DIR} && \ - chown -R luser:luser ${PETSC_INSTALL_DIR} - -# Switch user (petsc should be installed by non-root) -USER luser - -WORKDIR /petsc - -# Install petsc library in $PETSC_INSTALL_DIR -# Libraries path must be set explicitly -RUN ./configure --prefix=$PETSC_INSTALL_DIR \ ---with-debugging=0 \ ---with-precision=double \ ---download-suitesparse \ ---download-mumps \ ---download-superlu \ ---download-superlu_dist \ ---download-ml \ ---download-eigen \ ---download-hypre \ ---with-mpi-dir=/openmpi \ ---with-blas-lib=/lapack/libblas.so \ ---with-lapack-lib=/lapack/liblapack.so \ ---download-scalapack \ ---download-metis \ ---download-parmetis \ ---with-strict-petscerrorcode \ ---with-mpi-compilers=1 \ -COPTFLAGS='-g -O' \ -FOPTFLAGS='-g -O' \ -CXXOPTFLAGS='-g -O' && \ -make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt all && \ -make PETSC_DIR=/petsc PETSC_ARCH=arch-linux-c-opt install && \ -make PETSC_DIR=$PETSC_INSTALL_DIR PETSC_ARCH="" check - -# Cleanup -USER root -WORKDIR / -RUN rm -rf /petsc - - -# ================================================================================ -# FINAL IMAGE -# ================================================================================ - -# Use a base image for building tools and dependencise -FROM ubuntu:22.04 AS final - -# Any debian-based command will not prompt user-input -ENV DEBIAN_FRONTEND=noninteractive - -# Install essentials tools -RUN apt-get update && \ - apt-get install -y \ - build-essential wget git git-lfs lcov \ - python3 gfortran default-jdk default-jre \ - libglu1-mesa-dev freeglut3-dev mesa-common-dev \ - openssl libssl-dev zlib1g-dev libicu-dev libglvnd-dev && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# Copy all libraries and set ENV -COPY --from=buildcmake /cmake /cmake -COPY --from=buildompi /openmpi /openmpi -COPY --from=buildvtk /vtk /vtk -COPY --from=buildboost /boost /boost -COPY --from=buildhdf5 /hdf5 /hdf5 -COPY --from=buildlapack /tmp/lapack /lapack -COPY --from=buildhypre /hypre-install /hypre/ -COPY --from=buildtrilinos /trilinos /trilinos -COPY --from=buildpetsc /petsc-install /petsc - -# ================================================================================ -# CONDA -ENV CONDA_DIR /conda -RUN ls -l /lib/ -RUN wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-aarch64.sh -O /miniconda.sh && \ - /bin/bash /miniconda.sh -b -p $CONDA_DIR - -# Set conda environment -ENV PATH="${CONDA_DIR}/bin:${PATH}" - -# Create and activate Conda environment -RUN conda create -y -n svfsiplus && \ - conda run -n svfsiplus pip install pytest pytest-cov pytest-mock numpy meshio pandas - -# Set libraries environment -ENV PATH="/vtk:/openmpi/bin:/cmake/bin:/trilinos/lib/cmake/Trilinos:${PATH}" -ENV LD_LIBRARY_PATH="/petsc/lib:/lapack:$LD_LIBRARY_PATH" - -ENV OMPI_ALLOW_RUN_AS_ROOT=1 -ENV OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1 diff --git a/tests/cases/cep/cable_TTP_1d/result_001.vtu b/tests/cases/cep/cable_TTP_1d/result_001.vtu index a98765d8..e8d9f50c 100644 --- a/tests/cases/cep/cable_TTP_1d/result_001.vtu +++ b/tests/cases/cep/cable_TTP_1d/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:15a085fafbfa77ab98c969cb81495a4e2d01d22eacd39f248db78a40f3d8d714 -size 4075 +oid sha256:8be46ee399abf9577bb89126c7d7e0bca146dac9d0c5ce10b97086abe85b078c +size 3862 diff --git a/tests/cases/cep/cable_TTP_1d/svFSI.xml b/tests/cases/cep/cable_TTP_1d/svFSI.xml index a009a6a5..5f0dfc95 100644 --- a/tests/cases/cep/cable_TTP_1d/svFSI.xml +++ b/tests/cases/cep/cable_TTP_1d/svFSI.xml @@ -31,8 +31,8 @@ true 1 - 5 - 1e-6 + 2 + 1e-12 TTP @@ -57,11 +57,8 @@ - - fsils - 100 - 1e-6 + 1e-12 50 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu index 03842bc3..4e7b6e6c 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6af5a1ba655072991230391acabfddff4cb3a34b0a5c81241ee4a311aa550fe3 -size 8305950 +oid sha256:5ca618669a71038a1385eb16a483d0d4ac1b4213df67a15d59b0522d47f8ac71 +size 8238606 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu index 91f6d532..4cdc28a4 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bd7cc1fa1369a3965e615577e1f9c584cd794013794cf0d1077217a19b2ac88f -size 8279618 +oid sha256:94e247849b57f1feac14e3cde7c52af13b4112751a41a7320754b91da1c8f7cd +size 8282430 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu index 8d8a62f7..ecd13e8b 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4a3b96e0e8fad864daeda38acf5fbe46a0db55a054a60b7c28542ec94d258098 -size 8288167 +oid sha256:862e6a065fc065f25169b9b0ca220e4e4ea70ab461d0eae68bb38435fcb8b729 +size 8224038 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu index 05deeb85..a7a017b4 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d044cb38f9578ec54541e5097674dbce5b06bd7b8fd7b5f56ae36f78590c770e -size 8286611 +oid sha256:a38f51e854c188ffee9a4e893de80fc5bb617d93ac68112d587ca75aef172d38 +size 8301266 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml index f34e11b6..575b28aa 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-6 + 1e-12 BO @@ -104,11 +104,8 @@ - - fsils - 100 - 1e-6 + 1e-12 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml index 5479af77..255f4e31 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-6 + 1e-12 BO @@ -104,10 +104,8 @@ - - fsils - - 1e-6 + svfsi + 1e-12 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml index b5d8fe6f..fe6aa6eb 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-6 + 1e-12 TTP @@ -116,11 +116,8 @@ - - fsils - 100 - 1e-6 + 1e-12 50 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml index 3b666f2e..31745800 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-6 + 1e-12 AP @@ -104,11 +104,8 @@ - - fsils - 100 - 1e-6 + 1e-12 50 diff --git a/tests/cases/cep/purkinje/result_001.vtu b/tests/cases/cep/purkinje/result_001.vtu index 9fb9be7f..66163a3e 100644 --- a/tests/cases/cep/purkinje/result_001.vtu +++ b/tests/cases/cep/purkinje/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cd457cc3a4b72665dfbc0814b22071f7b2fbe718b0a11a3b52e32a8793ff5c84 -size 722384 +oid sha256:1bf39effdb55cf6f0ee63645720a788c869b6eeba3dc23c044cc15321e2c0eef +size 718891 diff --git a/tests/cases/cep/purkinje/svFSI.xml b/tests/cases/cep/purkinje/svFSI.xml index e6c5476b..0209f2ca 100644 --- a/tests/cases/cep/purkinje/svFSI.xml +++ b/tests/cases/cep/purkinje/svFSI.xml @@ -39,8 +39,8 @@ true 1 - 3 - 1e-6 + 2 + 1e-12 TTP @@ -67,11 +67,8 @@ - - fsils - 100 - 1e-6 + 1e-12 50 diff --git a/tests/cases/cep/spiral_BO_2d/result_001.vtu b/tests/cases/cep/spiral_BO_2d/result_001.vtu index 32fd4a4f..9e3dab81 100644 --- a/tests/cases/cep/spiral_BO_2d/result_001.vtu +++ b/tests/cases/cep/spiral_BO_2d/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6e05fcc0004f38abef3eede2d4a8e9b62f4e33269886d9f3bbcddc0d49f8ed72 -size 14228715 +oid sha256:9cf7d9d6e416ac49dd62c09683677bcfa4673d0d027a33ec23f0e0b248ac144a +size 14201942 diff --git a/tests/cases/cep/spiral_BO_2d/svFSI.xml b/tests/cases/cep/spiral_BO_2d/svFSI.xml index 2a18b3af..ad9b3daa 100644 --- a/tests/cases/cep/spiral_BO_2d/svFSI.xml +++ b/tests/cases/cep/spiral_BO_2d/svFSI.xml @@ -49,8 +49,8 @@ true 1 - 5 - 1e-4 + 2 + 1e-12 BO @@ -87,10 +87,8 @@ - - rcs - - 1e-6 + rcs + 1e-12 diff --git a/tests/cases/cep/square_AP_2d/result_001.vtu b/tests/cases/cep/square_AP_2d/result_001.vtu index e8ff19f1..3c45cb1c 100644 --- a/tests/cases/cep/square_AP_2d/result_001.vtu +++ b/tests/cases/cep/square_AP_2d/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:60bc623969a212be4f5e87be73a614329489d3f587e5c07fe1970ececee23c24 -size 2180579 +oid sha256:61e7da67b5f90550dbbf3fbeef101f45494e5de92f0db1b536f26a92f8b3ef36 +size 2174946 diff --git a/tests/cases/cep/square_AP_2d/svFSI.xml b/tests/cases/cep/square_AP_2d/svFSI.xml index 99635666..5d48cf1d 100644 --- a/tests/cases/cep/square_AP_2d/svFSI.xml +++ b/tests/cases/cep/square_AP_2d/svFSI.xml @@ -49,8 +49,8 @@ true 1 - 4 - 1e-4 + 2 + 1e-12 AP @@ -74,10 +74,8 @@ - - fsils - - 1e-6 + fsils + 1e-12 diff --git a/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml b/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml index ea9dec2c..152f6a75 100755 --- a/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml +++ b/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml @@ -60,9 +60,6 @@ - - fsils - 10 10 300 diff --git a/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml b/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml index e0b4b382..b6d9a9f6 100755 --- a/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml +++ b/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml @@ -48,14 +48,14 @@ - - fsils - 500 1e-12 50 + + + traction spatial diff --git a/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml b/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml index bb68a5eb..e94f1a01 100755 --- a/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml +++ b/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml @@ -79,12 +79,11 @@ - - fsils - + FSILS 100 1e-12 + Dir diff --git a/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml b/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml index ac825aa4..df1e690a 100755 --- a/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml @@ -61,9 +61,6 @@ - - fsils - 10 3 500 diff --git a/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml b/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml index 365ff66d..45496fdf 100644 --- a/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml @@ -45,9 +45,6 @@ - - fsils - 500 1e-12 diff --git a/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml b/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml index b6639dc4..5f115416 100644 --- a/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml @@ -48,9 +48,6 @@ - - fsils - 500 1e-12 diff --git a/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml b/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml index d7407b2a..b882537b 100644 --- a/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml @@ -70,13 +70,12 @@ - - fsils - + FSILS 10 1e-12 50 + Dir diff --git a/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml b/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml index 0ec907cb..4485f508 100644 --- a/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml @@ -71,9 +71,7 @@ - - fsils - + FSILS 100 1e-12 diff --git a/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml b/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml index 917c0608..bf19dc23 100755 --- a/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml +++ b/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml @@ -62,9 +62,6 @@ - - fsils - 100 1e-12 diff --git a/tests/cases/heats/diffusion_line_source/svFSI_CG.xml b/tests/cases/heats/diffusion_line_source/svFSI_CG.xml index adb0a73c..99579a64 100755 --- a/tests/cases/heats/diffusion_line_source/svFSI_CG.xml +++ b/tests/cases/heats/diffusion_line_source/svFSI_CG.xml @@ -62,9 +62,7 @@ - - rcs - + RCS 1e-12 diff --git a/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml b/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml index 52002bd5..f3f60bba 100755 --- a/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml +++ b/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml @@ -62,9 +62,7 @@ - - fsils - + FSILS 100 1e-12 50 diff --git a/tests/cases/shell/plate/svFSI.xml b/tests/cases/shell/plate/svFSI.xml index 12d9d47e..9b03ff7d 100644 --- a/tests/cases/shell/plate/svFSI.xml +++ b/tests/cases/shell/plate/svFSI.xml @@ -69,9 +69,6 @@ - - fsils - 1e-12 100 50 diff --git a/tests/cases/shell/valve/svFSI.xml b/tests/cases/shell/valve/svFSI.xml index 5df6e564..a03b5554 100644 --- a/tests/cases/shell/valve/svFSI.xml +++ b/tests/cases/shell/valve/svFSI.xml @@ -111,9 +111,6 @@ - - fsils - 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml index 6c841099..6f726a08 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml @@ -54,9 +54,7 @@ 10.0 - - fsils - + svfsi 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml index 9f7c24e5..41d99f7a 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml @@ -54,9 +54,7 @@ 10.0 - - fsils - + svfsi 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml index a2337808..91dd1cfa 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml @@ -54,10 +54,7 @@ 10.0 - - fsils - - 1e-9 + svfsi 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml index 77e5a9ee..e394d60f 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml @@ -54,9 +54,7 @@ 10.0 - - fsils - + svfsi 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml index 601115cb..321c300b 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml @@ -60,9 +60,7 @@ 10.0 - - fsils - + svfsi 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml index ff3cd9cc..779ed2cf 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml @@ -60,9 +60,8 @@ 10.0 - - trilinos-ilut - + + Trilinos-ILUT 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml index 48712fbf..b822d29a 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml @@ -60,9 +60,8 @@ 10.0 - - trilinos-ilut - + + Trilinos-ILUT 1e-9 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml index 815e63f3..46c215b6 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml @@ -54,9 +54,8 @@ 0.0 - - trilinos-diagnonal - + + Trilinos-Diagonal 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml index 0238139f..b5b0d685 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml @@ -54,9 +54,8 @@ 0.0 - - trilinos-diagnonal - + + Trilinos-Diagonal 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml index 54288f9b..ce4617c7 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml @@ -54,9 +54,8 @@ 0.0 - - trilinos-diagnonal - + + Trilinos-Diagonal 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml index f2fbdd7b..0a3535cf 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml @@ -54,9 +54,9 @@ 0.0 - - trilinos-diagnonal - + + + Trilinos-Diagonal 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml index 60fac398..fa557672 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml @@ -54,9 +54,7 @@ 0.0 - - rcs - + RCS 1e-9 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml index ff2a7758..3efaab47 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml @@ -54,9 +54,7 @@ 0.0 - - rcs - + RCS 1e-9 100 50 diff --git a/tests/cases/struct/LV_Guccione_passive/svFSI.xml b/tests/cases/struct/LV_Guccione_passive/svFSI.xml index 4f1086c7..fae73d81 100644 --- a/tests/cases/struct/LV_Guccione_passive/svFSI.xml +++ b/tests/cases/struct/LV_Guccione_passive/svFSI.xml @@ -79,9 +79,7 @@ - - fsils - + FSILS 1e-14 400 @@ -101,4 +99,4 @@ - + \ No newline at end of file diff --git a/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml b/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml index 2253a66b..e08d1e22 100644 --- a/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml +++ b/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml @@ -44,10 +44,10 @@ mesh/fibersLongCells.vtu mesh/fibersSheetCells.vtu - 100.0 + 100.0 - + true @@ -55,16 +55,16 @@ 4 1e-10 - 1.0 - 1.0e6 + 1.0 + 1.0e6 0.483333 0.0 - 590.0 - 8.023 + 590.0 + 8.023 184720.0 16.026 24810.0 @@ -88,9 +88,7 @@ - - fsils - + FSILS 1e-12 1000 50 @@ -98,8 +96,8 @@ Robin - 1.0e7 - 5.0e2 + 1.0e7 + 5.0e2 1 diff --git a/tests/cases/struct/block_compression/svFSI.xml b/tests/cases/struct/block_compression/svFSI.xml index 8571d652..8a2536cf 100644 --- a/tests/cases/struct/block_compression/svFSI.xml +++ b/tests/cases/struct/block_compression/svFSI.xml @@ -84,9 +84,7 @@ - - fsils - + FSILS 1e-12 600 diff --git a/tests/cases/struct/robin/svFSI.xml b/tests/cases/struct/robin/svFSI.xml index 3ca743fd..05581f91 100644 --- a/tests/cases/struct/robin/svFSI.xml +++ b/tests/cases/struct/robin/svFSI.xml @@ -71,9 +71,7 @@ - - fsils - + FSILS 1e-12 600 diff --git a/tests/cases/ustruct/LV_Guccione_active/result_001.vtu b/tests/cases/ustruct/LV_Guccione_active/result_001.vtu index 20dc8af9..6a022183 100644 --- a/tests/cases/ustruct/LV_Guccione_active/result_001.vtu +++ b/tests/cases/ustruct/LV_Guccione_active/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e96385b077d909be53eb8db6d7b3fe23a485aa1c7183af28920474128126f622 -size 71817 +oid sha256:9a063d96839c465428d82ffc4638c16feb3a33d9ee49422353b5f300f5b79479 +size 45994 diff --git a/tests/cases/ustruct/LV_Guccione_active/svFSI.xml b/tests/cases/ustruct/LV_Guccione_active/svFSI.xml index 1589360f..493e198e 100644 --- a/tests/cases/ustruct/LV_Guccione_active/svFSI.xml +++ b/tests/cases/ustruct/LV_Guccione_active/svFSI.xml @@ -75,9 +75,7 @@ - - fsils - + svfsi 1e-12 100 50 diff --git a/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml b/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml index d723f84d..85f3e4a5 100644 --- a/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml +++ b/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml @@ -91,9 +91,7 @@ - - fsils - + svfsi 1e-12 100 500 diff --git a/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml b/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml index 70c94d93..dab127b8 100644 --- a/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml +++ b/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml @@ -95,9 +95,7 @@ - - fsils - + FSILS 1e-12 100 50 diff --git a/tests/test_struct.py b/tests/test_struct.py index 5376207d..b6658479 100644 --- a/tests/test_struct.py +++ b/tests/test_struct.py @@ -1,4 +1,6 @@ from .conftest import run_with_reference +import os +import subprocess # Common folder for all tests in this file base_folder = "struct" @@ -31,7 +33,29 @@ def test_block_compression(n_proc): test_folder = "block_compression" run_with_reference(base_folder, test_folder, fields, n_proc) - def test_robin(n_proc): test_folder = "robin" run_with_reference(base_folder, test_folder, fields, n_proc) + +def test_LV_NeoHookean_passive(n_proc): + test_folder = "LV_NeoHookean_passive" + run_with_reference(base_folder, test_folder, fields, n_proc, t_max=5) + +def test_LV_NeoHookean_passive_genBC(n_proc): + test_folder = "LV_NeoHookean_passive_genBC" + + # Remove old genBC output + os.chdir(os.path.join("cases", base_folder, test_folder)) + for name in ["AllData", "InitialData", "GenBC.int"]: + if os.path.isfile(name): + os.remove(name) + + # Compile genBC + os.chdir("genBC_svFSIplus") + subprocess.run(["make", "clean"], check=True) + subprocess.run(["make"], check=True) + + # Change back to original directory + os.chdir("../../../../") + + run_with_reference(base_folder, test_folder, fields, n_proc, t_max=3) diff --git a/tests/test_ustruct.py b/tests/test_ustruct.py index b276edeb..f60b853d 100644 --- a/tests/test_ustruct.py +++ b/tests/test_ustruct.py @@ -1,5 +1,6 @@ import os import pytest +import subprocess from .conftest import run_with_reference @@ -32,3 +33,22 @@ def test_tensile_adventitia_HGO(n_proc): def test_LV_Guccione_active(n_proc): test_folder = "LV_Guccione_active" run_with_reference(base_folder, test_folder, fields, n_proc) + +def test_LV_NeoHookean_passive_genBC(n_proc): + test_folder = "LV_NeoHookean_passive_genBC" + + # Remove old genBC output + os.chdir(os.path.join("cases", base_folder, test_folder)) + for name in ["AllData", "InitialData", "GenBC.int"]: + if os.path.isfile(name): + os.remove(name) + + # Compile genBC + os.chdir("genBC_svFSIplus") + subprocess.run(["make", "clean"], check=True) + subprocess.run(["make"], check=True) + + # Change back to original directory + os.chdir("../../../../") + + run_with_reference(base_folder, test_folder, fields, n_proc, t_max=3) From b887fd6aa14382cd941909a1ce9fedcf985c2ed3 Mon Sep 17 00:00:00 2001 From: dcodoni <160075903+dcodoni@users.noreply.github.com> Date: Thu, 16 May 2024 18:17:02 -0700 Subject: [PATCH 4/6] Update README.md --- Docker/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Docker/README.md b/Docker/README.md index c5fb7304..0af87b95 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -1,11 +1,11 @@ # Docker -In order to use the dockerfiles and/or docker containers, Docker Desktop must be installed. Docker installation is straightforward [install](https://www.docker.com/products/docker-desktop/). +In order to use the dockerfiles and/or docker containers, Docker Desktop must be installed. Docker [installation](https://www.docker.com/products/docker-desktop/) is straightforward. Once installed, Docker engine can be started using the graphic interface of Docker. When the engine is running, the containers can be built and run using the terminal's commands. It is suggested to change the resources that Docker engine is using, since containers may require more memory than the default allocation. In order to do this, open Docker Desktop, then click on settings->resources, adjust based on personal needs. It is also useful to change the default storage limite of the Docker Engine in settings->Docker Engine and change the builder storage default. ## Docker containers A container is an isolated environment based on a specific operating system (OS) (typically Linux based), in which a solver can be built. The environment created in a container includes all the dependencies of the solver that needs to be built. Once the container is created, it can be run on any machine and the solver can be built directly in this virtual environment. -In this work the containers are created using Docker software [Docker](https://www.docker.com). A Docker container is built from a dockerfile. After it is created, it is saved as an image that can be copied anywhere is needed or uploaded on the cloud DockerHub [DockerHub](https://hub.docker.com). +In this work the containers are created using software [Docker](https://www.docker.com). A Docker container is built from a dockerfile. After it is created, it is saved as an image that can be copied anywhere is needed or uploaded on the cloud [DockerHub](https://hub.docker.com). ## Dockerfile In the folder Docker/ there are two subfolders ubuntu20/ and ubuntu22/ containing a dockerfile each. A dockerfile usually begins with an image import of the environment OS, which in this case is Ubuntu-20.04 and Ubuntu-22.04. From a353e3906e1bb1e188639bdfb818583eb6e1672b Mon Sep 17 00:00:00 2001 From: dcodoni Date: Fri, 17 May 2024 16:02:03 -0700 Subject: [PATCH 5/6] Test Cases added, tolerances set to the updated value from svFSIplus and README file for Docker created. --- Docker/README.md | 4 ++-- tests/cases/cep/cable_TTP_1d/result_001.vtu | 4 ++-- tests/cases/cep/cable_TTP_1d/svFSI.xml | 3 +++ .../result_BICG_CN_epicardium_BO_001.vtu | 4 ++-- .../result_CG_RK4_myocardium_BO_001.vtu | 4 ++-- .../result_GMRES_FE_epicardium_TTP_001.vtu | 4 ++-- .../result_GMRES_FE_pfib_AP_001.vtu | 4 ++-- .../svFSI_BICG_CN_epicardium_BO.xml | 7 +++++-- .../svFSI_CG_RK4_myocardium_BO.xml | 8 +++++--- .../svFSI_GMRES_FE_epicardium_TTP.xml | 7 +++++-- .../svFSI_GMRES_FE_pfib_AP.xml | 7 +++++-- tests/cases/cep/purkinje/result_001.vtu | 4 ++-- tests/cases/cep/purkinje/svFSI.xml | 3 +++ tests/cases/cep/spiral_BO_2d/result_001.vtu | 4 ++-- tests/cases/cep/spiral_BO_2d/svFSI.xml | 4 +++- tests/cases/cep/square_AP_2d/result_001.vtu | 4 ++-- tests/cases/cep/square_AP_2d/svFSI.xml | 4 +++- .../1-rigid-solution/svFSI.xml | 3 +++ .../2-inflate/svFSI.xml | 6 +++--- .../3-inflate-cmm/svFSI.xml | 5 +++-- .../cmm/pipe_3d/1-rigid-solution/svFSI.xml | 3 +++ tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml | 3 +++ .../cases/cmm/pipe_3d/2b-prestress/svFSI.xml | 3 +++ .../cmm/pipe_3d/3a-inflate-cmm/svFSI.xml | 5 +++-- .../cmm/pipe_3d/3b-prestress-cmm/svFSI.xml | 4 +++- tests/cases/fsi/pipe_3d/svFSI.xml | 3 +-- tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml | 3 +-- tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml | 3 +-- tests/cases/fsi/pipe_3d_petsc/svFSI.xml | 3 +-- .../diffusion_line_source/svFSI_BICG.xml | 3 +++ .../heats/diffusion_line_source/svFSI_CG.xml | 4 +++- .../diffusion_line_source/svFSI_GMRES.xml | 4 +++- tests/cases/shell/plate/svFSI.xml | 3 +++ tests/cases/shell/valve/svFSI.xml | 3 +++ .../manufactured_solution/P1P1/N004/svFSI.xml | 4 +++- .../manufactured_solution/P1P1/N008/svFSI.xml | 4 +++- .../manufactured_solution/P1P1/N016/svFSI.xml | 5 ++++- .../manufactured_solution/P1P1/N032/svFSI.xml | 4 +++- .../manufactured_solution/P1P1/N064/svFSI.xml | 4 +++- .../manufactured_solution/P1P1/N128/svFSI.xml | 5 +++-- .../manufactured_solution/P1P1/N256/svFSI.xml | 5 +++-- .../manufactured_solution/P2P1/N004/svFSI.xml | 5 +++-- .../manufactured_solution/P2P1/N008/svFSI.xml | 5 +++-- .../manufactured_solution/P2P1/N016/svFSI.xml | 5 +++-- .../manufactured_solution/P2P1/N032/svFSI.xml | 6 +++--- .../manufactured_solution/P2P1/N064/svFSI.xml | 4 +++- .../manufactured_solution/P2P1/N128/svFSI.xml | 4 +++- .../struct/LV_Guccione_passive/svFSI.xml | 6 ++++-- .../struct/LV_Holzapfel_passive/svFSI.xml | 20 ++++++++++--------- .../struct/LV_NeoHookean_passive/svFSI.xml | 4 +++- .../LV_NeoHookean_passive_genBC/svFSI.xml | 4 +++- .../cases/struct/block_compression/svFSI.xml | 4 +++- tests/cases/struct/robin/svFSI.xml | 4 +++- .../ustruct/LV_Guccione_active/result_001.vtu | 4 ++-- .../ustruct/LV_Guccione_active/svFSI.xml | 4 +++- .../LV_NeoHookean_passive_genBC/svFSI.xml | 4 +++- .../block_compression/P1P1_VMS/svFSI.xml | 4 +++- .../ustruct/tensile_adventitia_HGO/svFSI.xml | 4 +++- 58 files changed, 174 insertions(+), 88 deletions(-) diff --git a/Docker/README.md b/Docker/README.md index c5fb7304..10e9811d 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -1,11 +1,11 @@ # Docker -In order to use the dockerfiles and/or docker containers, Docker Desktop must be installed. Docker installation is straightforward [install](https://www.docker.com/products/docker-desktop/). +In order to use the dockerfiles and/or docker containers, Docker Desktop must be installed. Docker [installation](https://www.docker.com/products/docker-desktop/) is straightforward. Once installed, Docker engine can be started using the graphic interface of Docker. When the engine is running, the containers can be built and run using the terminal's commands. It is suggested to change the resources that Docker engine is using, since containers may require more memory than the default allocation. In order to do this, open Docker Desktop, then click on settings->resources, adjust based on personal needs. It is also useful to change the default storage limite of the Docker Engine in settings->Docker Engine and change the builder storage default. ## Docker containers A container is an isolated environment based on a specific operating system (OS) (typically Linux based), in which a solver can be built. The environment created in a container includes all the dependencies of the solver that needs to be built. Once the container is created, it can be run on any machine and the solver can be built directly in this virtual environment. -In this work the containers are created using Docker software [Docker](https://www.docker.com). A Docker container is built from a dockerfile. After it is created, it is saved as an image that can be copied anywhere is needed or uploaded on the cloud DockerHub [DockerHub](https://hub.docker.com). +In this work the containers are created using [Docker](https://www.docker.com). A Docker container is built from a dockerfile. After it is created, it is saved as an image that can be copied anywhere is needed or uploaded on the cloud [DockerHub](https://hub.docker.com). ## Dockerfile In the folder Docker/ there are two subfolders ubuntu20/ and ubuntu22/ containing a dockerfile each. A dockerfile usually begins with an image import of the environment OS, which in this case is Ubuntu-20.04 and Ubuntu-22.04. diff --git a/tests/cases/cep/cable_TTP_1d/result_001.vtu b/tests/cases/cep/cable_TTP_1d/result_001.vtu index e8d9f50c..a98765d8 100644 --- a/tests/cases/cep/cable_TTP_1d/result_001.vtu +++ b/tests/cases/cep/cable_TTP_1d/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8be46ee399abf9577bb89126c7d7e0bca146dac9d0c5ce10b97086abe85b078c -size 3862 +oid sha256:15a085fafbfa77ab98c969cb81495a4e2d01d22eacd39f248db78a40f3d8d714 +size 4075 diff --git a/tests/cases/cep/cable_TTP_1d/svFSI.xml b/tests/cases/cep/cable_TTP_1d/svFSI.xml index 5f0dfc95..d4caf296 100644 --- a/tests/cases/cep/cable_TTP_1d/svFSI.xml +++ b/tests/cases/cep/cable_TTP_1d/svFSI.xml @@ -57,6 +57,9 @@ + + fsils + 100 1e-12 50 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu index 4e7b6e6c..03842bc3 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_BICG_CN_epicardium_BO_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:5ca618669a71038a1385eb16a483d0d4ac1b4213df67a15d59b0522d47f8ac71 -size 8238606 +oid sha256:6af5a1ba655072991230391acabfddff4cb3a34b0a5c81241ee4a311aa550fe3 +size 8305950 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu index 4cdc28a4..91f6d532 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_CG_RK4_myocardium_BO_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:94e247849b57f1feac14e3cde7c52af13b4112751a41a7320754b91da1c8f7cd -size 8282430 +oid sha256:bd7cc1fa1369a3965e615577e1f9c584cd794013794cf0d1077217a19b2ac88f +size 8279618 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu index ecd13e8b..8d8a62f7 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_epicardium_TTP_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:862e6a065fc065f25169b9b0ca220e4e4ea70ab461d0eae68bb38435fcb8b729 -size 8224038 +oid sha256:4a3b96e0e8fad864daeda38acf5fbe46a0db55a054a60b7c28542ec94d258098 +size 8288167 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu index a7a017b4..05deeb85 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/result_GMRES_FE_pfib_AP_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a38f51e854c188ffee9a4e893de80fc5bb617d93ac68112d587ca75aef172d38 -size 8301266 +oid sha256:d044cb38f9578ec54541e5097674dbce5b06bd7b8fd7b5f56ae36f78590c770e +size 8286611 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml index 575b28aa..f34e11b6 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-12 + 1e-6 BO @@ -104,8 +104,11 @@ + + fsils + 100 - 1e-12 + 1e-6 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml index 255f4e31..5479af77 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_CG_RK4_myocardium_BO.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-12 + 1e-6 BO @@ -104,8 +104,10 @@ - svfsi - 1e-12 + + fsils + + 1e-6 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml index fe6aa6eb..b5d8fe6f 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_epicardium_TTP.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-12 + 1e-6 TTP @@ -116,8 +116,11 @@ + + fsils + 100 - 1e-12 + 1e-6 50 diff --git a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml index 31745800..3b666f2e 100644 --- a/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml +++ b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_GMRES_FE_pfib_AP.xml @@ -68,7 +68,7 @@ true 1 1 - 1e-12 + 1e-6 AP @@ -104,8 +104,11 @@ + + fsils + 100 - 1e-12 + 1e-6 50 diff --git a/tests/cases/cep/purkinje/result_001.vtu b/tests/cases/cep/purkinje/result_001.vtu index 66163a3e..9fb9be7f 100644 --- a/tests/cases/cep/purkinje/result_001.vtu +++ b/tests/cases/cep/purkinje/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1bf39effdb55cf6f0ee63645720a788c869b6eeba3dc23c044cc15321e2c0eef -size 718891 +oid sha256:cd457cc3a4b72665dfbc0814b22071f7b2fbe718b0a11a3b52e32a8793ff5c84 +size 722384 diff --git a/tests/cases/cep/purkinje/svFSI.xml b/tests/cases/cep/purkinje/svFSI.xml index 0209f2ca..8aa70824 100644 --- a/tests/cases/cep/purkinje/svFSI.xml +++ b/tests/cases/cep/purkinje/svFSI.xml @@ -67,6 +67,9 @@ + + fsils + 100 1e-12 50 diff --git a/tests/cases/cep/spiral_BO_2d/result_001.vtu b/tests/cases/cep/spiral_BO_2d/result_001.vtu index 9e3dab81..32fd4a4f 100644 --- a/tests/cases/cep/spiral_BO_2d/result_001.vtu +++ b/tests/cases/cep/spiral_BO_2d/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9cf7d9d6e416ac49dd62c09683677bcfa4673d0d027a33ec23f0e0b248ac144a -size 14201942 +oid sha256:6e05fcc0004f38abef3eede2d4a8e9b62f4e33269886d9f3bbcddc0d49f8ed72 +size 14228715 diff --git a/tests/cases/cep/spiral_BO_2d/svFSI.xml b/tests/cases/cep/spiral_BO_2d/svFSI.xml index ad9b3daa..7e37b9fb 100644 --- a/tests/cases/cep/spiral_BO_2d/svFSI.xml +++ b/tests/cases/cep/spiral_BO_2d/svFSI.xml @@ -87,7 +87,9 @@ - rcs + + rcs + 1e-12 diff --git a/tests/cases/cep/square_AP_2d/result_001.vtu b/tests/cases/cep/square_AP_2d/result_001.vtu index 3c45cb1c..e8ff19f1 100644 --- a/tests/cases/cep/square_AP_2d/result_001.vtu +++ b/tests/cases/cep/square_AP_2d/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:61e7da67b5f90550dbbf3fbeef101f45494e5de92f0db1b536f26a92f8b3ef36 -size 2174946 +oid sha256:60bc623969a212be4f5e87be73a614329489d3f587e5c07fe1970ececee23c24 +size 2180579 diff --git a/tests/cases/cep/square_AP_2d/svFSI.xml b/tests/cases/cep/square_AP_2d/svFSI.xml index 5d48cf1d..d3e54a7d 100644 --- a/tests/cases/cep/square_AP_2d/svFSI.xml +++ b/tests/cases/cep/square_AP_2d/svFSI.xml @@ -74,7 +74,9 @@ - fsils + + fsils + 1e-12 diff --git a/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml b/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml index 152f6a75..ea9dec2c 100755 --- a/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml +++ b/tests/cases/cmm/iliac_artery_variable_wall_props/1-rigid-solution/svFSI.xml @@ -60,6 +60,9 @@ + + fsils + 10 10 300 diff --git a/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml b/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml index b6d9a9f6..e0b4b382 100755 --- a/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml +++ b/tests/cases/cmm/iliac_artery_variable_wall_props/2-inflate/svFSI.xml @@ -48,14 +48,14 @@ + + fsils + 500 1e-12 50 - - - traction spatial diff --git a/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml b/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml index e94f1a01..bb68a5eb 100755 --- a/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml +++ b/tests/cases/cmm/iliac_artery_variable_wall_props/3-inflate-cmm/svFSI.xml @@ -79,11 +79,12 @@ - FSILS + + fsils + 100 1e-12 - Dir diff --git a/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml b/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml index df1e690a..ac825aa4 100755 --- a/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/1-rigid-solution/svFSI.xml @@ -61,6 +61,9 @@ + + fsils + 10 3 500 diff --git a/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml b/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml index 45496fdf..365ff66d 100644 --- a/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/2a-inflate/svFSI.xml @@ -45,6 +45,9 @@ + + fsils + 500 1e-12 diff --git a/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml b/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml index 5f115416..b6639dc4 100644 --- a/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/2b-prestress/svFSI.xml @@ -48,6 +48,9 @@ + + fsils + 500 1e-12 diff --git a/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml b/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml index b882537b..d7407b2a 100644 --- a/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/3a-inflate-cmm/svFSI.xml @@ -70,12 +70,13 @@ - FSILS + + fsils + 10 1e-12 50 - Dir diff --git a/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml b/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml index 4485f508..0ec907cb 100644 --- a/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml +++ b/tests/cases/cmm/pipe_3d/3b-prestress-cmm/svFSI.xml @@ -71,7 +71,9 @@ - FSILS + + fsils + 100 1e-12 diff --git a/tests/cases/fsi/pipe_3d/svFSI.xml b/tests/cases/fsi/pipe_3d/svFSI.xml index 61649eae..fb8f03c5 100755 --- a/tests/cases/fsi/pipe_3d/svFSI.xml +++ b/tests/cases/fsi/pipe_3d/svFSI.xml @@ -12,7 +12,7 @@ result 5 1 - 100 + 1 0 1 0 @@ -83,7 +83,6 @@ fsils - 1e-6 1e-12 100 50 diff --git a/tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml b/tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml index 5ce9f28d..7232e927 100755 --- a/tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml @@ -12,7 +12,7 @@ result 5 1 - 100 + 1 0 1 0 @@ -83,7 +83,6 @@ trilinos-blockjacobi - 1e-6 1e-12 100 50 diff --git a/tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml b/tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml index b8e75921..83a619a7 100755 --- a/tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml @@ -12,7 +12,7 @@ result 5 1 - 100 + 1 0 1 0 @@ -83,7 +83,6 @@ trilinos-ml - 1e-6 1e-12 100 50 diff --git a/tests/cases/fsi/pipe_3d_petsc/svFSI.xml b/tests/cases/fsi/pipe_3d_petsc/svFSI.xml index 329e794e..30ed00bb 100755 --- a/tests/cases/fsi/pipe_3d_petsc/svFSI.xml +++ b/tests/cases/fsi/pipe_3d_petsc/svFSI.xml @@ -12,7 +12,7 @@ result 5 1 - 100 + 1 0 1 0 @@ -83,7 +83,6 @@ petsc-jacobi - 1e-6 1e-12 100 50 diff --git a/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml b/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml index bf19dc23..917c0608 100755 --- a/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml +++ b/tests/cases/heats/diffusion_line_source/svFSI_BICG.xml @@ -62,6 +62,9 @@ + + fsils + 100 1e-12 diff --git a/tests/cases/heats/diffusion_line_source/svFSI_CG.xml b/tests/cases/heats/diffusion_line_source/svFSI_CG.xml index 99579a64..adb0a73c 100755 --- a/tests/cases/heats/diffusion_line_source/svFSI_CG.xml +++ b/tests/cases/heats/diffusion_line_source/svFSI_CG.xml @@ -62,7 +62,9 @@ - RCS + + rcs + 1e-12 diff --git a/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml b/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml index f3f60bba..52002bd5 100755 --- a/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml +++ b/tests/cases/heats/diffusion_line_source/svFSI_GMRES.xml @@ -62,7 +62,9 @@ - FSILS + + fsils + 100 1e-12 50 diff --git a/tests/cases/shell/plate/svFSI.xml b/tests/cases/shell/plate/svFSI.xml index 9b03ff7d..12d9d47e 100644 --- a/tests/cases/shell/plate/svFSI.xml +++ b/tests/cases/shell/plate/svFSI.xml @@ -69,6 +69,9 @@ + + fsils + 1e-12 100 50 diff --git a/tests/cases/shell/valve/svFSI.xml b/tests/cases/shell/valve/svFSI.xml index a03b5554..5df6e564 100644 --- a/tests/cases/shell/valve/svFSI.xml +++ b/tests/cases/shell/valve/svFSI.xml @@ -111,6 +111,9 @@ + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml index 6f726a08..6c841099 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N004/svFSI.xml @@ -54,7 +54,9 @@ 10.0 - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml index 41d99f7a..9f7c24e5 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N008/svFSI.xml @@ -54,7 +54,9 @@ 10.0 - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml index 91dd1cfa..a2337808 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N016/svFSI.xml @@ -54,7 +54,10 @@ 10.0 - svfsi + + fsils + + 1e-9 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml index e394d60f..77e5a9ee 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N032/svFSI.xml @@ -54,7 +54,9 @@ 10.0 - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml index 321c300b..601115cb 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N064/svFSI.xml @@ -60,7 +60,9 @@ 10.0 - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml index 779ed2cf..ff3cd9cc 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N128/svFSI.xml @@ -60,8 +60,9 @@ 10.0 - - Trilinos-ILUT + + trilinos-ilut + 1e-12 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml b/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml index b822d29a..48712fbf 100644 --- a/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P1P1/N256/svFSI.xml @@ -60,8 +60,9 @@ 10.0 - - Trilinos-ILUT + + trilinos-ilut + 1e-9 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml index 46c215b6..815e63f3 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N004/svFSI.xml @@ -54,8 +54,9 @@ 0.0 - - Trilinos-Diagonal + + trilinos-diagnonal + 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml index b5b0d685..0238139f 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N008/svFSI.xml @@ -54,8 +54,9 @@ 0.0 - - Trilinos-Diagonal + + trilinos-diagnonal + 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml index ce4617c7..54288f9b 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N016/svFSI.xml @@ -54,8 +54,9 @@ 0.0 - - Trilinos-Diagonal + + trilinos-diagnonal + 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml index 0a3535cf..f2fbdd7b 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N032/svFSI.xml @@ -54,9 +54,9 @@ 0.0 - - - Trilinos-Diagonal + + trilinos-diagnonal + 1e-9 1000 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml index fa557672..60fac398 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N064/svFSI.xml @@ -54,7 +54,9 @@ 0.0 - RCS + + rcs + 1e-9 100 50 diff --git a/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml b/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml index 3efaab47..ff2a7758 100644 --- a/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml +++ b/tests/cases/stokes/manufactured_solution/P2P1/N128/svFSI.xml @@ -54,7 +54,9 @@ 0.0 - RCS + + rcs + 1e-9 100 50 diff --git a/tests/cases/struct/LV_Guccione_passive/svFSI.xml b/tests/cases/struct/LV_Guccione_passive/svFSI.xml index fae73d81..4f1086c7 100644 --- a/tests/cases/struct/LV_Guccione_passive/svFSI.xml +++ b/tests/cases/struct/LV_Guccione_passive/svFSI.xml @@ -79,7 +79,9 @@ - FSILS + + fsils + 1e-14 400 @@ -99,4 +101,4 @@ - \ No newline at end of file + diff --git a/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml b/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml index e08d1e22..2253a66b 100644 --- a/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml +++ b/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml @@ -44,10 +44,10 @@ mesh/fibersLongCells.vtu mesh/fibersSheetCells.vtu - 100.0 + 100.0 - + true @@ -55,16 +55,16 @@ 4 1e-10 - 1.0 - 1.0e6 + 1.0 + 1.0e6 0.483333 0.0 - 590.0 - 8.023 + 590.0 + 8.023 184720.0 16.026 24810.0 @@ -88,7 +88,9 @@ - FSILS + + fsils + 1e-12 1000 50 @@ -96,8 +98,8 @@ Robin - 1.0e7 - 5.0e2 + 1.0e7 + 5.0e2 1 diff --git a/tests/cases/struct/LV_NeoHookean_passive/svFSI.xml b/tests/cases/struct/LV_NeoHookean_passive/svFSI.xml index f820ef98..529b4c10 100644 --- a/tests/cases/struct/LV_NeoHookean_passive/svFSI.xml +++ b/tests/cases/struct/LV_NeoHookean_passive/svFSI.xml @@ -76,7 +76,9 @@ - FSILS + + fsils + 1e-9 1000 50 diff --git a/tests/cases/struct/LV_NeoHookean_passive_genBC/svFSI.xml b/tests/cases/struct/LV_NeoHookean_passive_genBC/svFSI.xml index d8a0a9ee..4b8153b8 100644 --- a/tests/cases/struct/LV_NeoHookean_passive_genBC/svFSI.xml +++ b/tests/cases/struct/LV_NeoHookean_passive_genBC/svFSI.xml @@ -76,7 +76,9 @@ - FSILS + + fsils + 1e-9 1000 50 diff --git a/tests/cases/struct/block_compression/svFSI.xml b/tests/cases/struct/block_compression/svFSI.xml index 8a2536cf..8571d652 100644 --- a/tests/cases/struct/block_compression/svFSI.xml +++ b/tests/cases/struct/block_compression/svFSI.xml @@ -84,7 +84,9 @@ - FSILS + + fsils + 1e-12 600 diff --git a/tests/cases/struct/robin/svFSI.xml b/tests/cases/struct/robin/svFSI.xml index 05581f91..3ca743fd 100644 --- a/tests/cases/struct/robin/svFSI.xml +++ b/tests/cases/struct/robin/svFSI.xml @@ -71,7 +71,9 @@ - FSILS + + fsils + 1e-12 600 diff --git a/tests/cases/ustruct/LV_Guccione_active/result_001.vtu b/tests/cases/ustruct/LV_Guccione_active/result_001.vtu index 6a022183..20dc8af9 100644 --- a/tests/cases/ustruct/LV_Guccione_active/result_001.vtu +++ b/tests/cases/ustruct/LV_Guccione_active/result_001.vtu @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9a063d96839c465428d82ffc4638c16feb3a33d9ee49422353b5f300f5b79479 -size 45994 +oid sha256:e96385b077d909be53eb8db6d7b3fe23a485aa1c7183af28920474128126f622 +size 71817 diff --git a/tests/cases/ustruct/LV_Guccione_active/svFSI.xml b/tests/cases/ustruct/LV_Guccione_active/svFSI.xml index 493e198e..1589360f 100644 --- a/tests/cases/ustruct/LV_Guccione_active/svFSI.xml +++ b/tests/cases/ustruct/LV_Guccione_active/svFSI.xml @@ -75,7 +75,9 @@ - svfsi + + fsils + 1e-12 100 50 diff --git a/tests/cases/ustruct/LV_NeoHookean_passive_genBC/svFSI.xml b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/svFSI.xml index 669fee21..65c51282 100644 --- a/tests/cases/ustruct/LV_NeoHookean_passive_genBC/svFSI.xml +++ b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/svFSI.xml @@ -77,7 +77,9 @@ - FSILS + + fsils + 1e-9 1000 50 diff --git a/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml b/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml index 85f3e4a5..d723f84d 100644 --- a/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml +++ b/tests/cases/ustruct/block_compression/P1P1_VMS/svFSI.xml @@ -91,7 +91,9 @@ - svfsi + + fsils + 1e-12 100 500 diff --git a/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml b/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml index dab127b8..70c94d93 100644 --- a/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml +++ b/tests/cases/ustruct/tensile_adventitia_HGO/svFSI.xml @@ -95,7 +95,9 @@ - FSILS + + fsils + 1e-12 100 50 From 40e47a7502d013aa3c46a5472327baf90d1f5394 Mon Sep 17 00:00:00 2001 From: dcodoni Date: Fri, 17 May 2024 16:11:22 -0700 Subject: [PATCH 6/6] README.md file fixed --- Docker/README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Docker/README.md b/Docker/README.md index a721824c..0af87b95 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -5,11 +5,7 @@ It is suggested to change the resources that Docker engine is using, since conta ## Docker containers A container is an isolated environment based on a specific operating system (OS) (typically Linux based), in which a solver can be built. The environment created in a container includes all the dependencies of the solver that needs to be built. Once the container is created, it can be run on any machine and the solver can be built directly in this virtual environment. -<<<<<<< HEAD -In this work the containers are created using [Docker](https://www.docker.com). A Docker container is built from a dockerfile. After it is created, it is saved as an image that can be copied anywhere is needed or uploaded on the cloud [DockerHub](https://hub.docker.com). -======= In this work the containers are created using software [Docker](https://www.docker.com). A Docker container is built from a dockerfile. After it is created, it is saved as an image that can be copied anywhere is needed or uploaded on the cloud [DockerHub](https://hub.docker.com). ->>>>>>> b887fd6aa14382cd941909a1ce9fedcf985c2ed3 ## Dockerfile In the folder Docker/ there are two subfolders ubuntu20/ and ubuntu22/ containing a dockerfile each. A dockerfile usually begins with an image import of the environment OS, which in this case is Ubuntu-20.04 and Ubuntu-22.04.