1 2 static char help[] = "Tests PetscTreeProcess()"; 3 4 #include <petscsys.h> 5 6 /* 7 2 6 8 1 4 9 5 10 */ 11 int main(int argc,char **argv) 12 { 13 PetscInt n = 7,cnt = 0,i,j; 14 PetscBool mask[] = {PETSC_TRUE,PETSC_FALSE,PETSC_FALSE,PETSC_TRUE,PETSC_FALSE,PETSC_FALSE,PETSC_FALSE}; 15 PetscInt parentId[] = {-1, 2, 0, -1, 2, 1, 0}; 16 PetscInt Nlevels,*Level,*Levelcnt,*Idbylevel,*Column; 17 18 PetscCall(PetscInitialize(&argc,&argv,NULL,help)); 19 PetscCall(PetscProcessTree(n,mask,parentId,&Nlevels,&Level,&Levelcnt,&Idbylevel,&Column)); 20 for (i=0; i<n; i++) { 21 if (!mask[i]) { 22 PetscCall(PetscPrintf(PETSC_COMM_WORLD," %" PetscInt_FMT " ",Level[i])); 23 } 24 } 25 PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\nNumber of levels %" PetscInt_FMT "\n",Nlevels)); 26 for (i=0; i<Nlevels; i++) { 27 PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\nLevel %" PetscInt_FMT " ",i)); 28 for (j=0; j<Levelcnt[i]; j++) { 29 PetscCall(PetscPrintf(PETSC_COMM_WORLD,"%" PetscInt_FMT " ",Idbylevel[cnt++])); 30 } 31 } 32 PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\nColumn of each node")); 33 for (i=0; i<n; i++) { 34 if (!mask[i]) { 35 PetscCall(PetscPrintf(PETSC_COMM_WORLD," %" PetscInt_FMT " ",Column[i])); 36 } 37 } 38 PetscCall(PetscPrintf(PETSC_COMM_WORLD,"\n")); 39 PetscCall(PetscFree(Level)); 40 PetscCall(PetscFree(Levelcnt)); 41 PetscCall(PetscFree(Idbylevel)); 42 PetscCall(PetscFree(Column)); 43 PetscCall(PetscFinalize()); 44 return 0; 45 } 46 47 /*TEST 48 49 test: 50 51 TEST*/ 52