<div dir="ltr"><div dir="ltr">On Thu, Jun 15, 2023 at 8:32 AM Karsten Lettmann <<a href="mailto:karsten.lettmann@uni-oldenburg.de">karsten.lettmann@uni-oldenburg.de</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">Dear all,<br>
<br>
<br>
I'm quite new to PETSC. So I hope the following questions are not too <br>
stupid.<br>
<br>
<br>
1) We have a (Fortran) code, that we want to update from an older PETSC <br>
version (petsc.2.3.3-p16) to a newer version.<br>
<br>
Inside the old code, for creating matrices A, there are function calls <br>
of the from:<br>
MatCreateMPIAIJ<br>
<br>
In the reference page for this old version it says:<br>
When calling this routine with a single process communicator, a matrix <br>
of type SEQAIJ is returned.<br>
<br>
So I assume the following behavior of this old routine:<br>
- for N_proc == 1:<br>
a matrix of type SEQAIJ is returned.<br>
<br>
- for N_proc > 1:<br>
a matrix of type MPIAIJ is returned<br>
<br>
<br>
<br>
2a) So, in the new code, we want to have a similar behavior.<br>
<br>
I found that this function is not present any more in the newer PETSC <br>
versions.<br>
<br>
Instead, one might use: MatCreateAIJ(….)<br>
( <a href="https://petsc.org/release/manualpages/Mat/MatCreateAIJ/" rel="noreferrer" target="_blank">https://petsc.org/release/manualpages/Mat/MatCreateAIJ/</a> )<br>
<br>
If I understand the reference page of the function correctly, then, <br>
actually, a similar behavior should be expected:<br>
<br>
- for N_proc == 1:<br>
a matrix of type SEQAIJ is returned.<br>
<br>
- for N_proc > 1:<br>
a matrix of type MPIAIJ is returned<br>
<br>
<br>
2b) However, on the reference page, there is the note:<br>
<br>
It is recommended that one use the MatCreate(), MatSetType() and/or <br>
MatSetFromOptions(), MatXXXXSetPreallocation() paradigm instead of this <br>
routine directly.<br>
<br>
So, if I want the behavior above, it is recommended to code it like <br>
this, isn't it:<br>
<br>
If (N_Proc == 1)<br>
<br>
MatCreate(.. ,A ,...)<br>
MatSetType(…,A, MATSEQAIJ,..)<br>
MatSetSizes(…,A, ..)<br>
MatSeqAIJSetPreallocation(,...A,...)<br>
<br>
else<br>
<br>
MatCreate(.. ,A ,...)<br>
MatSetType(…,A, MATMPIAIJ,..)<br>
MatSetSizes(…,A, ..)<br>
MatMPIAIJSetPreallocation(,...A,...)<br></blockquote><div><br></div><div>You can use</div><div><br></div><div> MatCreate(comm, &A);</div><div> MatSetType(A, MATAIJ);</div><div> MatSetSizes(A, ...);</div><div> MatXAIJSetPreallocation(A, ...);</div><div><br></div><div>We recommend this because we would like to get rid of the convenience functions that</div><div>wrap up exactly this code.</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">
end<br>
<br>
<br>
<br>
3) So my questions are:<br>
<br>
- Is my present understanding correct?<br>
<br>
If yes:<br>
<br>
- Why might using MatCreateAIJ(….) for my case not be helpful?<br>
<br>
- So, why is it recommended to use the way 2b) instead of this <br>
MatCreateAIJ(….) ?<br>
<br>
<br>
Best, Karsten<br>
<br>
<br>
<br>
<br>
-- <br>
ICBM<br>
Section: Physical Oceanography<br>
Universitaet Oldenburg<br>
Postfach 5634<br>
D-26046 Oldenburg<br>
Germany<br>
<br>
Tel: +49 (0)441 798 4061<br>
email: <a href="mailto:karsten.lettmann@uni-oldenburg.de" target="_blank">karsten.lettmann@uni-oldenburg.de</a><br>
<br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><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>