[petsc-users] Construct Matrix based on row and column values

Matthew Knepley knepley at gmail.com
Mon Mar 23 07:02:34 CDT 2020


On Mon, Mar 23, 2020 at 7:46 AM Elias Karabelas <karabelaselias at gmail.com>
wrote:

> Dear Users,
>
> I want to implement a FCT (flux corrected transport) scheme with PETSc.
> To this end I have amongst other things create a Matrix whose entries
> are given by
>
> L_ij = -max(0, A_ij, A_ji) for i neq j
>
> L_ii = Sum_{j=0,..n, j neq i} L_ij
>
> where Mat A is an (non-symmetric) Input Matrix created beforehand.
>
> I was wondering how to do this. My first search brought me to
>
> https://www.mcs.anl.gov/petsc/petsc-current/src/mat/examples/tutorials/ex16.c.html
>
>
> but this just goes over the rows of one matrix to set new values and now
> I would need to run over the rows and columns of the matrix. My Idea was
> to just create a transpose of A and do the same but then the row-layout
> will be different and I can't use the same for loop for A and AT and
> thus also won't be able to calculate the max's above.
>
> Any help would be appreciated
>

I think it would likely be much easier to write your algorithm directly on
the mesh, rather than using matrices, since the locality information is
explicit with the mesh, but has to be reconstructed with the matrix.

The problem here is that in parallel there would be no easy way to get the
halo you need using a matrix. You
really want the ghosted space for assembly, and that is provided by the DM
objects. Does this make sense?
Unless anybody in PETSc has a better idea.

  Thanks,

     Matt


> Best regards
>
> Elias
>
>

-- 
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

https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20200323/8a68869b/attachment.html>


More information about the petsc-users mailing list