[ET Trac] [Einstein Toolkit] #1906: CarpetRegrid2: possible off-by-one error when using regrid_every parameter
Einstein Toolkit
trac-noreply at einsteintoolkit.org
Fri Jun 3 14:14:49 CDT 2016
#1906: CarpetRegrid2: possible off-by-one error when using regrid_every parameter
----------------------+-----------------------------------------------------
Reporter: bmundim | Owner: eschnett
Type: defect | Status: new
Priority: major | Milestone:
Component: Carpet | Version: development version
Resolution: | Keywords: CarpetRegrid2
----------------------+-----------------------------------------------------
Comment (by bmundim):
Replying to [comment:1 eschnett]:
> It is possible that there is an off-by-one error, however:
>
> The first iteration, right after setting up initial conditions, is
iteration 1. Regridding occurs before the evolution step, and thus the
first time it can occur is at iteration 1 (i.e. before the first time
step).
>
Then why it advances time/iteration before regridding? Let's say we have
just entered the Evolve routine. We can safely assume we are starting at
least the first iteration. If I followed your argument right above, then
we could step on the block calling CallRegrid and once we are out of it,
call the AdvanceTime routine, no?
> Iteration 0 is setting up initial conditions. There can be regridding as
well while setting up initial conditions, but this is governed by slightly
different rules, so let's disregard this here.
>
> Maybe it is just how iterations are counted that is confusing? With two
levels, you have:
> * it=0: initial conditions
> * it=1: coarse grid step
> * it=1: fine grid step
> * it=2: fine grid step
> * it=2: restriction to coarse grid
> * it=3: coarse grid step
> * it=3: fine grid step
> * it=4: fine grid step
> * it=4: restriction to coarse grid
>
> etc.
Definitely I might have misunderstood the iteration labels. Let me explain
how I understand. Correct me if I am wrong. First, the way you labelled
the iteration in your example above assumes max_refinement_levels =
num_levels_1 = 2. The iteration labels are very different if
max_refinement_levels != num_levels_1. Let's say max_refinement_levels =
3. Then the finest possible grid of your simulation would need 2 to (3-1)
= 4 iterations to reach one coarse iteration of level 0 grid. Since this
number is the maximum one and we need a way to label these iterations,
carpet labels the iterations sequentially for this maximum refinement
level. The next coarser grid would need 2 iterations and then will exist
only on iterations 0, 2, 4, and the coarser level will exist only on
iterations 0, 4, assuming we take only one coarse step (one step of level
0 grid). Is this way of reading correct?
Now, let's say we keep the order AdvanceTime and then CallRegrid on Evolve
routine. I still find hard to understand why we would enforce regrid based
on the previous iteration and not the current one. I would change
statements such as
{{{
(cctk_iteration - 1) % regrid_every == 0
}}}
to
{{{
cctk_iteration % regrid_every == 0
}}}
as in line 707 of CarpetRegrid2/src/regrid.cc. Why would that not be
correct?
Thanks!
--
Ticket URL: <https://trac.einsteintoolkit.org/ticket/1906#comment:2>
Einstein Toolkit <http://einsteintoolkit.org>
The Einstein Toolkit
More information about the Trac
mailing list