Skip to content
  • Mark OLESEN's avatar
    ENH: provide getter/setter interface to standard communicators · 20566a87
    Mark OLESEN authored
    - similar to UPstream::parRun(), the setter returns the previous value.
    
      The accessors are prefixed with 'comm':
      Eg, commGlobal(), commWarn(), commWorld(), commSelf().
      This distinguishes them from any existing variables (eg, worldComm)
      and arguably more similar to MPI_COMM_WORLD etc...
    
      If demand-driven communicators are added in the future, the function
      call syntax can help encapsulate that.
    
      Previously:
    
          const label oldWarnComm = UPstream::warnComm;
          const label oldWorldComm = UPstream::worldComm;
          UPstream::warnComm = myComm;
          UPstream::worldComm = myComm;
          ...
    
          UPstream::warnComm = oldWarnComm;
          UPstream::worldComm = oldWorldComm;
    
      Now:
          const label oldWarnComm = UPstream::commWarn(myComm);
          const label oldWorldComm = UPstream::commWorld(myComm);
          ...
    
          UPstream::commWarn(oldWarnComm);
          UPstream::commWorld(oldWorldComm);
    
    STYLE: check (warnComm >= 0) instead of (warnComm != -1)
    20566a87