incorrect normal vector when looping over boundary using CCTK_LOOP3_BND

Create issue
Issue #2385 open
Roland Haas created an issue

I am trying to loop over the boundary of my domain using CCTK_LOOP3_BND(cckGH, i,j,k, ni,nj,nk). The documentation http://einsteintoolkit.org/usersguide/UsersGuidech9.html#x13-102000C1.7.1
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."

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.

Looking at the code in flesh/src/include/cctk_Loop.h shows that ni iscomputed as

const int ni CCTK_ATTRIBUTE_UNUSED = cctki0_idir<0 ? i+1 : cctki0_idir==0 ? 0 : cctki0_imax-i;

ie by construction is always non-negative. LoopControl does the same.

Comments (6)

  1. Erik Schnetter

    The original intent is that ni is the outward normal of the physical boundary, and zero in the interior. For example, ni=(-1,0,0)` at the lower x boundary, and ni=(0,1,1) at the upper y-z-edge. This direction is needed for some boundary conditions, e.g. for the standard BSSN radiative boundary (which doesn’t use LoopControl).

  2. Roland Haas reporter

    In that case the current code is certainly in error since (see snipped in description) it is always positive and its magnitude is not 1.

  3. Erik Schnetter

    I think these variables instead contain the location of the next grid point further inward which can be used to calculate directional derivatives.

    This seems useful. Should we just update the documentation instead?

  4. Roland Haas reporter

    That might be good, yes.

    I am not sure if it really is a point further inward though. For the upper boundary (cctki0_idir > 0) the code sets ni = cctki0_imax-i which, for i close to the upper boundary, is actually a number close to 0. So it seems to me that it really gives magnitude of distance from the boundary such that the point on the boundary has distance +1 (since cctki_imax is exclusive).

    I would also want to check two things before / when / very shortly after doing so:

    • is there any code that (tries to) use(s) the ni as they are currently documented (there shouldn’t given that it would be quite horribly wrong)
    • is there anything provided by the looping macros that does actually give information which boundary one is looping over (ie makes the ccti[012]_dir visible to the caller (which would also seem useful)

  5. Log in to comment