[petsc-users] DMCreateMatrix with some dense row

Sang pham van pvsang002 at gmail.com
Sat Oct 24 16:01:47 CDT 2015


Many thanks, Dave!

Best,
Pham

On Sun, Oct 25, 2015 at 12:46 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> > On Oct 24, 2015, at 1:43 AM, Sang pham van <pvsang002 at gmail.com> wrote:
> >
> > Thank you, Dave,
> >
> > Can I just call My_DMCreateMatrix_DA_3d_MPIAIJ(DM da, Mat J, void*
> my_context) when I need to create my matrix, and forget about
> DMDASetGetMatrix()?
>
>   You can do that if that is all you need. In some contexts when something
> else in PETSc needs to create a specific matrix (like with geometric
> multigrid) then that code calls DMCreateMatrix() which would then use your
> creation routine.
>
>    So, in summary you can start by just calling your own routine and
> convert it to use DMSetGetMatrix() later if you need to.
>
>   Barry
>
> >
> > Thank you.
> >
> > Pham
> >
> > On Sat, Oct 24, 2015 at 1:33 PM, Dave May <dave.mayhem23 at gmail.com>
> wrote:
> > If you need to access a user defined context from within your
> CreateMatrix function, you can attach it to the DM via PetscObjectCompose
> >
> >
> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscObjectCompose.html
> >
> > If your context is not a petsc object, you can use
> PetscContainerCreate(),
> >
> >
> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Sys/PetscContainerCreate.html#PetscContainerCreate
> >
> > You would then set your user context pointer inside the container and
> then use PetscObjectCompose() to attach the container to the DM
> >
> > Thanks,
> >   Dave
> >
> >
> > On 24 October 2015 at 06:04, Sang pham van <pvsang002 at gmail.com> wrote:
> > Hi Barry,
> >
> > The routine DMCreateMatrix_DA_3d_MPIAIJ has 2 input arguments (DM da,
> Mat J), the function pointer in DMDASetGetMatrix() only accept function
> with that two arguments.
> > As you suggested, I am writing a routine (based on
> DMCreateMatrix_DA_3d_MPIAIJ()) to preallocate the matrix in the way I wish,
> to do that I think It needs to have one more input argument:
> My_DMCreateMatrix_DA_3d_MPIAIJ(DM da, Mat J, void* my_context). But
> DMDASetGetMatrix() will not accept pointer of this function. Please give a
> suggestion to overcome this.
> >
> > Thank you.
> >
> > Pham
> >
> >
> > On Fri, Sep 4, 2015 at 1:24 AM, Barry Smith <bsmith at mcs.anl.gov> wrote:
> >
> >     Look at DMCreateMatrix_DA_2d_MPIAIJ  (or the 3d version if working
> in 3d)   You need to copy this routine and add whatever additional
> preallocation information you need.   Then call DMDASetGetMatrix()  so that
> the DM will use your routine to create the matrix for you.
> >
> >    Barry
> >
> >
> >
> >
> > > On Sep 3, 2015, at 11:28 AM, Sang pham van <pvsang002 at gmail.com>
> wrote:
> > >
> > > Hi,
> > >
> > > I am using DMCreateMatrix to create matrix from a existed DM object
> and defined stencil.
> > > In my code, boundary nodes need to involve many inner nodes, thus
> matrix rows corresponding to boundary nodes are almost dense. How can I
> tell petsc that those rows need to be preallocated with more entries? I
> don't want to use MatMPIAIJSetPreallocation() since advantages of DM might
> be lost.
> > >
> > > Many thanks.
> > >
> > > Sam.
> > >
> > >
> >
> >
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20151025/508d8d87/attachment.html>


More information about the petsc-users mailing list