Date: 2022-08-02T03:14:11+00:00

Actual source code: fndsep.c

      2: /* fndsep.f -- translated by f2c (version 19931217).
      3: */

      5: #include <petsc/private/matorderimpl.h>

      7: /*****************************************************************/
      8: /*************     FNDSEP ..... FIND SEPARATOR       *************/
      9: /*****************************************************************/
     10: /*    PURPOSE - THIS ROUTINE IS USED TO FIND A SMALL             */
     11: /*              SEPARATOR FOR A CONNECTED COMPONENT SPECIFIED    */
     12: /*              BY MASK IN THE GIVEN GRAPH.                      */
     13: /*                                                               */
     14: /*    INPUT PARAMETERS -                                         */
     15: /*       ../../.. - IS THE NODE THAT DETERMINES THE MASKED           */
     16: /*              COMPONENT.                                       */
     17: /*       (XADJ, ADJNCY) - THE ADJACENCY STRUCTURE PAIR.          */
     18: /*                                                               */
     19: /*    OUTPUT PARAMETERS -                                        */
     20: /*       NSEP - NUMBER OF VARIABLES IN THE SEPARATOR.            */
     21: /*       SEP - VECTOR CONTAINING THE SEPARATOR NODES.            */
     22: /*                                                               */
     23: /*    UPDATED PARAMETER -                                        */
     24: /*       MASK - NODES IN THE SEPARATOR HAVE THEIR MASK           */
     25: /*              VALUES SET TO ZERO.                              */
     26: /*                                                               */
     27: /*    WORKING PARAMETERS -                                       */
     28: /*       (XLS, LS) - LEVEL STRUCTURE PAIR FOR LEVEL STRUCTURE    */
     29: /*              FOUND BY FN../../...                                 */
     30: /*                                                               */
     31: /*    PROGRAM SUBROUTINES -                                      */
     32: /*       FN../../...                                                 */
     33: /*                                                               */
     34: /*****************************************************************/
     35: PetscErrorCode SPARSEPACKfndsep(PetscInt *root,const PetscInt *inxadj,const PetscInt *adjncy,PetscInt *mask, PetscInt *nsep, PetscInt *sep, PetscInt *xls, PetscInt *ls)
     36: {
     37:   PetscInt *xadj = (PetscInt*)inxadj; /* Used as temporary and reset within this function */

     39:   /* System generated locals */
     40:   PetscInt i__1, i__2;

     42:   /* Local variables */
     43:   PetscInt node, nlvl, i, j, jstop, jstrt, mp1beg, mp1end, midbeg, midend, midlvl;
     44:   PetscInt nbr;

     46:   /* Parameter adjustments */
     47:   --ls;
     48:   --xls;
     49:   --sep;
     50:   --mask;
     51:   --adjncy;
     52:   --xadj;

     54:   SPARSEPACKfnroot(root, &xadj[1], &adjncy[1], &mask[1], &nlvl, &xls[1], &ls[1]);
     55: /*       IF THE NUMBER OF LEVELS IS LESS THAN 3, RETURN */
     56: /*       THE WHOLE COMPONENT AS THE SEPARATOR.*/
     57:   if (nlvl >= 3) goto L200;
     58:   *nsep = xls[nlvl + 1] - 1;
     59:   i__1  = *nsep;
     60:   for (i = 1; i <= i__1; ++i) {
     61:     node       = ls[i];
     62:     sep[i]     = node;
     63:     mask[node] = 0;
     64:   }
     65:   return 0;
     66: /*       FIND THE MIDDLE LEVEL OF THE ../../..ED LEVEL STRUCTURE.*/
     67: L200:
     68:   midlvl = (nlvl + 2) / 2;
     69:   midbeg = xls[midlvl];
     70:   mp1beg = xls[midlvl + 1];
     71:   midend = mp1beg - 1;
     72:   mp1end = xls[midlvl + 2] - 1;
     73: /*       THE SEPARATOR IS OBTAINED BY INCLUDING ONLY THOSE*/
     74: /*       MIDDLE-LEVEL NODES WITH NEIGHBORS IN THE MIDDLE+1*/
     75: /*       LEVEL. XADJ IS USED TEMPORARILY TO MARK THOSE*/
     76: /*       NODES IN THE MIDDLE+1 LEVEL.*/
     77:   i__1 = mp1end;
     78:   for (i = mp1beg; i <= i__1; ++i) {
     79:     node       = ls[i];
     80:     xadj[node] = -xadj[node];
     81:   }
     82:   *nsep = 0;
     83:   i__1  = midend;
     84:   for (i = midbeg; i <= i__1; ++i) {
     85:     node  = ls[i];
     86:     jstrt = xadj[node];
     87:     i__2  = xadj[node + 1];
     88:     jstop = (PetscInt)PetscAbsInt(i__2) - 1;
     89:     i__2  = jstop;
     90:     for (j = jstrt; j <= i__2; ++j) {
     91:       nbr = adjncy[j];
     92:       if (xadj[nbr] > 0) goto L400;
     93:       ++(*nsep);
     94:       sep[*nsep] = node;
     95:       mask[node] = 0;
     96:       goto L500;
     97: L400:
     98:       ;
     99:     }
    100: L500:
    101:     ;
    102:   }
    103: /*       RESET XADJ TO ITS CORRECT SIGN.*/
    104:   i__1 = mp1end;
    105:   for (i = mp1beg; i <= i__1; ++i) {
    106:     node       = ls[i];
    107:     xadj[node] = -xadj[node];
    108:   }
    109:   return 0;
    110: }