Actual source code: aopart.c

      1: #define PETSCDM_DLL

     3:  #include petscao.h

      7: /*@C
      8:     AODataKeyPartition - Partitions a key across the processors to reduce
      9:     communication costs.

     11:     Collective on AOData

     13:     Input Parameters:
     14: +   aodata - the database
     15: -   key - the key you wish partitioned and renumbered

     17:    Level: advanced

     19: .seealso: AODataSegmentPartition()
     20: @*/
     21: PetscErrorCode PETSCDM_DLLEXPORT AODataKeyPartition(AOData aodata,const char key[])
     22: {
     23:   AO              ao;
     24:   Mat             adj;
     25:   MatPartitioning part;
     26:   IS              is,isg;
     28:   MPI_Comm        comm;

     32:   PetscObjectGetComm((PetscObject)aodata,&comm);

     34:   AODataKeyGetAdjacency(aodata,key,&adj);
     35:   MatPartitioningCreate(comm,&part);
     36:   MatPartitioningSetAdjacency(part,adj);
     37:   MatPartitioningSetFromOptions(part);
     38:   MatPartitioningApply(part,&is);
     39:   MatPartitioningDestroy(part);
     40:   MatDestroy(adj);
     41:   ISPartitioningToNumbering(is,&isg);
     42:   ISDestroy(is);

     44:   AOCreateBasicIS(isg,PETSC_NULL,&ao);
     45:   ISDestroy(isg);

     47:   AODataKeyRemap(aodata,key,ao);
     48:   AODestroy(ao);
     49:   return(0);
     50: }