int AODataSegmentGetReducedIS(AOData aodata,char *name,char *segment,IS is,IS *isout)Collective on AOData and IS
aodata | - the database |
name | - the name of the key |
segment | - the name of the segment |
is | - the keys for data requested on this processor |
keys -> 0 1 2 3 4 5 6 7 if the segment contains -> 1 2 1 3 1 4 2 0 and you request keys 0 1 2 5 7, AODataSegmentGetReducedIS() will return 1 2 4 0 .vb .keywords: database transactions .seealso: @*/ int AODataSegmentGetReducedIS(AOData aodata,char *name,char *segment,IS is,IS *isout) { int ierr,n,*keys; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); PetscValidHeaderSpecific(is,IS_COOKIE); ierr = ISGetSize(is,&n); CHKERRQ(ierr); ierr = ISGetIndices(is,&keys); CHKERRQ(ierr); ierr = (*aodata->ops->segmentgetreduced)(aodata,name,segment,n,keys,isout); CHKERRQ(ierr); ierr = ISRestoreIndices(is,&keys); CHKERRQ(ierr); PetscFunctionReturn(0); } /* ------------------------------------------------------------------------------------*/ #undef __FUNC__ #define __FUNC__ "AODataKeySetLocalToGlobalMapping" /*@C AODataKeySetLocalToGlobalMapping - Add another data key to a AOData database. Not collective Input Parameters: + aodata - the database . name - the name of the key - map - local to global mapping .keywords: database additions .seealso: @*/ int AODataKeySetLocalToGlobalMapping(AOData aodata,char *name,ISLocalToGlobalMapping map) { int ierr,flag; AODataKey *ikey; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = AODataKeyFind_Private(aodata,name,&flag,&ikey);CHKERRQ(ierr); if (!flag) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Key does not exist"); ikey->ltog = map; PetscObjectReference((PetscObject) map); PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataKeyGetLocalToGlobalMapping" /*@C AODataKeyGetLocalToGlobalMapping - Add another data key to a AOData database. Not collective Input Parameters: + aodata - the database - name - the name of the key Output Parameters: . map - local to global mapping .keywords: database additions .seealso: @*/ int AODataKeyGetLocalToGlobalMapping(AOData aodata,char *name,ISLocalToGlobalMapping *map) { int ierr,flag; AODataKey *ikey; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = AODataKeyFind_Private(aodata,name,&flag,&ikey);CHKERRQ(ierr); if (!flag) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Key does not exist"); *map = ikey->ltog; PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataKeyRemove" /*@C AODataKeyRemove - Remove a data key from a AOData database. Collective on AOData Input Parameters: + aodata - the database - name - the name of the key .keywords: database removal .seealso: @*/ int AODataKeyRemove(AOData aodata,char *name) { int ierr; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = (*aodata->ops->keyremove)(aodata,name);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataSegmentRemove" /*@C AODataSegmentRemove - Remove a data segment from a AOData database. Collective on AOData Input Parameters: + aodata - the database . name - the name of the key - segname - name of the segment .keywords: database removal .seealso: @*/ int AODataSegmentRemove(AOData aodata,char *name,char *segname) { int ierr; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = (*aodata->ops->segmentremove)(aodata,name,segname);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataKeyAdd" /*@C AODataKeyAdd - Add another data key to a AOData database. Collective on AOData Input Parameters: + aodata - the database . name - the name of the key . N - the number of indices in the key - nlocal - number of indices to be associated with this processor .keywords: database additions .seealso: @*/ int AODataKeyAdd(AOData aodata,char *name,int nlocal,int N) { int ierr,flag,Ntmp,size,rank,i,len; AODataKey *key,*oldkey; MPI_Comm comm = aodata->comm; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = AODataKeyFind_Private(aodata,name,&flag,&oldkey);CHKERRQ(ierr); if (flag == 1) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Key already exists with given name"); if (nlocal == PETSC_DECIDE && N == PETSC_DECIDE) SETERRQ(PETSC_ERR_ARG_WRONG,1,"nlocal and N both PETSC_DECIDE"); key = PetscNew(AODataKey);CHKPTRQ(key); if (oldkey) { oldkey->next = key;} else { aodata->keys = key;} len = PetscStrlen(name); key->name = (char *) PetscMalloc((len+1)*sizeof(char));CHKPTRQ(key->name); PetscStrcpy(key->name,name); key->N = N; key->nsegments = 0; key->segments = 0; key->ltog = 0; key->next = 0; MPI_Comm_rank(comm,&rank); MPI_Comm_size(comm,&size); /* Set nlocal and ownership ranges */ if (N == PETSC_DECIDE) { ierr = MPI_Allreduce(&nlocal,&N,1,MPI_INT,MPI_SUM,comm);CHKERRQ(ierr); } else if (nlocal != PETSC_DECIDE) { ierr = MPI_Allreduce(&nlocal,&Ntmp,1,MPI_INT,MPI_SUM,comm);CHKERRQ(ierr); if (Ntmp != N) SETERRQ(PETSC_ERR_ARG_WRONG,1,"Sum of nlocal is not N"); } else { nlocal = N/size + ((N % size) > rank); } key->rowners = (int *) PetscMalloc((size+1)*sizeof(int));CHKPTRQ(key->rowners); ierr = MPI_Allgather(&nlocal,1,MPI_INT,key->rowners+1,1,MPI_INT,comm);CHKERRQ(ierr); key->rowners[0] = 0; for (i=2; i<=size; i++ ) { key->rowners[i] += key->rowners[i-1]; } key->rstart = key->rowners[rank]; key->rend = key->rowners[rank+1]; key->nlocal = nlocal; aodata->nkeys++; PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataSegmentAdd" /*@C AODataSegmentAdd - Add another data segment to a AOData database. Collective on AOData Input Parameters: + aodata - the database . name - the name of the key . segment - the name of the data segment . bs - the fundamental blocksize of the data . n - the number of data items contributed by this processor . keys - the keys provided by this processor . data - the actual data - dtype - the data type, one of PETSC_INT, PETSC_DOUBLE, PETSC_SCALAR, etc. .keywords: database additions .seealso: AODataSegmentAddIS() @*/ int AODataSegmentAdd(AOData aodata,char *name,char *segment,int bs,int n,int *keys,void *data, PetscDataType dtype) { int ierr; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = (*aodata->ops->segmentadd)(aodata,name,segment,bs,n,keys,data,dtype); CHKERRQ(ierr); /* ierr = OptionsHasName(PETSC_NULL,"-ao_data_view",&flg1); CHKERRQ(ierr); if (flg1) { ierr = AODataView(aodata,VIEWER_STDOUT_(comm)); CHKERRQ(ierr); } ierr = OptionsHasName(PETSC_NULL,"-ao_data_view_info",&flg1); CHKERRQ(ierr); if (flg1) { ierr = ViewerPushFormat(VIEWER_STDOUT_(comm),VIEWER_FORMAT_ASCII_INFO,0);CHKERRQ(ierr); ierr = AODataView(aodata,VIEWER_STDOUT_(comm)); CHKERRQ(ierr); ierr = ViewerPopFormat(VIEWER_STDOUT_(comm));CHKERRQ(ierr); } */ PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataSegmentAddIS" /*@C AODataSegmentAddIS - Add another data segment to a AOData database. Collective on AOData and IS Input Parameters: + aodata - the database . name - the name of the key . segment - name of segment . bs - the fundamental blocksize of the data . is - the keys provided by this processor . data - the actual data - dtype - the data type, one of PETSC_INT, PETSC_DOUBLE, PETSC_SCALAR, etc. .keywords: database additions .seealso: AODataSegmentAdd() @*/ int AODataSegmentAddIS(AOData aodata,char *name,char *segment,int bs,IS is,void *data, PetscDataType dtype) { int n,*keys,ierr; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); PetscValidHeaderSpecific(is,IS_COOKIE); ierr = ISGetSize(is,&n); CHKERRQ(ierr); ierr = ISGetIndices(is,&keys); CHKERRQ(ierr); ierr = (*aodata->ops->segmentadd)(aodata,name,segment,bs,n,keys,data,dtype); CHKERRQ(ierr); ierr = ISRestoreIndices(is,&keys); CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataKeyGetOwnershipRange" /*@C AODataKeyGetOwnershipRange - Gets the ownership range to this key type. Not collective Input Parameters: + aodata - the database - name - the name of the key Output Parameters: + rstart - first key owned locally - rend - last key owned locally .keywords: database accessing .seealso: AODataKeyGetInfo() @*/ int AODataKeyGetOwnershipRange(AOData aodata,char *name,int *rstart,int *rend) { int ierr,flag; AODataKey *key; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = AODataKeyFind_Private(aodata,name,&flag,&key); CHKERRQ(ierr); if (!flag) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Key never created"); *rstart = key->rstart; *rend = key->rend; PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataKeyGetInfo" /*@C AODataKeyGetInfo - Gets the global size, local size and number of segments in a key. Not collective Input Parameters: + aodata - the database - name - the name of the key Output Parameters: + nglobal - global number of keys . nlocal - local number of keys . nsegments - number of segments associated with key - segnames - names of the segments or PETSC_NULL .keywords: database accessing .seealso: AODataKeyGetOwnershipRange() @*/ int AODataKeyGetInfo(AOData aodata,char *name,int *nglobal,int *nlocal,int *nsegments, char ***segnames) { int ierr,flag,i,n=0; AODataKey *key; AODataSegment *seg; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = AODataKeyFind_Private(aodata,name,&flag,&key); CHKERRQ(ierr); if (!flag) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Key never created"); if (nglobal) *nglobal = key->N; if (nlocal) *nlocal = key->nlocal; if (nsegments) *nsegments = n = key->nsegments; if (nsegments && segnames) { *segnames = (char **) PetscMalloc((n+1)*sizeof(char *));CHKPTRQ(segnames); seg = key->segments; for ( i=0; i<n; i++ ) { if (!seg) SETERRQ(PETSC_ERR_COR,1,"Less segments in database then indicated"); (*segnames)[i] = seg->name; seg = seg->next; } } PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataSegmentGetInfo" /*@C AODataSegmentGetInfo - Gets the blocksize and type of a data segment Not collective Input Parameters: + aodata - the database . keyname - the name of the key - segname - the name of the segment Output Parameters: + bs - the blocksize - dtype - the datatype .keywords: database accessing .seealso: AODataGetInfo() @*/ int AODataSegmentGetInfo(AOData aodata,char *keyname,char *segname,int *bs, PetscDataType *dtype) { int ierr,flag; AODataKey *key; AODataSegment *seg; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = AODataSegmentFind_Private(aodata,keyname,segname,&flag,&key,&seg); CHKERRQ(ierr); if (flag == 0) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Segment never created"); if (flag == -1) SETERRQ(PETSC_ERR_ARG_OUTOFRANGE,1,"Key never created"); if (bs) *bs = seg->bs; if (dtype) *dtype = seg->datatype; PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataView" /*@C AODataView - Displays an application ordering. Collective on AOData and Viewer Input Parameters: + aodata - the database - viewer - viewer used for display The available visualization contexts include + VIEWER_STDOUT_SELF - standard output (default) - VIEWER_STDOUT_WORLD - synchronized standard output where only the first processor opens the file. All other processors send their data to the first processor to print. The user can open an alternative visualization context with ViewerFileOpenASCII() - output to a specified file. .keywords: database viewing .seealso: ViewerFileOpenASCII() @*/ int AODataView(AOData aodata, Viewer viewer) { int ierr; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = (*aodata->ops->view)(aodata,viewer);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataDestroy" /*@C AODataDestroy - Destroys an application ordering set. Collective on AOData Input Parameters: . aodata - the database .keywords: destroy, database .seealso: AODataCreateBasic() @*/ int AODataDestroy(AOData aodata) { int ierr; PetscFunctionBegin; if (!aodata) PetscFunctionReturn(0); PetscValidHeaderSpecific(aodata,AODATA_COOKIE); if (--aodata->refct > 0) PetscFunctionReturn(0); ierr = (*aodata->ops->destroy)(aodata); CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataKeyRemap" /*@C AODataKeyRemap - Remaps a key and all references to a key to a new numbering scheme where each processor indicates its new nodes by listing them in the previous numbering scheme. Collective on AOData and AO Input Parameters: + aodata - the database . key - the key to remap - ao - the old to new ordering .keywords: database remapping .seealso: AODataKeyGetAdjacency() @*/ int AODataKeyRemap(AOData aodata, char *key,AO ao) { int ierr; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); PetscValidHeaderSpecific(ao,AO_COOKIE); ierr = (*aodata->ops->keyremap)(aodata,key,ao);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataKeyGetAdjacency" /*@C AODataKeyGetAdjacency - Gets the adjacency graph for a key. Collective on AOData Input Parameters: + aodata - the database - key - the key Output Parameter: . adj - the adjacency graph .keywords: database, adjacency graph .seealso: AODataKeyRemap() @*/ int AODataKeyGetAdjacency(AOData aodata, char *key,Mat *adj) { int ierr; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = (*aodata->ops->keygetadjacency)(aodata,key,adj);CHKERRQ(ierr); PetscFunctionReturn(0); } #undef __FUNC__ #define __FUNC__ "AODataSegmentPartition" /*@C AODataSegmentPartition - Partitions a segment type across processors relative to a key that is partitioned. This will try to keep as many elements of the segment on the same processor as corresponding neighboring key elements are. Collective on AOData Input Parameters: + aodata - the database - key - the key to be partitioned and renumbered .seealso: AODataKeyPartition() @*/ int AODataSegmentPartition(AOData aodata,char *key,char *seg) { int ierr; PetscFunctionBegin; PetscValidHeaderSpecific(aodata,AODATA_COOKIE); ierr = (*aodata->ops->segmentpartition)(aodata,key,seg);CHKERRQ(ierr); PetscFunctionReturn(0); }
Location: src/ao/interface/aodata.c
IS and DA Index
Table of Contents