Actual source code: aosetlocal.c

  1: #define PETSCDM_DLL

 3:  #include petscao.h

  7: /*@C     
  8:        AODataPartitionAndSetupLocal - Partitions across a given key (for example cells), then partitions a segment
  9:          (for example vertices) subservient to that key.

 11:     Collective on AOData

 13:   Input Parameters:
 14: +  ao           - the AO database
 15: .  keyname      - the name of the key
 16: -  segmentname  - the name of the segment 


 19:   Output Parameters:
 20: +  iskey         - the local indices in global numbering of the key entries (cells). Note that these are
 21:                          contiguous from rstart to rend
 22: .  issegment     - the local indices in global numbering of the segment entries (vertices)
 23: -  ltog          - the local to global mapping for the segment entries (vertices)

 25:   Level: advanced

 27:   Notes: this renumbers the key and segment entries in the AO database to reflect the new partitioning.
 28:   The ltog mapping is a mapping for the issegment indices, that is ltog applied to the indices
 29:   0 to sizeof(issegment)-1 is the entries in issegment. 

 31: .seealso: AODataKeyParition(), AODataSegmentPartition()
 32: @*/
 33: PetscErrorCode  AODataPartitionAndSetupLocal(AOData ao,const char keyname[],const char segmentname[],IS *iskey,IS *issegment,ISLocalToGlobalMapping *ltog)
 34: {
 35:   ISLocalToGlobalMapping ltogkey;
 36:   PetscErrorCode         ierr;
 37:   PetscInt               rstart,rend;
 38:   MPI_Comm               comm;


 42:   /*      Partition the keys (cells)   */
 43:   AODataKeyPartition(ao,keyname);

 45:   /*      Partition the segment (vertices) subservient to the keys (cells)  */
 46:   AODataSegmentPartition(ao,keyname,segmentname);

 48:  /*     Generate the list of key entries (cells) on this processor   */
 49:   AODataKeyGetOwnershipRange(ao,"cell",&rstart,&rend);
 50:   PetscObjectGetComm((PetscObject)ao,&comm);

 52:   ISCreateStride(comm,rend-rstart,rstart,1,iskey);

 54:  /*       Get the list of segment entries (vertices) used by these key entries (cells)   */
 55:   AODataSegmentGetReducedIS(ao,keyname,segmentname,*iskey,issegment);

 57:  /*     Make local to global mapping of key entries (cells)  */
 58:   ISLocalToGlobalMappingCreateIS(*iskey,&ltogkey);

 60:   /*       Make local to global mapping of segment entries (vertices)  */
 61:   ISLocalToGlobalMappingCreateIS(*issegment,ltog);

 63:   /*        Attach the local to global mappings to the database */
 64:   AODataKeySetLocalToGlobalMapping(ao,keyname,ltogkey);
 65:   AODataKeySetLocalToGlobalMapping(ao,segmentname,*ltog);

 67:   /*      Dereference the ltogkey; we don't need a copy of it */
 68:   PetscObjectDereference((PetscObject)ltogkey);

 70:   return(0);
 71: }