<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div class="">
<div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;">-- <br class="">_________________________________________________</div><div style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none;"><br class="">Timo Koch phone: +49 711 685 64676<br class="">IWS, Universität Stuttgart fax: +49 711 685 60430<br class="">Pfaffenwaldring 61 <a href="mailto:timo.koch@iws.uni-stuttgart.de" class="">email: timo.koch@iws.uni-stuttgart.de</a><br class="">D-70569 Stuttgart url: <a href="http://www.iws.uni-stuttgart.de/en/lh2/" class="">www.iws.uni-stuttgart.de/en/lh2/</a><br class="">_________________________________________________</div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">On 19. Jun 2020, at 12:38, Dedner, Andreas <<a href="mailto:A.S.Dedner@warwick.ac.uk" class="">A.S.Dedner@warwick.ac.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">Hi.</div><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">I might have misunderstood you but the way I see it the term `dof position` doesn't actually make any sense in the concept of `dune-localfunctions`. The interface there is too generic . As an example I could define a continuous Lagrange space using moments on the edges instead of point values. The only thing available then is the information to which subentity a dof is connected. The issue that the local keys are often 'the wrong way around' has been discussed a few times... But your approach of using the local interpolation to get some point coordinates would of course fail with that type of space.</div><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">Since dune-localfunctions is generic we didn't add a concept of `Lagrangepoints`.<br class=""></div></div></blockquote><div><br class=""></div><div>Hi Andreas,</div><div><br class=""></div><div>thanks a lot for the explanation, that already makes sense a lot more sense now. That means that our interface `<span class="x_n" style="font-family: Menlo;">problem</span><span class="x_p" style="font-family: Menlo;">.</span><span class="x_n" style="font-family: Menlo;">dirichlet</span><span class="x_p" style="font-family: Menlo;">(</span><span class="x_n" style="font-family: Menlo;">element</span><span class="x_p" style="font-family: Menlo;">,</span><span style="font-family: Menlo;" class=""> localPos</span><span style="font-family: Menlo;" class="">)` </span>is not very useful, if we want it to be more general.</div><div>We’ll try to revisit the approach.</div><div><br class=""></div><div>Timo</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">In this generic setting the only way to get dof values is to use the local interpolation as you do but for the Dirichlet function. I.e. you interpolate your localized dirichlet data on to the element (we don't have a method to only perform the interpolation to a subentity). That gives you a local dof vector and then you extract the dofs you want to constrain using the local dof key.</div><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">As I said, I'm not sure if this helps because as I said I might have misunderstood your problem (not being too familiar with dune-functions doesn't help of course...)</div><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class=""><br class=""></div><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">Best</div><div style="caret-color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">Andreas<br class=""></div><div id="appendonsend" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""></div><hr tabindex="-1" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; display: inline-block; width: 1229.890625px;" class=""><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;" class=""></span><div id="divRplyFwdMsg" dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><font face="Calibri, sans-serif" style="font-size: 11pt;" class=""><b class="">From:</b><span class="Apple-converted-space"> </span>Dune <<a href="mailto:dune-bounces@lists.dune-project.org" class="">dune-bounces@lists.dune-project.org</a>> on behalf of Timo Koch <<a href="mailto:timo.koch@iws.uni-stuttgart.de" class="">timo.koch@iws.uni-stuttgart.de</a>><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>19 June 2020 11:13<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span><a href="mailto:dune@lists.dune-project.org" class="">dune@lists.dune-project.org</a> <<a href="mailto:dune@lists.dune-project.org" class="">dune@lists.dune-project.org</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>[Dune] Position of dofs for finite elements</font><div class=""> </div></div><div class="" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; line-break: after-white-space;">Dear Dune users & developers,<div class=""><br class=""></div><div class="">we are using dune-functions and the core modules in a simple FEM code. We want to strongly enforce Dirichlet boundary conditions.</div><div class="">The boundary conditions are specified locally for each element as a function of the element and the local position.</div><div class=""><br class=""></div><div class="">For globally defined analytical functions, we could use a global interpolate to get the coefficient / Dirichlet values. But how do we do this for “piece-wise”-defined boundary conditions?</div><div class="">We came up with something like this (restriction to simple Lagrange basis, nothing composite and assuming all dofs are Dirichlet for now):</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">Dune::BlockVector<Dune::FieldVector<double, numEq>> dirichletValues;</font></div><div class=""><pre class="x_code x_highlight" lang="cpp"><font face="Menlo" class=""><span id="x_LC389" class="x_line" lang="cpp"><span class="x_k">auto</span> <span class="x_n">getDirichletValues</span> <span class="x_o">=</span> <span class="x_p">[</span><span class="x_o">&</span><span class="x_p">]</span> <span class="x_p">(</span><span class="x_k">auto</span> <span class="x_n">localIndex</span><span class="x_p">, </span></span><span id="x_LC390" class="x_line" lang="cpp"><span class="x_k">const</span> <span class="x_k">auto</span><span class="x_o">&</span> <span class="x_n">localView</span><span class="x_p">, </span></span><span id="x_LC391" class="x_line" lang="cpp"><span class="x_k">const</span> <span class="x_k">auto</span><span class="x_o">&</span> <span class="x_n">intersection</span><span class="x_p">)</span></span>
<span id="x_LC392" class="x_line" lang="cpp"><span class="x_p">{</span></span>
<span id="x_LC393" class="x_line" lang="cpp"><span class="x_k"> const</span> <span class="x_k">auto</span><span class="x_o">&</span> <span class="x_n">element</span> <span class="x_o">=</span> <span class="x_n">localView</span><span class="x_p">.</span><span class="x_n">element</span><span class="x_p">();</span></span>
<span id="x_LC400" class="x_line" lang="cpp"><span class="x_c1"> // get the local coordinates of the dofs of the element</span></span>
<span id="x_LC404" class="x_line" lang="cpp"><span class="x_n"> std</span><span class="x_o">::</span><span class="x_n">vector</span><span class="x_o"><</span><span class="x_kt">double</span><span class="x_o">></span> <span class="x_n">coords</span><span class="x_p">;</span></span>
<span id="x_LC405" class="x_line" lang="cpp"> <span class="x_k">const</span> <span class="x_k">auto</span><span class="x_o">&</span> <span class="x_n">interp</span> <span class="x_o">=</span> <span class="x_n">localView</span><span class="x_p">.</span><span class="x_n">tree</span><span class="x_p">().</span><span class="x_n">finiteElement</span><span class="x_p">().</span><span class="x_n">localInterpolation</span><span class="x_p">();</span></span></font></pre><pre class="x_code x_highlight" lang="cpp"><font face="Menlo" class=""><span id="x_LC406" class="x_line" lang="cpp"> <span class="x_n">interp</span><span class="x_p">.</span><span class="x_n">interpolate</span><span class="x_p">([</span><span class="x_o">&</span><span class="x_p">]</span> <span class="x_p">(</span><span class="x_k">const</span> <span class="x_n">LocalCoordinate</span><span class="x_o">&</span> <span class="x_n">x</span><span class="x_p">)</span> <span class="x_p">{</span> <span class="x_k">return</span> <span class="x_n">x</span><span class="x_p">[</span><span class="x_mi">0</span><span class="x_p">];</span> <span class="x_p">},</span> <span class="x_n">coords</span><span class="x_p">);</span></span>
<span id="x_LC408" class="x_line" lang="cpp"> <span class="x_n">localDofCoords</span><span class="x_p">.</span><span class="x_n">resize</span><span class="x_p">(</span><span class="x_n">coords</span><span class="x_p">.</span><span class="x_n">size</span><span class="x_p">());</span></span>
<span id="x_LC409" class="x_line" lang="cpp"> <span class="x_k">for</span> <span class="x_p">(</span><span class="x_kt">unsigned</span> <span class="x_kt">int</span> <span class="x_n">i</span> <span class="x_o">=</span> <span class="x_mi">0</span><span class="x_p">;</span> <span class="x_n">i</span> <span class="x_o"><</span> <span class="x_n">coords</span><span class="x_p">.</span><span class="x_n">size</span><span class="x_p">();</span> <span class="x_o">++</span><span class="x_n">i</span><span class="x_p">)</span></span>
<span id="x_LC410" class="x_line" lang="cpp"> <span class="x_n">localDofCoords</span><span class="x_p">[</span><span class="x_n">i</span><span class="x_p">][</span><span class="x_mi">0</span><span class="x_p">]</span> <span class="x_o">=</span> <span class="x_n">coords</span><span class="x_p">[</span><span class="x_n">i</span><span class="x_p">];</span></span>
<span id="x_LC411" class="x_line" lang="cpp"></span>
<span id="x_LC412" class="x_line" lang="cpp"> <span class="x_n">interp</span><span class="x_p">.</span><span class="x_n">interpolate</span><span class="x_p">([</span><span class="x_o">&</span><span class="x_p">]</span> <span class="x_p">(</span><span class="x_k">const</span> <span class="x_n">LocalCoordinate</span><span class="x_o">&</span> <span class="x_n">x</span><span class="x_p">)</span> <span class="x_p">{</span> <span class="x_k">return</span> <span class="x_n">x</span><span class="x_p">[</span><span class="x_mi">1</span><span class="x_p">];</span> <span class="x_p">},</span> <span class="x_n">coords</span><span class="x_p">);</span></span>
<span id="x_LC413" class="x_line" lang="cpp"> <span class="x_k">for</span> <span class="x_p">(</span><span class="x_kt">unsigned</span> <span class="x_kt">int</span> <span class="x_n">i</span> <span class="x_o">=</span> <span class="x_mi">0</span><span class="x_p">;</span> <span class="x_n">i</span> <span class="x_o"><</span> <span class="x_n">coords</span><span class="x_p">.</span><span class="x_n">size</span><span class="x_p">();</span> <span class="x_o">++</span><span class="x_n">i</span><span class="x_p">)</span></span>
<span id="x_LC414" class="x_line" lang="cpp"> <span class="x_n">localDofCoords</span><span class="x_p">[</span><span class="x_n">i</span><span class="x_p">][</span><span class="x_mi">1</span><span class="x_p">]</span> <span class="x_o">=</span> <span class="x_n">coords</span><span class="x_p">[</span><span class="x_n">i</span><span class="x_p">];</span></span>
<span id="x_LC415" class="x_line" lang="cpp"></span>
<span id="x_LC416" class="x_line" lang="cpp"> </span><span id="x_LC420" class="x_line" lang="cpp"><span class="x_k">const</span> <span class="x_k">auto</span> <span class="x_n">index</span> <span class="x_o">=</span> <span class="x_n">localView</span><span class="x_p">.</span><span class="x_n">index</span><span class="x_p">(</span><span class="x_n">localIndex</span><span class="x_p">);</span></span>
<span id="x_LC421" class="x_line" lang="cpp"> <span class="x_k">for</span> <span class="x_p">(</span><span class="x_kt">unsigned</span> <span class="x_kt">int</span> <span class="x_n">eqIdx</span> <span class="x_o">=</span> <span class="x_mi">0</span><span class="x_p">;</span> <span class="x_n">eqIdx</span> <span class="x_o"><</span> <span class="x_n">numEq</span><span class="x_p">;</span> <span class="x_o">++</span><span class="x_n">eqIdx</span><span class="x_p">)</span></span>
<span id="x_LC422" class="x_line" lang="cpp"> </span><span class="" style="white-space: normal;">dirichletValues</span><span id="x_LC424" class="x_line" lang="cpp"><span class="x_p">[</span><span class="x_n">index</span><span class="x_p">]</span> <span class="x_o">=</span> <span class="x_n">problem</span><span class="x_p">.</span><span class="x_n">dirichlet</span><span class="x_p">(</span><span class="x_n">element</span><span class="x_p">,</span> <span class="x_n">localDofCoords</span><span class="x_p">[</span><span class="x_n">localIndex</span><span class="x_p">]</span>);<br class=""></span>};</font></pre><pre class="x_code x_highlight" lang="cpp"><font face="Menlo" class=""><span id="x_LC427" class="x_line" lang="cpp"></span>
<span id="x_LC428" class="x_line" lang="cpp"><span class="x_n">Dune</span><span class="x_o">::</span><span class="x_n">Functions</span><span class="x_o">::</span><span class="x_n">forEachBoundaryDOF</span><span class="x_p">(lagrangeB</span><span class="x_n">asis</span><span class="x_p">,</span> <span class="x_n">getDirichletValues</span><span class="x_p">);</span></span></font>
</pre><div class=""><br class=""></div></div><div class="">which is far from nice. In this way the coordinates are recomputed every time although it would be enough to compute them once per element type. Also we could figure out how to get the full position instead of only the x,y,z-components separately.</div><div class="">There seems to be no obvious way to get the local position of a DOF within an element, although this sounds like a very basic thing to do.</div><div class="">With the `localKey` it is possible to obtain the subEntity and its center position via the reference element. But this doesn’t (necessarily) correspond to the DOF position of course.</div><div class=""><br class=""></div><div class="">Is there some obvious way that we are missing on how to solve this problem without writing an excessive amount of code?</div><div class="">Do you have any suggestion or comments on how “piece-wise” defined strongly enforced Dirichlet boundary conditions could be realized?</div><div class=""><br class=""></div><div class="">Thanks a lot for your help</div><div class="">Timo</div><div class=""><br class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class="">-- <br class="">_________________________________________________</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class=""><br class="">Timo Koch phone: +49 711 685 64676<br class="">IWS, Universität Stuttgart fax: +49 711 685 60430<br class="">Pfaffenwaldring 61 <span class="Apple-converted-space"> </span><a href="mailto:timo.koch@iws.uni-stuttgart.de" class="">email: timo.koch@iws.uni-stuttgart.de</a><br class="">D-70569 Stuttgart url: <a href="http://www.iws.uni-stuttgart.de/en/lh2/" class="">www.iws.uni-stuttgart.de/en/lh2/</a><br class="">_________________________________________________</div></div></div></div></div></blockquote></div><br class=""></body></html>