Skip to content

Commit 3f39003

Browse files
Upstream updates
1 parent e86625e commit 3f39003

12 files changed

Lines changed: 731 additions & 404 deletions

01-spd-helmholtz.ipynb

Lines changed: 86 additions & 45 deletions
Large diffs are not rendered by default.

02-poisson.ipynb

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{
44
"cell_type": "code",
55
"execution_count": null,
6+
"id": "8d668cbf",
67
"metadata": {},
78
"outputs": [],
89
"source": [
@@ -15,19 +16,16 @@
1516
},
1617
{
1718
"cell_type": "markdown",
19+
"id": "018449d5",
1820
"metadata": {},
1921
"source": [
2022
"# Strong (Dirichlet) boundary conditions"
2123
]
2224
},
2325
{
2426
"cell_type": "markdown",
25-
"metadata": {
26-
"collapsed": true,
27-
"jupyter": {
28-
"outputs_hidden": true
29-
}
30-
},
27+
"id": "dca32fa6",
28+
"metadata": {},
3129
"source": [
3230
"Let's move on from the Helmholtz problem to Poisson:\n",
3331
"\n",
@@ -51,11 +49,12 @@
5149
"\n",
5250
"$$\\int_\\Omega \\nabla u \\cdot \\nabla v\\, \\mathrm{d}x - \\int_{\\Gamma_N} hv\\, \\mathrm{d}s = \\int_\\Omega fv\\mathrm{d}x \\quad\\forall v\\in V_0.$$\n",
5351
"\n",
54-
"In Firedrake, the weak form is always formulated in the unmodified space $V$. The modification to the function spaces implied by the Dirichlet conditions is then imposed by supplying a [`DirichletBC` object](http://firedrakeproject.org/firedrake.html#firedrake.bcs.DirichletBC) to the solve."
52+
"In Firedrake, the weak form is always formulated in the unmodified space $V$. The modification to the function spaces implied by the Dirichlet conditions is then imposed by supplying a [DirichletBC object](http://firedrakeproject.org/firedrake.html#firedrake.bcs.DirichletBC) to the solve."
5553
]
5654
},
5755
{
5856
"cell_type": "markdown",
57+
"id": "a1e48503",
5958
"metadata": {},
6059
"source": [
6160
"As usual, we start by setting up the notebook matplotlib interaction, and importing Firedrake. We then choose a triangulation of our domain and select an appropriate $H^1$-conforming function space."
@@ -64,20 +63,17 @@
6463
{
6564
"cell_type": "code",
6665
"execution_count": null,
66+
"id": "ed2ff100",
6767
"metadata": {},
6868
"outputs": [],
6969
"source": [
70-
"# Code in this cell makes plots appear an appropriate size and resolution in the browser window\n",
71-
"%config InlineBackend.figure_format = 'svg'\n",
72-
"\n",
73-
"import matplotlib.pyplot as plt\n",
74-
"\n",
75-
"plt.rcParams['figure.figsize'] = (11, 6)"
70+
"import matplotlib.pyplot as plt"
7671
]
7772
},
7873
{
7974
"cell_type": "code",
8075
"execution_count": null,
76+
"id": "ed1d6a3a",
8177
"metadata": {},
8278
"outputs": [],
8379
"source": [
@@ -88,6 +84,7 @@
8884
},
8985
{
9086
"cell_type": "markdown",
87+
"id": "c440c521",
9188
"metadata": {},
9289
"source": [
9390
"Let us specify the details of our problem. We will solve\n",
@@ -103,6 +100,7 @@
103100
{
104101
"cell_type": "code",
105102
"execution_count": null,
103+
"id": "4767decb",
106104
"metadata": {},
107105
"outputs": [],
108106
"source": [
@@ -113,6 +111,7 @@
113111
},
114112
{
115113
"cell_type": "markdown",
114+
"id": "410e7264",
116115
"metadata": {},
117116
"source": [
118117
"As before, we'll require test and trial functions to define our problem."
@@ -121,6 +120,7 @@
121120
{
122121
"cell_type": "code",
123122
"execution_count": null,
123+
"id": "68542038",
124124
"metadata": {},
125125
"outputs": [],
126126
"source": [
@@ -132,6 +132,7 @@
132132
},
133133
{
134134
"cell_type": "markdown",
135+
"id": "0e515a50",
135136
"metadata": {},
136137
"source": [
137138
"Now we need to tell Firedrake how to modify the function space to take into account the Dirichlet condition. This is done by constructing a [DirichletBC object](http://firedrakeproject.org/firedrake.html#firedrake.bcs.DirichletBC). As usual, we can ask for help using Python's builtin documentation facilities."
@@ -140,6 +141,7 @@
140141
{
141142
"cell_type": "code",
142143
"execution_count": null,
144+
"id": "3ab76829",
143145
"metadata": {},
144146
"outputs": [],
145147
"source": [
@@ -148,6 +150,7 @@
148150
},
149151
{
150152
"cell_type": "markdown",
153+
"id": "71ba54e1",
151154
"metadata": {},
152155
"source": [
153156
"We want to apply the zero Dirichlet condition to all exterior nodes of the space, so we need to provide the list of boundary ids that corresponds to the exterior boundary of the domain. For the `UnitSquareMesh`, this is the set `(1, 2, 3, 4)`."
@@ -156,6 +159,7 @@
156159
{
157160
"cell_type": "code",
158161
"execution_count": null,
162+
"id": "c8624cd6",
159163
"metadata": {},
160164
"outputs": [],
161165
"source": [
@@ -165,6 +169,7 @@
165169
},
166170
{
167171
"cell_type": "markdown",
172+
"id": "2b1ff9a7",
168173
"metadata": {},
169174
"source": [
170175
"We supply the boundary condition as an argument to `solve`."
@@ -173,6 +178,7 @@
173178
{
174179
"cell_type": "code",
175180
"execution_count": null,
181+
"id": "85728956",
176182
"metadata": {},
177183
"outputs": [],
178184
"source": [
@@ -183,10 +189,14 @@
183189
{
184190
"cell_type": "code",
185191
"execution_count": null,
186-
"metadata": {},
192+
"id": "e9ac8978",
193+
"metadata": {
194+
"tags": [
195+
"nbval-ignore-output"
196+
]
197+
},
187198
"outputs": [],
188199
"source": [
189-
"# NBVAL_IGNORE_OUTPUT\n",
190200
"from firedrake.pyplot import tripcolor\n",
191201
"\n",
192202
"fig, axes = plt.subplots()\n",
@@ -196,9 +206,10 @@
196206
},
197207
{
198208
"cell_type": "markdown",
209+
"id": "e7719c3f",
199210
"metadata": {},
200211
"source": [
201-
"# Exercises\n",
212+
"## Exercises\n",
202213
"\n",
203214
"Most of the time, we don't want to impose the same Dirichlet condition everywhere. Instead of solving with homogeneous Dirichlet conditions everywhere, solve the following problem.\n",
204215
"\n",
@@ -219,30 +230,23 @@
219230
{
220231
"cell_type": "code",
221232
"execution_count": null,
233+
"id": "daa736cd",
222234
"metadata": {},
223235
"outputs": [],
224236
"source": []
225237
}
226238
],
227239
"metadata": {
240+
"jupytext": {
241+
"cell_metadata_filter": "tags,-all",
242+
"notebook_metadata_filter": "-jupytext.text_representation.jupytext_version"
243+
},
228244
"kernelspec": {
229245
"display_name": "Python 3 (ipykernel)",
230246
"language": "python",
231247
"name": "python3"
232-
},
233-
"language_info": {
234-
"codemirror_mode": {
235-
"name": "ipython",
236-
"version": 3
237-
},
238-
"file_extension": ".py",
239-
"mimetype": "text/x-python",
240-
"name": "python",
241-
"nbconvert_exporter": "python",
242-
"pygments_lexer": "ipython3",
243-
"version": "3.13.3"
244248
}
245249
},
246250
"nbformat": 4,
247-
"nbformat_minor": 4
251+
"nbformat_minor": 5
248252
}

0 commit comments

Comments
 (0)