<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Maybe a short addition.</p>
<p>In 3D I depend on volume elements like <span>tetraeders and due to</span></p>
<p><span>the geometry i need to read the mesh in via the gmsh-reader.<br>
</span></p>
<p><span>So i can't really check the implementation with other grid-types,</span></p>
<p><span>like AlbertaGrid. I might could set up a simple case with a <br>
</span></p>
<p><span>YaspGrid, but that wouldn't help me in the long term. So the only</span></p>
<p><span>option is the UGGrid-implementation.<br>
</span></p>
<p><span><br>
</span></p>
<p><span>For the simple one element, hexaeder case the tags are read into</span></p>
<p><span>the boundaryEntity vector like [0, 0, 3, 0, 1, 0]. So on four faces</span></p>
<p><span>there is just a 0, which means no B.C. is applied. For front and back</span></p>
<p><span>either <span>B.C.</span> 1 or 3 should be applied. Looping over the boundary</span></p>
<p><span>intersections my insertion index for the segments is something like</span></p>
<p><span>[0, 1, 2, 4, 3, 5], which is identical to the boundarySegmentIndex()</span></p>
<p><span>method (somewhere it's said that they don't need to be identical</span></p>
<p><span>somehow, for this case they are).<br>
</span></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> Dune <dune-bounces@lists.dune-project.org> im Auftrag von Firmbach, Max <max.firmbach@tum.de><br>
<b>Gesendet:</b> Freitag, 21. August 2020 20:20:43<br>
<b>An:</b> Dedner, Andreas; dune@lists.dune-project.org<br>
<b>Betreff:</b> Re: [Dune] Boundary conditions, segments and indexing</font>
<div> </div>
</div>
<div><style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hello Andreas,</p>
<p><br>
</p>
<p>thanks for the quick response.</p>
<p>I followed the "get-started" tutorial, so I'm using the UG-Grid implementation.</p>
<p>Like this, where UG-Grid depends on the dimension and a LeafGridView</p>
<p>is later generated:<br>
</p>
<p><br>
</p>
<p></p>
<div> using Grid = UGGrid<Parameters::dim()>;<br>
using GridView = Grid::LeafGridView;</div>
<div><br>
</div>
<div>So I'm also not sure if either the indexing of the boundary segments might</div>
<div>be wrong in my code, so that the wrong array-entry and thus wrong tag is <br>
</div>
<div>chosen for a specific intersection/boundary segment. Or the calculation of <br>
</div>
<div>the row, where the entry is placed/modified might be false.</div>
<div><br>
</div>
<div>Hope that helps.</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Max<br>
</div>
<p></p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> Dedner, Andreas <A.S.Dedner@warwick.ac.uk><br>
<b>Gesendet:</b> Freitag, 21. August 2020 19:33:37<br>
<b>An:</b> Firmbach, Max; dune@lists.dune-project.org<br>
<b>Betreff:</b> Re: Boundary conditions, segments and indexing</font>
<div> </div>
</div>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Max.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Looks alright to me but I might have missed something.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Could you please add which grid manager you are using since it might be a bug in the grid implementation you are using.<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Best</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Andreas</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Dune <dune-bounces@lists.dune-project.org> on behalf of Firmbach, Max <max.firmbach@tum.de><br>
<b>Sent:</b> 21 August 2020 17:58<br>
<b>To:</b> dune@lists.dune-project.org <dune@lists.dune-project.org><br>
<b>Subject:</b> [Dune] Boundary conditions, segments and indexing</font>
<div> </div>
</div>
<style type="text/css" style="display:none">
<!--
p
{margin-top:0;
margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Hello DUNE-developers,</p>
<p><br>
</p>
<p>I have a question regarding the boundary segment indexing and</p>
<p>connecting tags corresponding to the segments with boundary conditions.</p>
<p><br>
</p>
<p>Right now, I load a gmsh-file and obtain a vector with boundary tags.</p>
<p>Those tags should trigger some kind of boundary condition for example</p>
<p>set some values in a block-vector or sparse-matrix.</p>
<p>After reading the book from Mr. Sander and some how-to's I think I <br>
</p>
<p>understood the principle concept of intersections and so, but still</p>
<p>something is not working right for me.<br>
</p>
<p>My actual code loops over all elements of the gridview and over</p>
<p>the corresponding intersections. Inside the loop i check if</p>
<p>the intersection is in contact with the boundary (because I</p>
<p>want to set boundary conditions). If that is true, a switch</p>
<p>should select the right b.c. code, depending on the tag that is</p>
<p>stored inside the boundaryEntitity vector I obtain from loading the</p>
<p>gmsh-file. The array-entry of the boundaryEntitiy vector is</p>
<p>selected via the intersection boundary segment index (is this the right</p>
<p>approach ?).</p>
<p><br>
</p>
<p>And here starts my actual question ... in two dimensions that is working</p>
<p>fine (even for complex geometries and several tags), but for three dimensions <br>
</p>
<p>it's not working properly even for a single element (for example a hexa-element
<br>
</p>
<p>with different tags on each of the boundary faces). <br>
</p>
<p>So is my description the common approach to handle the boundary situation <br>
</p>
<p>or is there a more efficient or better way ? Or am I missing something ?<br>
</p>
<p><br>
</p>
<p>My code looks like this (the 3 lines after the double loop and the</p>
<p>code inside case 1 should set the corresponding entry in a block-</p>
<p>vector, by looping over the vertices of the intersection geometry and</p>
<p>getting the "global" index for that position):<br>
</p>
<p><br>
</p>
<p></p>
<div>for( const auto& element : elements(gridView)) {<br>
for( const auto& isect : intersections(gridView, element)) {</div>
<div><br>
</div>
<div><br>
GeometryType elementGeometry = element.type();<br>
using Factory = ReferenceElements<double, dim>;<br>
const auto &ref = Factory::general(elementGeometry);</div>
<div><br>
</div>
<div><br>
if(isect.boundary()) {<br>
<br>
switch(boundaryEntity[isect.boundarySegmentIndex()]) {<br>
case 0:</div>
<div> ...<br>
break;<br>
case 1:</div>
<div><br>
for(int i=0; i<ref.size(isect.indexInInside(), 1, dim); i++) {<br>
int row = indexSet.subIndex(element, ref.subEntity(isect.indexInInside(), 1, i, dim), dim);
<br>
loadVector[row] = Load; <br>
}</div>
<div><br>
</div>
<div> ...<br>
}<br>
}<br>
}<br>
}</div>
<div><br>
</div>
<div>As written before, for 2d meshes it works pretty well, but for 3d it's the complete</div>
<div>opposite and I don't really understand why.<br>
</div>
<div><br>
</div>
<div>Thanks for your help and best regards,</div>
<div>Max<br>
</div>
<br>
<p></p>
</div>
</div>
</div>
</div>
</body>
</html>