diff --git a/.github/workflows/test_ubuntu.yml b/.github/workflows/test_ubuntu.yml new file mode 100644 index 00000000..dbddd316 --- /dev/null +++ b/.github/workflows/test_ubuntu.yml @@ -0,0 +1,64 @@ +name: test Ubuntu +on: [push, pull_request] +jobs: + test: + strategy: + matrix: + name: [Ubuntu-20.04, Ubuntu-22.04] + include: + - name: Ubuntu-20.04 + version: ubuntu-20.04 + image: ubuntu20 + - name: Ubuntu-22.04 + version: ubuntu-22.04 + image: ubuntu22 + runs-on: ${{ matrix.version }} + container: dcodoni/lib:${{ matrix.image }} + steps: + - uses: actions/checkout@v3 + - name: Build svFSIplus + run: | + if [ -d "build" ]; then + rm -rf "build" + fi + 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 }} + + + 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..7adb0f89 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}) @@ -267,24 +296,37 @@ if(ENABLE_UNIT_TEST) find_package(Threads REQUIRED) # install Google Test + #if(NOT TARGET gtest_main AND NOT TARGET gtest) include(FetchContent) FetchContent_Declare( googletest - URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip + URL https://github.com/google/googletest/archive/refs/heads/main.zip + DOWNLOAD_EXTRACT_TIMESTAMP TRUE ) FetchContent_MakeAvailable(googletest) + #endif() + 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") + set(TEST_SOURCES "../../../tests/unitTests/test.cpp") list(REMOVE_ITEM CSRCS "main.cpp") - + list(APPEND CSRCS ${TEST_SOURCES}) + # include source files (same as what svFSI does except for main.cpp) add_executable(run_all_unit_tests ${CSRCS}) + if(USE_TRILINOS) + target_link_libraries(run_all_unit_tests ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES}) + endif() + + if(USE_PETSC) + target_link_libraries(run_all_unit_tests ${PETSC_LIBRARY_DIRS}) + endif() + # libraries target_link_libraries(run_all_unit_tests ${GLOBAL_LIBRARIES} diff --git a/Code/Source/svFSI/ComMod.h b/Code/Source/svFSI/ComMod.h index dcd0536d..7ff6d5e2 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; }; @@ -1071,6 +1072,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 +1302,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. /// @@ -1597,9 +1593,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..4dad059f 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(); @@ -2143,6 +2150,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 +2280,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 +2298,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 +2310,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 +2321,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..6c02feb9 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 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.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/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..8d7e9720 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 { @@ -462,11 +469,25 @@ std::ostream& operator<<(typename std::enable_if::value, std::os //// 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..73ea5c0b 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]; @@ -485,7 +486,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 +930,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 +985,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 +1149,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]); } + } diff --git a/Code/Source/svFSI/eq_assem.cpp b/Code/Source/svFSI/eq_assem.cpp index fe274e30..fe6b3400 100644 --- a/Code/Source/svFSI/eq_assem.cpp +++ b/Code/Source/svFSI/eq_assem.cpp @@ -53,10 +53,6 @@ #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,21 +167,10 @@ 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. /// We use Nanson's formula to take change in normal direction with @@ -309,103 +294,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/fluid.cpp b/Code/Source/svFSI/fluid.cpp index bf640f57..e35b3362 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, @@ -675,19 +671,7 @@ void construct_fluid(ComMod& com_mod, const mshType& lM, const Array& 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..48ef42a0 100644 --- a/Code/Source/svFSI/initialize.cpp +++ b/Code/Source/svFSI/initialize.cpp @@ -573,15 +573,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); 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..608a57f2 100644 --- a/Code/Source/svFSI/lhsa.cpp +++ b/Code/Source/svFSI/lhsa.cpp @@ -96,10 +96,13 @@ 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/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..c9eb5df4 100644 --- a/Code/Source/svFSI/main.cpp +++ b/Code/Source/svFSI/main.cpp @@ -60,6 +60,22 @@ #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. // void read_files(Simulation* simulation, const std::string& file_name) @@ -812,6 +828,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/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/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/read_files.cpp b/Code/Source/svFSI/read_files.cpp index 41312c00..acb77d1e 100644 --- a/Code/Source/svFSI/read_files.cpp +++ b/Code/Source/svFSI/read_files.cpp @@ -1968,6 +1968,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 +1987,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 +2006,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 +2016,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 +2048,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 +2077,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..a955223a 100644 --- a/Code/Source/svFSI/set_bc.cpp +++ b/Code/Source/svFSI/set_bc.cpp @@ -44,10 +44,6 @@ #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, @@ -1301,14 +1297,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); } } @@ -1663,16 +1652,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 +1767,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/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..f9755d60 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, @@ -361,28 +357,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_linear_solver.cpp b/Code/Source/svFSI/trilinos_impl.cpp similarity index 80% rename from Code/Source/svFSI/trilinos_linear_solver.cpp rename to Code/Source/svFSI/trilinos_impl.cpp index 0d9bb69d..3009b90f 100644 --- a/Code/Source/svFSI/trilinos_linear_solver.cpp +++ b/Code/Source/svFSI/trilinos_impl.cpp @@ -39,7 +39,8 @@ \brief wrap Trilinos solver functions */ -#include "trilinos_linear_solver.h" +#include "trilinos_impl.h" +#include "ComMod.h" #define NOOUTPUT // --- Define global Trilinos variables to be used in below functions --------- @@ -155,12 +156,6 @@ 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) -*/ { #ifdef debug_trilinos_lhs_create @@ -338,9 +333,14 @@ void trilinos_lhs_create_(unsigned &numGlobalNodes, unsigned &numLocalNodes, * \param lR element local force vector of size * (dof, numNodesPerElement) */ -void trilinos_doassem_(int &numNodesPerElement, const int *eqN, - const double *lK, double *lR) +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; @@ -409,7 +409,7 @@ void trilinos_doassem_(int &numNodesPerElement, const int *eqN, error = Trilinos::K->EndSubmitEntries(); if (error != 0) { - std::cout << "ERROR: End submitting block entries!" << std::endl; + std::cout << "[trilinos_doassem_] ERROR: End submitting block entries!" << std::endl; exit(1); } } @@ -443,10 +443,6 @@ void trilinos_global_solve_(const double *Val, const double *RHS, double *x, double &solverTime, double &dB, bool &converged, int &lsType, double &relTol, int &maxIters, int &kspace, int &precondType) { - - //std::cout << "[trilinos_global_solve] ========== trilinos_global_solve ==========" << std::endl; - //std::cout << "[trilinos_global_solve] ghostAndLocalNodes: " << ghostAndLocalNodes << std::endl; - int nnzCount = 0; //cumulate count of block nnz per rows int count = 0; int numValuesPerID = dof; //dof values per id pointer to dof @@ -1079,4 +1075,253 @@ void printSolutionToFile() 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_linear_solver.h b/Code/Source/svFSI/trilinos_impl.h similarity index 100% rename from Code/Source/svFSI/trilinos_linear_solver.h rename to Code/Source/svFSI/trilinos_impl.h diff --git a/Code/Source/svFSI/ustruct.cpp b/Code/Source/svFSI/ustruct.cpp index 8e661ca1..3ddd9744 100644 --- a/Code/Source/svFSI/ustruct.cpp +++ b/Code/Source/svFSI/ustruct.cpp @@ -377,24 +377,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/ThirdParty/metis_svfsi/simvascular_metis_svfsi/METISLib/temp/metis.h b/Code/ThirdParty/metis_svfsi/simvascular_metis_svfsi/METISLib/temp/metis.h new file mode 100644 index 00000000..c8cd6cde --- /dev/null +++ b/Code/ThirdParty/metis_svfsi/simvascular_metis_svfsi/METISLib/temp/metis.h @@ -0,0 +1,359 @@ +/*! +\file metis.h +\brief This file contains function prototypes and constant definitions for METIS + * +\author George +\date Started 8/9/02 +\version\verbatim $Id$\endverbatim +*/ + +#ifndef _METIS_H_ +#define _METIS_H_ + +/**************************************************************************** +* A set of defines that can be modified by the user +*****************************************************************************/ + +/*-------------------------------------------------------------------------- + Specifies the width of the elementary data type that will hold information + about vertices and their adjacency lists. + + Possible values: + 32 : Use 32 bit signed integers + 64 : Use 64 bit signed integers + + A width of 64 should be specified if the number of vertices or the total + number of edges in the graph exceed the limits of a 32 bit signed integer + i.e., 2^31-1. + Proper use of 64 bit integers requires that the c99 standard datatypes + int32_t and int64_t are supported by the compiler. + GCC does provides these definitions in stdint.h, but it may require some + modifications on other architectures. +--------------------------------------------------------------------------*/ +// IDXTYPEWIDTH must be set to 32, setting it to 64 causes a failure. +#define IDXTYPEWIDTH 32 + +/*-------------------------------------------------------------------------- + Specifies the data type that will hold floating-point style information. + + Possible values: + 32 : single precision floating point (float) + 64 : double precision floating point (double) +--------------------------------------------------------------------------*/ +// REALTYPEWIDTH must be set to 32, setting it to 64 causes a failure. +#define REALTYPEWIDTH 32 + +/**************************************************************************** +* In principle, nothing needs to be changed beyond this point, unless the +* int32_t and int64_t cannot be found in the normal places. +*****************************************************************************/ + +/* Uniform definitions for various compilers */ +#if defined(_MSC_VER) + #define COMPILER_MSC +#endif +#if defined(__ICC) + #define COMPILER_ICC +#endif +#if defined(__GNUC__) + #define COMPILER_GCC +#endif + +/* Include c99 int definitions and need constants. When building the library, + * these are already defined by GKlib hence the test for _GKLIB_H_ */ +#ifndef _GKLIB_H_ +#ifdef COMPILER_MSC +#include + +typedef __int32 int32_t +typedef __int64 int64_t +#define PRId32 "I32d" +#define PRId64 "I64d" +#define SCNd32 "ld" +#define SCNd64 "I64d" +#define INT32_MIN ((int32_t)_I32_MIN) +#define INT32_MAX _I32_MAX +#define INT64_MIN ((int64_t)_I64_MIN) +#define INT64_MAX _I64_MAX +#else +#include +#endif +#endif + + +/*------------------------------------------------------------------------ +* Setup the basic datatypes +*-------------------------------------------------------------------------*/ +#if IDXTYPEWIDTH == 32 + typedef int32_t idx_t + + #define IDX_MAX INT32_MAX + #define IDX_MIN INT32_MIN + + #define SCIDX SCNd32 + #define PRIDX PRId32 + + #define strtoidx strtol + #define iabs abs +#elif IDXTYPEWIDTH == 64 + typedef int64_t idx_t + + #define IDX_MAX INT64_MAX + #define IDX_MIN INT64_MIN + + #define SCIDX SCNd64 + #define PRIDX PRId64 + +#ifdef COMPILER_MSC + #define strtoidx _strtoi64 +#else + #define strtoidx strtoll +#endif + #define iabs labs +#else + #error "Incorrect user-supplied value fo IDXTYPEWIDTH" +#endif + + +#if REALTYPEWIDTH == 32 + typedef float real_t + + #define SCREAL "f" + #define PRREAL "f" + #define REAL_MAX FLT_MAX + #define REAL_MIN FLT_MIN + #define REAL_EPSILON FLT_EPSILON + + #define rabs fabsf + #define REALEQ(x,y) ((rabs((x)-(y)) <= FLT_EPSILON)) + +#ifdef COMPILER_MSC + #define strtoreal (float)strtod +#else + #define strtoreal strtof +#endif +#elif REALTYPEWIDTH == 64 + typedef double real_t + + #define SCREAL "lf" + #define PRREAL "lf" + #define REAL_MAX DBL_MAX + #define REAL_MIN DBL_MIN + #define REAL_EPSILON DBL_EPSILON + + #define rabs fabs + #define REALEQ(x,y) ((rabs((x)-(y)) <= DBL_EPSILON)) + + #define strtoreal strtod +#else + #error "Incorrect user-supplied value for REALTYPEWIDTH" +#endif + + +/*------------------------------------------------------------------------ +* Constant definitions +*-------------------------------------------------------------------------*/ +/* Metis's version number */ +#define METIS_VER_MAJOR 5 +#define METIS_VER_MINOR 2 +#define METIS_VER_SUBMINOR 1 + +/* The maximum length of the options[] array */ +#define METIS_NOPTIONS 40 + + + +/*------------------------------------------------------------------------ +* Function prototypes +*-------------------------------------------------------------------------*/ + +#ifdef _WINDLL +#define METIS_API(type) __declspec(dllexport) type __cdecl +#elif defined(__cdecl) +#define METIS_API(type) type __cdecl +#else +#define METIS_API(type) type +#endif + + + +#ifdef __cplusplus +extern "C" { +#endif + +METIS_API(int) METIS_PartGraphRecursive(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, + idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, + idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, + idx_t *edgecut, idx_t *part) + +METIS_API(int) METIS_PartGraphKway(idx_t *nvtxs, idx_t *ncon, idx_t *xadj, + idx_t *adjncy, idx_t *vwgt, idx_t *vsize, idx_t *adjwgt, + idx_t *nparts, real_t *tpwgts, real_t *ubvec, idx_t *options, + idx_t *edgecut, idx_t *part) + +METIS_API(int) METIS_MeshToDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, + idx_t *ncommon, idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy) + +METIS_API(int) METIS_MeshToNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, + idx_t *numflag, idx_t **r_xadj, idx_t **r_adjncy) + +METIS_API(int) METIS_PartMeshNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, + idx_t *vwgt, idx_t *vsize, idx_t *nparts, real_t *tpwgts, + idx_t *options, idx_t *objval, idx_t *epart, idx_t *npart) + +METIS_API(int) METIS_PartMeshDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, + idx_t *vwgt, idx_t *vsize, idx_t *ncommon, idx_t *nparts, + real_t *tpwgts, idx_t *options, idx_t *objval, idx_t *epart, + idx_t *npart) + +METIS_API(int) METIS_NodeND(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, + idx_t *options, idx_t *perm, idx_t *iperm) + +METIS_API(int) METIS_Free(void *ptr) + +METIS_API(int) METIS_SetDefaultOptions(idx_t *options) + + +/* These functions are used by ParMETIS */ + +METIS_API(int) METIS_NodeNDP(idx_t nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, + idx_t npes, idx_t *options, idx_t *perm, idx_t *iperm, + idx_t *sizes) + +METIS_API(int) METIS_ComputeVertexSeparator(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, + idx_t *vwgt, idx_t *options, idx_t *sepsize, idx_t *part) + +METIS_API(int) METIS_NodeRefine(idx_t nvtxs, idx_t *xadj, idx_t *vwgt, idx_t *adjncy, + idx_t *where, idx_t *hmarker, real_t ubfactor) + + +/* These functions are used by DGL */ + +METIS_API(int) METIS_CacheFriendlyReordering(idx_t nvtxs, idx_t *xadj, idx_t *adjncy, + idx_t *part, idx_t *old2new) + +#ifdef __cplusplus +} +#endif + + + +/*------------------------------------------------------------------------ +* Enum type definitions +*-------------------------------------------------------------------------*/ +/*! Return codes */ +typedef enum { + METIS_OK = 1, /*!< Returned normally */ + METIS_ERROR_INPUT = -2, /*!< Returned due to erroneous inputs and/or options */ + METIS_ERROR_MEMORY = -3, /*!< Returned due to insufficient memory */ + METIS_ERROR = -4 /*!< Some other errors */ +} rstatus_et + + +/*! Operation type codes */ +typedef enum { + METIS_OP_PMETIS, + METIS_OP_KMETIS, + METIS_OP_OMETIS +} moptype_et + + +/*! Options codes (i.e., options[]) */ +typedef enum { + METIS_OPTION_PTYPE, + METIS_OPTION_OBJTYPE, + METIS_OPTION_CTYPE, + METIS_OPTION_IPTYPE, + METIS_OPTION_RTYPE, + METIS_OPTION_DBGLVL, + METIS_OPTION_NIPARTS, + METIS_OPTION_NITER, + METIS_OPTION_NCUTS, + METIS_OPTION_SEED, + METIS_OPTION_ONDISK, + METIS_OPTION_MINCONN, + METIS_OPTION_CONTIG, + METIS_OPTION_COMPRESS, + METIS_OPTION_CCORDER, + METIS_OPTION_PFACTOR, + METIS_OPTION_NSEPS, + METIS_OPTION_UFACTOR, + METIS_OPTION_NUMBERING, + METIS_OPTION_DROPEDGES, + METIS_OPTION_NO2HOP, + METIS_OPTION_TWOHOP, + METIS_OPTION_FAST, + + /* Used for command-line parameter purposes */ + METIS_OPTION_HELP, + METIS_OPTION_TPWGTS, + METIS_OPTION_NCOMMON, + METIS_OPTION_NOOUTPUT, + METIS_OPTION_BALANCE, + METIS_OPTION_GTYPE, + METIS_OPTION_UBVEC +} moptions_et + + +/*! Partitioning Schemes */ +typedef enum { + METIS_PTYPE_RB, + METIS_PTYPE_KWAY +} mptype_et + +/*! Graph types for meshes */ +typedef enum { + METIS_GTYPE_DUAL, + METIS_GTYPE_NODAL +} mgtype_et + +/*! Coarsening Schemes */ +typedef enum { + METIS_CTYPE_RM, + METIS_CTYPE_SHEM +} mctype_et + +/*! Initial partitioning schemes */ +typedef enum { + METIS_IPTYPE_GROW, + METIS_IPTYPE_RANDOM, + METIS_IPTYPE_EDGE, + METIS_IPTYPE_NODE, + METIS_IPTYPE_METISRB +} miptype_et + + +/*! Refinement schemes */ +typedef enum { + METIS_RTYPE_FM, + METIS_RTYPE_GREEDY, + METIS_RTYPE_SEP2SIDED, + METIS_RTYPE_SEP1SIDED +} mrtype_et + + +/*! Debug Levels */ +typedef enum { + METIS_DBG_INFO = 1, /*!< Shows various diagnostic messages */ + METIS_DBG_TIME = 2, /*!< Perform timing analysis */ + METIS_DBG_COARSEN = 4, /*!< Show the coarsening progress */ + METIS_DBG_REFINE = 8, /*!< Show the refinement progress */ + METIS_DBG_IPART = 16, /*!< Show info on initial partitioning */ + METIS_DBG_MOVEINFO = 32, /*!< Show info on vertex moves during refinement */ + METIS_DBG_SEPINFO = 64, /*!< Show info on vertex moves during sep refinement */ + METIS_DBG_CONNINFO = 128, /*!< Show info on minimization of subdomain connectivity */ + METIS_DBG_CONTIGINFO = 256, /*!< Show info on elimination of connected components */ + METIS_DBG_MEMORY = 2048 /*!< Show info related to wspace allocation */ +} mdbglvl_et + + +/* Types of objectives */ +typedef enum { + METIS_OBJTYPE_CUT, + METIS_OBJTYPE_VOL, + METIS_OBJTYPE_NODE +} mobjtype_et + + + +#endif /* _METIS_H_ */ diff --git a/Docker/README.md b/Docker/README.md new file mode 100644 index 00000000..0af87b95 --- /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](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 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. +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/dockerfile b/Docker/ubuntu20/dockerfile new file mode 100644 index 00000000..46a59b6d --- /dev/null +++ b/Docker/ubuntu20/dockerfile @@ -0,0 +1,656 @@ +# ================================================================================ +# 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 + +#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/build +RUN cmake -C /hdf5build/hdf5/config/cmake/cacheinit.cmake -G "Unix Makefiles" \ +-DHDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16:BOOL=OFF \ +-DHDF5_BUILD_JAVA:BOOL=OFF \ +-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 \ +-DTrilinos_ENABLE_Gtest=OFF /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 + +# ================================================================================ +# GOOGLE TEST +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:20.04 AS buildgtest + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi + +ENV PATH="/cmake/bin:/openmpi/bin:${PATH}" + +# 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 \ + 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/* + +# ================================================================================ +# GTEST +RUN git clone https://github.com/google/googletest.git -b v1.14.0 +WORKDIR /googletest +RUN mkdir build && \ + cd build && \ + cmake .. -DBUILD_SHARED_LIBS=ON -DBUILD_GMOCK=OFF -DCMAKE_INSTALL_PREFIX=/google && \ + make && \ + make install + +# Clenup +WORKDIR / +RUN rm -rf /googletest + +# ================================================================================ +# 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 +COPY --from=buildgtest /google /google + +# ================================================================================ +# 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="/google:/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..d9ac677f --- /dev/null +++ b/Docker/ubuntu22/dockerfile @@ -0,0 +1,656 @@ +# ================================================================================ +# 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 + +#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/build +RUN cmake -C /hdf5build/hdf5/config/cmake/cacheinit.cmake -G "Unix Makefiles" \ +-DHDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16:BOOL=OFF \ +-DHDF5_BUILD_JAVA:BOOL=OFF \ +-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 \ +-DTrilinos_ENABLE_Gtest=OFF /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 + +# ================================================================================ +# GOOGLE TEST +# ================================================================================ +# Use a base image for building tools and dependencise +FROM ubuntu:22.04 AS buildgtest + +# Copy all dependencies and set ENV +COPY --from=buildcmake /cmake /cmake +COPY --from=buildompi /openmpi /openmpi + +ENV PATH="/cmake/bin:/openmpi/bin:${PATH}" + +# 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 \ + 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/* + +# ================================================================================ +# GTEST +RUN git clone https://github.com/google/googletest.git -b v1.14.0 +WORKDIR /googletest +RUN mkdir build && \ + cd build && \ + cmake .. -DBUILD_SHARED_LIBS=ON -DBUILD_GMOCK=OFF -DCMAKE_INSTALL_PREFIX=/google && \ + make && \ + make install + +# Clenup +WORKDIR / +RUN rm -rf /googletest + +# ================================================================================ +# 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 +COPY --from=buildgtest /google /google + +# ================================================================================ +# 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="/google:/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/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/svFSI_BICG_CN_epicardium_BO.xml b/tests/cases/cep/niederer_benchmark_ECGs_quadrature/svFSI_BICG_CN_epicardium_BO.xml index 575b28aa..21428c64 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 @@ -104,6 +104,9 @@ + + fsils + 100 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 255f4e31..b02fc20f 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 @@ -104,7 +104,9 @@ - svfsi + + fsils + 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 fe6aa6eb..40164f9d 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 @@ -116,6 +116,9 @@ + + fsils + 100 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 31745800..726663d5 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 @@ -104,6 +104,9 @@ + + fsils + 100 1e-12 50 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/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/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/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/fluid/pipe_RCR_3d_trilinos_bj/README.md b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/README.md new file mode 100755 index 00000000..67fcc6bb --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/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_trilinos_bj/lumen_inlet.fcs b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/lumen_inlet.fcs new file mode 100755 index 00000000..84448314 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/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_trilinos_bj/lumen_inlet.flow b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/lumen_inlet.flow new file mode 100755 index 00000000..174af3c6 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/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_trilinos_bj/mesh/mesh-complete.mesh.vtu b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/mesh/mesh-complete.mesh.vtu new file mode 100644 index 00000000..36bc739d --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/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_trilinos_bj/mesh/mesh-surfaces/lumen_inlet.vtp b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/mesh/mesh-surfaces/lumen_inlet.vtp new file mode 100644 index 00000000..6311c773 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/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_trilinos_bj/mesh/mesh-surfaces/lumen_outlet.vtp b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/mesh/mesh-surfaces/lumen_outlet.vtp new file mode 100644 index 00000000..9aa15e6e --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/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_trilinos_bj/mesh/mesh-surfaces/lumen_wall.vtp b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/mesh/mesh-surfaces/lumen_wall.vtp new file mode 100644 index 00000000..b5f092a5 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/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_trilinos_bj/result_002.vtu b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/result_002.vtu new file mode 100644 index 00000000..d3084268 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/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_trilinos_bj/svFSI.xml b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/svFSI.xml new file mode 100755 index 00000000..11c6c7fd --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_bj/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_trilinos_ilut/README.md b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/README.md new file mode 100755 index 00000000..67fcc6bb --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/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_trilinos_ilut/lumen_inlet.fcs b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/lumen_inlet.fcs new file mode 100755 index 00000000..84448314 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/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_trilinos_ilut/lumen_inlet.flow b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/lumen_inlet.flow new file mode 100755 index 00000000..174af3c6 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/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_trilinos_ilut/mesh/mesh-complete.mesh.vtu b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/mesh/mesh-complete.mesh.vtu new file mode 100644 index 00000000..36bc739d --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/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_trilinos_ilut/mesh/mesh-surfaces/lumen_inlet.vtp b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/mesh/mesh-surfaces/lumen_inlet.vtp new file mode 100644 index 00000000..6311c773 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/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_trilinos_ilut/mesh/mesh-surfaces/lumen_outlet.vtp b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/mesh/mesh-surfaces/lumen_outlet.vtp new file mode 100644 index 00000000..9aa15e6e --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/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_trilinos_ilut/mesh/mesh-surfaces/lumen_wall.vtp b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/mesh/mesh-surfaces/lumen_wall.vtp new file mode 100644 index 00000000..b5f092a5 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/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_trilinos_ilut/result_002.vtu b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/result_002.vtu new file mode 100644 index 00000000..d3084268 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/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_trilinos_ilut/svFSI.xml b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/svFSI.xml new file mode 100755 index 00000000..bf9eea56 --- /dev/null +++ b/tests/cases/fluid/pipe_RCR_3d_trilinos_ilut/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/precomputed_dye_AD/svFSI.xml b/tests/cases/fluid/precomputed_dye_AD/svFSI.xml index fbcc46c7..c5546ceb 100644 --- a/tests/cases/fluid/precomputed_dye_AD/svFSI.xml +++ b/tests/cases/fluid/precomputed_dye_AD/svFSI.xml @@ -67,7 +67,9 @@ - FSILS + + fsils + 1e-6 100 50 diff --git a/tests/cases/fsi/pipe_3d/svFSI.xml b/tests/cases/fsi/pipe_3d/svFSI.xml index 4befad05..fb8f03c5 100755 --- a/tests/cases/fsi/pipe_3d/svFSI.xml +++ b/tests/cases/fsi/pipe_3d/svFSI.xml @@ -10,7 +10,7 @@ STOP_SIM true result - 1 + 5 1 1 0 @@ -80,8 +80,9 @@ - FSILS - + + fsils + 1e-12 100 50 @@ -130,7 +131,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..7232e927 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_bj_trilinos/svFSI.xml @@ -0,0 +1,156 @@ + + + + + 0 + 3 + 5 + 1e-4 + 0.50 + STOP_SIM + true + result + 5 + 1 + 1 + 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-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..83a619a7 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_ml_trilinos/svFSI.xml @@ -0,0 +1,156 @@ + + + + + 0 + 3 + 5 + 1e-4 + 0.50 + STOP_SIM + true + result + 5 + 1 + 1 + 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-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..30ed00bb --- /dev/null +++ b/tests/cases/fsi/pipe_3d_petsc/svFSI.xml @@ -0,0 +1,156 @@ + + + + + 0 + 3 + 5 + 1e-4 + 0.50 + STOP_SIM + true + result + 5 + 1 + 1 + 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-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/fsi/pipe_3d_trilinos_bj/README.md b/tests/cases/fsi/pipe_3d_trilinos_bj/README.md new file mode 100755 index 00000000..9c92f6a3 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/configuration.png b/tests/cases/fsi/pipe_3d_trilinos_bj/configuration.png new file mode 100644 index 00000000..47d287aa --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/mesh/fluid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_trilinos_bj/mesh/fluid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..8ddb1119 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/mesh/fluid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_trilinos_bj/mesh/fluid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..e7c6c313 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/mesh/fluid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_trilinos_bj/mesh/fluid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..c52d70d2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/mesh/fluid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_trilinos_bj/mesh/fluid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..55f41e4f --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/mesh/solid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_trilinos_bj/mesh/solid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..08402c8e --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/mesh/solid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_trilinos_bj/mesh/solid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..4f2a8129 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/mesh/solid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_trilinos_bj/mesh/solid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..9a8bafd8 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/mesh/solid/mesh-surfaces/outside.vtp b/tests/cases/fsi/pipe_3d_trilinos_bj/mesh/solid/mesh-surfaces/outside.vtp new file mode 100644 index 00000000..1c5fbfe2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/mesh/solid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_trilinos_bj/mesh/solid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..37fd38c9 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/result_005.vtu b/tests/cases/fsi/pipe_3d_trilinos_bj/result_005.vtu new file mode 100644 index 00000000..b3c68f1b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/results.gif b/tests/cases/fsi/pipe_3d_trilinos_bj/results.gif new file mode 100644 index 00000000..0c87216b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_bj/svFSI.xml b/tests/cases/fsi/pipe_3d_trilinos_bj/svFSI.xml new file mode 100755 index 00000000..5ce9f28d --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_bj/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_trilinos_ml/README.md b/tests/cases/fsi/pipe_3d_trilinos_ml/README.md new file mode 100755 index 00000000..9c92f6a3 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/configuration.png b/tests/cases/fsi/pipe_3d_trilinos_ml/configuration.png new file mode 100644 index 00000000..47d287aa --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/mesh/fluid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_trilinos_ml/mesh/fluid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..8ddb1119 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/mesh/fluid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_trilinos_ml/mesh/fluid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..e7c6c313 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/mesh/fluid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_trilinos_ml/mesh/fluid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..c52d70d2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/mesh/fluid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_trilinos_ml/mesh/fluid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..55f41e4f --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/mesh/solid/mesh-complete.mesh.vtu b/tests/cases/fsi/pipe_3d_trilinos_ml/mesh/solid/mesh-complete.mesh.vtu new file mode 100644 index 00000000..08402c8e --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/mesh/solid/mesh-surfaces/end.vtp b/tests/cases/fsi/pipe_3d_trilinos_ml/mesh/solid/mesh-surfaces/end.vtp new file mode 100644 index 00000000..4f2a8129 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/mesh/solid/mesh-surfaces/interface.vtp b/tests/cases/fsi/pipe_3d_trilinos_ml/mesh/solid/mesh-surfaces/interface.vtp new file mode 100644 index 00000000..9a8bafd8 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/mesh/solid/mesh-surfaces/outside.vtp b/tests/cases/fsi/pipe_3d_trilinos_ml/mesh/solid/mesh-surfaces/outside.vtp new file mode 100644 index 00000000..1c5fbfe2 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/mesh/solid/mesh-surfaces/start.vtp b/tests/cases/fsi/pipe_3d_trilinos_ml/mesh/solid/mesh-surfaces/start.vtp new file mode 100644 index 00000000..37fd38c9 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/result_005.vtu b/tests/cases/fsi/pipe_3d_trilinos_ml/result_005.vtu new file mode 100644 index 00000000..b3c68f1b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/results.gif b/tests/cases/fsi/pipe_3d_trilinos_ml/results.gif new file mode 100644 index 00000000..0c87216b --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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_trilinos_ml/svFSI.xml b/tests/cases/fsi/pipe_3d_trilinos_ml/svFSI.xml new file mode 100755 index 00000000..b8e75921 --- /dev/null +++ b/tests/cases/fsi/pipe_3d_trilinos_ml/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/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..d3d7007c 100644 --- a/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml +++ b/tests/cases/struct/LV_Holzapfel_passive/svFSI.xml @@ -88,7 +88,9 @@ - FSILS + + fsils + 1e-12 1000 50 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/genBC_svFSIplus/genBC.exe b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/genBC.exe new file mode 100755 index 00000000..d49ebdd0 Binary files /dev/null and b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/genBC.exe differ diff --git a/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/GenBC.o b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/GenBC.o new file mode 100644 index 00000000..cd7f8c85 Binary files /dev/null and b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/GenBC.o differ diff --git a/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/Modules.o b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/Modules.o new file mode 100644 index 00000000..50a54281 Binary files /dev/null and b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/Modules.o differ diff --git a/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/USER.o b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/USER.o new file mode 100644 index 00000000..7a77aafe Binary files /dev/null and b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/USER.o differ diff --git a/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/com.mod b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/com.mod new file mode 100644 index 00000000..4f421fcd Binary files /dev/null and b/tests/cases/struct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/com.mod differ diff --git a/tests/cases/struct/LV_NeoHookean_passive_genBC/svFSI.xml b/tests/cases/struct/LV_NeoHookean_passive_genBC/svFSI.xml index d8a0a9ee..4ce3b646 100644 --- a/tests/cases/struct/LV_NeoHookean_passive_genBC/svFSI.xml +++ b/tests/cases/struct/LV_NeoHookean_passive_genBC/svFSI.xml @@ -50,8 +50,8 @@ true 3 - 10 - 1e-9 + 20 + 1e-12 1.0 1.0e5 @@ -76,10 +76,12 @@ - FSILS - 1e-9 - 1000 - 50 + + fsils + + 1e-12 + 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/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/genBC_svFSIplus/genBC.exe b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/genBC.exe new file mode 100755 index 00000000..d49ebdd0 Binary files /dev/null and b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/genBC.exe differ diff --git a/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/GenBC.o b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/GenBC.o new file mode 100644 index 00000000..cd7f8c85 Binary files /dev/null and b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/GenBC.o differ diff --git a/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/Modules.o b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/Modules.o new file mode 100644 index 00000000..50a54281 Binary files /dev/null and b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/Modules.o differ diff --git a/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/USER.o b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/USER.o new file mode 100644 index 00000000..7a77aafe Binary files /dev/null and b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/USER.o differ diff --git a/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/com.mod b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/com.mod new file mode 100644 index 00000000..4f421fcd Binary files /dev/null and b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/genBC_svFSIplus/obj/com.mod differ diff --git a/tests/cases/ustruct/LV_NeoHookean_passive_genBC/svFSI.xml b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/svFSI.xml index 669fee21..ec7758a8 100644 --- a/tests/cases/ustruct/LV_NeoHookean_passive_genBC/svFSI.xml +++ b/tests/cases/ustruct/LV_NeoHookean_passive_genBC/svFSI.xml @@ -50,8 +50,8 @@ true 3 - 10 - 1e-9 + 20 + 1e-12 1.0 1.0e5 @@ -77,8 +77,10 @@ - FSILS - 1e-9 + + fsils + + 1e-12 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 diff --git a/tests/conftest.py b/tests/conftest.py index 4c4fd670..3f5ed9bd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,11 +3,16 @@ 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 = { @@ -58,16 +63,44 @@ def run_by_name(folder, name, t_max, n_proc=1): 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 +137,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..c26a9ff0 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" 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