diff --git a/.github/workflows/build-and-tests.yml b/.github/workflows/build-and-tests.yml index 4f38636a..c688eca6 100644 --- a/.github/workflows/build-and-tests.yml +++ b/.github/workflows/build-and-tests.yml @@ -8,8 +8,6 @@ on: jobs: build-linux: runs-on: ${{ matrix.os }} - env: - CORES: $(nproc) strategy: matrix: @@ -24,6 +22,9 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Set number of cores + run: echo "CORES=$(nproc)" >> $GITHUB_ENV + - name: Set up Spack uses: spack/setup-spack@v2 with: @@ -35,20 +36,16 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y mpich wget unzip libboost-all-dev libopenblas-dev perl - + sudo apt-get install -y mpich libmpich-dev wget unzip libncurses-dev libboost-all-dev libopenblas-dev perl - name: Install MFEM shell: spack-bash {0} run: | - spack env activate . - - spack mirror add ghcr oci://ghcr.io/spack/github-actions-buildcache || true - spack buildcache keys --install --trust - + spack compiler find spack external find openmpi mpich openblas perl - + spack env activate . spack concretize -f - spack install --fail-fast --use-buildcache auto + + spack install -j $CORES --fail-fast echo "ExprTk_INCLUDE_DIR=$(spack location -i exprtk)/include/exprtk" >> $GITHUB_ENV @@ -58,27 +55,33 @@ jobs: cache: 'pip' - name: Install Python dependencies - run: python -m pip install --upgrade pip gcovr cpplint matplotlib pandas numpy scipy sympy vtk + run: | + python3 -m venv pysloth + source pysloth/bin/activate + python3 -m pip install --upgrade pip gcovr cpplint matplotlib pandas numpy scipy sympy vtk - name: Build SLOTH shell: spack-bash {0} run: | spack env activate . + source pysloth/bin/activate + mkdir -p ${{ github.workspace }}/build cd ${{ github.workspace }}/build - bash ../envSloth.sh --coverage --exprtk=$ExprTk_INCLUDE_DIR --np=${{ env.CORES }} - make -j${{ env.CORES }} tests + bash ../envSloth.sh --coverage --exprtk=$ExprTk_INCLUDE_DIR --np=$CORES + make -j $CORES tests - name: Test SLOTH shell: spack-bash {0} run: | spack env activate . + source pysloth/bin/activate cd ${{ github.workspace }}/build - find . -name "Save*" |xargs rm -fr - ctest -j${{ env.CORES }} --output-on-failure + find . -type d -name "Save*" -exec rm -rf {} + + ctest -j $CORES --output-on-failure - name: Save Tests on Failure if: ${{ failure() }} @@ -88,57 +91,73 @@ jobs: path: ${{ github.workspace }}/build/tests retention-days: 1 - # build-MacOS: - # runs-on: macos-latest - # env: - # CORES: $(sysctl -n hw.ncpu) - # steps: - # - uses: actions/checkout@v4 + build-MacOS: + runs-on: macos-latest + steps: + - uses: actions/checkout@v4 + + - name: Set number of cores + run: echo "CORES=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV + + - name: Install MFEM + run: brew install mfem + + - name: Setup Python + uses: actions/setup-python@v5 + with: + cache: 'pip' - # - name: Install MFEM - # run: brew install mfem + - name: Install Python dependencies + run: | + python3 -m venv pysloth + source pysloth/bin/activate + python3 -m pip install --upgrade pip gcovr cpplint matplotlib pandas numpy scipy sympy vtk - # - name: Setup Python - # uses: actions/setup-python@v5 - # with: - # python-version: '3.10' - # - name: Install Python dependencies - # run: python -m pip install --upgrade pip gcovr cpplint matplotlib pandas numpy scipy - - # - name: Build SLOTH - # run: | - # mkdir -p ${{ github.workspace }}/build - # cd ${{ github.workspace }}/build - # bash ../envSloth.sh --coverage - # make -j${{ env.CORES }} - - # - name: Test SLOTH - # run: | - # cd ${{ github.workspace }}/build - # ctest -j${{ env.CORES }} --output-on-failure - - # - name: Save Tests on Failure - # if: ${{ failure() }} - # uses: actions/upload-artifact@v4 - # with: - # name: test-reports-macos - # path: ${{ github.workspace }}/build/tests - # retention-days: 1 - - # - name: Code Coverage Analysis - # if: ${{ always() }} - # run: | - # cd ${{ github.workspace }}/build - # make cc - - # - name: Save Code Coverage Analysis - # if: ${{ always() }} - # uses: actions/upload-artifact@v4 - # with: - # name: code-coverage-report - # path: ${{ github.workspace }}/build/Coverage - # retention-days: 1 + - name: Install ExprTk + run: | + git clone https://github.com/ArashPartow/exprtk.git + + - name: Set ExprTk path + run: echo "ExprTk_INCLUDE_DIR=${{ github.workspace }}/exprtk" >> $GITHUB_ENV + + - name: Build SLOTH + run: | + source pysloth/bin/activate + mkdir -p ${{ github.workspace }}/build + cd ${{ github.workspace }}/build + bash ../envSloth.sh --coverage --exprtk=$ExprTk_INCLUDE_DIR + make -j $CORES tests + + - name: Test SLOTH + run: | + source pysloth/bin/activate + cd ${{ github.workspace }}/build + find . -type d -name "Save*" -exec rm -rf {} + + ctest -j $CORES --output-on-failure + + - name: Save Tests on Failure + if: ${{ failure() }} + uses: actions/upload-artifact@v4 + with: + name: test-reports-macos + path: ${{ github.workspace }}/build/tests + retention-days: 1 + + - name: Code Coverage Analysis + if: ${{ always() }} + run: | + source pysloth/bin/activate + cd ${{ github.workspace }}/build + make cc + + - name: Save Code Coverage Analysis + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: code-coverage-report + path: ${{ github.workspace }}/build/Coverage + retention-days: 1 - name: CppLint if: ${{ always() }} @@ -146,9 +165,9 @@ jobs: run: | cd ${{ github.workspace }}/build cpplint \ - --filter=-runtime/references,-build/header_guard,-runtime/string \ + --filter=-runtime/references,-build/header_guard,-runtime/string,-build/include \ --counting=total \ - --extensions=cpp,cxx,hpp,h,hxx \ + --extensions=cpp,cxx,hpp,h,hxx,tpp \ --linelength=100 \ --recursive ../kernel ../tests \ COMMENT "Linting source files" diff --git a/CMakeLists.txt b/CMakeLists.txt index e6748ead..125caeb6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,11 @@ endif() # ######################## include(MFEM4SLOTH) +# ######################## +# # Compiler options +# ######################## +include(COMPILE4SLOTH) + # ######################## # # Sloth header's only # # library (interface) @@ -64,10 +69,6 @@ if(NOT TARGET doc) add_subdirectory(doc) endif(NOT TARGET doc) -# ######################## -# # Test Configuration -# ######################## -include(COMPILE4SLOTH) # ######################## # LibTorch API ?? @@ -109,7 +110,7 @@ IF(CMAKE_BUILD_TYPE MATCHES Coverage) # Collect CodeCoverage analysis with gcovr add_custom_target(cc COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/Coverage - COMMAND gcovr -r ${CMAKE_SOURCE_DIR} --exclude '${CMAKE_SOURCE_DIR}/kernel/MAToolsProfiling/.*' --sort-uncovered --exclude-unreachable-branches --xml=${CMAKE_BINARY_DIR}/Coverage/coverage.xml --html --html-details -o ${CMAKE_BINARY_DIR}/Coverage/coverage.html + COMMAND gcovr -r ${CMAKE_BINARY_DIR}/kernel --filter ${CMAKE_SOURCE_DIR}/kernel/src --filter ${CMAKE_SOURCE_DIR}/kernel/include --exclude '${CMAKE_SOURCE_DIR}/kernel/include/MAToolsProfiling/.*' --exclude-unreachable-branches --xml=${CMAKE_BINARY_DIR}/Coverage/coverage.xml --html --html-details -o ${CMAKE_BINARY_DIR}/Coverage/coverage.html COMMENT "Generate Html report for code coverage analysis (see Coverage/coverage.html)" ) ENDIF() @@ -124,9 +125,9 @@ if(NOT TARGET lint) # Add a custom target for linting add_custom_target(lint COMMAND ${CPP_LINT} - --filter=-runtime/references,-build/header_guard,-runtime/string + --filter=-runtime/references,-build/header_guard,-runtime/string,-build/include --counting=total - --extensions=cpp,cxx,hpp,h,hxx + --extensions=cpp,cxx,hpp,h,hxx,tpp --linelength=100 --exclude ${CMAKE_SOURCE_DIR}/kernel/MAToolsProfiling --recursive ${CMAKE_SOURCE_DIR}/kernel ${CMAKE_SOURCE_DIR}/tests diff --git a/cmake/modules/COMPILE4SLOTH.cmake b/cmake/modules/COMPILE4SLOTH.cmake index 435bd8d2..ad24dc66 100644 --- a/cmake/modules/COMPILE4SLOTH.cmake +++ b/cmake/modules/COMPILE4SLOTH.cmake @@ -32,7 +32,7 @@ set(COVERAGE_OPTIONS -g -O0 --coverage) set(COVERAGE_LINK_OPTIONS --coverage) # Function called at each build -function(set_compile_options target) +function(set_compile_options CURRENT_EXE) if(CMAKE_BUILD_TYPE MATCHES Debug) target_compile_options(${CURRENT_EXE} PRIVATE ${DEBUG_OPTIONS}) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index 24cad207..5117e637 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -6,7 +6,6 @@ else() add_library(Sloth STATIC) endif(SLOTH_USE_SHARED) - # Get all cpp files file(GLOB_RECURSE SLOTH_SRC CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/kernel/src/*.cpp @@ -18,6 +17,7 @@ if(NOT SLOTH_USE_EXPRTK) endif() target_sources(Sloth PRIVATE ${SLOTH_SRC}) +set_compile_options(Sloth) set_target_properties(Sloth PROPERTIES CXX_STANDARD 20 diff --git a/kernel/include/BCs/Boundary.hpp b/kernel/include/BCs/Boundary.hpp index 618eab33..ec16db90 100644 --- a/kernel/include/BCs/Boundary.hpp +++ b/kernel/include/BCs/Boundary.hpp @@ -44,7 +44,6 @@ class Boundary { std::string boundary_name_; BoundaryConditionType::value boundary_type_; int boundary_index_; - bool is_essential_boundary_{false}; bool is_periodic_boundary_{false}; double boundary_value_{0.}; diff --git a/kernel/include/Convergence/Convergence.tpp b/kernel/include/Convergence/Convergence.tpp index f6eecb35..8720a1a3 100644 --- a/kernel/include/Convergence/Convergence.tpp +++ b/kernel/include/Convergence/Convergence.tpp @@ -46,4 +46,4 @@ template Convergence::Convergence(Args... args) { this->vect_convergence_ = std::vector{args...}; -} \ No newline at end of file +} diff --git a/kernel/include/Parameters/Parameters.tpp b/kernel/include/Parameters/Parameters.tpp index c1e93b56..8ee7b875 100644 --- a/kernel/include/Parameters/Parameters.tpp +++ b/kernel/include/Parameters/Parameters.tpp @@ -106,4 +106,4 @@ T Parameters::get_param_value(const std::string& name) const { " Not Found. Please check the data.\n##############"; mfem::mfem_error(error_mess.c_str()); } -} \ No newline at end of file +} diff --git a/kernel/src/BCs/Boundary.cpp b/kernel/src/BCs/Boundary.cpp index df449e01..0fd7ce06 100644 --- a/kernel/src/BCs/Boundary.cpp +++ b/kernel/src/BCs/Boundary.cpp @@ -47,8 +47,8 @@ Boundary::Boundary(const std::string& boundary_name, int boundary_index, const std::string& boundary_type) : boundary_name_(boundary_name), - boundary_index_(boundary_index), - boundary_type_(BoundaryConditionType::from(boundary_type)) { + boundary_type_(BoundaryConditionType::from(boundary_type)), + boundary_index_(boundary_index) { switch (boundary_type_) { case BoundaryConditionType::Dirichlet: case BoundaryConditionType::Neumann: @@ -76,9 +76,9 @@ Boundary::Boundary(const std::string& boundary_name, int boundary_index, Boundary::Boundary(const std::string& boundary_name, int boundary_index, const std::string& boundary_type, double boundary_value) : boundary_name_(boundary_name), + boundary_type_(BoundaryConditionType::from(boundary_type)), boundary_index_(boundary_index), - boundary_value_(boundary_value), - boundary_type_(BoundaryConditionType::from(boundary_type)) { + boundary_value_(boundary_value) { this->is_periodic_boundary_ = false; if (boundary_type_ != BoundaryConditionType::Dirichlet) { mfem::mfem_error( diff --git a/spack.yaml b/spack.yaml index d64c9a0e..fb13c000 100644 --- a/spack.yaml +++ b/spack.yaml @@ -1,17 +1,21 @@ spack: - specs: - - hypre@2.33.0 +shared - - mfem@4.8.0 +mpi +suite-sparse +sundials +superlu-dist + - hypre@3.1.0 +shared %gcc@14 + - mfem@4.9.0 +mpi +suite-sparse +sundials +superlu-dist %gcc@14 - exprtk concretizer: unify: true + packages: mpi: - buildable: true + buildable: false openblas: - buildable: true + buildable: false perl: - buildable: true + buildable: false + ncurses: + buildable: false + intel-oneapi-mkl: + buildable: false