Skip to content

Commit

Permalink
Update for DOLFINx 0.7.2 (#9)
Browse files Browse the repository at this point in the history
* Update to v0.6.0

* Update for 0.7.2, switch to scikit-build-core, remove sphinx makefile

* flake8 and isort

* Definetly doesn't work with nanobind based DOLFINx

* Trigger test.

* Install scikit-build-core
  • Loading branch information
jhale committed Nov 27, 2023
1 parent d062473 commit 7a18e64
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 175 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
build-and-test:
runs-on: ubuntu-latest
container: ghcr.io/fenics/dolfinx/dolfinx:v0.6.0-r1
container: ghcr.io/fenics/dolfinx/dolfinx:v0.7.2
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -33,12 +33,13 @@ jobs:
- name: Install FEniCSx-Shells
run: |
python3 -m pip install .
pip install scikit-build-core[pyproject] # TO REMOVE ONCE 0.8.0 RELEASED
python3 -m pip install --no-build-isolation --check-build-dependencies .
- name: Build documentation
run: |
cd doc
make html
python3 -m sphinx -W -b html source/ build/html/
- name: Run demos
run: |
Expand Down
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.18)

project(fenicsx_shells VERSION "0.1.0")
project(fenicsx_shells VERSION "0.1.0.0")

set(Python_FIND_IMPLEMENTATIONS CPython)
find_package(Python REQUIRED COMPONENTS Interpreter Development)
find_package(Python COMPONENTS Interpreter Development REQUIRED)
find_package(DOLFINX REQUIRED)

# Set C++ standard before finding pybind11
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ numerical methods for solving a wide range of thin structural models (beams,
plates and shells) expressed in the Unified Form Language (UFL) of the FEniCS
Project.

*FEniCSx-Shells is an experimental version targeting version v0.5.0 of the new
*FEniCSx-Shells is an experimental version targeting version v0.7.2 of the new
[DOLFINx solver](https://github.com/fenics/dolfinx).*

The foundational aspects of the FEniCS-Shells project are described in the paper:
Expand Down
18 changes: 8 additions & 10 deletions demo/demo_kirchhoff-love-clamped.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@
import ufl
from dolfinx.fem import FunctionSpace, dirichletbc
from dolfinx.fem.petsc import LinearProblem
from dolfinx.mesh import create_unit_square, CellType
from dolfinx.mesh import CellType, create_unit_square
from ufl import (FacetNormal, FiniteElement, Identity, Measure, MixedElement,
grad, inner, sym, tr)

from mpi4py import MPI

# We then create a two-dimensional mesh of the mid-plane of the plate $\Omega =
# [0, 1] \times [0, 1]$. `GhostMode.shared_facet` is required as the Form will
# use Nédélec elements and DG-type restrictions.
# [0, 1] \times [0, 1]$.

mesh = create_unit_square(MPI.COMM_WORLD, 16, 16, CellType.triangle,
dolfinx.mesh.GhostMode.shared_facet)
mesh = create_unit_square(MPI.COMM_WORLD, 16, 16, CellType.triangle)

# The Hellen-Herrmann-Johnson element for the Kirchhoff-Love plate problem
# consists of:
Expand Down Expand Up @@ -207,19 +205,19 @@ def all_boundary(x):

# +
problem = LinearProblem(a, L, bcs=bcs, petsc_options={
"ksp_type": "preonly", "pc_type": "lu", "pc_factor_mat_solver_type": "mumps", "ksp_view": ""})
"ksp_type": "preonly", "pc_type": "lu", "pc_factor_mat_solver_type": "mumps"})
u_h = problem.solve()

bb_tree = dolfinx.geometry.BoundingBoxTree(mesh, 2)
point = np.array([0.5, 0.5, 0.0], dtype=np.float64)
cell_candidates = dolfinx.geometry.compute_collisions(bb_tree, point)
bb_tree = dolfinx.geometry.bb_tree(mesh, 2)
point = np.array([[0.5, 0.5, 0.0]], dtype=np.float64)
cell_candidates = dolfinx.geometry.compute_collisions_points(bb_tree, point)
cells = dolfinx.geometry.compute_colliding_cells(
mesh, cell_candidates, point)

w, M = u_h.split()

if len(cells) > 0:
value = w.eval(point, cells[0])
value = w.eval(point, cells.array[0])
print(value[0])

# TODO: IO?
36 changes: 14 additions & 22 deletions demo/demo_reissner-mindlin-clamped-tdnns.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
import ufl
from dolfinx.fem import Function, FunctionSpace, dirichletbc
from dolfinx.fem.petsc import LinearProblem
from dolfinx.io.utils import XDMFFile
from dolfinx.mesh import CellType, GhostMode, create_unit_square
from dolfinx.mesh import CellType, create_unit_square
from ufl import (FacetNormal, FiniteElement, Identity, Measure, MixedElement,
grad, inner, split, sym, tr)

Expand All @@ -53,12 +52,10 @@
# -

# We then create a two-dimensional mesh of the mid-plane of the plate $\Omega =
# [0, 1] \times [0, 1]$. `GhostMode.shared_facet` is required as the Form will
# use Nédélec elements and DG-type restrictions.
# [0, 1] \times [0, 1]$.

