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

PETSc and Trilinos interface #214

Closed
wants to merge 7 commits into from
Closed
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
60 changes: 60 additions & 0 deletions .github/workflows/test_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: test Ubuntu
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
os:
- name: Ubuntu-20.04
version: ubuntu-20.04
image: ubuntu20
- name: Ubuntu-22.04
version: ubuntu-22.04
image: ubuntu22
runs-on: ${{ matrix.os.version }}
container: dcodoni/lib:${{ matrix.os.image }}
steps:
- uses: actions/checkout@v3
- name: Build svFSIplus
run: |
mkdir build
cd build
cmake -DENABLE_COVERAGE=ON -DENABLE_ARRAY_INDEX_CHECKING=ON -DENABLE_UNIT_TEST=ON -DSV_USE_TRILINOS:BOOL=ON ..
make -j2
cd ..
- name: Build svFSIplus (PETSc)
run: |
if [ -d "build-petsc" ]; then
rm -rf "build-petsc"
fi
mkdir build-petsc
cd build-petsc
cmake -DENABLE_COVERAGE=ON -DENABLE_ARRAY_INDEX_CHECKING=ON -DENABLE_UNIT_TEST=ON -DSV_PETSC_DIR:STRING=/petsc ..
make -j2
cd ..
- name: Run integration tests
run: |
git config --global --add safe.directory /__w/svFSIplus/svFSIplus
git lfs pull
cd tests
conda run -n svfsiplus pytest -rPv --durations=0
- name: Run unit tests
run: |
cd build/svFSI-build/Source/svFSI
ctest --verbose
- name: Generate code coverage
run: |
cd build/svFSI-build
make coverage
- name: Save coverage report
uses: actions/upload-artifact@v3
with:
name: coverage_report
path: build/svFSI-build/coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}



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.

95 changes: 36 additions & 59 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 @@ -260,56 +289,4 @@ if(ENABLE_COVERAGE)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
endif()

# unit tests and Google Test
if(ENABLE_UNIT_TEST)

# link pthread on ubuntu20
find_package(Threads REQUIRED)

# install Google Test
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
FetchContent_MakeAvailable(googletest)
enable_testing()
include(GoogleTest)

# add test.cpp for unit test

# remove the main.cpp and add test.cpp
list(APPEND CSRCS "../../../tests/unitTests/test.cpp")
list(REMOVE_ITEM CSRCS "main.cpp")

# include source files (same as what svFSI does except for main.cpp)
add_executable(run_all_unit_tests ${CSRCS})

# libraries
target_link_libraries(run_all_unit_tests
${GLOBAL_LIBRARIES}
${INTELRUNTIME_LIBRARIES}
${ZLIB_LIBRARY}
${BLAS_LIBRARIES}
${LAPACK_LIBRARIES}
${METIS_SVFSI_LIBRARY_NAME}
${PARMETIS_SVFSI_LIBRARY_NAME}
${TETGEN_LIBRARY_NAME}
${TINYXML_LIBRARY_NAME}
${SV_LIB_SVFSILS_NAME}${SV_MPI_NAME_EXT}
${VTK_LIBRARIES}
)

# link Google Test
target_link_libraries(
run_all_unit_tests
gtest
GTest::gtest_main
pthread # link pthread on ubuntu20
)

# gtest_discover_tests(runUnitTest)
add_test(NAME all_unit_tests COMMAND run_all_unit_tests)

endif()

Loading
Loading