Skip to content

Commit 4b5b2bb

Browse files
committed
Add propsoed solution to #205 (#257)
1 parent 9d52627 commit 4b5b2bb

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

chapter3/component_bc.ipynb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,15 @@
118118
"cell_type": "markdown",
119119
"metadata": {},
120120
"source": [
121-
"Next, we locate the degrees of freedom on the top boundary. However, as the boundary condition is in a sub space of our solution, we need to supply both the parent space $V$ and the sub space $V_0$ to `dolfinx.locate_dofs_topological`."
121+
"Next, we locate the degrees of freedom on the top boundary.\n",
122+
"However, as the boundary condition is in a sub space of our solution,\n",
123+
"we have to carefully decide whoe to locate the degrees of freedom.\n",
124+
"In the example below, we will use a constant value as the prescribed value.\n",
125+
"This means that we can use `dolfinx.fem.locate_dofs_topological`\n",
126+
"on the (un-collapsed) sub space to locate the degrees of freedom on the boundary.\n",
127+
"If you want to use a spatially dependent function, see\n",
128+
"[FEniCS Workshop: Dirichlet conditions in mixed spaces](https://jsdokken.com/FEniCS-workshop/src/deep_dive/mixed_problems.html#dirichlet-conditions-in-mixed-spaces)\n",
129+
"for a detailed discussion."
122130
]
123131
},
124132
{
@@ -285,7 +293,7 @@
285293
"if not pyvista.OFF_SCREEN:\n",
286294
" p.show()\n",
287295
"else:\n",
288-
" fig_array = p.screenshot(f\"component.png\")"
296+
" fig_array = p.screenshot(\"component.png\")"
289297
]
290298
}
291299
],

chapter3/component_bc.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,15 @@ def clamped_boundary(x):
8787
# Next we would like to constrain the $x$-component of our solution at $x=L$ to $0$. We start by creating the sub space only containing the $x$
8888
# -component.
8989

90-
# Next, we locate the degrees of freedom on the top boundary. However, as the boundary condition is in a sub space of our solution, we need to supply both the parent space $V$ and the sub space $V_0$ to `dolfinx.locate_dofs_topological`.
90+
# Next, we locate the degrees of freedom on the top boundary.
91+
# However, as the boundary condition is in a sub space of our solution,
92+
# we have to carefully decide whoe to locate the degrees of freedom.
93+
# In the example below, we will use a constant value as the prescribed value.
94+
# This means that we can use `dolfinx.fem.locate_dofs_topological`
95+
# on the (un-collapsed) sub space to locate the degrees of freedom on the boundary.
96+
# If you want to use a spatially dependent function, see
97+
# [FEniCS Workshop: Dirichlet conditions in mixed spaces](https://jsdokken.com/FEniCS-workshop/src/deep_dive/mixed_problems.html#dirichlet-conditions-in-mixed-spaces)
98+
# for a detailed discussion.
9199

92100
def right(x):
93101
return np.logical_and(np.isclose(x[0], L), x[1] < H)
@@ -157,4 +165,4 @@ def sigma(u):
157165
if not pyvista.OFF_SCREEN:
158166
p.show()
159167
else:
160-
fig_array = p.screenshot(f"component.png")
168+
fig_array = p.screenshot("component.png")

0 commit comments

Comments
 (0)