<html>#1906: CarpetRegrid2: possible off-by-one error when using regrid_every parameter
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Bruno Mundim</td></tr>
<tr><td style='text-align:right'> Status:</td><td>wontfix</td></tr>
<tr><td style='text-align:right'>Milestone:</td><td></td></tr>
<tr><td style='text-align:right'> Version:</td><td>development version</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>Carpet</td></tr>
</table>
<p>Changes (by Roland Haas):</p>
<p><table>
<tr><td>status:</td><td>wontfix (was new)</td></tr>
</table></p>
<p>I was working on a par file for a quick regridding test and found out an unexpected behaviour regarding regridding. Basically I want a par file with a few iterations such that it adds a refinement level every 4 iterations for example. I set the following parameters then:</p>
<div class="codehilite"><pre><span></span>CarpetRegrid2::add_levels_automatically = "yes"
CarpetRegrid2::regrid_every = 4
</pre></div>
<p>for a grid structure as such:</p>
<div class="codehilite"><pre><span></span>Cactus::cctk_itlast = 10
CoordBase::xmin = -0.5
CoordBase::ymin = -0.5
CoordBase::zmin = -0.5
CoordBase::xmax = 0.5
CoordBase::ymax = 0.5
CoordBase::zmax = 0.5
CoordBase::ncells_x = 16
CoordBase::ncells_y = 16
CoordBase::ncells_z = 16
Carpet::max_refinement_levels = 3
CarpetRegrid2::num_centres = 1
CarpetRegrid2::active_1 = "yes"
CarpetRegrid2::num_levels_1 = 1
CarpetRegrid2::radius_1[1] = 0.12
CarpetRegrid2::radius_1[2] = 0.04
</pre></div>
<p>I was expecting then regridding to happen at iterations 4 and 8, however if you run the attached par file, a modification of balsara shocktube test, you see that the level additions actually happen at iterations 5 and 9 instead:</p>
<div class="codehilite"><pre><span></span>...
INFO (CarpetRegrid2): Increasing number of levels of centre 1 to 2 (it=5)
...
INFO (CarpetRegrid2): Increasing number of levels of centre 1 to 3 (it=9)
</pre></div>
<p>which is apparently an off-by-one kind of error. I tracked down the code producing these messages and it comes from function CarpetRegrid2_RegridMaps at CarpetRegrid2/src/regrid.cc, lines 745 to 747. In order for that piece of code to execute we do have to have do_recompose set to true. Strangely the condition to set it, compares the previous iteration to the regrid_every parameter on line 707 of the same file:</p>
<div class="codehilite"><pre><span></span>(cctk_iteration - 1) % regrid_every == 0
</pre></div>
<p>Investigating if this actually makes sense I was led to what I think it migh
<p>Comment (by Roland Haas):</p>
<p>The observed behaviour was as intended, no bug.</p>
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/1906/carpetregrid2-possible-off-by-one-error'>https://bitbucket.org/einsteintoolkit/tickets/issues/1906/carpetregrid2-possible-off-by-one-error</a></p>
</html>