MatGetVecs and MATMFFD
Matthew Knepley
knepley at gmail.com
Thu Aug 21 13:51:13 CDT 2008
On Thu, Aug 21, 2008 at 12:29 PM, Boyce Griffith
<griffith at courant.nyu.edu> wrote:
> On Thu, 21 Aug 2008, Matthew Knepley wrote:
>
>> On Thu, Aug 21, 2008 at 11:58 AM, Boyce Griffith
>> <griffith at courant.nyu.edu> wrote:
>>>
>>>
>>> On Thu, 21 Aug 2008, Lisandro Dalcin wrote:
>>>
>>>> On Thu, Aug 21, 2008 at 1:23 PM, Boyce Griffith
>>>> <griffith at courant.nyu.edu> wrote:
>>>>>
>>>>> Is there any way to associate a context with a MFFD matrix? It seems
>>>>> like
>>>>> the Otherwise, it seems like the implementation of MatGetVecs would
>>>>> need
>>>>> to
>>>>> use global variables in order to create the appropriate vectors.
>>>>
>>>> You can use a PetscContainer (see PetscContainerCreate() and friends)
>>>> to save your user data and then you can set put that container in any
>>>> PETSc object with PetscObjectCompose(), and next retrieve the
>>>> container with PetscObjectQuery(), and finally recover your user data
>>>> with PetscContainerGetPointer().
>>>
>>> Sounds like that should do the trick.
>>>
>>>>> Or is it possible to get access to the solution and right-hand-side
>>>>> vectors
>>>>> used by an associated SNES and use VecDuplicate on them?
>>>>
>>>> You can use SNESGetRhs() and SNESGetSolution(). At least in petsc-dev
>>>> (not so sure in last public release, I do not remember), you will get
>>>> back a reference to the 'b' and 'x' Vec's you passed to
>>>> 'SNESSolve(snes, b, x)'. You can even SNESGetSolutionUpdate() for
>>>> getting the Vec where the solution update for the Newton step is
>>>> formed.
>>>
>>> Right, but if all I have is the Mat, is there a userland function which
>>> will
>>> return the corresponding SNES?
>>
>> There is no SNES that corresponds to a Mat, rather the SNES holds a Mat,
>> which is oblivious. The MatGetVecs() routine is there to provide vectors
>> which have a layout that matches the Mat. This is done by using the same
>> PetscMap as the matrix rows.
>
> Presumably it isn't *totally* oblivious, otherwise MatCreateMFFD wouldn't
> take a SNES as an argument?
I don't think it takes it just to create vectors. The MatMFFD is created by the
SNES itself and is guaranteed to be associated with that SNES. However,
above you state that you create your matrix in isolation. Thus, I would suggest
creating vectors using the PetscMap information,
VecCreate()
VecSetSizes(map.n, map.N)
VecSetFromOptions()
If it is always associated with a SNES, I would set the SNES as a context like
we do in MatMFFD.
Matt
> -- Boyce
>
>>
>> Matt
>>
>>> Thanks,
>>>
>>> -- Boyce
>>
>> --
>> 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
--
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
More information about the petsc-users
mailing list