<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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;
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.apple-converted-space
{mso-style-name:apple-converted-space;}
p.xmsonormal, li.xmsonormal, div.xmsonormal
{mso-style-name:xmsonormal;
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.EmailStyle21
{mso-style-type:personal-reply;
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:802385814;
mso-list-template-ids:1574180180;}
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">My comments are between Barry’s lines<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span lang="IT">Marco Cisternino</span><span lang="IT"> </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> Barry Smith <bsmith@petsc.dev> <br>
<b>Sent:</b> venerdì 24 dicembre 2021 23:57<br>
<b>To:</b> Marco Cisternino <marco.cisternino@optimad.it><br>
<b>Cc:</b> Matthew Knepley <knepley@gmail.com>; 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"><o:p> </o:p></p>
</div>
<p class="MsoNormal"> I tried your code but it appears the ./gyroid_solution.txt contains a vector of all zeros. Is this intended?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Yes it is, it should be the initial guess and not the solution of the linear system. It is read just to build a null space vector of the right size in case 2.<o:p></o:p></p>
<p class="MsoNormal">However, the purpose here is not to solve the linear system but to understand why the constant null space is working (it passes the MatNullSpaceTest) in case 1 and it is not working in case 2. That was what Matthew asked me in his last
message to this thread.<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> Actually VecDuplicateVecs() does not copy the values in the vector so your nsp[0] will contain the zero vector anyways.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I know, that’s why there is a VecSet on nsp Vec. Is it not correct? It should be a Vec of 1s …<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> Would you be able to send the data that indicates what rows of the vector are associated with each subdomain? For example a vector with all 1s on the first domain and all 2s on the second domain? I think with this one should be able
to construct the 2 dimensional null space.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I would, but again the case was meant to test the two ways of building the constant null space. The idea is to understand why case 1 passes the MatNullSpaceTest and case 2 doesn’t.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"> Barry<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thank you, Barry. As soon as the issue Matthew noted is understood, I will come back to the 2-dimensional null space.<o:p></o:p></p>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Dec 16, 2021, at 11:09 AM, Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it">marco.cisternino@optimad.it</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hello Matthew,<o:p></o:p></p>
</div>
<div>
<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>
</div>
<div>
<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>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<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>
</div>
<div>
<p class="MsoNormal">This case has homogeneous Neumann boundary conditions. Computational domain has two independent and separated sub-domains.<o:p></o:p></p>
</div>
<div>
<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>
</div>
<div>
<p class="MsoNormal">The underlying mesh is not uniform, therefore cells have different volumes.<o:p></o:p></p>
</div>
<div>
<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>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">I usually build the null space sub-domain by sub-domain with<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="text-indent:36.0pt">MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, nConstants, constants, &nullspace);<o:p></o:p></p>
</div>
<div>
<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>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<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>
</div>
<ol style="margin-top:0cm" start="1" type="1">
<li class="MsoListParagraph" style="margin-top:0cm;margin-bottom:0cm;mso-list:l0 level1 lfo1">
MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);<o:p></o:p></li><li class="MsoListParagraph" style="margin-top:0cm;margin-bottom:0cm;mso-list:l0 level1 lfo1">
Vec* nsp;<o:p></o:p></li></ol>
<div style="margin-left:36.0pt">
<p class="MsoNormal">VecDuplicateVecs(solution, 1, &nsp);<o:p></o:p></p>
</div>
<div style="margin-left:36.0pt">
<p class="MsoNormal">VecSet(nsp[0],1.0);<o:p></o:p></p>
</div>
<div style="margin-left:36.0pt">
<p class="MsoNormal">VecNormalize(nsp[0], nullptr);<o:p></o:p></p>
</div>
<div style="margin-left:36.0pt">
<p class="MsoNormal">MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, nsp, &nullspace);<o:p></o:p></p>
</div>
<div style="margin-left:36.0pt">
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<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);</span><o:p></o:p></p>
<p class="MsoNormal" style="text-align:justify"><span lang="IT"> </span><o:p></o:p></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>
<div>
<p class="MsoNormal">Marco Cisternino<span class="apple-converted-space"> </span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><span lang="IT">Marco Cisternino, PhD<br>
<a href="mailto:marco.cisternino@optimad.it">marco.cisternino@optimad.it</a></span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">______________________<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Optimad Engineering Srl<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Via Bligny 5,<span class="apple-converted-space"> </span><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>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<div>
<p class="MsoNormal"><b>From:</b><span class="apple-converted-space"> </span>Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it">marco.cisternino@optimad.it</a>><span class="apple-converted-space"> </span><br>
<b>Sent:</b><span class="apple-converted-space"> </span>martedì 7 dicembre 2021 19:36<br>
<b>To:</b><span class="apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>><br>
<b>Cc:</b><span class="apple-converted-space"> </span>petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="apple-converted-space"> </span>Re: [petsc-users] Nullspaces<o:p></o:p></p>
</div>
</div>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal" style="background:white"><span style="color:#212121">I will, as soon as possible...</span><o:p></o:p></p>
</div>
</div>
<div id="ms-outlook-mobile-signature">
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal">Scarica<span class="apple-converted-space"> </span><a href="https://aka.ms/AAb9ysg">Outlook per Android</a><o:p></o:p></p>
</div>
</div>
<div class="MsoNormal" align="center" style="text-align:center">
<hr size="2" width="98%" align="center">
</div>
<div id="divRplyFwdMsg">
<div>
<p class="MsoNormal"><b>From:</b><span class="apple-converted-space"> </span>Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>><br>
<b>Sent:</b><span class="apple-converted-space"> </span>Tuesday, December 7, 2021 7:25:43 PM<br>
<b>To:</b><span class="apple-converted-space"> </span>Marco Cisternino <<a href="mailto:marco.cisternino@optimad.it">marco.cisternino@optimad.it</a>><br>
<b>Cc:</b><span class="apple-converted-space"> </span>petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>><br>
<b>Subject:</b><span class="apple-converted-space"> </span>Re: [petsc-users] Nullspaces<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
</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>
<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="xmsonormal"><span lang="IT">Good morning,</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">I’m still struggling with the Poisson equation with Neumann BCs.</span><o:p></o:p></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><o:p></o:p></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><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">Moreover, in my computational domain there are 2 separated sub-domains.</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">I build the null space and then I use MatNullSpaceTest to check it.</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">If I do this:</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">It works</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">This produces the normalized constant vector.<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <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-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="xmsonormal"><span lang="EN-GB">If I do this:</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="FR">Vec nsp;</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="FR">VecDuplicate(m_rhs, &nsp);</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="FR">VecSet(nsp,1.0);</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="FR">VecNormalize(nsp, nullptr);</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, &nsp, &nullspace);</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">It does not work</span><o:p></o:p></p>
</div>
</div>
</blockquote>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal">This is also the normalized constant vector.<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<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>
<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>
<div>
<div>
<p class="MsoNormal">through and debug it.<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> Thanks,<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> Matt<o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal"> <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-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<div>
<div>
<p class="xmsonormal"><span lang="EN-GB">Probably, I have wrong expectations, but should not it be the same?</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB"> </span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">Thanks</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB"> </span><o:p></o:p></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></span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">______________________</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">Optimad Engineering Srl</span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB">Via Bligny 5,<span class="apple-converted-space"> </span></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></span><o:p></o:p></p>
<p class="xmsonormal"><span lang="EN-GB"> </span><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal">--<span class="apple-converted-space"> </span><o:p></o:p></p>
</div>
<div>
<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>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<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>
<p class="MsoNormal"><nullspaceTest.tar.gz><o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>