<div dir="ltr"><div dir="ltr">On Fri, Sep 3, 2021 at 12:34 PM Samuel Estes <<a href="mailto:samuelestes91@gmail.com">samuelestes91@gmail.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>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:</div></div></blockquote><div><br></div><div>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</div><div>to have with this scheme over just using two matrices.</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>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.</div><div>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.</div><div>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.</div><div><br></div><div>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!</div><div><br></div><div>Sam</div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>