AHFinderDirect uses incorrect origin_* upon recovery when horizon was never found before

Issue #1239 closed
Christian Reisswig created an issue

Problem: After some time in the simulation, I want to search for an horizon. I do not know where the horizon appears initially when the simulation started. I therefore leave origin_ and initial_guess__coord_sphere___center at zero.

By some means later, I have figured out where the horizon will appear. Therefore, after recovery, I want to set origin_ and initial_guess__coord_sphere___center to the origin where I believe the horizon will appear.

Unfortunately, upon recovery, the new origin_ is overwritten by whatever was stored in ah_origin_ (this would be zero). Generally, this means that the initial guess ellipsoid that is setup when a horizon has never been found, is ill-posed (because the initial (and incorrect) origin_ are used with the updated initial_guess__coord_sphere___center).

Solution: Don't use the stored AH origin upon recovery when a horizon has never been found before.

The attach patch solves the problem.

Keyword: AHFinderDirect

Comments (9)

  1. Roland Haas
    • removed comment

    Three comments: * there is commented out code in the commit which might as well be not committed :-) * this code seems to pose the danger of ps.origin() never being called when both h_found_flag[horizon_number-1] == 0 and (ah_really_initial_find_flag[horizon_number-1] . Since before ps.origin() was always called, I wonder if this might cause it to remain initialized. * finally the code in the else branch uses horizon_number instead of horizon_number-1

    A general question: This seems to be an instance of a thorn that makes copies of Cactus' parameters (or quantities computed from them) and then checkpoints them. This seems to interfere badly with Cactus' ability to change parameter values on recovery. My question is if there is use in such thorns trying to emulate the logic in Cactus as to when to update values? I believe the login in Cactus goes something like this: at recovery the values for parameters are those stored in checkpoints unless it is explicitly set in the new parameter file and this setting differs from the one in the original parameter file used at checkpoint time in which case values from the new parameter file are used. Is this correct? Do we want to implement something similar in AHFinderDirect (I assume this to involve checking how often a parameter has been set at POST_RECOVER_VARIABLES time).

  2. anonymous
    • removed comment

    Replying to [comment:1 rhaas]:

    Three comments: * there is commented out code in the commit which might as well be not committed :-) * this code seems to pose the danger of ps.origin() never being called when both h_found_flag[horizon_number-1] == 0 and (ah_really_initial_find_flag[horizon_number-1] . Since before ps.origin() was always called, I wonder if this might cause it to remain initialized.

    I think the new behavior is correct. If a horizon has never been found, then its ps.origin is just at whatever was there in the initial par-file (it got set to this value initially). If one wants to change the origin parameter upon recovery (the parameter is steerable= recovery!), this new steered parameter value would never be used! This is desasterous when one decides to try to find a horizon elsewhere. Remark: I picked the condition such that it matches the condition for when the initial_guess_ellipsoid routine is called (which is causing all the trouble).

    Once a horizon was found, one could argue that instead of using the parameter value of origin_*, it should take the origin value that was stored in the checkpoint. Actually, I think this behavior is more correct, because without pretracking or tracking from a grid scalar, we rely on the fact that the old origin is not too far from the anticipated new origin (at least I believe that this is the case). If we would take the value from the parfile upon recovery, the user would have to set the value according to where the horizon was found the last time! This is clearly to much of a hassle.

    • finally the code in the else branch uses horizon_number instead of horizon_number-1

    Yes, but not for parameters. Jonathan starts counting from 1.

    A general question: This seems to be an instance of a thorn that makes copies of Cactus' parameters (or quantities computed from them) and then checkpoints them. This seems to interfere badly with Cactus' ability to change parameter values on recovery. My question is if there is use in such thorns trying to emulate the logic in Cactus as to when to update values? I believe the login in Cactus goes something like this: at recovery the values for parameters are those stored in checkpoints unless it is explicitly set in the new parameter file and this setting differs from the one in the original parameter file used at checkpoint time in which case values from the new parameter file are used. Is this correct? Do we want to implement something similar in AHFinderDirect (I assume this to involve checking how often a parameter has been set at POST_RECOVER_VARIABLES time).

  3. Roland Haas
    • removed comment

    ok to the third reply (on numbering). Ok to the second reply in that the proposed behaviour is more correct. My worry was that the patchsystem might be left unitialized, reading the code however reveals that the patchsystem is unconditionally initialized with the origin_[yxz] parameters in AHFinderDirect_setup. It thus seems as if indeed the assignment in the "else" branch is superfluous but harmless since it will never change the values from those already set in AHFinderDirect_setup. Is this correct?

    Otherwise ok to apply (possibly sans comment and possibly sans the "else" branch).

  4. Christian Reisswig reporter
    • removed comment

    Replying to [comment:4 rhaas]:

    ok to the third reply (on numbering). Ok to the second reply in that the proposed behaviour is more correct. My worry was that the patchsystem might be left unitialized, reading the code however reveals that the patchsystem is unconditionally initialized with the origin_[yxz] parameters in AHFinderDirect_setup. It thus seems as if indeed the assignment in the "else" branch is superfluous but harmless since it will never change the values from those already set in AHFinderDirect_setup. Is this correct?

    Otherwise ok to apply (possibly sans comment and possibly sans the "else" branch).

    Agreed. I have removed and tested it without the else branch and it works fine. I can commit my changes.

  5. Log in to comment