<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="moz-cite-prefix">On 29/11/2017 12:46, Matthew Knepley
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAMYG4GnsP76QOBGOxL0P7OCj4MOai3jpkHEdOtFeN4Rnsh_C4g@mail.gmail.com">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Wed, Nov 29, 2017 at 2:26 AM,
Matteo Semplice <span dir="ltr"><<a
href="mailto:matteo.semplice@unito.it" target="_blank"
moz-do-not-send="true">matteo.semplice@unito.it</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF"> On 25/11/2017 02:05, Matthew
Knepley wrote:<br>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Fri, Nov 24, 2017 at
4:21 PM, Matteo Semplice <span dir="ltr"><<a
href="mailto:matteo.semplice@unito.it"
target="_blank" moz-do-not-send="true">matteo.semplice@unito.it</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">Hi.<br>
<br>
The manual for DMCreateMatrix says "Notes:
This properly preallocates the number of
nonzeros in the sparse matrix so you do not
need to do it yourself", so I got the
impression that one does not need to call the
preallocation routine for the matrix and
indeed in most examples listed in the manual
page for DMCreateMatrix this is not done or
(KSP tutorial ex4) it is called declaring 0
entries per row.<br>
<br>
However, if read in a mesh in a DMPlex ore
create a DMDA and then call DMCreateMatrix,
the resulting matrix errors out when I call
MatSetValues. I have currently followed the
suggestion of the error message and call
MatSetOption(A, MAT_NEW_NONZERO_ALLOCATION_ERR<wbr>,
PETSC_FALSE), but I'd like to fix this
properly.<br>
</blockquote>
<div><br>
</div>
<div>It sounds like your nonzero pattern does
not obey the topology. What nonzero pattern
are you trying to input?</div>
</div>
</div>
</div>
</blockquote>
<br>
Hi.<br>
<br>
The problem with the DMDA was a bug in our code.
Sorry for the noise.<br>
<br>
On the other hand, with the DMPLex, I still experience
problems. It's a FV code and I reduced it to the case of
the simple case of a laplacian operator: I need
non-diagonal entries at (i,j) if cell i and cell j have
a common face. <br>
Here below is my code that reads in a grid of 4 cells
(unit square divided by the diagonals), create a section
with 1 dof per cell, creates a matrix and assembles it.</div>
</blockquote>
<blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left:1px solid
rgb(204,204,204);padding-left:1ex">
<div bgcolor="#FFFFFF"><tt><br>
</tt><tt> ierr = DMPlexCreateFromFile(PETSC_<wbr>COMM_WORLD,
"square1.msh", PETSC_TRUE, &dm);CHKERRQ(ierr);</tt></div>
</blockquote>
<div><br>
</div>
<div>Can you show me the mesh?</div>
<div><br>
</div>
<div> ierr = DMViewFromOptions(dm, NULL,
"-dm_view");CHKERRQ(ierr);</div>
<div><br>
</div>
<div>and then run with -dm_view ::ascii_info_detail</div>
<div><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 bgcolor="#FFFFFF"><tt><br>
</tt><tt> ierr = DMPlexSetAdjacencyUseCone(dm,
PETSC_TRUE); CHKERRQ(ierr);</tt><tt><br>
</tt><tt> ierr = DMPlexSetAdjacencyUseClosure(<wbr>dm,
PETSC_FALSE); CHKERRQ(ierr);</tt></div>
</blockquote>
<div><br>
</div>
<div>This looks like the right FVM adjacency, but your
matrix is diagonal it appears below. TS ex11</div>
<div>has an identical call, but produces the correct matrix,
which is why I want to look at your mesh.</div>
</div>
</div>
</div>
</blockquote>
<br>
I have put the DMViewFromOptions call after the SetAdjacency calls
and this is the output:<br>
<br>
<tt>matteo@signalkuppe:~/software/petscMplex$ ./mplexMatrix -dm_view
::ascii_info_detail</tt><tt><br>
</tt><tt>DM Object: 1 MPI processes</tt><tt><br>
</tt><tt> type: plex</tt><tt><br>
</tt><tt>Mesh 'DM_0x557496ad8380_0':</tt><tt><br>
</tt><tt>orientation is missing</tt><tt><br>
</tt><tt>cap --> base:</tt><tt><br>
</tt><tt>[0] Max sizes cone: 3 support: 4</tt><tt><br>
</tt><tt>[0]: 4 ----> 9</tt><tt><br>
</tt><tt>[0]: 4 ----> 11</tt><tt><br>
</tt><tt>[0]: 4 ----> 12</tt><tt><br>
</tt><tt>[0]: 5 ----> 10</tt><tt><br>
</tt><tt>[0]: 5 ----> 11</tt><tt><br>
</tt><tt>[0]: 5 ----> 15</tt><tt><br>
</tt><tt>[0]: 6 ----> 14</tt><tt><br>
</tt><tt>[0]: 6 ----> 15</tt><tt><br>
</tt><tt>[0]: 6 ----> 16</tt><tt><br>
</tt><tt>[0]: 7 ----> 12</tt><tt><br>
</tt><tt>[0]: 7 ----> 13</tt><tt><br>
</tt><tt>[0]: 7 ----> 16</tt><tt><br>
</tt><tt>[0]: 8 ----> 9</tt><tt><br>
</tt><tt>[0]: 8 ----> 10</tt><tt><br>
</tt><tt>[0]: 8 ----> 13</tt><tt><br>
</tt><tt>[0]: 8 ----> 14</tt><tt><br>
</tt><tt>[0]: 9 ----> 0</tt><tt><br>
</tt><tt>[0]: 9 ----> 1</tt><tt><br>
</tt><tt>[0]: 10 ----> 0</tt><tt><br>
</tt><tt>[0]: 10 ----> 2</tt><tt><br>
</tt><tt>[0]: 11 ----> 0</tt><tt><br>
</tt><tt>[0]: 12 ----> 1</tt><tt><br>
</tt><tt>[0]: 13 ----> 1</tt><tt><br>
</tt><tt>[0]: 13 ----> 3</tt><tt><br>
</tt><tt>[0]: 14 ----> 2</tt><tt><br>
</tt><tt>[0]: 14 ----> 3</tt><tt><br>
</tt><tt>[0]: 15 ----> 2</tt><tt><br>
</tt><tt>[0]: 16 ----> 3</tt><tt><br>
</tt><tt>base <-- cap:</tt><tt><br>
</tt><tt>[0]: 0 <---- 9 (0)</tt><tt><br>
</tt><tt>[0]: 0 <---- 10 (0)</tt><tt><br>
</tt><tt>[0]: 0 <---- 11 (0)</tt><tt><br>
</tt><tt>[0]: 1 <---- 12 (0)</tt><tt><br>
</tt><tt>[0]: 1 <---- 13 (0)</tt><tt><br>
</tt><tt>[0]: 1 <---- 9 (-2)</tt><tt><br>
</tt><tt>[0]: 2 <---- 10 (-2)</tt><tt><br>
</tt><tt>[0]: 2 <---- 14 (0)</tt><tt><br>
</tt><tt>[0]: 2 <---- 15 (0)</tt><tt><br>
</tt><tt>[0]: 3 <---- 14 (-2)</tt><tt><br>
</tt><tt>[0]: 3 <---- 13 (-2)</tt><tt><br>
</tt><tt>[0]: 3 <---- 16 (0)</tt><tt><br>
</tt><tt>[0]: 9 <---- 4 (0)</tt><tt><br>
</tt><tt>[0]: 9 <---- 8 (0)</tt><tt><br>
</tt><tt>[0]: 10 <---- 8 (0)</tt><tt><br>
</tt><tt>[0]: 10 <---- 5 (0)</tt><tt><br>
</tt><tt>[0]: 11 <---- 5 (0)</tt><tt><br>
</tt><tt>[0]: 11 <---- 4 (0)</tt><tt><br>
</tt><tt>[0]: 12 <---- 4 (0)</tt><tt><br>
</tt><tt>[0]: 12 <---- 7 (0)</tt><tt><br>
</tt><tt>[0]: 13 <---- 7 (0)</tt><tt><br>
</tt><tt>[0]: 13 <---- 8 (0)</tt><tt><br>
</tt><tt>[0]: 14 <---- 8 (0)</tt><tt><br>
</tt><tt>[0]: 14 <---- 6 (0)</tt><tt><br>
</tt><tt>[0]: 15 <---- 6 (0)</tt><tt><br>
</tt><tt>[0]: 15 <---- 5 (0)</tt><tt><br>
</tt><tt>[0]: 16 <---- 7 (0)</tt><tt><br>
</tt><tt>[0]: 16 <---- 6 (0)</tt><tt><br>
</tt><tt>coordinates with 1 fields</tt><tt><br>
</tt><tt> field 0 with 2 components</tt><tt><br>
</tt><tt>Process 0:</tt><tt><br>
</tt><tt> ( 4) dim 2 offset 0 0. 0.</tt><tt><br>
</tt><tt> ( 5) dim 2 offset 2 0. 1.</tt><tt><br>
</tt><tt> ( 6) dim 2 offset 4 1. 1.</tt><tt><br>
</tt><tt> ( 7) dim 2 offset 6 1. 0.</tt><tt><br>
</tt><tt> ( 8) dim 2 offset 8 0.5 0.5</tt><tt><br>
</tt><br>
For the records, the mesh is loaded from the (gmsh generated) file<br>
<br>
<tt>==== square1.msh =====</tt><tt><br>
</tt><tt>$MeshFormat</tt><tt><br>
</tt><tt>2.2 0 8</tt><tt><br>
</tt><tt>$EndMeshFormat</tt><tt><br>
</tt><tt>$Nodes</tt><tt><br>
</tt><tt>5</tt><tt><br>
</tt><tt>1 0 0 0</tt><tt><br>
</tt><tt>2 0 1 0</tt><tt><br>
</tt><tt>3 1 1 0</tt><tt><br>
</tt><tt>4 1 0 0</tt><tt><br>
</tt><tt>5 0.5 0.5 0</tt><tt><br>
</tt><tt>$EndNodes</tt><tt><br>
</tt><tt>$Elements</tt><tt><br>
</tt><tt>12</tt><tt><br>
</tt><tt>1 15 2 0 1 1</tt><tt><br>
</tt><tt>2 15 2 0 2 2</tt><tt><br>
</tt><tt>3 15 2 0 3 3</tt><tt><br>
</tt><tt>4 15 2 0 4 4</tt><tt><br>
</tt><tt>5 1 2 0 1 4 3</tt><tt><br>
</tt><tt>6 1 2 0 2 3 2</tt><tt><br>
</tt><tt>7 1 2 0 3 2 1</tt><tt><br>
</tt><tt>8 1 2 0 4 1 4</tt><tt><br>
</tt><tt>9 2 2 0 6 1 5 2</tt><tt><br>
</tt><tt>10 2 2 0 6 1 4 5</tt><tt><br>
</tt><tt>11 2 2 0 6 2 5 3</tt><tt><br>
</tt><tt>12 2 2 0 6 3 5 4</tt><tt><br>
</tt><tt>$EndElements</tt><tt><br>
</tt><tt>===================</tt><tt><br>
</tt><br>
Thanks,<br>
Matteo<br>
<br>
<br>
</body>
</html>