<html>#2385: incorrect normal vector when looping over boundary using CCTK_LOOP3_BND
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Roland Haas</td></tr>
<tr><td style='text-align:right'>   Status:</td><td>new</td></tr>
<tr><td style='text-align:right'>Milestone:</td><td></td></tr>
<tr><td style='text-align:right'>  Version:</td><td></td></tr>
<tr><td style='text-align:right'>     Type:</td><td>bug</td></tr>
<tr><td style='text-align:right'> Priority:</td><td>minor</td></tr>
<tr><td style='text-align:right'>Component:</td><td>Cactus</td></tr>
</table>

<p>I am trying to loop over the boundary of my domain using CCTK_LOOP3_BND(cckGH, i,j,k, ni,nj,nk). The documentation <a data-is-external-link="true" href="http://einsteintoolkit.org/usersguide/UsersGuidech9.html#x13-102000C1.7.1" rel="nofollow">http://einsteintoolkit.org/usersguide/UsersGuidech9.html#x13-102000C1.7.1</a><br />
says that "ni, nj, and nk are names of variables describing the (outwards pointing) normal direction to the boundary as well as the distance to the boundary."</p>
<p>However on a 5x5x5 grid and 1 boundary point in a uniprocess setup ni, nj, nk are either 0 or 1 but never eg -1 which I would expect for the lower boundary.</p>
<p>Looking at the code in flesh/src/include/cctk_Loop.h shows that ni iscomputed as</p>
<div class="codehilite language-c"><pre><span></span><span class="k">const</span> <span class="kt">int</span> <span class="n">ni</span> <span class="n">CCTK_ATTRIBUTE_UNUSED</span> <span class="o">=</span> <span class="n">cctki0_idir</span><span class="o">&lt;</span><span class="mi">0</span> <span class="o">?</span> <span class="n">i</span><span class="o">+</span><span class="mi">1</span> <span class="o">:</span> <span class="n">cctki0_idir</span><span class="o">==</span><span class="mi">0</span> <span class="o">?</span> <span class="mi">0</span> <span class="o">:</span> <span class="n">cctki0_imax</span><span class="o">-</span><span class="n">i</span><span class="p">;</span>
</pre></div>


<p>ie by construction is always non-negative. LoopControl does the same.</p>
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/2385/incorrect-normal-vector-when-looping-over'>https://bitbucket.org/einsteintoolkit/tickets/issues/2385/incorrect-normal-vector-when-looping-over</a></p>
</html>