[petsc-users] PETSc object creation/destruction with adaptive grid

Matthew Knepley knepley at gmail.com
Tue Dec 7 13:08:34 CST 2021


On Tue, Dec 7, 2021 at 12:54 PM Samuel Estes <samuelestes91 at gmail.com>
wrote:

> Hi,
>
> I have a code implementing a finite element method with an adaptive grid.
> Rather than destroying the PETSc objects (the Jacobian matrix and RHS
> residual vector) every time the code refines the grid, we want to
> (over-)allocate some "padding" for these objects so that we only
> destroy/create new PETSc objects when the number of new nodes exceeds the
> padding. In order to solve the linear system with padding, we just fill the
> matrix with ones on the diagonal and fill the residual with zeros for the
> padded parts.
>
> Is this a reasonable way to do things?
>

It can be. You have to be careful that the 1 on the diagonal is not too
much different in magnitude from the other rows.


> I'm sure that this problem has come up before but I haven't found anything
> about it. I would like to know what other solutions people have come up
> with when using PETSc for adaptive problems since PETSc does not support
> dynamic reallocation of objects (i.e. I don't think you are allowed to
> change the size of a PETSc matrix).
>

What I do is just rebuild the structures when the mesh changes. I am mostly
looking at implicit things, so the solver and mesh adaptation cost swamp
allocation and copying.


> If this problem has come up before, can you please point me to a link to
> the discussion?
>

I can't recall having it before, but maybe Satish can remember.


> In particular, I'm curious if there is any way to solve the padded linear
> system without having to fill in values for the unused parts of the system.
> The linear solver obviously complains if there are rows of the matrix
> without any values, I'm just wondering if it's possible to get the linear
> solver to ignore them?
>

Actually, we do have a thing that does something similar right now.
SNESVI_RS "freezes" the rows of the Jacobian associated with active
constraints, We could do this
same freezing with your rows I think. However, that is as much copying and
allocation as just eliminating those rows, so maybe it does not buy you
much.

  Thanks

    Matt


> Thanks!
>
> Sam
>
-- 
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/20211207/8ea3808a/attachment-0001.html>


More information about the petsc-users mailing list