BOUT-dev icon indicating copy to clipboard operation
BOUT-dev copied to clipboard

BoutMesh::set_connection always called with same argument

Open ZedThree opened this issue 4 years ago • 0 comments

BoutMesh::set_connection is always called with xge = 0, which means there is some unreachable code in the function. This is a private method of BoutMesh, so we can be sure it's not called anywhere else.

If xge = 0 always, then the else branch is unreachable:

  if (MYPE == PROC_NUM(PE_XIND, ypeup)) { /* PROCESSOR SENDING +VE Y */
    /* Set the branch cut x position */
    if (xge <= MXG) {
      /* Connect on the inside */
      UDATA_XSPLIT = xlt;
      UDATA_INDEST = PROC_NUM(PE_XIND, ypedown);
      if (UDATA_XSPLIT == LocalNx)
        UDATA_OUTDEST = -1;

      TS_up_in = ts; // Twist-shift

      output_info.write("=> This processor sending in up\n");
    } else {
      /* Connect on the outside */
      if (UDATA_XSPLIT <= 0)
        UDATA_INDEST = UDATA_OUTDEST;
      UDATA_XSPLIT = xge;
      UDATA_OUTDEST = PROC_NUM(PE_XIND, ypedown);
      if (UDATA_XSPLIT <= 0)
        UDATA_INDEST = -1;

      TS_up_out = ts;
      output_info.write("=> This processor sending out up\n");
    }
  }

Can we delete the xge argument and the unreachable code, or are there plausibly circumstances where we might need it? For example, if Bp is anti-clockwise? (But in that case, that would imply that x increases towards the magnetic axis I guess?)

If we do delete it, I think this also implies we can delete TS_up_out and TS_down_out as never being needed?

ZedThree avatar Mar 22 '21 09:03 ZedThree