<div dir="auto"><div><br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il Mar 4 Gen 2022, 16:56 Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it">marco.cisternino@optimad.it</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="m_-7278557784837845280WordSection1">
<p class="MsoNormal">Hello Mark,<u></u><u></u></p>
<p class="MsoNormal">I analyzed the codes with valgrind, both the real code and the tiny one.<u></u><u></u></p>
<p class="MsoNormal">I obviously used memcheck tool but with full leak check compiling the codes with debug info.<u></u><u></u></p>
<p class="MsoNormal">Not considering OpenMPI events (I have no wrappers on the machine I used for the analysis), the real code gave zero errors and the tiny one gave this<u></u><u></u></p>
<p class="MsoNormal">==17911== 905,536 (1,552 direct, 903,984 indirect) bytes in 1 blocks are definitely lost in loss record 33 of 33<u></u><u></u></p>
<p class="MsoNormal">==17911== at 0x483E340: memalign (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)<u></u><u></u></p>
<p class="MsoNormal">==17911== by 0x49CB672: PetscMallocAlign (in /usr/lib/x86_64-linux-gnu/libpetsc_real.so.3.12.4)<u></u><u></u></p>
<p class="MsoNormal">==17911== by 0x49CBE1D: PetscMallocA (in /usr/lib/x86_64-linux-gnu/libpetsc_real.so.3.12.4)<u></u><u></u></p>
<p class="MsoNormal">==17911== by 0x4B26187: VecCreate (in /usr/lib/x86_64-linux-gnu/libpetsc_real.so.3.12.4)<u></u><u></u></p>
<p class="MsoNormal">==17911== by 0x10940D: main (testNullSpace.cpp:30)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">due to the fact that I forgot to destroy the solution Vec (adding VecDestroy(&solution) at the end of the main, the error disappear).<u></u><u></u></p>
<p class="MsoNormal">For both the codes, I analyzed the two ways of passing the constant to the null space of the operator, no memory errors but still the same results from MatNullSpaceTest, i.e.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_TRUE, 0, nullptr, &nullspace);<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">passes the test while <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="FR">Vec* nsp;<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="FR">VecDuplicateVecs(solution, 1, &nsp);<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="FR">VecSet(nsp[0],1.0);<u></u><u></u></span></p>
<p class="MsoNormal"><span lang="FR">VecNormalize(nsp[0], nullptr);<u></u><u></u></span></p>
<p class="MsoNormal">MatNullSpaceCreate(PETSC_COMM_WORLD, PETSC_FALSE, 1, nsp, &nullspace);<u></u><u></u></p>
<p class="MsoNormal">VecDestroyVecs(1,&nsp);<u></u><u></u></p>
<p class="MsoNormal">PetscFree(nsp);<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">does not.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I hope this can satisfy your doubt about the memory behavior, but please do not hesitate to ask for more analysis if it cannot.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">As Matthew said some weeks ago, something should be wrong in the code, I would say in the matrix, that’s why I provided the matrix and the way I test it.<u></u><u></u></p>
<p class="MsoNormal">Unfortunately, it is hard (read impossible) for me to share the code producing the matrix. I hope the minimal code I provided is enough to understand something.</p></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Try running slepc to find the smallest eigenvalues. There should be two zero eigenvalues, then inspect the eigenvectors</div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word"><div class="m_-7278557784837845280WordSection1"><p class="MsoNormal"><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thank you all.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Marco Cisternino <u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Marco Cisternino <br>
<b>Sent:</b> lunedì 3 gennaio 2022 16:08<br>
<b>To:</b> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank" rel="noreferrer">mfadams@lbl.gov</a>><br>
<b>Cc:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" rel="noreferrer">knepley@gmail.com</a>>; petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="noreferrer">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> RE: [petsc-users] Nullspaces<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">We usually analyze the code with valgrind, when important changes are implemented.<u></u><u></u></p>
<p class="MsoNormal">I have to admit that this analysis is still not automatic and the case we are talking about is not a test case for our workload.<u></u><u></u></p>
<p class="MsoNormal">The test cases we have give no errors in valgrind analysis.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">However, I will analyze both the real code and the tiny one for this case with valgrind and report the results.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thank you,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><span lang="IT">Marco Cisternino </span><u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank" rel="noreferrer">mfadams@lbl.gov</a>>
<br>
<b>Sent:</b> lunedì 3 gennaio 2022 15:50<br>
<b>To:</b> Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a>><br>
<b>Cc:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" rel="noreferrer">knepley@gmail.com</a>>; petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="noreferrer">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-users] Nullspaces<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">I have not looked at your code, but as a general observation you want to have some sort of memory checker, like valgrid for CPUs, in your workflow.<u></u><u></u></p>
<div>
<p class="MsoNormal">It is the fastest way to find some classes of bugs.<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Mon, Jan 3, 2022 at 8:47 AM Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal">Are you talking about the code that produce the linear system or about the tiny code that test the null space?<br>
In the first case, it is absolutely possible, but I would expect no problem in the tiny code, do you agree?<br>
It is important to remark that the real code and the tiny one behave in the same way when testing the null space of the operator. I can analyze with valgrind and I will, but I would not expect great insights.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span lang="IT">Marco Cisternino, PhD<br>
<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a></span><u></u><u></u></p>
<p class="MsoNormal">______________________<u></u><u></u></p>
<p class="MsoNormal">Optimad Engineering Srl<u></u><u></u></p>
<p class="MsoNormal">Via Bligny 5,
<span style="font-family:"Segoe UI",sans-serif;color:#201f1e;background:white">Torino, Italia.</span><span style="font-family:"Segoe UI",sans-serif;color:#201f1e"><br>
<span style="background:white">+3901119719782</span><br>
</span><span lang="IT"><a href="http://www.optimad.it/" target="_blank" rel="noreferrer"><span lang="EN-US" style="font-family:"Segoe UI",sans-serif;border:none windowtext 1.0pt;padding:0cm;background:white">www.optimad.it</span></a></span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank" rel="noreferrer">mfadams@lbl.gov</a>>
<br>
<b>Sent:</b> lunedì 3 gennaio 2022 14:42<br>
<b>To:</b> Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a>><br>
<b>Cc:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" rel="noreferrer">knepley@gmail.com</a>>; petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="noreferrer">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-users] Nullspaces<u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">There could be a memory bug that does not cause a noticeable problem until it hits some vital data and valgrind might find it on a small problem.<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">However you might have a bug like a hardwired buffer size that overflows that is in fact not a bug until you get to this large size and in that case valgrid would need to be run
on the large case and would have a good chance of finding it.<u></u><u></u></p>
</div>
<div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Mon, Jan 3, 2022 at 4:42 AM Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal">My comments are between the Mark’s lines and they starts with “#”<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><span lang="IT">Marco Cisternino
</span><u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank" rel="noreferrer">mfadams@lbl.gov</a>>
<br>
<b>Sent:</b> sabato 25 dicembre 2021 14:59<br>
<b>To:</b> Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a>><br>
<b>Cc:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" rel="noreferrer">knepley@gmail.com</a>>; petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="noreferrer">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-users] Nullspaces<u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">If "triggering the issue" requires a substantial mesh, that makes me think there is a logic bug somewhere. Maybe use valgrind.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"># Are you suggesting to use valgrind on this tiny toy code or on the original one? However, considering the purpose of the tiny code, i.e. testing the constant null space, why there
should be a logical bug? Case 1 passes and case 2 should be exactly the same, shouldn’t be it?
<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Also you say you divide by the cell volume. Maybe I am not understanding this but that is basically diagonal scaling and that will change the null space (ie, not a constant anymore)<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"># I agree on this, but it pushes a question: why the case 1 passes the test?<u></u><u></u></p>
<p class="MsoNormal"># Thank you, Mark.<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div>
<p class="MsoNormal">On Thu, Dec 16, 2021 at 11:11 AM Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal">Hello Matthew,<u></u><u></u></p>
<p class="MsoNormal">as promised I prepared a minimal (112960 rows. I’m not able to produce anything smaller than this and triggering the issue) example of the behavior I was talking about some days
ago.<u></u><u></u></p>
<p class="MsoNormal">What I did is to produce matrix, right hand side and initial solution of the linear system.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">As I told you before, this linear system is the discretization of the pressure equation of a predictor-corrector method for NS equations in the framework of finite volume method.<u></u><u></u></p>
<p class="MsoNormal">This case has homogeneous Neumann boundary conditions. Computational domain has two independent and separated sub-domains.<u></u><u></u></p>
<p class="MsoNormal">I discretize the weak formulation and I divide every row of the linear system by the volume of the relative cell.<u></u><u></u></p>
<p class="MsoNormal">The underlying mesh is not uniform, therefore cells have different volumes.
<u></u><u></u></p>
<p class="MsoNormal">The issue I’m going to explain does not show up if the mesh is uniform, same volume for all the cells.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I usually build the null space sub-domain by sub-domain with<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:36.0pt">
MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, nConstants, constants, &nullspace);<u></u><u></u></p>
<p class="MsoNormal">Where nConstants = 2 and constants contains two normalized arrays with constant values on degrees of freedom relative to the associated sub-domain and zeros elsewhere.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">However, as a test I tried the constant over the whole domain using 2 alternatives that should produce the same null space:<u></u><u></u></p>
<ol start="1" type="1">
<li class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678msolistparagraph">
MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);<u></u><u></u></li><li class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678msolistparagraph">
Vec* nsp;<u></u><u></u></li></ol>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678msolistparagraph">
VecDuplicateVecs(solution, 1, &nsp);<u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678msolistparagraph">
VecSet(nsp[0],1.0);<u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678msolistparagraph">
VecNormalize(nsp[0], nullptr);<u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678msolistparagraph">
MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, nsp, &nullspace);<u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678msolistparagraph">
<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
Once I created the null space I test it using:<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify;text-indent:36.0pt">
<span lang="IT">MatNullSpaceTest(nullspace, m_A, &isNullSpaceValid);</span><u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
<span lang="IT"> </span><u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
The case 1 pass the test while case 2 don’t.<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
I have a small code for matrix loading, null spaces creation and testing.<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
Unfortunately I cannot implement a small code able to produce that linear system.<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
As attachment you can find an archive containing the matrix, the initial solution (used to manually build the null space) and the rhs (not used in the test code) in binary format.<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
You can also find the testing code in the same archive.<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
I used petsc 3.12(gcc+openMPI) and petsc 3.15.2(intelOneAPI) same results.<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
If the attachment is not delivered, I can share a link to it.<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
Thanks for any help.<u></u><u></u></p>
<p class="MsoNormal" style="text-align:justify">
<u></u><u></u></p>
<p class="MsoNormal">Marco Cisternino
<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal"><span lang="IT">Marco Cisternino, PhD<br>
<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a></span><u></u><u></u></p>
<p class="MsoNormal">______________________<u></u><u></u></p>
<p class="MsoNormal">Optimad Engineering Srl<u></u><u></u></p>
<p class="MsoNormal">Via Bligny 5,
<span style="font-family:"Segoe UI",sans-serif;color:#201f1e;background:white">Torino, Italia.</span><span style="font-family:"Segoe UI",sans-serif;color:#201f1e"><br>
<span style="background:white">+3901119719782</span><br>
</span><span lang="IT"><a href="http://www.optimad.it/" target="_blank" rel="noreferrer"><span lang="EN-US" style="font-family:"Segoe UI",sans-serif;border:none windowtext 1.0pt;padding:0cm;background:white">www.optimad.it</span></a></span><u></u><u></u></p>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a>>
<br>
<b>Sent:</b> martedì 7 dicembre 2021 19:36<br>
<b>To:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" rel="noreferrer">knepley@gmail.com</a>><br>
<b>Cc:</b> petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="noreferrer">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-users] Nullspaces<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal" style="background:white">
<span style="color:#212121">I will, as soon as possible...</span><u></u><u></u></p>
</div>
<div id="m_-7278557784837845280gmail-m_3341636103748299633gmail-m_-5975417477470143245gmail-m_-2794061875066224678ms-outlook-mobile-signature">
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">Scarica
<a href="https://aka.ms/AAb9ysg" target="_blank" rel="noreferrer">Outlook per Android</a><u></u><u></u></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="m_-7278557784837845280gmail-m_3341636103748299633gmail-m_-5975417477470143245gmail-m_-2794061875066224678divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" rel="noreferrer">knepley@gmail.com</a>><br>
<b>Sent:</b> Tuesday, December 7, 2021 7:25:43 PM<br>
<b>To:</b> Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a>><br>
<b>Cc:</b> petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="noreferrer">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-users] Nullspaces</span> <u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
</div>
<div>
<div>
<div>
<p class="MsoNormal">On Tue, Dec 7, 2021 at 11:19 AM Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a>> wrote:<u></u><u></u></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="IT">Good morning,</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">I’m still struggling with the Poisson equation with Neumann BCs.</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">I discretize the equation by finite volume method and I divide every line of the linear system by the volume of the cell. I could avoid this division, but I’m trying to understand.</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">My mesh is not uniform, i.e. cells have different volumes (it is an octree mesh).</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">Moreover, in my computational domain there are 2 separated sub-domains.</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">I build the null space and then I use MatNullSpaceTest to check it.</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB"> </span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">If I do this:</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">It works</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">This produces the normalized constant vector.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">If I do this:</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="FR">Vec nsp;</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="FR">VecDuplicate(m_rhs, &nsp);</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="FR">VecSet(nsp,1.0);</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="FR">VecNormalize(nsp, nullptr);</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, &nsp, &nullspace);</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">It does not work</span><u></u><u></u></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">This is also the normalized constant vector.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">So you are saying that these two vectors give different results with MatNullSpaceTest()?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Something must be wrong in the code. Can you send a minimal example of this? I will go<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">through and debug it.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> Matt<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">Probably, I have wrong expectations, but should not it be the same?</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB"> </span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">Thanks</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB"> </span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="IT">Marco Cisternino, PhD<br>
<a href="mailto:marco.cisternino@optimad.it" target="_blank" rel="noreferrer">marco.cisternino@optimad.it</a></span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">______________________</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">Optimad Engineering Srl</span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB">Via Bligny 5, </span><span lang="EN-GB" style="font-family:"Segoe UI",sans-serif;color:#201f1e;background:white">Torino, Italia.</span><span lang="EN-GB" style="font-family:"Segoe UI",sans-serif;color:#201f1e"><br>
<span style="background:white">+3901119719782</span><br>
</span><span lang="IT"><a href="http://www.optimad.it/" target="_blank" rel="noreferrer"><span lang="EN-GB" style="font-family:"Segoe UI",sans-serif;border:none windowtext 1.0pt;padding:0cm;background:white">www.optimad.it</span></a></span><u></u><u></u></p>
<p class="m_-7278557784837845280gmail-m3341636103748299633gmail-m-5975417477470143245gmail-m-2794061875066224678xmsonormal">
<span lang="EN-GB"> </span><u></u><u></u></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<p class="MsoNormal">--
<u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">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<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"> <u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" rel="noreferrer">https://www.cse.buffalo.edu/~knepley/</a><u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</blockquote></div></div></div>