# +
mesh = create_unit_square(MPI.COMM_WORLD, 16, 16, CellType.triangle,
GhostMode.shared_facet)
mesh = create_unit_square(MPI.COMM_WORLD, 16, 16, CellType.triangle)

# -

Expand Down Expand Up @@ -161,7 +158,8 @@ def inner_divdiv(M, theta):
"""Discrete div-div inner product"""
n = FacetNormal(M.ufl_domain())
M_nn = nn(M)
result = -inner(M, k_theta(theta))*dx + inner(M_nn("+"), ufl.jump(theta, n))*dS + inner(M_nn, ufl.dot(theta, n))*ds
result = -inner(M, k_theta(theta))*dx + inner(M_nn("+"),
ufl.jump(theta, n))*dS + inner(M_nn, ufl.dot(theta, n))*ds
return result


Expand All @@ -179,11 +177,11 @@ def gamma(theta, w):
# Imposition of boundary conditions requires some care. We reproduce the table
# from Pechstein and Schöberl specifying the different types of boundary condition.
#
# | Essential | Natural | Non-homogeneous term |
# | ------------------------------------ | ------------------------------------ | ------------------------------------------------------------------- |
# | $w = \bar{w}$ | $\mu(\partial_n w - \theta_n) = g_w$ | $\int_{\Gamma} g_w \tilde{w} \; \mathrm{d}s$ |
# | $\theta_\tau = \bar{\theta}_{\tau} $ | $m_{n\tau} = g_{\theta_\tau}$ | $\int_{\Gamma} g_{\theta_\tau} \cdot \tilde{\theta} \; \mathrm{d}s$ |
# | $m_{nn} = \bar{m}_{nn}$ | $\theta_n = g_{\theta_n}$ | $\int_{\Gamma} g_{\theta_n} \tilde{m}_{nn} \; \mathrm{d}s$ |
# | Essential | Natural | Non-homogeneous term | # noqa: E501
# | ------------------------------------ | ------------------------------------ | ------------------------------------------------------------------- | # noqa: E501
# | $w = \bar{w}$ | $\mu(\partial_n w - \theta_n) = g_w$ | $\int_{\Gamma} g_w \tilde{w} \; \mathrm{d}s$ | # noqa: E501
# | $\theta_\tau = \bar{\theta}_{\tau} $ | $m_{n\tau} = g_{\theta_\tau}$ | $\int_{\Gamma} g_{\theta_\tau} \cdot \tilde{\theta} \; \mathrm{d}s$ | # noqa: E501
# | $m_{nn} = \bar{m}_{nn}$ | $\theta_n = g_{\theta_n}$ | $\int_{\Gamma} g_{\theta_n} \tilde{m}_{nn} \; \mathrm{d}s$ | # noqa: E501
#
# where $\theta_{n} = \theta_n$ is the normal component of the rotation,
# $\theta_{\tau} = \theta \cdot \tau $ is the tangential component of the
Expand Down Expand Up @@ -235,20 +233,14 @@ def all_boundary(x):
"ksp_type": "preonly", "pc_type": "lu", "pc_factor_mat_solver_type": "mumps"})
u_h = problem.solve()

bb_tree = dolfinx.geometry.BoundingBoxTree(mesh, 2)
point = np.array([0.5, 0.5, 0.0], dtype=np.float64)
cell_candidates = dolfinx.geometry.compute_collisions(bb_tree, point)
bb_tree = dolfinx.geometry.bb_tree(mesh, 2)
point = np.array([[0.5, 0.5, 0.0]], dtype=np.float64)
cell_candidates = dolfinx.geometry.compute_collisions_points(bb_tree, point)
cells = dolfinx.geometry.compute_colliding_cells(
mesh, cell_candidates, point)

theta, w, M = u_h.split()

if len(cells) > 0:
value = w.eval(point, cells[0])
value = w.eval(point, cells.array[0])
print(value[0])

with XDMFFile(MPI.COMM_WORLD, "w.xdmf", "w") as f:
f.write_mesh(mesh)
f.write_function(w)

# TODO: Output of m and theta using new interpolation functions?
14 changes: 5 additions & 9 deletions demo/demo_reissner-mindlin-clamped.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
# [0, 1] \times [0, 1]$. `GhostMode.shared_facet` is required as the Form will
# use Nédélec elements and DG-type restrictions.

mesh = create_unit_square(MPI.COMM_WORLD, 32, 32, CellType.triangle,
dolfinx.cpp.mesh.GhostMode.shared_facet)
mesh = create_unit_square(MPI.COMM_WORLD, 32, 32, CellType.triangle)

# The Durán-Liberman element [1] for the Reissner-Mindlin plate problem
# consists of:
Expand Down Expand Up @@ -217,16 +216,16 @@ def all_boundary(x):
"ksp_type": "preonly", "pc_type": "lu", "pc_factor_mat_solver_type": "mumps"})
u_ = problem.solve()

