Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trilinos and PETSc interfaces (#30) and Docker containers (#211) #216

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/test_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -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 }}



25 changes: 0 additions & 25 deletions .github/workflows/test_ubuntu20.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/test_ubuntu22.yml

This file was deleted.

62 changes: 52 additions & 10 deletions Code/Source/svFSI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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})
Expand Down Expand Up @@ -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}
Expand Down
41 changes: 17 additions & 24 deletions Code/Source/svFSI/ComMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
#include <string>
#include <vector>

class LinearAlgebra;

/// @brief Fourier coefficients that are used to specify unsteady BCs
//
class fcType
Expand Down Expand Up @@ -613,7 +615,6 @@ class outputType
std::string name;
};


/// @brief Linear system of equations solver type
//
class lsType
Expand All @@ -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;

Expand Down Expand Up @@ -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;
};


Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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<int> ltg;

/// @brief Factor for Dirichlet BCs
Array<double> W;

/// @brief Residual
Array<double> R;
};


/// @brief The ComMod class duplicates the data structures in the Fortran COMMOD module
/// defined in MOD.f.
///
Expand Down Expand Up @@ -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;
Expand Down
Loading
Loading