<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Segoe UI";
panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0cm;
margin-right:0cm;
margin-bottom:0cm;
margin-left:36.0pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
p.xmsonormal, li.xmsonormal, div.xmsonormal
{mso-style-name:x_msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.EmailStyle22
{mso-style-type:personal;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 2.0cm 2.0cm 2.0cm;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1318076265;
mso-list-type:hybrid;
mso-list-template-ids:1483896982 67698705 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-text:"%1\)";
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-18.0pt;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0cm;}
ul
{margin-bottom:0cm;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hello Matthew,<o:p></o:p></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.<o:p></o:p></p>
<p class="MsoNormal">What I did is to produce matrix, right hand side and initial solution of the linear system.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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.<o:p></o:p></p>
<p class="MsoNormal">This case has homogeneous Neumann boundary conditions. Computational domain has two independent and separated sub-domains.<o:p></o:p></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.<o:p></o:p></p>
<p class="MsoNormal">The underlying mesh is not uniform, therefore cells have different volumes.
<o:p></o:p></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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I usually build the null space sub-domain by sub-domain with<o:p></o:p></p>
<p class="MsoNormal" style="text-indent:36.0pt">MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, nConstants, constants, &nullspace);<o:p></o:p></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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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:<o:p></o:p></p>
<ol style="margin-top:0cm" start="1" type="1">
<li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1">MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);<o:p></o:p></li><li class="MsoListParagraph" style="margin-left:0cm;mso-list:l0 level1 lfo1">Vec* nsp;<o:p></o:p></li></ol>
<p class="MsoListParagraph">VecDuplicateVecs(solution, 1, &nsp);<o:p></o:p></p>
<p class="MsoListParagraph">VecSet(nsp[0],1.0);<o:p></o:p></p>
<p class="MsoListParagraph">VecNormalize(nsp[0], nullptr);<o:p></o:p></p>
<p class="MsoListParagraph">MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, nsp, &nullspace);<o:p></o:p></p>
<p class="MsoListParagraph"><o:p> </o:p></p>
<p class="MsoNormal" style="text-align:justify">Once I created the null space I test it using:<o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify;text-indent:36.0pt"><span lang="IT">MatNullSpaceTest(nullspace, m_A, &isNullSpaceValid);<o:p></o:p></span></p>
<p class="MsoNormal" style="text-align:justify"><span lang="IT"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-align:justify">The case 1 pass the test while case 2 don’t.<o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify"><o:p> </o:p></p>
<p class="MsoNormal" style="text-align:justify">I have a small code for matrix loading, null spaces creation and testing.<o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify">Unfortunately I cannot implement a small code able to produce that linear system.<o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify"><o:p> </o:p></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.<o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify">You can also find the testing code in the same archive.<o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify">I used petsc 3.12(gcc+openMPI) and petsc 3.15.2(intelOneAPI) same results.<o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify">If the attachment is not delivered, I can share a link to it.<o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify"><o:p> </o:p></p>
<p class="MsoNormal" style="text-align:justify">Thanks for any help.<o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify"><o:p> </o:p></p>
<p class="MsoNormal">Marco Cisternino <o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span lang="IT">Marco Cisternino, PhD<br>
<a href="mailto:marco.cisternino@optimad.it">marco.cisternino@optimad.it</a><o:p></o:p></span></p>
<p class="MsoNormal">______________________<o:p></o:p></p>
<p class="MsoNormal">Optimad Engineering Srl<o:p></o:p></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"><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><o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></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 <marco.cisternino@optimad.it> <br>
<b>Sent:</b> marted́ 7 dicembre 2021 19:36<br>
<b>To:</b> Matthew Knepley <knepley@gmail.com><br>
<b>Cc:</b> petsc-users <petsc-users@mcs.anl.gov><br>
<b>Subject:</b> Re: [petsc-users] Nullspaces<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="background:white"><span style="color:#212121">I will, as soon as possible...<o:p></o:p></span></p>
</div>
<div id="ms-outlook-mobile-signature">
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">Scarica <a href="https://aka.ms/AAb9ysg">Outlook per Android</a><o:p></o:p></p>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<p class="MsoNormal"><b><span style="color:black">From:</span></b><span style="color:black"> Matthew Knepley <<a href="mailto:knepley@gmail.com">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">marco.cisternino@optimad.it</a>><br>
<b>Cc:</b> petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b> Re: [petsc-users] Nullspaces</span> <o:p></o:p></p>
<div>
<p class="MsoNormal"> <o:p></o:p></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">marco.cisternino@optimad.it</a>> wrote:<o:p></o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="xmsonormal"><span lang="IT">Good morning,<o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">I’m still struggling with the Poisson equation with Neumann BCs.</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><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><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">My mesh is not uniform, i.e. cells have different volumes (it is an octree mesh).</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">Moreover, in my computational domain there are 2 separated sub-domains.</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">I build the null space and then I use MatNullSpaceTest to check it.</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB"> </span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">If I do this:</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">It works</span><span lang="IT"><o:p></o:p></span></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This produces the normalized constant vector.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="xmsonormal"><span lang="EN-GB">If I do this:</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="FR">Vec nsp;</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="FR">VecDuplicate(m_rhs, &nsp);</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="FR">VecSet(nsp,1.0);</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="FR">VecNormalize(nsp, nullptr);</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, &nsp, &nullspace);</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">It does not work</span><span lang="IT"><o:p></o:p></span></p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This is also the normalized constant vector.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">So you are saying that these two vectors give different results with MatNullSpaceTest()?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Something must be wrong in the code. Can you send a minimal example of this? I will go<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">through and debug it.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> Matt<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="xmsonormal"><span lang="EN-GB">Probably, I have wrong expectations, but should not it be the same?</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB"> </span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">Thanks</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB"> </span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="IT">Marco Cisternino, PhD<br>
<a href="mailto:marco.cisternino@optimad.it" target="_blank">marco.cisternino@optimad.it</a><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">______________________</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB">Optimad Engineering Srl</span><span lang="IT"><o:p></o:p></span></p>
<p class="xmsonormal"><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"><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><o:p></o:p></span></p>
<p class="xmsonormal"><span lang="EN-GB"> </span><span lang="IT"><o:p></o:p></span></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></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<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>