[petsc-users] DMCreateMatrix error with Composite (no getlocaltoglobalmapping)

Mark Adams mfadams at lbl.gov
Wed Aug 6 13:34:37 CDT 2014


It looks like DMShellCreate does not set dm->ops->getlocaltoglobalmapping,
which is needed for DMCreateMatrix with a composite DM.  I do set a global
and local vector and a matrix.  It looks like I could call
DMShellSetLocalToGlobal.
 Should I be doing this?  Seems low level and the kind of thing this using
the DM was supposed to avoid

This seems like it is simply a copy of a local vector to to local part of a
global vector.

Mark



On Wed, Aug 6, 2014 at 12:23 PM, Mark Adams <mfadams at lbl.gov> wrote:

> adding a subject ...
>
>
> On Wed, Aug 6, 2014 at 12:00 PM, Mark Adams <mfadams at lbl.gov> wrote:
>
>> I am moving my code to have the DM create the matrix and am hitting this
>> error in DMGetLocalToGlobalMapping:
>>
>> if (!dm->ops->getlocaltoglobalmapping)
>> SETERRQ(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"DM can not create
>> LocalToGlobalMapping");
>>
>> This happens when I create the matrix like this:
>>
>>   call DMCompositeCreate(comm,solver%da,ierr)
>>   call DMSetOptionsPrefix(solver%da,'fsa_',ierr)
>>   call DMCompositeAddDM(solver%da,solver%daphi,ierr)
>>   call DMCompositeAddDM(solver%da,solver%dalam,ierr)
>>   call DMSetFromOptions(solver%da,ierr)
>>   call DMCreateMatrix(solver%da,solver%KKTmat,ierr)
>>
>> I am using DMShell and create them like so:
>>
>>   ! phi DM
>>   call VecCreate(comm,x1Vec,ierr)
>>   call VecSetSizes(x1Vec,N1loc,N1Glob,ierr)
>>    call VecSetFromOptions(x1Vec,ierr)
>>
>>   call DMShellCreate(comm,solver%daphi,ierr)
>>   call DMShellSetGlobalVector(solver%daphi,x1Vec,ierr)
>>   call DMShellSetMatrix(solver%daphi,solver%A0Mat,ierr)
>>   call VecDestroy(x1Vec,ierr)
>>   call DMSetOptionsPrefix(solver%daphi,'phi_',ierr)
>>   call DMSetFromOptions(solver%daphi,ierr)
>>
>>   call VecCreate(PETSC_COMM_SELF,x1Vecloc,ierr)
>>   call VecSetSizes(x1Vecloc,N1loc,N1loc,ierr)
>>   call VecSetFromOptions(x1Vecloc,ierr)
>>   call DMShellSetLocalVector(solver%daphi,x1Vecloc,ierr)
>>   call VecDestroy(x1Vecloc,ierr)
>>
>> All the examples that I see use DMDAs.  I am able to create a global
>> vector with this DM.
>>
>> Any ideas?
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140806/80d952e5/attachment.html>


More information about the petsc-users mailing list