bb_tree = dolfinx.geometry.BoundingBoxTree(mesh, 2)
point = np.array([0.5, 0.5, 0.0], dtype=np.float64)
cell_candidates = dolfinx.geometry.compute_collisions(bb_tree, point)
bb_tree = dolfinx.geometry.bb_tree(mesh, 2)
point = np.array([[0.5, 0.5, 0.0]], dtype=np.float64)
cell_candidates = dolfinx.geometry.compute_collisions_points(bb_tree, point)
cells = dolfinx.geometry.compute_colliding_cells(
mesh, cell_candidates, point)

theta, w, R_gamma, p = u_.split()

if len(cells) > 0:
value = w.eval(point, cells[0])
value = w.eval(point, cells.array[0])
print(value[0])
# NOTE: FEniCS-Shells (old dolfin) `demo/documented/reissner-mindlin-clamped`
# gives 1.28506469462e-06 on a 32 x 32 mesh and 1.2703580973e-06 on a 64 x 64
Expand All @@ -239,9 +238,6 @@ def test_center_displacement():
f.write_mesh(mesh)
f.write_function(w)

with XDMFFile(MPI.COMM_WORLD, "theta.xdmf", "w") as f:
f.write_mesh(mesh)
f.write_function(theta)
# -

# ## Appendix
Expand Down
21 changes: 5 additions & 16 deletions demo/demo_reissner-mindlin-simply-supported.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import ufl
from dolfinx.fem import Function, FunctionSpace, dirichletbc
from dolfinx.fem.petsc import LinearProblem
from dolfinx.io.utils import XDMFFile
from dolfinx.mesh import CellType, create_unit_square
from ufl import (FiniteElement, MixedElement, VectorElement, dx, grad, inner,
split, sym, tr)
Expand All @@ -44,8 +43,7 @@
# [0, 1] \times [0, 1]$. `GhostMode.shared_facet` is required as the Form will
# use Nédélec elements and DG-type restrictions.

mesh = create_unit_square(MPI.COMM_WORLD, 32, 32, CellType.quadrilateral,
dolfinx.cpp.mesh.GhostMode.shared_facet)
mesh = create_unit_square(MPI.COMM_WORLD, 32, 32, CellType.quadrilateral)

# The MITC4 element [1] for the Reissner-Mindlin plate problem
# consists of:
Expand Down Expand Up @@ -233,24 +231,15 @@ def make_bc(value, V, on_boundary):
"ksp_type": "preonly", "pc_type": "lu", "pc_factor_mat_solver_type": "mumps"})
u_ = problem.solve()

bb_tree = dolfinx.geometry.BoundingBoxTree(mesh, 2)
point = np.array([0.5, 0.5, 0.0], dtype=np.float64)
cell_candidates = dolfinx.geometry.compute_collisions(bb_tree, point)
bb_tree = dolfinx.geometry.bb_tree(mesh, 2)
point = np.array([[0.5, 0.5, 0.0]], dtype=np.float64)
cell_candidates = dolfinx.geometry.compute_collisions_points(bb_tree, point)
cells = dolfinx.geometry.compute_colliding_cells(
mesh, cell_candidates, point)

theta, w, R_gamma, p = u_.split()

if len(cells) > 0:
value = w.eval(point, cells[0])
value = w.eval(point, cells.array[0])
print(value[0])


with XDMFFile(MPI.COMM_WORLD, "w.xdmf", "w") as f:
f.write_mesh(mesh)
f.write_function(w)

with XDMFFile(MPI.COMM_WORLD, "theta.xdmf", "w") as f:
f.write_mesh(mesh)
f.write_function(theta)
# -
20 changes: 0 additions & 20 deletions doc/Makefile

This file was deleted.

3 changes: 1 addition & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import sys
import os
import sys

sys.path.insert(0, os.path.abspath('.'))
import jupytext_process


jupytext_process.process()

project = 'FEniCSx-Shells'
Expand Down
4 changes: 2 additions & 2 deletions doc/source/jupytext_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#
# SPDX-License-Identifier: LGPL-3.0-or-later

import shutil
import pathlib
import os
import pathlib
import shutil

import jupytext

Expand Down
2 changes: 1 addition & 1 deletion launch-container.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
CONTAINER_ENGINE="docker"
${CONTAINER_ENGINE} run -ti -v $(pwd):/shared -w /shared dolfinx/dolfinx:v0.6.0-r1
${CONTAINER_ENGINE} run -ti -v $(pwd):/shared -w /shared dolfinx/dolfinx:v0.7.2
19 changes: 17 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
[build-system]
requires = ["setuptools>=42", "wheel", "pybind11", "cmake"]
build-backend = "setuptools.build_meta"
requires = ["scikit-build-core[pyproject]", "wheel", "pybind11"]
build-backend = "scikit_build_core.build"

[project]
name = "fenicsx-shells"
version = "0.1.0.dev0"
description = "FEniCSx-Shells"
readme = "README.md"
requires-python = ">=3.8.0"
license = { file = "COPYING.LESSER" }
authors = [
{ email = "[email protected]" },
{ name = "Jack S. Hale" },
]
dependencies = [
"fenics-dolfinx>=0.7.2,<0.8.0",
]
Loading

0 comments on commit 7a18e64

Please sign in to comment.