Actual source code: aosetlocal.c
2: #include petscao.h
6: /*@C
7: AODataPartitionAndSetupLocal - Partitions across a given key (for example cells), then partitions a segment
8: (for example vertices) subservient to that key.
10: Collective on AOData
12: Input Parameters:
13: + ao - the AO database
14: . keyname - the name of the key
15: - segmentname - the name of the segment
18: Output Parameters:
19: + iskey - the local indices in global numbering of the key entries (cells). Note that these are
20: contiguous from rstart to rend
21: . issegment - the local indices in global numbering of the segment entries (vertices)
22: - ltog - the local to global mapping for the segment entries (vertices)
24: Level: advanced
26: Notes: this renumbers the key and segment entries in the AO database to reflect the new partitioning.
27: The ltog mapping is a mapping for the issegment indices, that is ltog applied to the indices
28: 0 to sizeof(issegment)-1 is the entries in issegment.
30: .seealso: AODataKeyParition(), AODataSegmentPartition()
31: @*/
32: PetscErrorCode AODataPartitionAndSetupLocal(AOData ao,const char keyname[],const char segmentname[],IS *iskey,IS *issegment,ISLocalToGlobalMapping *ltog)
33: {
34: ISLocalToGlobalMapping ltogkey;
35: PetscErrorCode ierr;
36: PetscInt rstart,rend;
37: MPI_Comm comm;
41: /* Partition the keys (cells) */
42: AODataKeyPartition(ao,keyname);
44: /* Partition the segment (vertices) subservient to the keys (cells) */
45: AODataSegmentPartition(ao,keyname,segmentname);
47: /* Generate the list of key entries (cells) on this processor */
48: AODataKeyGetOwnershipRange(ao,"cell",&rstart,&rend);
49: PetscObjectGetComm((PetscObject)ao,&comm);
51: ISCreateStride(comm,rend-rstart,rstart,1,iskey);
53: /* Get the list of segment entries (vertices) used by these key entries (cells) */
54: AODataSegmentGetReducedIS(ao,keyname,segmentname,*iskey,issegment);
56: /* Make local to global mapping of key entries (cells) */
57: ISLocalToGlobalMappingCreateIS(*iskey,<ogkey);
59: /* Make local to global mapping of segment entries (vertices) */
60: ISLocalToGlobalMappingCreateIS(*issegment,ltog);
62: /* Attach the local to global mappings to the database */
63: AODataKeySetLocalToGlobalMapping(ao,keyname,ltogkey);
64: AODataKeySetLocalToGlobalMapping(ao,segmentname,*ltog);
66: /* Dereference the ltogkey; we don't need a copy of it */
67: PetscObjectDereference((PetscObject)ltogkey);
69: return(0);
70: }