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

Update to main branch #117

Merged
merged 21 commits into from
May 6, 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
4 changes: 2 additions & 2 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install DOLFINx
uses: jorgensd/actions/install-dolfinx@v0.2.0
uses: jorgensd/actions/install-dolfinx@v0.3
with:
dolfinx: main
ufl: main
Expand All @@ -35,7 +35,7 @@ jobs:
cmake --install build-dir

- name: Install DOLFINx-MPC (Python)
run: python3 -m pip -v install --config-settings=cmake.build-type="Release" --no-build-isolation ./python/[docs]
run: python3 -m pip -v install --break-system-packages --config-settings=cmake.build-type="Release" --no-build-isolation ./python/[docs]

- name: Build docs
run: jupyter book build .
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
on:
push:
branches:
- "!*"
tags:
- "v*"
pull_request:
branches:
- release
- main

workflow_dispatch:

Expand Down Expand Up @@ -43,6 +45,18 @@ jobs:

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
load: true
push: false
file: docker/Dockerfile
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
with:
context: .
push: true
Expand Down
15 changes: 9 additions & 6 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
run: |
apt-get -y update
apt-get install unzip
- name: Update pip
run: |
python3 -m pip install --break-system-packages --upgrade pip setuptools

- name: Set up JDK 17
uses: actions/setup-java@v4
Expand Down Expand Up @@ -64,13 +67,13 @@ jobs:
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH

- name: Install DOLFINx
uses: jorgensd/actions/install-dolfinx@v0.2.0
uses: jorgensd/actions/install-dolfinx@v0.3
with:
petsc_arch: ${PETSC_ARCH}
dolfinx: v0.8.0
basix: v0.8.0
ufl: 2024.1.0.post0
ffcx: v0.8.0
dolfinx: main
basix: main
ufl: main
ffcx: main

- name: Run build-wrapper
run: |
Expand All @@ -84,7 +87,7 @@ jobs:
cmake --install build-dir

- name: Install DOLFINx-MPC (Python)
run: python3 -m pip -v install --config-settings=cmake.build-type="Release" --no-build-isolation ./python
run: python3 -m pip -v install --break-system-packages --config-settings=cmake.build-type="Release" --no-build-isolation ./python

- name: Run sonar-scanner
env:
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test_mpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
HDF5_DIR: "/usr/local/"
MPC_BUILD_MODE: ${{ matrix.build_mode }}
MPC_CMAKE_CXX_FLAGS: "-Wall -Werror -g -pedantic -Ofast -march=native"
PYTHONPATH: "/usr/local/dolfinx-${PETSC_TYPE}/lib/python3.10/dist-packages:/usr/local/lib"
PYTHONPATH: "/usr/local/dolfinx-${PETSC_TYPE}/lib/python3.12/dist-packages:/usr/local/lib"
LD_LIBRARY_PATH: "/usr/local/petsc/${PETSC_ARCH}/lib/:/usr/local"
DEB_PYTHON_INSTALL_LAYOUT: deb_system
steps:
Expand All @@ -69,7 +69,7 @@ jobs:
apt-get install -y clang

- name: upgrade pip
run: python3 -m pip install --upgrade setuptools pip
run: python3 -m pip install --break-system-packages --upgrade setuptools pip

- name: Check formatting
run: |
Expand All @@ -78,16 +78,16 @@ jobs:

- name: Check typing
run: |
python3 -m pip install mypy
python3 -m pip install --break-system-packages mypy
cd python
python3 -m mypy . --exclude=build

- name: Install h5py
run: |
python3 -m pip install --no-cache-dir --no-binary=h5py h5py
python3 -m pip install --no-build-isolation --break-system-packages --no-cache-dir --no-binary=h5py h5py

- name: Install DOLFINx
uses: jorgensd/actions/install-dolfinx@v0.2.0
uses: jorgensd/actions/install-dolfinx@v0.3
with:
dolfinx: ${{ env.DOLFINX_BRANCH }}
ufl: ${{ env.UFL_BRANCH }}
Expand All @@ -102,7 +102,7 @@ jobs:
cmake --install build-dir

- name: Install DOLFINx-MPC (Python)
run: python3 -m pip -v install --config-settings=cmake.build-type=${MPC_BUILD_MODE} --no-build-isolation -e python/[test]
run: python3 -m pip -v install --break-system-packages --config-settings=cmake.build-type=${MPC_BUILD_MODE} --no-build-isolation -e python/[test]

- name: Run tests (serial)
run: coverage run --rcfile=.coveragerc -m mpi4py -m pytest python/tests/ -vs
Expand Down
14 changes: 8 additions & 6 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ FROM ghcr.io/fenics/dolfinx/dolfinx:nightly
WORKDIR /tmp

# This argument should be the same as what-ever the python version of the dol
ARG PYTHON_VERSION=3.10
ARG PYTHON_VERSION=3.12

# Set env variables
ENV HDF5_MPI="ON" \
HDF5_DIR="/usr/local"

