MatGetVecs and MATMFFD
Lisandro Dalcin
dalcinl at gmail.com
Thu Aug 21 11:44:51 CDT 2008
On Thu, Aug 21, 2008 at 1:23 PM, Boyce Griffith
<griffith at courant.nyu.edu> wrote:
> Hi, Lisandro --
Hi
> 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().
>
> 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.
>
> On Thu, 21 Aug 2008, Lisandro Dalcin wrote:
>
>> On Thu, Aug 21, 2008 at 9:01 AM, Boyce Griffith
>> <griffith at courant.nyu.edu> wrote:
>>>
>>> Hi, Folks --
>>>
>>> I am using a home-grown "multi-Vec" (i.e., vector of vectors)
>>> implementation
>>> with a PETSc nonlinear solver. I'd like to be able to use PETSc's
>>> matrix-free Jacobian with this solver along with a PCCOMPOSITE
>>> preconditioner; however, it seems like I need to override the default
>>> implementation of MatGetVecs in order to get this to work.
>>>
>>> Is there a kosher way to do this?
>>
>> You can use MatShellSetOperation() and set the operation
>> MATOP_GET_VECS. Despite the name, that function can let you set/change
>> the implementation of Mat operations for any matrix type. Try to make
>> the call to MatShellSetOperation() in the Jacobian routine and let me
>> know if you have trouble.
>>
>>
>>> Thanks,
>>>
>>> -- Boyce
>>>
>>>
>>
>>
>>
>> --
>> Lisandro Dalcín
>> ---------------
>> Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
>> Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
>> Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
>> PTLC - Güemes 3450, (3000) Santa Fe, Argentina
>> Tel/Fax: +54-(0)342-451.1594
>>
>
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
More information about the petsc-users
mailing list