Add nls::petsc::SNESSolver, a C++ wrapper for PETSc SNES #7818
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI (macOS) | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| push: | |
| branches: | |
| - main | |
| - release | |
| tags: | |
| - "v*" | |
| merge_group: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| # Cancel superseded runs: a new commit on a pull request makes the | |
| # previous run's result irrelevant. Pushes to 'main' and 'release' are | |
| # left to finish, since they populate caches and publish artefacts. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: ${{ github.event_name == 'pull_request' }} | |
| jobs: | |
| mac-os-build: | |
| name: macOS Homebrew install and test | |
| runs-on: macos-26 | |
| env: | |
| PETSC_ARCH: arch-darwin-c-opt | |
| PETSC_DIR: ${{ github.workspace }}/petsc | |
| PETSC_VERSION: 3.25.4 | |
| PYTEST_ADDOPTS: "-W error" | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Load environment variables | |
| run: | | |
| cat .github/workflows/fenicsx-refs.env >> $GITHUB_ENV | |
| echo "DYLD_LIBRARY_PATH=/usr/local/lib:${PETSC_DIR}/${PETSC_ARCH}/lib:${DYLD_LIBRARY_PATH}" >> $GITHUB_ENV | |
| - name: Set up Python | |
| uses: actions/setup-python@v7 | |
| id: cp3 | |
| with: | |
| python-version: "3.14" | |
| - name: Install Homebrew dependencies | |
| run: | | |
| brew install adios2 boost catch2 hdf5-mpi make ninja open-mpi pkgconf pugixml spdlog kahip # FEniCS | |
| brew install bison flex gfortran scalapack scotch # PETSc | |
| - name: Install Python dependencies (petsc4py) | |
| run: | | |
| pip install cython setuptools wheel | |
| pip install mpi4py numpy | |
| - name: Restore cache PETSc and petsc4py | |
| id: cache-petsc-restore | |
| uses: actions/cache/restore@v6 | |
| with: | |
| path: | | |
| ${{ env.PETSC_DIR }} | |
| ~/Library/Python/ | |
| key: ${{ runner.os }}-petsc-${{ env.PETSC_VERSION }}-${{ steps.cp3.outputs.python-version }} | |
| - name: Install minimal PETSc and petsc4py | |
| if: steps.cache-petsc-restore.outputs.cache-hit != 'true' | |
| run: | | |
| export PATH="$(brew --prefix gfortran)/bin:$(brew --prefix bison)/bin:$PATH" | |
| export PATH="$(brew --prefix make)/libexec/gnubin:$PATH" | |
| git clone --depth 1 --branch v${PETSC_VERSION} https://gitlab.com/petsc/petsc.git petsc | |
| cd petsc | |
| ./configure \ | |
| --with-64-bit-indices=no \ | |
| --with-debugging=no \ | |
| --with-fortran-bindings=no \ | |
| --with-scalar-type=real \ | |
| --with-shared-libraries \ | |
| --with-scalar-type=real \ | |
| --with-ptscotch-dir=$(brew --prefix scotch) \ | |
| --with-scalapack-dir=$(brew --prefix scalapack) \ | |
| --download-metis \ | |
| --download-mumps \ | |
| --download-mumps-avoid-mpi-in-place \ | |
| --download-parmetis \ | |
| --download-superlu_dist | |
| make all | |
| cd src/binding/petsc4py | |
| arch -arm64 pip -v install --user --no-build-isolation . | |
| - name: Save cache PETSc and petsc4py | |
| id: cache-petsc-save | |
| uses: actions/cache/save@v6 | |
| with: | |
| path: | | |
| ${{ env.PETSC_DIR }} | |
| ~/Library/Python/ | |
| key: ${{ steps.cache-petsc-restore.outputs.cache-primary-key }} | |
| - name: Install FEniCSx dependencies | |
| run: | | |
| pip install git+https://github.com/${{ env.ufl_repository }}.git@${{ env.ufl_ref }} | |
| pip install --config-settings=cmake.build-type="Developer" git+https://github.com/${{ env.basix_repository }}.git@${{ env.basix_ref }} | |
| pip install git+https://github.com/${{ env.ffcx_repository }}.git@${{ env.ffcx_ref }} | |
| - name: Configure (C++) | |
| working-directory: cpp | |
| run: > | |
| cmake -B build -S . -Werror=dev --warn-uninitialized -G Ninja \ | |
| -DCMAKE_BUILD_TYPE=Developer \ | |
| -DBUILD_TESTING=true \ | |
| -DDOLFINX_ENABLE_SCOTCH=true \ | |
| -DDOLFINX_ENABLE_PARMETIS=true \ | |
| -DDOLFINX_ENABLE_KAHIP=true \ | |
| -DDOLFINX_ENABLE_PETSC=true \ | |
| -DDOLFINX_ENABLE_SUPERLU_DIST=true | |
| - name: Build and install (C++) | |
| working-directory: cpp/build | |
| run: | | |
| cmake --build . | |
| sudo cmake --install . | |
| - name: Run tests (C++) | |
| working-directory: cpp/build | |
| run: | | |
| ctest -V --output-on-failure -R unittests_np_1 | |
| ctest -V --output-on-failure -R unittests_np_3 | |
| - name: Build and install DOLFINx Python interface | |
| working-directory: python | |
| run: | | |
| pip install pyamg | |
| pip install --group pyproject.toml:build | |
| pip install --group pyproject.toml:test --check-build-dependencies --no-build-isolation --config-settings=cmake.build-type="Developer" '.' | |
| - name: Basic test | |
| run: | | |
| mpiexec -np 1 python -c "from mpi4py import MPI; import dolfinx; assert dolfinx.has_parmetis and dolfinx.has_petsc and dolfinx.has_superlu_dist and dolfinx.has_ptscotch" | |
| mpiexec -np 1 python -c "from mpi4py import MPI; import dolfinx; dolfinx.mesh.create_rectangle(comm=MPI.COMM_WORLD, points=((0, 0), (2, 1)), n=(32, 16))" | |
| mpiexec -np 2 python -c "from mpi4py import MPI; import dolfinx; dolfinx.mesh.create_rectangle(comm=MPI.COMM_WORLD, points=((0, 0), (2, 1)), n=(32, 16))" | |
| - name: Run tests (Python) | |
| run: | | |
| pip install pytest-xdist | |
| mkdir -p ~/.config/dolfinx | |
| echo '{ "cffi_extra_compile_args": ["-g0", "-O0" ] }' > ~/.config/dolfinx/dolfinx_jit_options.json | |
| mpiexec -np 1 python -m pytest -n=auto --durations=50 python/test/unit/ | |
| mpiexec -np 3 python -m pytest python/test/unit/ |