-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfe_utils.html
More file actions
701 lines (638 loc) · 59.5 KB
/
fe_utils.html
File metadata and controls
701 lines (638 loc) · 59.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
<!DOCTYPE html>
<html lang="en" data-content_root="./">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>fe_utils package — Finite element course 2026.0 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="_static/fenics.css?v=7793b76c" />
<link rel="stylesheet" type="text/css" href="_static/proof.css" />
<link rel="stylesheet" type="text/css" href="_static/sphinx-design.min.css?v=95c83b7e" />
<script src="_static/documentation_options.js?v=9c5a5fc5"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/proof.js"></script>
<script src="_static/design-tabs.js?v=36754332"></script>
<script async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="fe_utils.scripts package" href="fe_utils.scripts.html" />
<link rel="prev" title="10. References" href="zbibliography.html" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="_static/ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->
<link rel="stylesheet" href="_static/featured.css">
<link rel="shortcut icon" href="_static/icon.ico" />
</head><body>
<div class="wrapper">
<a href="index.html"><img src="_static/banner.svg" width="900px" alt="FInAT Project Banner" /></a>
<div id="access">
<div class="menu">
<ul>
<li class="page_item"><a href="https://github.com/finite-element/finite-element-course" title="GitHub">GitHub</a></li>
</ul>
</div><!-- .menu -->
</div><!-- #access -->
</div><!-- #wrapper -->
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="fe-utils-package">
<h1>fe_utils package<a class="headerlink" href="#fe-utils-package" title="Link to this heading">¶</a></h1>
<section id="subpackages">
<h2>Subpackages<a class="headerlink" href="#subpackages" title="Link to this heading">¶</a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="fe_utils.scripts.html">fe_utils.scripts package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.scripts.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.scripts.html#module-fe_utils.scripts.plot_function_space_nodes">fe_utils.scripts.plot_function_space_nodes module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.scripts.html#fe_utils.scripts.plot_function_space_nodes.plot_function_space_nodes"><code class="docutils literal notranslate"><span class="pre">plot_function_space_nodes()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.scripts.html#module-fe_utils.scripts.plot_interpolate_lagrange">fe_utils.scripts.plot_interpolate_lagrange module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.scripts.html#fe_utils.scripts.plot_interpolate_lagrange.plot_interpolate_lagrange"><code class="docutils literal notranslate"><span class="pre">plot_interpolate_lagrange()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.scripts.html#module-fe_utils.scripts.plot_lagrange_basis_functions">fe_utils.scripts.plot_lagrange_basis_functions module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.scripts.html#fe_utils.scripts.plot_lagrange_basis_functions.plot_lagrange_basis_functions"><code class="docutils literal notranslate"><span class="pre">plot_lagrange_basis_functions()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.scripts.html#module-fe_utils.scripts.plot_lagrange_points">fe_utils.scripts.plot_lagrange_points module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.scripts.html#fe_utils.scripts.plot_lagrange_points.plot_lagrange_points"><code class="docutils literal notranslate"><span class="pre">plot_lagrange_points()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.scripts.html#module-fe_utils.scripts.plot_mesh">fe_utils.scripts.plot_mesh module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.scripts.html#fe_utils.scripts.plot_mesh.plot_mesh"><code class="docutils literal notranslate"><span class="pre">plot_mesh()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.scripts.html#module-fe_utils.scripts.plot_sin_function">fe_utils.scripts.plot_sin_function module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.scripts.html#fe_utils.scripts.plot_sin_function.plot_sin_function"><code class="docutils literal notranslate"><span class="pre">plot_sin_function()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.scripts.html#module-fe_utils.scripts">Module contents</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="fe_utils.solvers.html">fe_utils.solvers package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.solvers.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.solvers.html#module-fe_utils.solvers.helmholtz">fe_utils.solvers.helmholtz module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.solvers.html#fe_utils.solvers.helmholtz.assemble"><code class="docutils literal notranslate"><span class="pre">assemble()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.solvers.html#fe_utils.solvers.helmholtz.solve_helmholtz"><code class="docutils literal notranslate"><span class="pre">solve_helmholtz()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.solvers.html#module-fe_utils.solvers.mastery">fe_utils.solvers.mastery module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.solvers.html#fe_utils.solvers.mastery.solve_mastery"><code class="docutils literal notranslate"><span class="pre">solve_mastery()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.solvers.html#module-fe_utils.solvers.poisson">fe_utils.solvers.poisson module</a><ul>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.solvers.html#fe_utils.solvers.poisson.assemble"><code class="docutils literal notranslate"><span class="pre">assemble()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.solvers.html#fe_utils.solvers.poisson.boundary_nodes"><code class="docutils literal notranslate"><span class="pre">boundary_nodes()</span></code></a></li>
<li class="toctree-l3"><a class="reference internal" href="fe_utils.solvers.html#fe_utils.solvers.poisson.solve_poisson"><code class="docutils literal notranslate"><span class="pre">solve_poisson()</span></code></a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="fe_utils.solvers.html#module-fe_utils.solvers">Module contents</a></li>
</ul>
</li>
</ul>
</div>
</section>
<section id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Link to this heading">¶</a></h2>
</section>
<section id="module-fe_utils.finite_elements">
<span id="fe-utils-finite-elements-module"></span><h2>fe_utils.finite_elements module<a class="headerlink" href="#module-fe_utils.finite_elements" title="Link to this heading">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="fe_utils.finite_elements.FiniteElement">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">fe_utils.finite_elements.</span></span><span class="sig-name descname"><span class="pre">FiniteElement</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cell</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">degree</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">nodes</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">entity_nodes</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/finite_elements.html#FiniteElement"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.finite_elements.FiniteElement" title="Link to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>A finite element defined over cell.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cell</strong> – the <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a>
over which the element is defined.</p></li>
<li><p><strong>degree</strong> – the
polynomial degree of the element. We assume the element
spans the complete polynomial space.</p></li>
<li><p><strong>nodes</strong> – a list of coordinate tuples corresponding to
point evaluation node locations on the element.</p></li>
<li><p><strong>entity_nodes</strong> – a dictionary of dictionaries such that
entity_nodes[d][i] is the list of nodes associated with
entity <cite>(d, i)</cite> of dimension <cite>d</cite> and index <cite>i</cite>.</p></li>
</ul>
</dd>
</dl>
<p>Most of the implementation of this class is left as exercises.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.finite_elements.FiniteElement.cell">
<span class="sig-name descname"><span class="pre">cell</span></span><a class="headerlink" href="#fe_utils.finite_elements.FiniteElement.cell" title="Link to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a>
over which the element is defined.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.finite_elements.FiniteElement.degree">
<span class="sig-name descname"><span class="pre">degree</span></span><a class="headerlink" href="#fe_utils.finite_elements.FiniteElement.degree" title="Link to this definition">¶</a></dt>
<dd><p>The polynomial degree of the element. We assume the element
spans the complete polynomial space.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.finite_elements.FiniteElement.entity_nodes">
<span class="sig-name descname"><span class="pre">entity_nodes</span></span><a class="headerlink" href="#fe_utils.finite_elements.FiniteElement.entity_nodes" title="Link to this definition">¶</a></dt>
<dd><p>A dictionary of dictionaries such that <code class="docutils literal notranslate"><span class="pre">entity_nodes[d][i]</span></code>
is the list of nodes associated with entity <cite>(d, i)</cite>.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="fe_utils.finite_elements.FiniteElement.interpolate">
<span class="sig-name descname"><span class="pre">interpolate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fn</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/finite_elements.html#FiniteElement.interpolate"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.finite_elements.FiniteElement.interpolate" title="Link to this definition">¶</a></dt>
<dd><p>Interpolate fn onto this finite element by evaluating it
at each of the nodes.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>fn</strong> – A function <code class="docutils literal notranslate"><span class="pre">fn(X)</span></code> which takes a coordinate
vector and returns a scalar value.</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A vector containing the value of <code class="docutils literal notranslate"><span class="pre">fn</span></code> at each node
of this element.</p>
</dd>
</dl>
<p>The implementation of this method is left as an <a class="reference internal" href="2_finite_elements.html#ex-interpolate"><span class="std std-ref">exercise</span></a>.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.finite_elements.FiniteElement.node_count">
<span class="sig-name descname"><span class="pre">node_count</span></span><a class="headerlink" href="#fe_utils.finite_elements.FiniteElement.node_count" title="Link to this definition">¶</a></dt>
<dd><p>The number of nodes in this element.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.finite_elements.FiniteElement.nodes">
<span class="sig-name descname"><span class="pre">nodes</span></span><a class="headerlink" href="#fe_utils.finite_elements.FiniteElement.nodes" title="Link to this definition">¶</a></dt>
<dd><p>The list of coordinate tuples corresponding to the nodes of
the element.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.finite_elements.FiniteElement.nodes_per_entity">
<span class="sig-name descname"><span class="pre">nodes_per_entity</span></span><a class="headerlink" href="#fe_utils.finite_elements.FiniteElement.nodes_per_entity" title="Link to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">nodes_per_entity[d]</span></code> is the number of entities
associated with an entity of dimension d.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="fe_utils.finite_elements.FiniteElement.tabulate">
<span class="sig-name descname"><span class="pre">tabulate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">points</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">grad</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/finite_elements.html#FiniteElement.tabulate"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.finite_elements.FiniteElement.tabulate" title="Link to this definition">¶</a></dt>
<dd><p>Evaluate the basis functions of this finite element at the points
provided.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>points</strong> – a list of coordinate tuples at which to
tabulate the basis.</p></li>
<li><p><strong>grad</strong> – whether to return the tabulation of the basis or the
tabulation of the gradient of the basis.</p></li>
</ul>
</dd>
<dt class="field-even">Result<span class="colon">:</span></dt>
<dd class="field-even"><p>an array containing the value of each basis function
at each point. If <cite>grad</cite> is <cite>True</cite>, the gradient vector of
each basis vector at each point is returned as a rank 3
array. The shape of the array is (points, nodes) if
<code class="docutils literal notranslate"><span class="pre">grad</span></code> is <code class="docutils literal notranslate"><span class="pre">False</span></code> and (points, nodes, dim) if <code class="docutils literal notranslate"><span class="pre">grad</span></code>
is <code class="docutils literal notranslate"><span class="pre">True</span></code>.</p>
</dd>
</dl>
<p>The implementation of this method is left as an <a class="reference internal" href="2_finite_elements.html#ex-tabulate"><span class="std std-ref">exercise</span></a>.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="fe_utils.finite_elements.LagrangeElement">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">fe_utils.finite_elements.</span></span><span class="sig-name descname"><span class="pre">LagrangeElement</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cell</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">degree</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/finite_elements.html#LagrangeElement"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.finite_elements.LagrangeElement" title="Link to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#fe_utils.finite_elements.FiniteElement" title="fe_utils.finite_elements.FiniteElement"><code class="xref py py-class docutils literal notranslate"><span class="pre">FiniteElement</span></code></a></p>
<p>An equispaced Lagrange finite element.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cell</strong> – the <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a>
over which the element is defined.</p></li>
<li><p><strong>degree</strong> – the
polynomial degree of the element. We assume the element
spans the complete polynomial space.</p></li>
</ul>
</dd>
</dl>
<p>The implementation of this class is left as an <a class="reference internal" href="2_finite_elements.html#ex-lagrange-element"><span class="std std-ref">exercise</span></a>.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="fe_utils.finite_elements.lagrange_points">
<span class="sig-prename descclassname"><span class="pre">fe_utils.finite_elements.</span></span><span class="sig-name descname"><span class="pre">lagrange_points</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cell</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">degree</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/finite_elements.html#lagrange_points"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.finite_elements.lagrange_points" title="Link to this definition">¶</a></dt>
<dd><p>Construct the locations of the equispaced Lagrange nodes on cell.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cell</strong> – the <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a></p></li>
<li><p><strong>degree</strong> – the degree of polynomials for which to construct nodes.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>a rank 2 <code class="xref py py-class docutils literal notranslate"><span class="pre">array</span></code> whose rows are the
coordinates of the nodes.</p>
</dd>
</dl>
<p>The implementation of this function is left as an <a class="reference internal" href="2_finite_elements.html#ex-lagrange-points"><span class="std std-ref">exercise</span></a>.</p>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="fe_utils.finite_elements.vandermonde_matrix">
<span class="sig-prename descclassname"><span class="pre">fe_utils.finite_elements.</span></span><span class="sig-name descname"><span class="pre">vandermonde_matrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cell</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">degree</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">points</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">grad</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/finite_elements.html#vandermonde_matrix"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.finite_elements.vandermonde_matrix" title="Link to this definition">¶</a></dt>
<dd><p>Construct the generalised Vandermonde matrix for polynomials of the
specified degree on the cell provided.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cell</strong> – the <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a></p></li>
<li><p><strong>degree</strong> – the degree of polynomials for which to construct the matrix.</p></li>
<li><p><strong>points</strong> – a list of coordinate tuples corresponding to the points.</p></li>
<li><p><strong>grad</strong> – whether to evaluate the Vandermonde matrix or its gradient.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>the generalised <a class="reference internal" href="2_finite_elements.html#sec-vandermonde"><span class="std std-ref">Vandermonde matrix</span></a></p>
</dd>
</dl>
<p>The implementation of this function is left as an <a class="reference internal" href="2_finite_elements.html#ex-vandermonde"><span class="std std-ref">exercise</span></a>.</p>
</dd></dl>
</section>
<section id="module-fe_utils.function_spaces">
<span id="fe-utils-function-spaces-module"></span><h2>fe_utils.function_spaces module<a class="headerlink" href="#module-fe_utils.function_spaces" title="Link to this heading">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="fe_utils.function_spaces.Function">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">fe_utils.function_spaces.</span></span><span class="sig-name descname"><span class="pre">Function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">function_space</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/function_spaces.html#Function"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.function_spaces.Function" title="Link to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>A function in a finite element space. The main role of this object
is to store the basis function coefficients associated with the nodes
of the underlying function space.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>function_space</strong> – The <a class="reference internal" href="#fe_utils.function_spaces.FunctionSpace" title="fe_utils.function_spaces.FunctionSpace"><code class="xref py py-class docutils literal notranslate"><span class="pre">FunctionSpace</span></code></a> in which
this <a class="reference internal" href="#fe_utils.function_spaces.Function" title="fe_utils.function_spaces.Function"><code class="xref py py-class docutils literal notranslate"><span class="pre">Function</span></code></a> lives.</p></li>
<li><p><strong>name</strong> – An optional label for this <a class="reference internal" href="#fe_utils.function_spaces.Function" title="fe_utils.function_spaces.Function"><code class="xref py py-class docutils literal notranslate"><span class="pre">Function</span></code></a>
which will be used in output and is useful for debugging.</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.function_spaces.Function.function_space">
<span class="sig-name descname"><span class="pre">function_space</span></span><a class="headerlink" href="#fe_utils.function_spaces.Function.function_space" title="Link to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#fe_utils.function_spaces.FunctionSpace" title="fe_utils.function_spaces.FunctionSpace"><code class="xref py py-class docutils literal notranslate"><span class="pre">FunctionSpace</span></code></a> in which this <a class="reference internal" href="#fe_utils.function_spaces.Function" title="fe_utils.function_spaces.Function"><code class="xref py py-class docutils literal notranslate"><span class="pre">Function</span></code></a> lives.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="fe_utils.function_spaces.Function.integrate">
<span class="sig-name descname"><span class="pre">integrate</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/function_spaces.html#Function.integrate"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.function_spaces.Function.integrate" title="Link to this definition">¶</a></dt>
<dd><p>Integrate this <a class="reference internal" href="#fe_utils.function_spaces.Function" title="fe_utils.function_spaces.Function"><code class="xref py py-class docutils literal notranslate"><span class="pre">Function</span></code></a> over the domain.</p>
<dl class="field-list simple">
<dt class="field-odd">Result<span class="colon">:</span></dt>
<dd class="field-odd"><p>The integral (a scalar).</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="fe_utils.function_spaces.Function.interpolate">
<span class="sig-name descname"><span class="pre">interpolate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">fn</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/function_spaces.html#Function.interpolate"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.function_spaces.Function.interpolate" title="Link to this definition">¶</a></dt>
<dd><p>Interpolate a given Python function onto this finite element
<a class="reference internal" href="#fe_utils.function_spaces.Function" title="fe_utils.function_spaces.Function"><code class="xref py py-class docutils literal notranslate"><span class="pre">Function</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>fn</strong> – A function <code class="docutils literal notranslate"><span class="pre">fn(X)</span></code> which takes a coordinate
vector and returns a scalar value.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.function_spaces.Function.name">
<span class="sig-name descname"><span class="pre">name</span></span><a class="headerlink" href="#fe_utils.function_spaces.Function.name" title="Link to this definition">¶</a></dt>
<dd><p>The (optional) name of this <a class="reference internal" href="#fe_utils.function_spaces.Function" title="fe_utils.function_spaces.Function"><code class="xref py py-class docutils literal notranslate"><span class="pre">Function</span></code></a></p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="fe_utils.function_spaces.Function.plot">
<span class="sig-name descname"><span class="pre">plot</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">subdivisions</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/function_spaces.html#Function.plot"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.function_spaces.Function.plot" title="Link to this definition">¶</a></dt>
<dd><p>Plot the value of this <a class="reference internal" href="#fe_utils.function_spaces.Function" title="fe_utils.function_spaces.Function"><code class="xref py py-class docutils literal notranslate"><span class="pre">Function</span></code></a>. This is quite a low
performance plotting routine so it will perform poorly on
larger meshes, but it has the advantage of supporting higher
order function spaces than many widely available libraries.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>subdivisions</strong> – The number of points in each direction to
use in representing each element. The default is
<span class="math notranslate nohighlight">\(2d+1\)</span> where <span class="math notranslate nohighlight">\(d\)</span> is the degree of the
<a class="reference internal" href="#fe_utils.function_spaces.FunctionSpace" title="fe_utils.function_spaces.FunctionSpace"><code class="xref py py-class docutils literal notranslate"><span class="pre">FunctionSpace</span></code></a>. Higher values produce prettier plots
which render more slowly!</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.function_spaces.Function.values">
<span class="sig-name descname"><span class="pre">values</span></span><a class="headerlink" href="#fe_utils.function_spaces.Function.values" title="Link to this definition">¶</a></dt>
<dd><p>The basis function coefficient values for this <a class="reference internal" href="#fe_utils.function_spaces.Function" title="fe_utils.function_spaces.Function"><code class="xref py py-class docutils literal notranslate"><span class="pre">Function</span></code></a></p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="fe_utils.function_spaces.FunctionSpace">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">fe_utils.function_spaces.</span></span><span class="sig-name descname"><span class="pre">FunctionSpace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mesh</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">element</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/function_spaces.html#FunctionSpace"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.function_spaces.FunctionSpace" title="Link to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>A finite element space.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>mesh</strong> – The <a class="reference internal" href="#fe_utils.mesh.Mesh" title="fe_utils.mesh.Mesh"><code class="xref py py-class docutils literal notranslate"><span class="pre">Mesh</span></code></a> on which this space is built.</p></li>
<li><p><strong>element</strong> – The <a class="reference internal" href="#fe_utils.finite_elements.FiniteElement" title="fe_utils.finite_elements.FiniteElement"><code class="xref py py-class docutils literal notranslate"><span class="pre">FiniteElement</span></code></a> of this
space.</p></li>
</ul>
</dd>
</dl>
<p>Most of the implementation of this class is left as an <a class="reference internal" href="4_function_spaces.html#ex-function-space"><span class="std std-ref">exercise</span></a>.</p>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.function_spaces.FunctionSpace.cell_nodes">
<span class="sig-name descname"><span class="pre">cell_nodes</span></span><a class="headerlink" href="#fe_utils.function_spaces.FunctionSpace.cell_nodes" title="Link to this definition">¶</a></dt>
<dd><p>The global cell node list. This is a two-dimensional array in
which each row lists the global nodes incident to the corresponding
cell. The implementation of this member is left as an
<a class="reference internal" href="4_function_spaces.html#ex-function-space"><span class="std std-ref">exercise</span></a></p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.function_spaces.FunctionSpace.element">
<span class="sig-name descname"><span class="pre">element</span></span><a class="headerlink" href="#fe_utils.function_spaces.FunctionSpace.element" title="Link to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#fe_utils.finite_elements.FiniteElement" title="fe_utils.finite_elements.FiniteElement"><code class="xref py py-class docutils literal notranslate"><span class="pre">FiniteElement</span></code></a> of this space.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.function_spaces.FunctionSpace.mesh">
<span class="sig-name descname"><span class="pre">mesh</span></span><a class="headerlink" href="#fe_utils.function_spaces.FunctionSpace.mesh" title="Link to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#fe_utils.mesh.Mesh" title="fe_utils.mesh.Mesh"><code class="xref py py-class docutils literal notranslate"><span class="pre">Mesh</span></code></a> on which this space is built.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.function_spaces.FunctionSpace.node_count">
<span class="sig-name descname"><span class="pre">node_count</span></span><a class="headerlink" href="#fe_utils.function_spaces.FunctionSpace.node_count" title="Link to this definition">¶</a></dt>
<dd><p>The total number of nodes in the function space.</p>
</dd></dl>
</dd></dl>
</section>
<section id="module-fe_utils.mesh">
<span id="fe-utils-mesh-module"></span><h2>fe_utils.mesh module<a class="headerlink" href="#module-fe_utils.mesh" title="Link to this heading">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">fe_utils.mesh.</span></span><span class="sig-name descname"><span class="pre">Mesh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">vertex_coords</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">cell_vertices</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/mesh.html#Mesh"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.mesh.Mesh" title="Link to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>A one or two dimensional mesh composed of intervals or triangles
respectively.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>vertex_coords</strong> – a vertex_count x dim array of the coordinates of
the vertices in the mesh.</p></li>
<li><p><strong>cell_vertices</strong> – a cell_count x (dim+1) array of the
indices of the vertices of which each cell is made up.</p></li>
</ul>
</dd>
</dl>
<dl class="py method">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh.adjacency">
<span class="sig-name descname"><span class="pre">adjacency</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dim1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">dim2</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/mesh.html#Mesh.adjacency"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.mesh.Mesh.adjacency" title="Link to this definition">¶</a></dt>
<dd><p>Return the set of <cite>dim2</cite> entities adjacent to each <cite>dim1</cite>
entity. For example if <cite>dim1==2</cite> and <cite>dim2==1</cite> then return the list of
edges (1D entities) adjacent to each triangle (2D entity).</p>
<p>The return value is a rank 2 <code class="xref py py-class docutils literal notranslate"><span class="pre">numpy.array</span></code> such that
<code class="docutils literal notranslate"><span class="pre">adjacency(dim1,</span> <span class="pre">dim2)[e1,</span> <span class="pre">:]</span></code> is the list of dim2 entities
adjacent to entity <code class="docutils literal notranslate"><span class="pre">(dim1,</span> <span class="pre">e1)</span></code>.</p>
<p>This operation is only defined where <cite>self.dim >= dim1 > dim2</cite>.</p>
<p>This method is simply a more systematic way of accessing
<a class="reference internal" href="#fe_utils.mesh.Mesh.edge_vertices" title="fe_utils.mesh.Mesh.edge_vertices"><code class="xref py py-attr docutils literal notranslate"><span class="pre">edge_vertices</span></code></a>, <a class="reference internal" href="#fe_utils.mesh.Mesh.cell_edges" title="fe_utils.mesh.Mesh.cell_edges"><code class="xref py py-attr docutils literal notranslate"><span class="pre">cell_edges</span></code></a> and <a class="reference internal" href="#fe_utils.mesh.Mesh.cell_vertices" title="fe_utils.mesh.Mesh.cell_vertices"><code class="xref py py-attr docutils literal notranslate"><span class="pre">cell_vertices</span></code></a>.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh.cell">
<span class="sig-name descname"><span class="pre">cell</span></span><a class="headerlink" href="#fe_utils.mesh.Mesh.cell" title="Link to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a> of which this
<a class="reference internal" href="#fe_utils.mesh.Mesh" title="fe_utils.mesh.Mesh"><code class="xref py py-class docutils literal notranslate"><span class="pre">Mesh</span></code></a> is composed.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh.cell_edges">
<span class="sig-name descname"><span class="pre">cell_edges</span></span><a class="headerlink" href="#fe_utils.mesh.Mesh.cell_edges" title="Link to this definition">¶</a></dt>
<dd><p>The indices of the edges incident to each cell (only for 2D
meshes).</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh.cell_vertices">
<span class="sig-name descname"><span class="pre">cell_vertices</span></span><a class="headerlink" href="#fe_utils.mesh.Mesh.cell_vertices" title="Link to this definition">¶</a></dt>
<dd><p>The indices of the vertices incident to cell.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh.dim">
<span class="sig-name descname"><span class="pre">dim</span></span><a class="headerlink" href="#fe_utils.mesh.Mesh.dim" title="Link to this definition">¶</a></dt>
<dd><p>The geometric and topological dimension of the mesh. Immersed
manifolds are not supported.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh.edge_vertices">
<span class="sig-name descname"><span class="pre">edge_vertices</span></span><a class="headerlink" href="#fe_utils.mesh.Mesh.edge_vertices" title="Link to this definition">¶</a></dt>
<dd><p>The indices of the vertices incident to edge (only for 2D
meshes).</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh.entity_counts">
<span class="sig-name descname"><span class="pre">entity_counts</span></span><a class="headerlink" href="#fe_utils.mesh.Mesh.entity_counts" title="Link to this definition">¶</a></dt>
<dd><p>The number of entities of each dimension in the mesh. So
<code class="xref py py-attr docutils literal notranslate"><span class="pre">entity_counts[0]</span></code> is the number of vertices in the
mesh.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh.jacobian">
<span class="sig-name descname"><span class="pre">jacobian</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">c</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/mesh.html#Mesh.jacobian"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.mesh.Mesh.jacobian" title="Link to this definition">¶</a></dt>
<dd><p>Return the Jacobian matrix for the specified cell.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>c</strong> – The number of the cell for which to return the Jacobian.</p>
</dd>
<dt class="field-even">Result<span class="colon">:</span></dt>
<dd class="field-even"><p>The Jacobian for cell <code class="docutils literal notranslate"><span class="pre">c</span></code>.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.mesh.Mesh.vertex_coords">
<span class="sig-name descname"><span class="pre">vertex_coords</span></span><a class="headerlink" href="#fe_utils.mesh.Mesh.vertex_coords" title="Link to this definition">¶</a></dt>
<dd><p>The coordinates of all the vertices in the mesh.</p>
</dd></dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="fe_utils.mesh.UnitIntervalMesh">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">fe_utils.mesh.</span></span><span class="sig-name descname"><span class="pre">UnitIntervalMesh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/mesh.html#UnitIntervalMesh"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.mesh.UnitIntervalMesh" title="Link to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#fe_utils.mesh.Mesh" title="fe_utils.mesh.Mesh"><code class="xref py py-class docutils literal notranslate"><span class="pre">Mesh</span></code></a></p>
<p>A mesh of the unit interval.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>nx</strong> – The number of cells.</p>
</dd>
</dl>
</dd></dl>
<dl class="py class">
<dt class="sig sig-object py" id="fe_utils.mesh.UnitSquareMesh">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">fe_utils.mesh.</span></span><span class="sig-name descname"><span class="pre">UnitSquareMesh</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">nx</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">ny</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/mesh.html#UnitSquareMesh"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.mesh.UnitSquareMesh" title="Link to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#fe_utils.mesh.Mesh" title="fe_utils.mesh.Mesh"><code class="xref py py-class docutils literal notranslate"><span class="pre">Mesh</span></code></a></p>
<p>A triangulated <a class="reference internal" href="#fe_utils.mesh.Mesh" title="fe_utils.mesh.Mesh"><code class="xref py py-class docutils literal notranslate"><span class="pre">Mesh</span></code></a> of the unit square.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>nx</strong> – The number of cells in the x direction.</p></li>
<li><p><strong>ny</strong> – The number of cells in the y direction.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</section>
<section id="module-fe_utils.quadrature">
<span id="fe-utils-quadrature-module"></span><h2>fe_utils.quadrature module<a class="headerlink" href="#module-fe_utils.quadrature" title="Link to this heading">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="fe_utils.quadrature.QuadratureRule">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">fe_utils.quadrature.</span></span><span class="sig-name descname"><span class="pre">QuadratureRule</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cell</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">degree</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">points</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">weights</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/quadrature.html#QuadratureRule"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.quadrature.QuadratureRule" title="Link to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>A quadrature rule implementing integration of the reference cell
provided.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cell</strong> – the <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a> over which this quadrature
rule is defined.</p></li>
<li><p><strong>degree</strong> – the <a class="reference internal" href="1_quadrature.html#degree-of-precision"><span class="std std-ref">degree of precision</span></a>
of this quadrature rule.</p></li>
</ul>
</dd>
<dt class="field-even">Points<span class="colon">:</span></dt>
<dd class="field-even"><p>a list of the position vectors of the quadrature points.</p>
</dd>
<dt class="field-odd">Weights<span class="colon">:</span></dt>
<dd class="field-odd"><p>the corresponding vector of quadrature weights.</p>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.quadrature.QuadratureRule.cell">
<span class="sig-name descname"><span class="pre">cell</span></span><a class="headerlink" href="#fe_utils.quadrature.QuadratureRule.cell" title="Link to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a> over which this quadrature
rule is defined.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.quadrature.QuadratureRule.degree">
<span class="sig-name descname"><span class="pre">degree</span></span><a class="headerlink" href="#fe_utils.quadrature.QuadratureRule.degree" title="Link to this definition">¶</a></dt>
<dd><p>The degree of precision of the quadrature rule.</p>
</dd></dl>
<dl class="py method">
<dt class="sig sig-object py" id="fe_utils.quadrature.QuadratureRule.integrate">
<span class="sig-name descname"><span class="pre">integrate</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">function</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/quadrature.html#QuadratureRule.integrate"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.quadrature.QuadratureRule.integrate" title="Link to this definition">¶</a></dt>
<dd><p>Integrate the function provided using this quadrature rule.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>function</strong> – A Python function taking a position vector as
its single argument and returning a scalar value.</p>
</dd>
</dl>
<p>The implementation of this method is left as an <a class="reference internal" href="1_quadrature.html#ex-integrate"><span class="std std-ref">exercise</span></a>.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.quadrature.QuadratureRule.points">
<span class="sig-name descname"><span class="pre">points</span></span><a class="headerlink" href="#fe_utils.quadrature.QuadratureRule.points" title="Link to this definition">¶</a></dt>
<dd><p>Two dimensional array, the rows of which form the position
vectors of the quadrature points.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.quadrature.QuadratureRule.weights">
<span class="sig-name descname"><span class="pre">weights</span></span><a class="headerlink" href="#fe_utils.quadrature.QuadratureRule.weights" title="Link to this definition">¶</a></dt>
<dd><p>The corresponding array of quadrature weights.</p>
</dd></dl>
</dd></dl>
<dl class="py function">
<dt class="sig sig-object py" id="fe_utils.quadrature.gauss_quadrature">
<span class="sig-prename descclassname"><span class="pre">fe_utils.quadrature.</span></span><span class="sig-name descname"><span class="pre">gauss_quadrature</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">cell</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">degree</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/quadrature.html#gauss_quadrature"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.quadrature.gauss_quadrature" title="Link to this definition">¶</a></dt>
<dd><p>Return a Gauss-Legendre <a class="reference internal" href="#fe_utils.quadrature.QuadratureRule" title="fe_utils.quadrature.QuadratureRule"><code class="xref py py-class docutils literal notranslate"><span class="pre">QuadratureRule</span></code></a>.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cell</strong> – the <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a> over which this quadrature
rule is defined.</p></li>
<li><p><strong>degree</strong> – the <a class="reference internal" href="1_quadrature.html#degree-of-precision"><span class="std std-ref">degree of precision</span></a>
of this quadrature rule.</p></li>
</ul>
</dd>
</dl>
</dd></dl>
</section>
<section id="module-fe_utils.reference_elements">
<span id="fe-utils-reference-elements-module"></span><h2>fe_utils.reference_elements module<a class="headerlink" href="#module-fe_utils.reference_elements" title="Link to this heading">¶</a></h2>
<dl class="py class">
<dt class="sig sig-object py" id="fe_utils.reference_elements.ReferenceCell">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">fe_utils.reference_elements.</span></span><span class="sig-name descname"><span class="pre">ReferenceCell</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">vertices</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">topology</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">name</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/reference_elements.html#ReferenceCell"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.reference_elements.ReferenceCell" title="Link to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/functions.html#object" title="(in Python v3.14)"><code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></a></p>
<p>An object storing the geometry and topology of the reference cell.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>vertices</strong> – a list of coordinate vectors corresponding to
the coordinates of the vertices of the cell.</p></li>
<li><p><strong>topology</strong> – a dictionary of dictionaries such that topology[d][i]
is the list of vertices incident to the <cite>i</cite>-th entity of dimension
<cite>d</cite>.</p></li>
</ul>
</dd>
</dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.reference_elements.ReferenceCell.dim">
<span class="sig-name descname"><span class="pre">dim</span></span><a class="headerlink" href="#fe_utils.reference_elements.ReferenceCell.dim" title="Link to this definition">¶</a></dt>
<dd><p>The geometric and topological dimension of the reference cell.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.reference_elements.ReferenceCell.entity_counts">
<span class="sig-name descname"><span class="pre">entity_counts</span></span><a class="headerlink" href="#fe_utils.reference_elements.ReferenceCell.entity_counts" title="Link to this definition">¶</a></dt>
<dd><p>The number of entities of each dimension.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.reference_elements.ReferenceCell.topology">
<span class="sig-name descname"><span class="pre">topology</span></span><a class="headerlink" href="#fe_utils.reference_elements.ReferenceCell.topology" title="Link to this definition">¶</a></dt>
<dd><p>The vertices making up each topological entity of the reference
cell.</p>
</dd></dl>
<dl class="py attribute">
<dt class="sig sig-object py" id="fe_utils.reference_elements.ReferenceCell.vertices">
<span class="sig-name descname"><span class="pre">vertices</span></span><a class="headerlink" href="#fe_utils.reference_elements.ReferenceCell.vertices" title="Link to this definition">¶</a></dt>
<dd><p>The list of coordinate veritices of the reference cell.</p>
</dd></dl>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="fe_utils.reference_elements.ReferenceInterval">
<span class="sig-prename descclassname"><span class="pre">fe_utils.reference_elements.</span></span><span class="sig-name descname"><span class="pre">ReferenceInterval</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">ReferenceInterval</span></em><a class="headerlink" href="#fe_utils.reference_elements.ReferenceInterval" title="Link to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a> storing the geometry and topology of the
interval [0, 1].</p>
</dd></dl>
<dl class="py data">
<dt class="sig sig-object py" id="fe_utils.reference_elements.ReferenceTriangle">
<span class="sig-prename descclassname"><span class="pre">fe_utils.reference_elements.</span></span><span class="sig-name descname"><span class="pre">ReferenceTriangle</span></span><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">ReferenceTriangle</span></em><a class="headerlink" href="#fe_utils.reference_elements.ReferenceTriangle" title="Link to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#fe_utils.reference_elements.ReferenceCell" title="fe_utils.reference_elements.ReferenceCell"><code class="xref py py-class docutils literal notranslate"><span class="pre">ReferenceCell</span></code></a> storing the geometry and topology of the triangle
with vertices [[0., 0.], [1., 0.], [0., 1.]].</p>
</dd></dl>
</section>
<section id="module-fe_utils.utils">
<span id="fe-utils-utils-module"></span><h2>fe_utils.utils module<a class="headerlink" href="#module-fe_utils.utils" title="Link to this heading">¶</a></h2>
<dl class="py function">
<dt class="sig sig-object py" id="fe_utils.utils.errornorm">
<span class="sig-prename descclassname"><span class="pre">fe_utils.utils.</span></span><span class="sig-name descname"><span class="pre">errornorm</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">f1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f2</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/fe_utils/utils.html#errornorm"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#fe_utils.utils.errornorm" title="Link to this definition">¶</a></dt>
<dd><p>Calculate the L^2 norm of the difference between f1 and f2.</p>
</dd></dl>
</section>
<section id="module-fe_utils">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-fe_utils" title="Link to this heading">¶</a></h2>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer" role="contentinfo">
© Copyright 2014-2026, David A. Ham and Colin J. Cotter.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.4.7.
</div>
</body>
</html>