On Wed, Feb 24, 2016 at 9:58 AM, Florian Lindner <mailingli...@xgm.de> wrote:
> Hello, > > I create a couple of index sets: > > ISLocalToGlobalMapping _ISmapping; > IS ISlocal, ISlocalInv, ISglobal, ISidentity, ISidentityGlobal; > ISLocalToGlobalMapping ISidentityMapping; > > // Create an index set which maps myIndizes to continous chunks of > matrix rows. > ierr = ISCreateGeneral(PETSC_COMM_WORLD, myIndizes.size(), > myIndizes.data(), PETSC_COPY_VALUES, &ISlocal); CHKERRV(ierr); > ierr = ISSetPermutation(ISlocal); CHKERRV(ierr); > ierr = ISInvertPermutation(ISlocal, myIndizes.size(), &ISlocalInv); > CHKERRV(ierr); > ierr = ISAllGather(ISlocalInv, &ISglobal); CHKERRV(ierr); // Gather the > IS from all processors > ierr = ISLocalToGlobalMappingCreateIS(ISglobal, &_ISmapping); > CHKERRV(ierr); // Make it a mapping > > // Create an identity mapping and use that for the rows of matrixA. > ierr = ISCreateStride(PETSC_COMM_WORLD, _matrixA.ownerRange().second - > _matrixA.ownerRange().first, _matrixA.ownerRange().first, 1, &ISidentity); > CHKERRV(ierr); > ierr = ISSetIdentity(ISidentity); CHKERRV(ierr); > ierr = ISAllGather(ISidentity, &ISidentityGlobal); CHKERRV(ierr); > ierr = ISLocalToGlobalMappingCreateIS(ISidentityGlobal, > &ISidentityMapping); CHKERRV(ierr); > > ierr = MatSetLocalToGlobalMapping(_matrixC.matrix, _ISmapping, > _ISmapping); CHKERRV(ierr); // Set mapping for rows and cols > ierr = MatSetLocalToGlobalMapping(_matrixA.matrix, ISidentityMapping, > _ISmapping); CHKERRV(ierr); // Set mapping only for cols, use identity for > rows > > > Two questions: > > 1) Since I only need the _ISmapping again, is there any way to optimize > that, i.e. use less temporary variables? > It is not clear to me what is being done. > 2) Do all IS variables (_ISmapping, ISlocal, ISlocalInv, ISglobal, > ISidentity, ISidentityGlobal, ISidentityMapping) need to be destroyed using > ISDestroy at the end? Or only the ones that were created using a ISCreate* > function (ISlocal, ISidentity)? > All of them since you create new ISes with all those functions like ISInvertPermutation. Matt > Thanks, > > Florian > -- What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead. -- Norbert Wiener