From 3ce39ab2e80a1211d5bc55f4933fc354671442f4 Mon Sep 17 00:00:00 2001 From: jorgensd Date: Thu, 2 May 2024 21:43:40 +0200 Subject: [PATCH 01/21] Update main branch --- .github/workflows/build_docs.yml | 10 +++++----- .github/workflows/docker.yml | 18 ++++++++++++++++-- .github/workflows/sonarcloud.yml | 2 +- docker/Dockerfile | 7 +++++-- python/pyproject.toml | 2 +- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 1da0944a..8865c563 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -10,7 +10,7 @@ on: jobs: build: runs-on: ubuntu-22.04 - container: ghcr.io/fenics/dolfinx/dev-env:current-mpich + container: ghcr.io/fenics/dolfinx/dev-env:v0.8.0-mpich env: # Directory that will be published on github pages PUBLISH_DIR: ./_build/html @@ -22,10 +22,10 @@ jobs: - name: Install DOLFINx uses: jorgensd/actions/install-dolfinx@v0.2.0 with: - dolfinx: main - ufl: main - ffcx: main - basix: main + dolfinx: v0.8.0 + ufl: 2024.1.0.post0 + ffcx: v0.8.0 + basix: v0.8.0 petsc_arch: ${PETSC_ARCH} - name: Install DOLFINx-MPC (C++) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 9407a66f..9d740479 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,9 +1,11 @@ on: push: - branches: - - "!*" tags: - "v*" + pull_request: + branches: + - release + - main workflow_dispatch: @@ -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 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index ed8ab9c6..de428cb9 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -15,7 +15,7 @@ jobs: # avoid running on pull requests from forks # which don't have access to secrets if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) - container: ghcr.io/fenics/dolfinx/dev-env:current-mpich + container: ghcr.io/fenics/dolfinx/dev-env:v0.8.0-mpich env: SONAR_SCANNER_VERSION: 5.0.1.3006 # Find the latest version in at: https://github.com/SonarSource/sonar-scanner-cli/tags SONAR_SERVER_URL: "https://sonarcloud.io" diff --git a/docker/Dockerfile b/docker/Dockerfile index 3329540f..1d3b58a8 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -17,13 +17,15 @@ RUN python3 -m pip install meshio # Copy DOLFINX_MPC source dir COPY . dolfinx_mpc +RUN python3 -m pip install -U pip setuptools # Install real mode 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 --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 @@ -33,6 +35,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 -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 diff --git a/python/pyproject.toml b/python/pyproject.toml index bd58332e..42ea841f 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ "cffi", "petsc4py", "mpi4py", - "fenics-dolfinx>=0.8.0.dev0,<0.9.0", + "fenics-dolfinx>=0.8.0", ] [project.optional-dependencies] From 7837aa7175401c9e5cb5c07952fad215dc45eeff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Schartum=20Dokken?= Date: Thu, 2 May 2024 21:45:21 +0200 Subject: [PATCH 02/21] Apply suggestions from code review --- .github/workflows/build_docs.yml | 10 +++++----- .github/workflows/sonarcloud.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 8865c563..1da0944a 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -10,7 +10,7 @@ on: jobs: build: runs-on: ubuntu-22.04 - container: ghcr.io/fenics/dolfinx/dev-env:v0.8.0-mpich + container: ghcr.io/fenics/dolfinx/dev-env:current-mpich env: # Directory that will be published on github pages PUBLISH_DIR: ./_build/html @@ -22,10 +22,10 @@ jobs: - name: Install DOLFINx uses: jorgensd/actions/install-dolfinx@v0.2.0 with: - dolfinx: v0.8.0 - ufl: 2024.1.0.post0 - ffcx: v0.8.0 - basix: v0.8.0 + dolfinx: main + ufl: main + ffcx: main + basix: main petsc_arch: ${PETSC_ARCH} - name: Install DOLFINx-MPC (C++) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index de428cb9..ed8ab9c6 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -15,7 +15,7 @@ jobs: # avoid running on pull requests from forks # which don't have access to secrets if: (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) - container: ghcr.io/fenics/dolfinx/dev-env:v0.8.0-mpich + container: ghcr.io/fenics/dolfinx/dev-env:current-mpich env: SONAR_SCANNER_VERSION: 5.0.1.3006 # Find the latest version in at: https://github.com/SonarSource/sonar-scanner-cli/tags SONAR_SERVER_URL: "https://sonarcloud.io" From 436466ded4683649edaf92db6621864d439497ed Mon Sep 17 00:00:00 2001 From: "Jorgen S. Dokken" Date: Fri, 3 May 2024 09:32:15 +0000 Subject: [PATCH 03/21] Fix python nanobind wrapping --- python/CMakeLists.txt | 6 ++++-- python/dolfinx_mpc/mpc.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index e61b726c..87a33291 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -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 @@ -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() diff --git a/python/dolfinx_mpc/mpc.cpp b/python/dolfinx_mpc/mpc.cpp index 5942caf4..30a73b9b 100644 --- a/python/dolfinx_mpc/mpc.cpp +++ b/python/dolfinx_mpc/mpc.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include namespace nb = nanobind; From 7012b4abc55f0c8c21e8b07e7b660fe2df16eb0e Mon Sep 17 00:00:00 2001 From: "Jorgen S. Dokken" Date: Fri, 3 May 2024 09:53:58 +0000 Subject: [PATCH 04/21] Set dtype --- python/tests/test_nonlinear_assembly.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/tests/test_nonlinear_assembly.py b/python/tests/test_nonlinear_assembly.py index 5885f7ad..54d2f3e3 100644 --- a/python/tests/test_nonlinear_assembly.py +++ b/python/tests/test_nonlinear_assembly.py @@ -199,7 +199,8 @@ def test_homogenize(tensor_order, poly_order): pytest.xfail("Unknown tensor order") cellname = mesh.ufl_cell().cellname() - el = basix.ufl.element(basix.ElementFamily.P, cellname, poly_order, shape=shape) + el = basix.ufl.element(basix.ElementFamily.P, cellname, poly_order, shape=shape, + dtype=mesh.geometry.x.dtype) V = dolfinx.fem.functionspace(mesh, el) From 84c71a9fbc394e986f25d9426b07d8605fa7a4be Mon Sep 17 00:00:00 2001 From: "Jorgen S. Dokken" Date: Fri, 3 May 2024 10:35:57 +0000 Subject: [PATCH 05/21] Update action --- .github/workflows/build_docs.yml | 2 +- .github/workflows/sonarcloud.yml | 10 +++++----- .github/workflows/test_mpc.yml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 1da0944a..5a9879ff 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -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.0 with: dolfinx: main ufl: main diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index ed8ab9c6..834df7a8 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -64,13 +64,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.0 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: | diff --git a/.github/workflows/test_mpc.yml b/.github/workflows/test_mpc.yml index 4539e36c..6a9cef96 100644 --- a/.github/workflows/test_mpc.yml +++ b/.github/workflows/test_mpc.yml @@ -87,7 +87,7 @@ jobs: python3 -m pip install --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.0 with: dolfinx: ${{ env.DOLFINX_BRANCH }} ufl: ${{ env.UFL_BRANCH }} From 9d53f56effa1fbf04c6d189aa97489b8ae05fd91 Mon Sep 17 00:00:00 2001 From: "Jorgen S. Dokken" Date: Fri, 3 May 2024 11:01:51 +0000 Subject: [PATCH 06/21] Add dtypes --- python/tests/test_rectangular_assembly.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/tests/test_rectangular_assembly.py b/python/tests/test_rectangular_assembly.py index afee480d..06e1b275 100644 --- a/python/tests/test_rectangular_assembly.py +++ b/python/tests/test_rectangular_assembly.py @@ -48,15 +48,16 @@ def test_mixed_element(cell_type, ghost_mode): # 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=dolfinx.default_real_type) + Qe = basix.ufl.element(basix.ElementFamily.P, cellname, 1, dtype=dolfinx.default_real_type) V = dolfinx.fem.functionspace(mesh, Ve) Q = dolfinx.fem.functionspace(mesh, Qe) W = dolfinx.fem.functionspace(mesh, basix.ufl.mixed_element([Ve, Qe])) inlet_velocity = dolfinx.fem.Function(V) - inlet_velocity.interpolate(lambda x: np.zeros((mesh.geometry.dim, x[0].shape[0]), dtype=np.double)) + inlet_velocity.interpolate(lambda x: np.zeros((mesh.geometry.dim, x[0].shape[0]), dtype=dolfinx.default_scalar_type)) inlet_velocity.x.scatter_forward() # -- Nested assembly From 500182ccbaac21756d45552f89a3e5daded9c242 Mon Sep 17 00:00:00 2001 From: "Jorgen S. Dokken" Date: Fri, 3 May 2024 11:45:40 +0000 Subject: [PATCH 07/21] Ruff formatting --- python/tests/test_nonlinear_assembly.py | 3 +-- python/tests/test_rectangular_assembly.py | 9 ++++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/python/tests/test_nonlinear_assembly.py b/python/tests/test_nonlinear_assembly.py index 54d2f3e3..9ae2d5c7 100644 --- a/python/tests/test_nonlinear_assembly.py +++ b/python/tests/test_nonlinear_assembly.py @@ -199,8 +199,7 @@ def test_homogenize(tensor_order, poly_order): pytest.xfail("Unknown tensor order") cellname = mesh.ufl_cell().cellname() - el = basix.ufl.element(basix.ElementFamily.P, cellname, poly_order, shape=shape, - dtype=mesh.geometry.x.dtype) + el = basix.ufl.element(basix.ElementFamily.P, cellname, poly_order, shape=shape, dtype=mesh.geometry.x.dtype) V = dolfinx.fem.functionspace(mesh, el) diff --git a/python/tests/test_rectangular_assembly.py b/python/tests/test_rectangular_assembly.py index 06e1b275..4d84ad5a 100644 --- a/python/tests/test_rectangular_assembly.py +++ b/python/tests/test_rectangular_assembly.py @@ -48,8 +48,9 @@ def test_mixed_element(cell_type, ghost_mode): # Create the function space cellname = mesh.ufl_cell().cellname() - Ve = basix.ufl.element(basix.ElementFamily.P, cellname, 2, shape=(mesh.geometry.dim,), - dtype=dolfinx.default_real_type) + Ve = basix.ufl.element( + basix.ElementFamily.P, cellname, 2, shape=(mesh.geometry.dim,), dtype=dolfinx.default_real_type + ) Qe = basix.ufl.element(basix.ElementFamily.P, cellname, 1, dtype=dolfinx.default_real_type) V = dolfinx.fem.functionspace(mesh, Ve) @@ -57,7 +58,9 @@ def test_mixed_element(cell_type, ghost_mode): W = dolfinx.fem.functionspace(mesh, basix.ufl.mixed_element([Ve, Qe])) inlet_velocity = dolfinx.fem.Function(V) - inlet_velocity.interpolate(lambda x: np.zeros((mesh.geometry.dim, x[0].shape[0]), dtype=dolfinx.default_scalar_type)) + inlet_velocity.interpolate( + lambda x: np.zeros((mesh.geometry.dim, x[0].shape[0]), dtype=dolfinx.default_scalar_type) + ) inlet_velocity.x.scatter_forward() # -- Nested assembly From f47b2a4b7dd4b954948426d442433970dbf9753f Mon Sep 17 00:00:00 2001 From: "Jorgen S. Dokken" Date: Fri, 3 May 2024 12:00:18 +0000 Subject: [PATCH 08/21] Add dtypes to elements in benchmarks --- python/benchmarks/bench_contact_3D.py | 3 ++- python/benchmarks/bench_elasticity.py | 5 +++-- python/benchmarks/bench_elasticity_edge.py | 5 +++-- python/benchmarks/ref_elasticity.py | 5 +++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/python/benchmarks/bench_contact_3D.py b/python/benchmarks/bench_contact_3D.py index d5769da6..fbffa312 100644 --- a/python/benchmarks/bench_contact_3D.py +++ b/python/benchmarks/bench_contact_3D.py @@ -211,7 +211,8 @@ 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 diff --git a/python/benchmarks/bench_elasticity.py b/python/benchmarks/bench_elasticity.py index 1024be95..f998b85e 100644 --- a/python/benchmarks/bench_elasticity.py +++ b/python/benchmarks/bench_elasticity.py @@ -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, @@ -49,7 +49,8 @@ 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) diff --git a/python/benchmarks/bench_elasticity_edge.py b/python/benchmarks/bench_elasticity_edge.py index 9ca1366d..e57f14fe 100644 --- a/python/benchmarks/bench_elasticity_edge.py +++ b/python/benchmarks/bench_elasticity_edge.py @@ -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, @@ -62,7 +62,8 @@ 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) diff --git a/python/benchmarks/ref_elasticity.py b/python/benchmarks/ref_elasticity.py index 9b464c79..615cf25e 100644 --- a/python/benchmarks/ref_elasticity.py +++ b/python/benchmarks/ref_elasticity.py @@ -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, @@ -73,7 +73,8 @@ 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) From 55d811660a1a5f7ab538762911f6350e43647244 Mon Sep 17 00:00:00 2001 From: "Jorgen S. Dokken" Date: Fri, 3 May 2024 12:25:46 +0000 Subject: [PATCH 09/21] Ruff formatting --- python/benchmarks/bench_contact_3D.py | 5 +++-- python/benchmarks/bench_elasticity.py | 7 ++++--- python/benchmarks/bench_elasticity_edge.py | 5 +++-- python/benchmarks/ref_elasticity.py | 5 +++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/python/benchmarks/bench_contact_3D.py b/python/benchmarks/bench_contact_3D.py index fbffa312..d9e36e95 100644 --- a/python/benchmarks/bench_contact_3D.py +++ b/python/benchmarks/bench_contact_3D.py @@ -211,8 +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,), - dtype=default_real_type) + 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 diff --git a/python/benchmarks/bench_elasticity.py b/python/benchmarks/bench_elasticity.py index f998b85e..aedbc39e 100644 --- a/python/benchmarks/bench_elasticity.py +++ b/python/benchmarks/bench_elasticity.py @@ -16,7 +16,7 @@ import basix.ufl import h5py import numpy as np -from dolfinx import default_real_type,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, @@ -49,8 +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,), dtype=default_real_type) + 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) diff --git a/python/benchmarks/bench_elasticity_edge.py b/python/benchmarks/bench_elasticity_edge.py index e57f14fe..237f6890 100644 --- a/python/benchmarks/bench_elasticity_edge.py +++ b/python/benchmarks/bench_elasticity_edge.py @@ -62,8 +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,), - dtype=default_real_type) + 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) diff --git a/python/benchmarks/ref_elasticity.py b/python/benchmarks/ref_elasticity.py index 615cf25e..c1eee62c 100644 --- a/python/benchmarks/ref_elasticity.py +++ b/python/benchmarks/ref_elasticity.py @@ -73,8 +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,), - dtype=default_real_type) + 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) From 8f1e2ee0438e871395310fe493c0626c8928e25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 07:55:05 +0000 Subject: [PATCH 10/21] Fix nullspace creation --- python/dolfinx_mpc/utils/mpc_utils.py | 63 ++++++++++++++------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/python/dolfinx_mpc/utils/mpc_utils.py b/python/dolfinx_mpc/utils/mpc_utils.py index 594a2010..4e15b50b 100644 --- a/python/dolfinx_mpc/utils/mpc_utils.py +++ b/python/dolfinx_mpc/utils/mpc_utils.py @@ -5,8 +5,6 @@ # SPDX-License-Identifier: MIT from __future__ import annotations -from contextlib import ExitStack - from mpi4py import MPI from petsc4py import PETSc @@ -176,36 +174,41 @@ def rigid_motions_nullspace(V: _fem.FunctionSpace): dim = 3 if gdim == 2 else 6 # Create list of vectors for null space - nullspace_basis = [_x.vector.copy() for _ in range(dim)] - - with ExitStack() as stack: - vec_local = [stack.enter_context(x.localForm()) for x in nullspace_basis] - basis = [np.asarray(x) for x in vec_local] - - dofs = [V.sub(i).dofmap.list.reshape(-1) for i in range(gdim)] - - # Build translational null space basis - for i in range(gdim): - basis[i][dofs[i]] = 1.0 - # Build rotational null space basis - x = V.tabulate_dof_coordinates() - dofs_block = V.dofmap.list.reshape(-1) - x0, x1, x2 = x[dofs_block, 0], x[dofs_block, 1], x[dofs_block, 2] - if gdim == 2: - basis[2][dofs[0]] = -x1 - basis[2][dofs[1]] = x0 - elif gdim == 3: - basis[3][dofs[0]] = -x1 - basis[3][dofs[1]] = x0 - - basis[4][dofs[0]] = x2 - basis[4][dofs[2]] = -x0 - basis[5][dofs[2]] = x1 - basis[5][dofs[1]] = -x2 + nullspace_basis = [ + _la.vector(V.dofmap.index_map, bs=V.dofmap.index_map_bs, dtype=PETSc.ScalarType) # type: ignore + for i in range(dim) + ] + + basis = [b.array for b in nullspace_basis] + dofs = [V.sub(i).dofmap.list.reshape(-1) for i in range(gdim)] + + # Build translational null space basis + for i in range(gdim): + basis[i][dofs[i]] = 1.0 + # Build rotational null space basis + x = V.tabulate_dof_coordinates() + dofs_block = V.dofmap.list.reshape(-1) + x0, x1, x2 = x[dofs_block, 0], x[dofs_block, 1], x[dofs_block, 2] + if gdim == 2: + basis[2][dofs[0]] = -x1 + basis[2][dofs[1]] = x0 + elif gdim == 3: + basis[3][dofs[0]] = -x1 + basis[3][dofs[1]] = x0 + + basis[4][dofs[0]] = x2 + basis[4][dofs[2]] = -x0 + basis[5][dofs[2]] = x1 + basis[5][dofs[1]] = -x2 _la.orthonormalize(nullspace_basis) - assert _la.is_orthonormal(nullspace_basis, float(500 * np.finfo(_x.x.array.dtype).resolution)) - return PETSc.NullSpace().create(vectors=nullspace_basis) # type: ignore + assert _la.is_orthonormal(nullspace_basis) + local_size = V.dofmap.index_map.size_local * V.dofmap.index_map_bs + basis_petsc = [ + PETSc.Vec().createWithArray(x[:local_size], bsize=gdim, comm=V.mesh.comm) # type: ignore + for x in basis + ] + return PETSc.NullSpace().create(comm=V.mesh.comm, vectors=basis_petsc) # type: ignore def determine_closest_block(V, point): From 9180a707a0620e0f5d18b6b13bffaa3be88a8c10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 08:03:01 +0000 Subject: [PATCH 11/21] Bump install action + python version --- .github/workflows/build_docs.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- .github/workflows/test_mpc.yml | 4 ++-- docker/Dockerfile | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 5a9879ff..e3358977 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v4 - name: Install DOLFINx - uses: jorgensd/actions/install-dolfinx@v0.3.0 + uses: jorgensd/actions/install-dolfinx@v0.3 with: dolfinx: main ufl: main diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 834df7a8..f2fa4526 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -64,7 +64,7 @@ jobs: echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH - name: Install DOLFINx - uses: jorgensd/actions/install-dolfinx@v0.3.0 + uses: jorgensd/actions/install-dolfinx@v0.3 with: petsc_arch: ${PETSC_ARCH} dolfinx: main diff --git a/.github/workflows/test_mpc.yml b/.github/workflows/test_mpc.yml index 6a9cef96..8a9c536b 100644 --- a/.github/workflows/test_mpc.yml +++ b/.github/workflows/test_mpc.yml @@ -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: @@ -87,7 +87,7 @@ jobs: python3 -m pip install --no-cache-dir --no-binary=h5py h5py - name: Install DOLFINx - uses: jorgensd/actions/install-dolfinx@v0.3.0 + uses: jorgensd/actions/install-dolfinx@v0.3 with: dolfinx: ${{ env.DOLFINX_BRANCH }} ufl: ${{ env.UFL_BRANCH }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 1d3b58a8..c410ab31 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -3,7 +3,7 @@ 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" \ From a396d14f445d7c792256632b8b5eaf174e938813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 08:13:45 +0000 Subject: [PATCH 12/21] Add break system packages --- .github/workflows/build_docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index e3358977..632b6279 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -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 . From 501d781cee9ad473f92d25749aff59ede7d85858 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 09:19:39 +0000 Subject: [PATCH 13/21] Fix sonarcloud --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index f2fa4526..f36a3901 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -84,7 +84,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 --break-system-packages -v install --config-settings=cmake.build-type="Release" --no-build-isolation ./python - name: Run sonar-scanner env: From 0fdec5011bc1fbb67bc3fa7b236ac64f55a62256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 09:39:48 +0000 Subject: [PATCH 14/21] More --break-system-packages --- .github/workflows/test_mpc.yml | 6 +++--- docker/Dockerfile | 11 +++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test_mpc.yml b/.github/workflows/test_mpc.yml index 8a9c536b..02285221 100644 --- a/.github/workflows/test_mpc.yml +++ b/.github/workflows/test_mpc.yml @@ -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: | @@ -84,7 +84,7 @@ jobs: - name: Install h5py run: | - python3 -m pip install --no-cache-dir --no-binary=h5py h5py + python3 -m pip install --break-system-packages --no-cache-dir --no-binary=h5py h5py - name: Install DOLFINx uses: jorgensd/actions/install-dolfinx@v0.3 @@ -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 diff --git a/docker/Dockerfile b/docker/Dockerfile index c410ab31..7f30d700 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -9,22 +9,21 @@ ARG PYTHON_VERSION=3.12 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 -RUN python3 -m pip install -U pip setuptools # Install real mode 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 \ + 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 @@ -35,7 +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 \ + 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 From 11457870c5c47433149b11ac9027fcf813616dca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 09:45:55 +0000 Subject: [PATCH 15/21] Missed one --- .github/workflows/test_mpc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_mpc.yml b/.github/workflows/test_mpc.yml index 02285221..78f295c8 100644 --- a/.github/workflows/test_mpc.yml +++ b/.github/workflows/test_mpc.yml @@ -78,7 +78,7 @@ 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 From 81b6c5d0647044e7f95b847f11e7a12e4cf74244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 09:51:15 +0000 Subject: [PATCH 16/21] Remove build isolation h5py --- .github/workflows/test_mpc.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_mpc.yml b/.github/workflows/test_mpc.yml index 78f295c8..273291b0 100644 --- a/.github/workflows/test_mpc.yml +++ b/.github/workflows/test_mpc.yml @@ -84,7 +84,7 @@ jobs: - name: Install h5py run: | - python3 -m pip install --break-system-packages --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.3 From 7ab937b12c2d0371db2824700f8dd73bed15eaba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 09:58:34 +0000 Subject: [PATCH 17/21] UPdate pip om sonar --- .github/workflows/sonarcloud.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index f36a3901..2d4293b0 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -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 From 985fafeb38d34478ad6f274d90ed1041fb3548fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 10:47:29 +0000 Subject: [PATCH 18/21] Scatter forward --- .github/workflows/sonarcloud.yml | 2 +- python/dolfinx_mpc/utils/mpc_utils.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 2d4293b0..c6c00379 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -87,7 +87,7 @@ jobs: cmake --install build-dir - name: Install DOLFINx-MPC (Python) - run: python3 -m pip --break-system-packages -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: diff --git a/python/dolfinx_mpc/utils/mpc_utils.py b/python/dolfinx_mpc/utils/mpc_utils.py index 4e15b50b..623c541b 100644 --- a/python/dolfinx_mpc/utils/mpc_utils.py +++ b/python/dolfinx_mpc/utils/mpc_utils.py @@ -200,6 +200,8 @@ def rigid_motions_nullspace(V: _fem.FunctionSpace): basis[4][dofs[2]] = -x0 basis[5][dofs[2]] = x1 basis[5][dofs[1]] = -x2 + for b in nullspace_basis: + b.scatter_forward() _la.orthonormalize(nullspace_basis) assert _la.is_orthonormal(nullspace_basis) From b0cf70019e61339ef866da58f7c4873d52565c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 11:06:46 +0000 Subject: [PATCH 19/21] Fix dtype in orthonormal --- python/dolfinx_mpc/utils/mpc_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/dolfinx_mpc/utils/mpc_utils.py b/python/dolfinx_mpc/utils/mpc_utils.py index 623c541b..9bf1689c 100644 --- a/python/dolfinx_mpc/utils/mpc_utils.py +++ b/python/dolfinx_mpc/utils/mpc_utils.py @@ -204,7 +204,7 @@ def rigid_motions_nullspace(V: _fem.FunctionSpace): b.scatter_forward() _la.orthonormalize(nullspace_basis) - assert _la.is_orthonormal(nullspace_basis) + assert _la.is_orthonormal(nullspace_basis, np.finfo(_x.x.array.dtype).eps) local_size = V.dofmap.index_map.size_local * V.dofmap.index_map_bs basis_petsc = [ PETSc.Vec().createWithArray(x[:local_size], bsize=gdim, comm=V.mesh.comm) # type: ignore From babf45d4d920b41586b5b19eada749260d165b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 11:33:14 +0000 Subject: [PATCH 20/21] Add default real type to support float32 codes --- python/demos/demo_elasticity_disconnect.py | 3 ++- python/demos/demo_stokes.py | 6 +++--- python/demos/demo_stokes_nest.py | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/python/demos/demo_elasticity_disconnect.py b/python/demos/demo_elasticity_disconnect.py index dce1b7a6..b2edcab0 100644 --- a/python/demos/demo_elasticity_disconnect.py +++ b/python/demos/demo_elasticity_disconnect.py @@ -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 ( @@ -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) diff --git a/python/demos/demo_stokes.py b/python/demos/demo_stokes.py index 1bf91873..d9753eff 100644 --- a/python/demos/demo_stokes.py +++ b/python/demos/demo_stokes.py @@ -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 ( @@ -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) diff --git a/python/demos/demo_stokes_nest.py b/python/demos/demo_stokes_nest.py index 35ff53a1..34732559 100644 --- a/python/demos/demo_stokes_nest.py +++ b/python/demos/demo_stokes_nest.py @@ -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 @@ -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) From afa41473c9acf2f183999263ed518f4ff3bc2d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20S=2E=20Dokken?= Date: Mon, 6 May 2024 12:08:33 +0000 Subject: [PATCH 21/21] Bump version requiremetn --- python/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pyproject.toml b/python/pyproject.toml index 42ea841f..b4c66854 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ "cffi", "petsc4py", "mpi4py", - "fenics-dolfinx>=0.8.0", + "fenics-dolfinx>0.8.0", ] [project.optional-dependencies]