#ifndef lint static char vcid[] = "$Id: isltog.c,v 1.9 1997/04/25 21:56:05 curfman Exp balay $"; #endif #include "sys.h" /*I "sys.h" I*/ #include "is.h" /*I "is.h" I*/ #undef __FUNC__ #define __FUNC__ "ISLocalToGlobalMappingCreate" /* ADIC Ignore */ /*@ ISLocalToGlobalMappingCreate - Creates a mapping between a local (0 to n) ordering and a global parallel ordering. Input Parameters: . n - the number of local elements . indices - the global index for each local element Output Parameters: . mapping - new mapping data structure .keywords: IS, local-to-global mapping, create .seealso: ISLocalToGlobalMappingDestroy() @*/ int ISLocalToGlobalMappingCreate(int n, int *indices,ISLocalToGlobalMapping *mapping) { PetscValidIntPointer(indices); PetscValidPointer(mapping); *mapping = PetscNew(struct _p_ISLocalToGlobalMapping); CHKPTRQ(*mapping); (*mapping)->refcnt = 1; (*mapping)->indices = (int *) PetscMalloc((n+1)*sizeof(int));CHKPTRQ((*mapping)->indices); PetscMemcpy((*mapping)->indices,indices,n*sizeof(int)); return 0; } #undef __FUNC__ #define __FUNC__ "ISLocalToGlobalMappingDestroy" /* ADIC Ignore */ /*@ ISLocalToGlobalMappingDestroy - Destroys a mapping between a local (0 to n) ordering and a global parallel ordering. Input Parameters: . mapping - mapping data structure .keywords: IS, local-to-global mapping, destroy .seealso: ISLocalToGlobalMappingCreate() @*/ int ISLocalToGlobalMappingDestroy(ISLocalToGlobalMapping mapping) { PetscValidPointer(mapping); if (--mapping->refcnt) return 0; PetscFree(mapping->indices); PetscFree(mapping); return 0; } #undef __FUNC__ #define __FUNC__ "ISLocalToGlobalMappingApplyIS" /* ADIC Ignore */ /*@ ISLocalToGlobalMappingApplyIS - Creates from an IS in the local numbering a new index set using the global numbering defined in an ISLocalToGlobalMapping context. Input Parameters: . ISLocalToGlobalMapping - mapping between local and global numbering . is - index set in local numbering Output Parameters: . newis - index set in global numbering .keywords: IS, local-to-global mapping, apply .seealso: ISLocalToGlobalMappingApply(), ISLocalToGlobalMappingCreate(), ISLocalToGlobalMappingDestroy() @*/ int ISLocalToGlobalMappingApplyIS(ISLocalToGlobalMapping mapping, IS is, IS *newis) { int ierr,n,i,*idxin,*idxmap,*idxout; PetscValidPointer(mapping); PetscValidHeaderSpecific(is,IS_COOKIE); PetscValidPointer(newis); ierr = ISGetSize(is,&n); CHKERRQ(ierr); ierr = ISGetIndices(is,&idxin); CHKERRQ(ierr); idxmap = mapping->indices; idxout = (int *) PetscMalloc((n+1)*sizeof(int));CHKPTRQ(idxout); for ( i=0; i