Skip to content

Commit b1daeb2

Browse files
authored
Resolve #117 (#261)
1 parent 867606b commit b1daeb2

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

chapter2/hyperelasticity.ipynb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@
323323
"id": "28",
324324
"metadata": {},
325325
"source": [
326-
"Define form F (we want to find u such that F(u) = 0)"
326+
"Define the residual of the equation (we want to find u such that residual(u) = 0)"
327327
]
328328
},
329329
{
@@ -333,7 +333,9 @@
333333
"metadata": {},
334334
"outputs": [],
335335
"source": [
336-
"F = ufl.inner(ufl.grad(v), P) * dx - ufl.inner(v, B) * dx - ufl.inner(v, T) * ds(2)"
336+
"residual = (\n",
337+
" ufl.inner(ufl.grad(v), P) * dx - ufl.inner(v, B) * dx - ufl.inner(v, T) * ds(2)\n",
338+
")"
337339
]
338340
},
339341
{
@@ -364,7 +366,11 @@
364366
" \"pc_factor_mat_solver_type\": \"mumps\",\n",
365367
"}\n",
366368
"problem = NonlinearProblem(\n",
367-
" F, u, bcs=bcs, petsc_options=petsc_options, petsc_options_prefix=\"hyperelasticity\"\n",
369+
" residual,\n",
370+
" u,\n",
371+
" bcs=bcs,\n",
372+
" petsc_options=petsc_options,\n",
373+
" petsc_options_prefix=\"hyperelasticity\",\n",
368374
")"
369375
]
370376
},

chapter2/hyperelasticity.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,11 @@ def right(x):
143143
ds = ufl.Measure("ds", domain=domain, subdomain_data=facet_tag, metadata=metadata)
144144
dx = ufl.Measure("dx", domain=domain, metadata=metadata)
145145

146-
# Define form F (we want to find u such that F(u) = 0)
146+
# Define the residual of the equation (we want to find u such that residual(u) = 0)
147147

148-
F = ufl.inner(ufl.grad(v), P) * dx - ufl.inner(v, B) * dx - ufl.inner(v, T) * ds(2)
148+
residual = (
149+
ufl.inner(ufl.grad(v), P) * dx - ufl.inner(v, B) * dx - ufl.inner(v, T) * ds(2)
150+
)
149151

150152
# As the varitional form is non-linear and written on residual form,
151153
# we use the non-linear problem class from DOLFINx to set up required structures to use a Newton solver.
@@ -162,7 +164,11 @@ def right(x):
162164
"pc_factor_mat_solver_type": "mumps",
163165
}
164166
problem = NonlinearProblem(
165-
F, u, bcs=bcs, petsc_options=petsc_options, petsc_options_prefix="hyperelasticity"
167+
residual,
168+
u,
169+
bcs=bcs,
170+
petsc_options=petsc_options,
171+
petsc_options_prefix="hyperelasticity",
166172
)
167173

168174
# We create a function to plot the solution at each time step.

0 commit comments

Comments
 (0)