[petsc-users] Solving subsystem using larger matrix
Matthew Knepley
knepley at gmail.com
Fri Sep 3 11:49:23 CDT 2021
On Fri, Sep 3, 2021 at 12:34 PM Samuel Estes <samuelestes91 at gmail.com>
wrote:
> Hi,
>
> I have a model in which we alternatively solve two submodels by the finite
> element method both on the same unstructured mesh. The first model (call it
> model 1) has three degrees of freedom per node while the second model
> (model 2) is scalar (one degree of freedom). We are trying several
> different implementations but one option that we would like to try is to
> use the same matrix for both models. In other words, assuming we have n
> nodes then we allocate a square matrix A to have 3*n rows, solve model 1,
> and then reuse this matrix to solve model 2. So for model 2 any non-zeros
> in the matrix A will be confined to the upper left ninth and the remaining
> 8/9ths of the matrix are irrelevant to the problem. I have several
> questions about how best to implement something like this which I will list
> below:
>
I can tell you how to do the operations below. However, I think we should
go over why you want to do this first. What benefit do you hope
to have with this scheme over just using two matrices.
Thanks,
Matt
> 1. The solver requires that the matrix at least have some non-zeros in
> each row, otherwise the solution ends up being all NANs. This makes sense
> as it is solving the subsystem 0*x=0 which is clearly ill-defined. Is there
> any way that I can communicate to PETSc, either through the solver or
> matrix classes or some other way, that all I care about is a subsystem and
> that I would like to use only a portion of the matrix A, the right hand
> side and the solution vector? There are some routines involving submatrices
> in the man pages but I'm not sure if they are appropriate for this problem
> or not. In particular, the MatGetLocalSubMatrix routine might be what I
> need but its not clear to me whether or not this actually copies the array
> of values in the submatrix (not desirable due to memory concerns) or if it
> is just essentially a pointer to the submatrix of values in the original
> matrix A (ideal). Basically, the idea is to use a part of the matrix that
> we have without allocating unnecessary extra memory.
> 2. Is there a way to use multiple local to global mappings for a single
> matrix. I have a problem when I try to use the same local to global mapping
> from model 1 in model 2. I understand why this is and can fix it but being
> able to reset the local to global mapping without destroying the matrix
> would be an ideal fix.
> 3. Any other input on the best way to approach solving a problem like this
> using PETSc would be appreciated. I'm somewhat of a novice when it comes to
> PETSc so I don't necessarily know all the tools which are available to me.
> It seems clear that I've reached a point where the manual and man pages
> aren't quite as helpful as they were for more basic operations.
>
> I hope my explanation of the problem and my questions was clear. If not,
> let me know and I can try to provide more details. 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/20210903/c09d7042/attachment.html>
More information about the petsc-users
mailing list