RUN python3 -m pip install -U pip setuptools
RUN python3 -m pip install --break-system-packages -U pip setuptools

# Install h5py https://github.com/h5py/h5py/issues/2222
RUN python3 -m pip install --no-cache-dir --no-binary=h5py git+https://github.com/h5py/h5py.git
RUN python3 -m pip install meshio
RUN python3 -m pip install --break-system-packages --no-cache-dir --no-binary=h5py git+https://github.com/h5py/h5py.git
RUN python3 -m pip install --break-system-packages meshio

# Copy DOLFINX_MPC source dir
COPY . dolfinx_mpc
Expand All @@ -23,7 +23,8 @@ RUN . /usr/local/bin/dolfinx-real-mode && \
. /usr/local/dolfinx-real/lib/dolfinx/dolfinx.conf && \
cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local/dolfinx-real -DCMAKE_BUILD_TYPE=Developer -B build-dir-real dolfinx_mpc/cpp/ && \
ninja install -j4 -C build-dir-real && \
python3 -m pip install -v --no-build-isolation --check-build-dependencies --no-dependencies --target /usr/local/dolfinx-real/lib/python${PYTHON_VERSION}/dist-packages --config-settings=cmake.build-type=Developer -e dolfinx_mpc/python/[test]
python3 -m pip install -v --break-system-packages --no-build-isolation --check-build-dependencies \
--target /usr/local/dolfinx-real/lib/python${PYTHON_VERSION}/dist-packages --no-dependencies --no-cache-dir ./dolfinx_mpc/python

# Clean repo to remove build dir from pip
RUN rm -rf dolfinx_mpc/python/build
Expand All @@ -33,6 +34,7 @@ RUN . /usr/local/bin/dolfinx-complex-mode && \
. /usr/local/dolfinx-complex/lib/dolfinx/dolfinx.conf && \
cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr/local/dolfinx-complex -DCMAKE_BUILD_TYPE=Developer -B build-dir-complex dolfinx_mpc/cpp/ && \
ninja install -j4 -C build-dir-complex && \
python3 -m pip install -v --no-build-isolation --check-build-dependencies --no-dependencies --target /usr/local/dolfinx-complex/lib/python${PYTHON_VERSION}/dist-packages --config-settings=cmake.build-type=Developer -e dolfinx_mpc/python/[test]
python3 -m pip install --break-system-packages -v --no-build-isolation --check-build-dependencies \
--target /usr/local/dolfinx-complex/lib/python${PYTHON_VERSION}/dist-packages --no-dependencies --no-cache-dir ./dolfinx_mpc/python

WORKDIR /root
6 changes: 4 additions & 2 deletions python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ target_link_libraries(cpp PRIVATE dolfinx_mpc)

