You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanid="secdirichlet"></span><h1><spanclass="section-number">7. </span>Dirichlet boundary conditions<aclass="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 <spanclass="math notranslate nohighlight">\(u\)</span> in
59
+
some finite element space <spanclass="math notranslate nohighlight">\(V\)</span> such that:</p>
<spanclass="eqno">(7.1)<aclass="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
+
<spanclass="math notranslate nohighlight">\(V\)</span> into two parts:</p>
<spanclass="eqno">(7.2)<aclass="headerlink" href="#equation-7-boundary-conditions-0" title="Link to this equation">¶</a></span>\[V = V_0 \oplus V_\Gamma\]</div>
66
+
<p>where <spanclass="math notranslate nohighlight">\(V_\Gamma\)</span> is the space spanned by those functions in the basis
67
+
of <spanclass="math notranslate nohighlight">\(V\)</span> which are non-zero on <spanclass="math notranslate nohighlight">\(\Gamma\)</span>, and <spanclass="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 <spanclass="math notranslate nohighlight">\(\Gamma\)</span>). It is a direct consequence of the nodal nature of
70
+
the basis that the basis functions for <spanclass="math notranslate nohighlight">\(V_\Gamma\)</span> are those
71
+
corresponding to the nodes on <spanclass="math notranslate nohighlight">\(\Gamma\)</span> while the basis for <spanclass="math notranslate nohighlight">\(V_0\)</span> is
72
+
composed of all the other functions.</p>
73
+
<p>We now write the weak form of <aclass="reference internal" href="#equation-poisson">(7.1)</a>, find <spanclass="math notranslate nohighlight">\(u=u_0 + u_\Gamma\)</span>
74
+
with <spanclass="math notranslate nohighlight">\(u_0 \in V_0\)</span> and <spanclass="math notranslate nohighlight">\(u_\Gamma \in V_\Gamma\)</span> such that:</p>
<spanclass="eqno">(7.3)<aclass="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
<spanclass="eqno">(7.4)<aclass="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
<h2><spanclass="section-number">7.1. </span>An algorithm for homogeneous Dirichlet conditions<aclass="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
+
<olclass="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 <spanclass="math notranslate nohighlight">\(V_0\)</span>, but incorrect on the <spanclass="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 <spanclass="math notranslate nohighlight">\(u_i = 0\)</span> for all boundary node numbers <spanclass="math notranslate nohighlight">\(i\)</span>.</p>
110
+
<divclass="admonition hint">
111
+
<pclass="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
+
<sectionid="implementing-boundary-conditions">
120
+
<h2><spanclass="section-number">7.2. </span>Implementing boundary conditions<aclass="headerlink" href="#implementing-boundary-conditions" title="Link to this heading">¶</a></h2>
<p>With this definition, <aclass="reference internal" href="#equation-weakpoisson">(7.4)</a> has solution:</p>
125
+
<divclass="math notranslate nohighlight">
126
+
\[u = \sin(4 \pi x_0) (x_1 - 1)^2 x_1^2\]</div>
127
+
<divclass="proof proof-type-exercise" id="id1">
128
+
129
+
<divclass="proof-title">
130
+
<spanclass="proof-type">Exercise 7.1</span>
131
+
132
+
</div><divclass="proof-content">
133
+
<p><codeclass="docutils literal notranslate"><spanclass="pre">fe_utils/solvers/poisson.py</span></code> contains a partial implementation of
134
+
this problem. You need to implement the <codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">assemble()</span></code>
135
+
function. You should base your implementation on your
136
+
<codeclass="docutils literal notranslate"><spanclass="pre">fe_utils/solvers/helmholtz.py</span></code> but take into account the difference
137
+
in the equation, and the boundary conditions. The
138
+
<aclass="reference internal" href="fe_utils.solvers.html#fe_utils.solvers.poisson.boundary_nodes" title="fe_utils.solvers.poisson.boundary_nodes"><codeclass="xref py py-func docutils literal notranslate"><spanclass="pre">fe_utils.solvers.poisson.boundary_nodes()</span></code></a> function in <codeclass="docutils literal notranslate"><spanclass="pre">fe_utils/solvers/poisson.py</span></code> is
139
+
likely to be helpful in implementing the boundary conditions. As
<h2><spanclass="section-number">7.3. </span>Inhomogeneous Dirichlet conditions<aclass="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
+
<divclass="clearer"></div>
161
+
</div>
162
+
</div>
163
+
</div>
164
+
<divclass="clearer"></div>
165
+
</div>
166
+
<divclass="footer" role="contentinfo">
167
+
© Copyright 2014-2024, David A. Ham and Colin J. Cotter.
168
+
Created using <ahref="https://www.sphinx-doc.org/">Sphinx</a> 7.4.7.
0 commit comments