Skip to content

Commit f1002b6

Browse files
committed
Website build
1 parent 27337b9 commit f1002b6

30 files changed

Lines changed: 11577 additions & 5 deletions

1_quadrature.html

Lines changed: 423 additions & 0 deletions
Large diffs are not rendered by default.

2_finite_elements.html

Lines changed: 611 additions & 0 deletions
Large diffs are not rendered by default.

3_meshes.html

Lines changed: 235 additions & 0 deletions
Large diffs are not rendered by default.

4_function_spaces.html

Lines changed: 326 additions & 0 deletions
Large diffs are not rendered by default.

5_functions.html

Lines changed: 391 additions & 0 deletions
Large diffs are not rendered by default.

6_finite_element_problems.html

Lines changed: 446 additions & 0 deletions
Large diffs are not rendered by default.

7_boundary_conditions.html

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
<!DOCTYPE html>
2+
3+
<html lang="en" data-content_root="./">
4+
<head>
5+
<meta charset="utf-8" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
7+
8+
<title>7. Dirichlet boundary conditions &#8212; Finite element course 2024.0 documentation</title>
9+
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
10+
<link rel="stylesheet" type="text/css" href="_static/fenics.css?v=7793b76c" />
11+
<link rel="stylesheet" type="text/css" href="_static/proof.css" />
12+
<link rel="stylesheet" type="text/css" href="_static/sphinx-design.min.css?v=95c83b7e" />
13+
<script src="_static/documentation_options.js?v=7ff0cb77"></script>
14+
<script src="_static/doctools.js?v=9a2dae69"></script>
15+
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
16+
<script src="_static/proof.js"></script>
17+
<script src="_static/design-tabs.js?v=36754332"></script>
18+
<script async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
19+
<link rel="index" title="Index" href="genindex.html" />
20+
<link rel="search" title="Search" href="search.html" />
21+
<link rel="next" title="8. Nonlinear problems" href="8_nonlinear_problems.html" />
22+
<link rel="prev" title="6. Assembling and solving finite element problems" href="6_finite_element_problems.html" />
23+
<!--[if lte IE 6]>
24+
<link rel="stylesheet" href="_static/ie6.css" type="text/css" media="screen" charset="utf-8" />
25+
<![endif]-->
26+
27+
<link rel="stylesheet" href="_static/featured.css">
28+
29+
30+
<link rel="shortcut icon" href="_static/icon.ico" />
31+
32+
33+
</head><body>
34+
<div class="wrapper">
35+
<a href="index.html"><img src="_static/banner.svg" width="900px" alt="FInAT Project Banner" /></a>
36+
<div id="access">
37+
<div class="menu">
38+
<ul>
39+
<li class="page_item"><a href="https://github.com/finite-element/finite-element-course" title="GitHub">GitHub</a></li>
40+
</ul>
41+
</div><!-- .menu -->
42+
</div><!-- #access -->
43+
</div><!-- #wrapper -->
44+
45+
46+
<div class="document">
47+
<div class="documentwrapper">
48+
<div class="bodywrapper">
49+
<div class="body" role="main">
50+
51+
<section id="dirichlet-boundary-conditions">
52+
<span id="secdirichlet"></span><h1><span class="section-number">7. </span>Dirichlet boundary conditions<a class="headerlink" href="#dirichlet-boundary-conditions" title="Link to this heading"></a></h1>
53+
<p>The Helmholtz problem we solved in the previous part was chosen to
54+
have homogeneous Neumann or <em>natural</em> boundary conditions, which can
55+
be implemented simply by cancelling the zero surface integral. We can
56+
now instead consider the case of Dirichlet, or <em>essential</em> boundary
57+
conditions. Instead of the Helmholtz problem we solved before, let us
58+
now specify a Poisson problem with homogeneous Dirichlet conditions, find <span class="math notranslate nohighlight">\(u\)</span> in
59+
some finite element space <span class="math notranslate nohighlight">\(V\)</span> such that:</p>
60+
<div class="math notranslate nohighlight" id="equation-poisson">
61+
<span class="eqno">(7.1)<a class="headerlink" href="#equation-poisson" title="Link to this equation"></a></span>\[ \begin{align}\begin{aligned}-\nabla^2 u = f\\u = 0 \textrm{ on }\Gamma\end{aligned}\end{align} \]</div>
62+
<p>In order to implement the Dirichlet conditions, we need to decompose
63+
<span class="math notranslate nohighlight">\(V\)</span> into two parts:</p>
64+
<div class="math notranslate nohighlight" id="equation-7-boundary-conditions-0">
65+
<span class="eqno">(7.2)<a class="headerlink" href="#equation-7-boundary-conditions-0" title="Link to this equation"></a></span>\[V = V_0 \oplus V_\Gamma\]</div>
66+
<p>where <span class="math notranslate nohighlight">\(V_\Gamma\)</span> is the space spanned by those functions in the basis
67+
of <span class="math notranslate nohighlight">\(V\)</span> which are non-zero on <span class="math notranslate nohighlight">\(\Gamma\)</span>, and <span class="math notranslate nohighlight">\(V_0\)</span> is the space spanned
68+
by the remaining basis functions (i.e. those basis functions which
69+
vanish on <span class="math notranslate nohighlight">\(\Gamma\)</span>). It is a direct consequence of the nodal nature of
70+
the basis that the basis functions for <span class="math notranslate nohighlight">\(V_\Gamma\)</span> are those
71+
corresponding to the nodes on <span class="math notranslate nohighlight">\(\Gamma\)</span> while the basis for <span class="math notranslate nohighlight">\(V_0\)</span> is
72+
composed of all the other functions.</p>
73+
<p>We now write the weak form of <a class="reference internal" href="#equation-poisson">(7.1)</a>, find <span class="math notranslate nohighlight">\(u=u_0 + u_\Gamma\)</span>
74+
with <span class="math notranslate nohighlight">\(u_0 \in V_0\)</span> and <span class="math notranslate nohighlight">\(u_\Gamma \in V_\Gamma\)</span> such that:</p>
75+
<div class="math notranslate nohighlight" id="equation-7-boundary-conditions-1">
76+
<span class="eqno">(7.3)<a class="headerlink" href="#equation-7-boundary-conditions-1" title="Link to this equation"></a></span>\[ \begin{align}\begin{aligned}\int_\Omega \nabla v_0 \cdot \nabla (u_0+u_\Gamma) \, \mathrm{d} x
77+
- \underbrace{\int_\Gamma v_0 \nabla (u_0+u_\Gamma) \cdot
78+
\mathbf{n}\, \mathrm{d} s}_{=0} = \int_\Omega v_0\, f\, \mathrm{d} x
79+
\qquad \forall v_0 \in V_0\\u_\Gamma = 0 \qquad \textrm{ on } \Gamma\end{aligned}\end{align} \]</div>
80+
<p>There are a number of features of this equation which require some explanation:</p>
81+
<ol class="arabic simple">
82+
<li><p>We only test with functions from <span class="math notranslate nohighlight">\(V_0\)</span>. This is because it is only
83+
necessary that the differential equation is satisfied on the interior
84+
of the domain: on the boundary of the domain we need only satisfy the
85+
boundary conditions.</p></li>
86+
<li><p>The surface integral now cancels because <span class="math notranslate nohighlight">\(v_0\)</span> is guaranteed to be
87+
zero everywhere on the boundary.</p></li>
88+
<li><p>The <span class="math notranslate nohighlight">\(u_\Gamma\)</span> definition actually implies that <span class="math notranslate nohighlight">\(u_\Gamma=0\)</span>
89+
everywhere, since all of the nodes in <span class="math notranslate nohighlight">\(V_\Gamma\)</span> lie on the boundary.</p></li>
90+
</ol>
91+
<p>This means that the weak form is actually:</p>
92+
<div class="math notranslate nohighlight" id="equation-weakpoisson">
93+
<span class="eqno">(7.4)<a class="headerlink" href="#equation-weakpoisson" title="Link to this equation"></a></span>\[ \begin{align}\begin{aligned}\int_\Omega \nabla v_0 \cdot \nabla u \, \mathrm{d} x
94+
= \int_\Omega v_0\, f\, \mathrm{d} x
95+
\qquad \forall v_0 \in V_0\\u_\Gamma = 0\end{aligned}\end{align} \]</div>
96+
<section id="an-algorithm-for-homogeneous-dirichlet-conditions">
97+
<h2><span class="section-number">7.1. </span>An algorithm for homogeneous Dirichlet conditions<a class="headerlink" href="#an-algorithm-for-homogeneous-dirichlet-conditions" title="Link to this heading"></a></h2>
98+
<p>The implementation of homogeneous Dirichlet conditions is actually
99+
rather straightforward.</p>
100+
<ol class="arabic simple">
101+
<li><p>The system is assembled completely ignoring the Dirichlet conditions.
102+
This results in a global matrix and vector which are correct on the rows
103+
corresponding to test functions in <span class="math notranslate nohighlight">\(V_0\)</span>, but incorrect on the <span class="math notranslate nohighlight">\(V_\Gamma\)</span> rows.</p></li>
104+
<li><p>The global vector rows corresponding to boundary nodes are set to 0.</p></li>
105+
<li><p>The global matrix rows corresponding to boundary nodes are set to 0.</p></li>
106+
<li><p>The diagonal entry on each matrix row corresponding to a boundary node is set to 1.</p></li>
107+
</ol>
108+
<p>This has the effect of replacing the incorrect boundary rows of the
109+
system with the equation <span class="math notranslate nohighlight">\(u_i = 0\)</span> for all boundary node numbers <span class="math notranslate nohighlight">\(i\)</span>.</p>
110+
<div class="admonition hint">
111+
<p class="admonition-title">Hint</p>
112+
<p>This algorithm has the unfortunate side effect of making the global
113+
matrix non-symmetric. If a symmetric matrix is required (for
114+
example in order to use a symmetric solver), then forward
115+
substition can be used to zero the boundary columns in the matrix,
116+
but that is beyond the scope of this module.</p>
117+
</div>
118+
</section>
119+
<section id="implementing-boundary-conditions">
120+
<h2><span class="section-number">7.2. </span>Implementing boundary conditions<a class="headerlink" href="#implementing-boundary-conditions" title="Link to this heading"></a></h2>
121+
<p>Let:</p>
122+
<div class="math notranslate nohighlight">
123+
\[f = \left(16 \pi^2 (x_1 - 1)^2 x_1^2 - 2 (x_1 - 1)^2 - 8 (x_1 - 1) x_1 - 2 x_1^2\right) \sin(4 \pi x_0)\]</div>
124+
<p>With this definition, <a class="reference internal" href="#equation-weakpoisson">(7.4)</a> has solution:</p>
125+
<div class="math notranslate nohighlight">
126+
\[u = \sin(4 \pi x_0) (x_1 - 1)^2 x_1^2\]</div>
127+
<div class="proof proof-type-exercise" id="id1">
128+
129+
<div class="proof-title">
130+
<span class="proof-type">Exercise 7.1</span>
131+
132+
</div><div class="proof-content">
133+
<p><code class="docutils literal notranslate"><span class="pre">fe_utils/solvers/poisson.py</span></code> contains a partial implementation of
134+
this problem. You need to implement the <code class="xref py py-func docutils literal notranslate"><span class="pre">assemble()</span></code>
135+
function. You should base your implementation on your
136+
<code class="docutils literal notranslate"><span class="pre">fe_utils/solvers/helmholtz.py</span></code> but take into account the difference
137+
in the equation, and the boundary conditions. The
138+
<a class="reference internal" href="fe_utils.solvers.html#fe_utils.solvers.poisson.boundary_nodes" title="fe_utils.solvers.poisson.boundary_nodes"><code class="xref py py-func docutils literal notranslate"><span class="pre">fe_utils.solvers.poisson.boundary_nodes()</span></code></a> function in <code class="docutils literal notranslate"><span class="pre">fe_utils/solvers/poisson.py</span></code> is
139+
likely to be helpful in implementing the boundary conditions. As
140+
before, run:</p>
141+
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">python</span> <span class="n">fe_utils</span><span class="o">/</span><span class="n">solvers</span><span class="o">/</span><span class="n">poisson</span><span class="o">.</span><span class="n">py</span> <span class="o">--</span><span class="n">help</span>
142+
</pre></div>
143+
</div>
144+
<p>for instructions (they are the same as for
145+
<code class="docutils literal notranslate"><span class="pre">fe_utils/solvers/helmholtz.py</span></code>). Similarly,
146+
<code class="docutils literal notranslate"><span class="pre">test/test_12_poisson_convergence.py</span></code> contains convergence tests
147+
for this problem.</p>
148+
</div></div></section>
149+
<section id="inhomogeneous-dirichlet-conditions">
150+
<h2><span class="section-number">7.3. </span>Inhomogeneous Dirichlet conditions<a class="headerlink" href="#inhomogeneous-dirichlet-conditions" title="Link to this heading"></a></h2>
151+
<p>The algorithm described here can be extended to inhomogeneous systems
152+
by setting the entries in the global vector to the value of the
153+
boundary condition at the corresponding boundary node. This additional
154+
step is required for the mastery exercise, but will be explained in
155+
more detail in the next section.</p>
156+
</section>
157+
</section>
158+
159+
160+
<div class="clearer"></div>
161+
</div>
162+
</div>
163+
</div>
164+
<div class="clearer"></div>
165+
</div>
166+
<div class="footer" role="contentinfo">
167+
&#169; Copyright 2014-2024, David A. Ham and Colin J. Cotter.
168+
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 7.4.7.
169+
</div>
170+
</body>
171+
</html>

0 commit comments

Comments
 (0)