<div dir="ltr">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.<div><br><div>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.</div><div><div><br></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jan 3, 2022 at 4:42 AM Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it">marco.cisternino@optimad.it</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US" style="overflow-wrap: break-word;">
<div class="gmail-m_-5975417477470143245WordSection1">
<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><span lang="IT"> </span>
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">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">marco.cisternino@optimad.it</a>><br>
<b>Cc:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>>; petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">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">marco.cisternino@optimad.it</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<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:36pt">
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="gmail-m_-5975417477470143245gmail-m-2794061875066224678msolistparagraph">
MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);<u></u><u></u></li><li class="gmail-m_-5975417477470143245gmail-m-2794061875066224678msolistparagraph">
Vec* nsp;<u></u><u></u></li></ol>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678msolistparagraph">VecDuplicateVecs(solution, 1, &nsp);<u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678msolistparagraph">VecSet(nsp[0],1.0);<u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678msolistparagraph">VecNormalize(nsp[0], nullptr);<u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678msolistparagraph">MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, nsp, &nullspace);<u></u><u></u></p>
<p class="gmail-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:36pt">
<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">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:rgb(32,31,30);background:white">Torino, Italia.</span><span style="font-family:"Segoe UI",sans-serif;color:rgb(32,31,30)"><br>
<span style="background:white">+3901119719782</span><br>
</span><span lang="IT"><a href="http://www.optimad.it/" target="_blank"><span lang="EN-US" style="font-family:"Segoe UI",sans-serif;border:1pt none windowtext;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-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0cm 0cm">
<p class="MsoNormal"><b>From:</b> Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it" target="_blank">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">knepley@gmail.com</a>><br>
<b>Cc:</b> petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">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:rgb(33,33,33)">I will, as soon as possible...</span><u></u><u></u></p>
</div>
<div id="gmail-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">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="gmail-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">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">marco.cisternino@optimad.it</a>><br>
<b>Cc:</b> petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">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">marco.cisternino@optimad.it</a>> wrote:<u></u><u></u></p>
</div>
<div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="IT">Good morning,</span><u></u><u></u></p>
<p class="gmail-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="gmail-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="gmail-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="gmail-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="gmail-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="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB"> </span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB">If I do this:</span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB">MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);</span><u></u><u></u></p>
<p class="gmail-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-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB">If I do this:</span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="FR">Vec nsp;</span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="FR">VecDuplicate(m_rhs, &nsp);</span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="FR">VecSet(nsp,1.0);</span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="FR">VecNormalize(nsp, nullptr);</span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB">MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, &nsp, &nullspace);</span><u></u><u></u></p>
<p class="gmail-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-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin:5pt 0cm 5pt 4.8pt">
<div>
<div>
<p class="gmail-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="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB"> </span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB">Thanks</span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB"> </span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="IT">Marco Cisternino, PhD<br>
<a href="mailto:marco.cisternino@optimad.it" target="_blank">marco.cisternino@optimad.it</a></span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB">______________________</span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB">Optimad Engineering Srl</span><u></u><u></u></p>
<p class="gmail-m_-5975417477470143245gmail-m-2794061875066224678xmsonormal"><span lang="EN-GB">Via Bligny 5,
</span><span lang="EN-GB" style="font-family:"Segoe UI",sans-serif;color:rgb(32,31,30);background:white">Torino, Italia.</span><span lang="EN-GB" style="font-family:"Segoe UI",sans-serif;color:rgb(32,31,30)"><br>
<span style="background:white">+3901119719782</span><br>
</span><span lang="IT"><a href="http://www.optimad.it/" target="_blank"><span lang="EN-GB" style="font-family:"Segoe UI",sans-serif;border:1pt none windowtext;padding:0cm;background:white">www.optimad.it</span></a></span><u></u><u></u></p>
<p class="gmail-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">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>