My comments are between Barry’s lines

Marco Cisternino

From: Barry Smith <bsm...@petsc.dev>
Sent: venerdì 24 dicembre 2021 23:57
To: Marco Cisternino <marco.cistern...@optimad.it>
Cc: Matthew Knepley <knep...@gmail.com>; petsc-users <petsc-users@mcs.anl.gov>
Subject: Re: [petsc-users] Nullspaces


   I tried your code but it appears the ./gyroid_solution.txt contains a vector 
of all zeros. Is this intended?

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.
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.

   Actually VecDuplicateVecs() does not copy the values in the vector so your 
nsp[0] will contain the zero vector anyways.

I know, that’s why there is a VecSet on nsp Vec. Is it not correct? It should 
be a Vec of 1s …

  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.

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.

  Barry

Thank you, Barry. As soon as the issue Matthew noted is understood, I will come 
back to the 2-dimensional null space.


On Dec 16, 2021, at 11:09 AM, Marco Cisternino 
<marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>> wrote:

Hello Matthew,
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.
What I did is to produce matrix, right hand side and initial solution of the 
linear system.

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.
This case has homogeneous Neumann boundary conditions. Computational domain has 
two independent and separated sub-domains.
I discretize the weak formulation and I divide every row of the linear system 
by the volume of the relative cell.
The underlying mesh is not uniform, therefore cells have different volumes.
The issue I’m going to explain does not show up if the mesh is uniform, same 
volume for all the cells.

I usually build the null space sub-domain by sub-domain with
MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, nConstants, constants, 
&nullspace);
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.

However, as a test I tried the constant over the whole domain using 2 
alternatives that should produce the same null space:

  1.  MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);
  2.  Vec* nsp;
VecDuplicateVecs(solution, 1, &nsp);
VecSet(nsp[0],1.0);
VecNormalize(nsp[0], nullptr);
MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, nsp, &nullspace);

Once I created the null space I test it using:
MatNullSpaceTest(nullspace, m_A, &isNullSpaceValid);

The case 1 pass the test while case 2 don’t.

I have a small code for matrix loading, null spaces creation and testing.
Unfortunately I cannot implement a small code able to produce that linear 
system.

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.
You can also find the testing code in the same archive.
I used petsc 3.12(gcc+openMPI) and petsc 3.15.2(intelOneAPI) same results.
If the attachment is not delivered, I can share a link to it.

Thanks for any help.

Marco Cisternino


Marco Cisternino, PhD
marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>
______________________
Optimad Engineering Srl
Via Bligny 5, Torino, Italia.
+3901119719782
www.optimad.it<http://www.optimad.it/>

From: Marco Cisternino 
<marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>>
Sent: martedì 7 dicembre 2021 19:36
To: Matthew Knepley <knep...@gmail.com<mailto:knep...@gmail.com>>
Cc: petsc-users <petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] Nullspaces

I will, as soon as possible...

Scarica Outlook per Android<https://aka.ms/AAb9ysg>
________________________________
From: Matthew Knepley <knep...@gmail.com<mailto:knep...@gmail.com>>
Sent: Tuesday, December 7, 2021 7:25:43 PM
To: Marco Cisternino 
<marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>>
Cc: petsc-users <petsc-users@mcs.anl.gov<mailto:petsc-users@mcs.anl.gov>>
Subject: Re: [petsc-users] Nullspaces

On Tue, Dec 7, 2021 at 11:19 AM Marco Cisternino 
<marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>> wrote:

Good morning,

I’m still struggling with the Poisson equation with Neumann BCs.

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.

My mesh is not uniform, i.e. cells have different volumes (it is an octree 
mesh).

Moreover, in my computational domain there are 2 separated sub-domains.

I build the null space and then I use MatNullSpaceTest to check it.



If I do this:

MatNullSpaceCreate(getCommunicator(), PETSC_TRUE, 0, nullptr, &nullspace);

It works

This produces the normalized constant vector.


If I do this:

Vec nsp;

VecDuplicate(m_rhs, &nsp);

VecSet(nsp,1.0);

VecNormalize(nsp, nullptr);

MatNullSpaceCreate(getCommunicator(), PETSC_FALSE, 1, &nsp, &nullspace);

It does not work

This is also the normalized constant vector.

So you are saying that these two vectors give different results with 
MatNullSpaceTest()?
Something must be wrong in the code. Can you send a minimal example of this? I 
will go
through and debug it.

  Thanks,

     Matt


Probably, I have wrong expectations, but should not it be the same?



Thanks



Marco Cisternino, PhD
marco.cistern...@optimad.it<mailto:marco.cistern...@optimad.it>

______________________

Optimad Engineering Srl

Via Bligny 5, Torino, Italia.
+3901119719782
www.optimad.it<http://www.optimad.it/>




--
What most experimenters take for granted before they begin their experiments is 
infinitely more interesting than any results to which their experiments lead.
-- Norbert Wiener

https://www.cse.buffalo.edu/~knepley/<http://www.cse.buffalo.edu/~knepley/>
<nullspaceTest.tar.gz>

Reply via email to