# Check for petsc4py
execute_process(
COMMAND ${Python_EXECUTABLE} -c "import petsc4py; print(petsc4py.get_include())"
COMMAND ${Python_EXECUTABLE} -c
"import petsc4py; print(petsc4py.get_include())"
OUTPUT_VARIABLE PETSC4PY_INCLUDE_DIR
RESULT_VARIABLE PETSC4PY_COMMAND_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
Expand All @@ -68,8 +69,9 @@ execute_process(
if(NOT PETSC4PY_COMMAND_RESULT)
message(STATUS "Found petsc4py include directory at ${PETSC4PY_INCLUDE_DIR}")
target_include_directories(cpp PRIVATE ${PETSC4PY_INCLUDE_DIR})
target_compile_definitions(cpp PRIVATE HAS_PETSC4PY)
else()
message(FATAL_ERROR "petsc4py could not be found.")
message(FATAL_ERROR "petsc4py not found.")
endif()


Expand Down
4 changes: 3 additions & 1 deletion python/benchmarks/bench_contact_3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ def demo_stacked_cubes(theta, ct, noslip, num_refinements, N0, timings=False):
mesh.name = f"mesh_{celltype}_{theta:.2f}{type_ext:s}"

# Create functionspaces
el = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 1, shape=(mesh.geometry.dim,))
el = basix.ufl.element(
"Lagrange", mesh.topology.cell_name(), 1, shape=(mesh.geometry.dim,), dtype=default_real_type
)
V = functionspace(mesh, el)

# Define boundary conditions
Expand Down
6 changes: 4 additions & 2 deletions python/benchmarks/bench_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import basix.ufl
import h5py
import numpy as np
from dolfinx import default_scalar_type
from dolfinx import default_real_type, default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.fem import (
Constant,
Expand Down Expand Up @@ -49,7 +49,9 @@ def bench_elasticity_one(
mesh = refine(mesh, redistribute=True)

fdim = mesh.topology.dim - 1
el = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 1, shape=(mesh.geometry.dim,))
el = basix.ufl.element(
"Lagrange", mesh.topology.cell_name(), 1, shape=(mesh.geometry.dim,), dtype=default_real_type
)
V = functionspace(mesh, el)

# Generate Dirichlet BC on lower boundary (Fixed)
Expand Down
6 changes: 4 additions & 2 deletions python/benchmarks/bench_elasticity_edge.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import basix.ufl
import h5py
import numpy as np
from dolfinx import default_scalar_type
from dolfinx import default_real_type, default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.fem import (
Constant,
Expand Down Expand Up @@ -62,7 +62,9 @@ def bench_elasticity_edge(
ct = CellType.tetrahedron if tetra else CellType.hexahedron
mesh = create_unit_cube(MPI.COMM_WORLD, N, N, N, ct)

el = basix.ufl.element("Lagrange", mesh.topology.cell_name(), int(degree), shape=(mesh.geometry.dim,))
el = basix.ufl.element(
"Lagrange", mesh.topology.cell_name(), int(degree), shape=(mesh.geometry.dim,), dtype=default_real_type
)
V = functionspace(mesh, el)

# Generate Dirichlet BC (Fixed)
Expand Down
6 changes: 4 additions & 2 deletions python/benchmarks/ref_elasticity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import basix.ufl
import h5py
import numpy as np
from dolfinx import default_scalar_type
from dolfinx import default_real_type, default_scalar_type
from dolfinx.common import Timer, TimingType, list_timings
from dolfinx.fem import (
Constant,
Expand Down Expand Up @@ -73,7 +73,9 @@ def ref_elasticity(
# set_log_level(LogLevel.ERROR)
N = degree * N
fdim = mesh.topology.dim - 1
el = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 1, shape=(mesh.geometry.dim,))
el = basix.ufl.element(
"Lagrange", mesh.topology.cell_name(), 1, shape=(mesh.geometry.dim,), dtype=default_real_type
)
V = functionspace(mesh, el)

# Generate Dirichlet BC on lower boundary (Fixed)
Expand Down
3 changes: 2 additions & 1 deletion python/demos/demo_elasticity_disconnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import basix.ufl
import gmsh
import numpy as np
from dolfinx import default_scalar_type
from dolfinx import default_real_type, default_scalar_type
from dolfinx.fem import Constant, Function, dirichletbc, functionspace, locate_dofs_topological
from dolfinx.io import XDMFFile, gmshio
from ufl import (
Expand Down Expand Up @@ -224,6 +224,7 @@ def sigma(v):
mesh.geometry.cmap.degree,
lagrange_variant=basix.LagrangeVariant(mesh.geometry.cmap.variant),
shape=(V.dofmap.bs,),
dtype=default_real_type,
),
)
u_out = Function(V_out)
Expand Down
6 changes: 3 additions & 3 deletions python/demos/demo_stokes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import gmsh
import numpy as np
import scipy.sparse.linalg
from dolfinx import common, default_scalar_type, fem, io
from dolfinx import common, default_real_type, default_scalar_type, fem, io
from dolfinx.io import gmshio
from numpy.typing import NDArray
from ufl import (
Expand Down Expand Up @@ -141,8 +141,8 @@ def create_mesh_gmsh(
# The next step is the create the function spaces for the fluid velocit and pressure.
# We will use a mixed-formulation, and we use `basix.ufl` to create the Taylor-Hood finite element pair

P2 = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 2, shape=(mesh.geometry.dim,))
P1 = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 1)
P2 = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 2, shape=(mesh.geometry.dim,), dtype=default_real_type)
P1 = basix.ufl.element("Lagrange", mesh.topology.cell_name(), 1, dtype=default_real_type)

TH = basix.ufl.mixed_element([P2, P1])
W = fem.functionspace(mesh, TH)
Expand Down
6 changes: 3 additions & 3 deletions python/demos/demo_stokes_nest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import numpy as np
import scipy.sparse.linalg
import ufl
from dolfinx import default_scalar_type
from dolfinx import default_real_type, default_scalar_type
from dolfinx.io import gmshio
from ufl.core.expr import Expr

Expand Down Expand Up @@ -120,8 +120,8 @@ def create_mesh_gmsh(

# Create the function space
cellname = mesh.ufl_cell().cellname()
Ve = basix.ufl.element(basix.ElementFamily.P, cellname, 2, shape=(mesh.geometry.dim,))
Qe = basix.ufl.element(basix.ElementFamily.P, cellname, 1)
Ve = basix.ufl.element(basix.ElementFamily.P, cellname, 2, shape=(mesh.geometry.dim,), dtype=default_real_type)
Qe = basix.ufl.element(basix.ElementFamily.P, cellname, 1, dtype=default_real_type)

V = dolfinx.fem.functionspace(mesh, Ve)
Q = dolfinx.fem.functionspace(mesh, Qe)
Expand Down
1 change: 1 addition & 0 deletions python/dolfinx_mpc/mpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <nanobind/stl/string.h>
#include <nanobind/stl/tuple.h>
#include <nanobind/stl/vector.h>
#include <petsc4py/petsc4py.h>
#include <petscmat.h>
#include <petscvec.h>
namespace nb = nanobind;
Expand Down
Loading