[petsc-users] DMDA questions

Xiangdong epscodes at gmail.com
Mon Mar 3 11:20:07 CST 2014


I have a question about using KSPSetComputeOperator with user provided
function ComputeMatrix().

In order to use multigrid, this function ComputeMatrix() should be able to
generate the matrix for any grid level. However, the matrix I am trying to
generate depending on a vector u (the solution at previous time step). It
is okay for ComputeMatrix at finest level, because I have the vector u at
the finest level. However, if the ComputeMatrix tries to compute the matrix
at a coarse level, I do not have the vector u at the coarse level. Then I
see some error messages about nonconfirming sizes. Should I manually
restrict the vector u at a coarse level or petsc has some functions on this?

In other words, there is a vector u in ctx struct passing to the
ComputeMatrix at finest level, how can I interpolate/restrict it to the
correct grid level for multigrid applications?

Thank you.

Xiangdong


On Fri, Feb 28, 2014 at 5:16 PM, Matthew Knepley <knepley at gmail.com> wrote:

> On Fri, Feb 28, 2014 at 2:14 PM, Xiangdong <epscodes at gmail.com> wrote:
>>
>> On Fri, Feb 28, 2014 at 5:11 PM, Matthew Knepley <knepley at gmail.com>wrote:
>>
>>> On Fri, Feb 28, 2014 at 2:10 PM, Xiangdong <epscodes at gmail.com> wrote:
>>>
>>>>
>>>>
>>>>
>>>> On Fri, Feb 28, 2014 at 4:48 PM, Barry Smith <bsmith at mcs.anl.gov>wrote:
>>>>
>>>>>
>>>>> On Feb 28, 2014, at 3:27 PM, Xiangdong <epscodes at gmail.com> wrote:
>>>>>
>>>>> >
>>>>> >
>>>>> >
>>>>> > On Fri, Feb 28, 2014 at 4:21 PM, Matthew Knepley <knepley at gmail.com>
>>>>> wrote:
>>>>> > On Fri, Feb 28, 2014 at 1:16 PM, Xiangdong <epscodes at gmail.com>
>>>>> wrote:
>>>>> > If I assembly the matrix with MatSetValuesStencil and use
>>>>> KspSetOpreators for Ksp, do I need to call KspSetDM first?
>>>>> >
>>>>> > No
>>>>> >
>>>>> > What is the key difference or advantage of using
>>>>> KspSetComputeOperators against KspSetOperators?
>>>>> >
>>>>> > With the later, you have to manage creating and preallocating the
>>>>> matrix.
>>>>> >
>>>>> > If I use DMCreateMatrix and MatSetValuesStencil, I do not need to
>>>>> preallocate the matrix.
>>>>>
>>>>>    Correct.
>>>>>
>>>>>    The SetComputeOperators and KSPSetDM is useful if you wish to use
>>>>> multigrid on system since PCMG will call your compute operators function on
>>>>> each level for you automatically. See src/ksp/ksp/examples/tutorials/
>>>>> ex25.c ex28.c ex29.c ex31.c ex32.c ex34.c ex45.c ex50.c   If you are just
>>>>> solving the one system and not using multigrid then there is no particular
>>>>> advantage in SetComputeOperators and KSPSetDM
>>>>>
>>>>
>>>> If I want to use multigrid as a preconditioner, I have to call
>>>> KspSetComputeOperators. Is this true?
>>>>
>>>
>>> No, you can always do everything by hand, but that call simplifies the
>>> job.
>>>
>>
>> Does "by hand" mean providing the routines for assembling the matrix at
>> different level/size manually?
>>
>
> It means providing the matrices directly, or using the Galerkin process.
> There is a manual section on it.
>
>    Matt
>
>
>> Xiangdong
>>
>>
>>>
>>>    Matt
>>>
>>>
>>>> Thank you.
>>>>
>>>> Xiangdong
>>>>
>>>>
>>>>
>>>>
>>>>>
>>>>>    Barry
>>>>>
>>>>> >
>>>>> > Xiangdong
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >    Matt
>>>>> >
>>>>> > Thanks you.
>>>>> >
>>>>> > Xiangdong
>>>>> >
>>>>> >
>>>>> > On Tue, Feb 25, 2014 at 4:24 PM, Jed Brown <jed at jedbrown.org> wrote:
>>>>> > Xiangdong <epscodes at gmail.com> writes:
>>>>> > > I am not clear about this. In this example, where is the format
>>>>> declaration
>>>>> > > (e.g.,mpiaij) of Mat jac? Why is this mat jac always distributed in
>>>>> > > a compatible way as the DM vectors?
>>>>> >
>>>>> > src/ksp/ksp/examples/tutorials/ex25.c calls KSPSetDM and sets
>>>>> functions
>>>>> > to assemble the matrices and right hand side.  Those objects are
>>>>> created
>>>>> > internally (you can use -dm_mat_type sbaij if you like) and the user
>>>>> > doesn't have to see them.
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> > --
>>>>> > 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
>>>
>>
>>
>
>
> --
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20140303/cc26d015/attachment-0001.html>


More information about the petsc-users mailing list