Skip to content

Commit

Permalink
Merge pull request #3 from jorgensd/dokken/v0.7.0
Browse files Browse the repository at this point in the history
Dokken/v0.7.0
  • Loading branch information
jorgensd committed Dec 7, 2023
2 parents 680746a + a87be4f commit b1c5ae4
Show file tree
Hide file tree
Showing 15 changed files with 316 additions and 2,379 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ jobs:
env:
PYTHONPATH: /usr/local/lib/python3/dist-packages:/usr/local/lib:/usr/local/dolfinx-real/lib/python3.10/dist-packages
DEB_PYTHON_INSTALL_LAYOUT: deb_system
PYVISTA_JUPYTER_BACKEND: "static"
PYVISTA_JUPYTER_BACKEND: "html"
runs-on: ubuntu-22.04
container: dolfinx/dolfinx:v0.6.0-r1
container: dolfinx/dolfinx:v0.7.2
steps:
# This action sets the current path to the root of your github repo
- uses: actions/checkout@v4
Expand All @@ -33,8 +33,7 @@ jobs:
apt-get install -y graphviz-dev libgl1-mesa-glx xvfb
- name: Update pip
# Pin setuptools for old dolfinx due to https://github.com/FEniCS/ffcx/issues/553
run: python3 -m pip install --upgrade pip setuptools==65.5.1
run: python3 -m pip install --upgrade pip setuptools

- name: Install dependencies
run: python3 -m pip install -e ".[dev]"
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:
group: "pages"
cancel-in-progress: true

jobs:
jobs:
build-docs:
uses: ./.github/workflows/build_docs.yml

Expand Down Expand Up @@ -44,8 +44,8 @@ jobs:
uses: actions/checkout@v4

- name: Setup Pages
uses: actions/configure-pages@v3
uses: actions/configure-pages@v4

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v3
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ in DOLFINx.
A short summary of the various components {cite}`DOLFINx2023` can be found below.
![Components of FEniCS](components_of_fenics.png)

The tutorial is currently built for `v0.7.x` of DOLFINx, for older versions see: https://github.com/jorgensd/FEniCS23-tutorial/releases

```{bibliography}
:filter: cited and ({"README"} >= docnames)
```
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
[build-system] # Require setuptool version due to https://github.com/pypa/setuptools/issues/2938
requires = ["setuptools>=61.0.0", "pip>=23.1"]
[build-system]
requires = ["setuptools>=64.4.0", "wheel", "pip>=22.3"]

[project]
name = "FEniCS23"
version = "0.6.0"
version = "0.7.0"
description = "Tutorial for FENiCS 2023"
authors = [{ name = "Jørgen S. Dokken", email = "dokken@simula.no" }]
license = { file = "LICENSE" }
readme = "README.md"
dependencies = [
"fenics-dolfinx==0.6.0",
"fenics-dolfinx>=0.7.0",
"pygraphviz",
"pyvista",
"pyvista[all]>=0.43.0",
"ipyparallel",
"tqdm",
]
Expand Down
14 changes: 8 additions & 6 deletions src/approximations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import pyvista
import numpy as np
import dolfinx
import dolfinx.fem.petsc
from mpi4py import MPI
import ufl
from petsc4py import PETSc
Expand Down Expand Up @@ -49,7 +50,7 @@ class Projector():

_A: PETSc.Mat # The mass matrix
_b: PETSc.Vec # The rhs vector
_lhs: dolfinx.fem.FormMetaClass # The compiled form for the mass matrix
_lhs: dolfinx.fem.Form # The compiled form for the mass matrix
_ksp: PETSc.KSP # The PETSc solver
_x: dolfinx.fem.Function # The solution vector
_dx: ufl.Measure # Integration measure
Expand Down Expand Up @@ -90,6 +91,8 @@ def __init__(self,
opts[k] = v
opts.prefixPop()
self._ksp.setFromOptions()
for opt in opts.getAll().keys():
del opts[opt]

# Set matrix and vector PETSc options
self._A.setOptionsPrefix(prefix)
Expand Down Expand Up @@ -158,8 +161,7 @@ def h(mesh: dolfinx.mesh.Mesh):

# We can now evaluate the expression at the point 0.5 in the reference element for any cell (this coordinate is then pushed forward to the given input cell).
# For instance, we can evaluate this expression in the cell with index 0 with

compiled_h.eval([0])
compiled_h.eval(mesh, np.array([0], dtype=np.int32))

# We can also interpolate functions from an expression into any suitable function space by calling

Expand All @@ -176,7 +178,7 @@ def h(mesh: dolfinx.mesh.Mesh):


V_projector = Projector(
V, petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
V, petsc_options={"ksp_type": "pre_only", "pc_type": "lu"})
uh = V_projector.project(h(V.mesh))

pyvista.start_xvfb(1.0)
Expand All @@ -186,7 +188,7 @@ def h(mesh: dolfinx.mesh.Mesh):

def plot_1D_scalar_function(u: dolfinx.fem.Function, title: str):
u_grid = pyvista.UnstructuredGrid(
*dolfinx.plot.create_vtk_mesh(u.function_space))
*dolfinx.plot.vtk_mesh(u.function_space))
u_grid.point_data["u"] = u.x.array
warped = u_grid.warp_by_scalar()
plotter = pyvista.Plotter()
Expand All @@ -205,7 +207,7 @@ def plot_1D_scalar_function(u: dolfinx.fem.Function, title: str):


W_projector = Projector(
W, petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
W, petsc_options={"ksp_type": "pre_only", "pc_type": "lu"})
wh = W_projector.project(h(W.mesh))


Expand Down
2 changes: 1 addition & 1 deletion src/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
# We can look at the assembly code for the local matrix. We start by inspecting the signature of the `tabulate_tensor` function,
# that computes the local element matrix

os.system("head -523 ufl_formulation.c | tail +476")
os.system("head -336 ufl_formulation.c | tail +283")
3 changes: 2 additions & 1 deletion src/form_compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import numpy as np
import ufl
from mpi4py import MPI
import dolfinx.fem.petsc
import dolfinx

# + tags=["hide-output"]
Expand Down Expand Up @@ -122,7 +123,7 @@ def u_init(x, sigma=0.1, mu=0.3):

uh = dolfinx.fem.Function(V)
petsc_options = {"ksp_type": "preonly",
"pc_type": "lu", "pc_factor_solver_type": "mumps"}
"pc_type": "lu", "pc_factor_mat_solver_type": "mumps"}
problem = dolfinx.fem.petsc.LinearProblem(
a_compiled, L_compiled, u=uh, bcs=[], petsc_options=petsc_options)

Expand Down
Loading

0 comments on commit b1c5ae4

Please sign in to comment.