<div dir="ltr">Can you just send your GMsh file so I can see what you are asking for?<div><br></div><div>Also, Plex stores hexes with outward normals, but some other programs store them with some inward normals. This</div><div>should be converted in the output. I can check this if you send your mesh.<br><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 12, 2022 at 10:48 AM Sami BEN ELHAJ SALAH <<a href="mailto:sami.ben-elhaj-salah@ensma.fr">sami.ben-elhaj-salah@ensma.fr</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 style="overflow-wrap: break-word;">Dear Matthew and Jed,<div>













<p class="MsoNormal"><span lang="EN-US">Thank you very much for
explaining and your help. </span>I am sorry for my late reply. </p><div>For me, the .vtu file is wrong when the <AppendedData> section seems to be not correct (I mean the raw encoding because when I visualize the .vtu file on paraview, the geometry is not good). The header is OK (see attached file). To generate the vtu file, I use the routine suggested by Matthew and the commande line proposed by Jed (-dm_plex_filename 2C3D8_msh.msh -dm_view vtk:2C3D8_msh.vtu).</div><div><br></div><div>On the other hand,  when I use the routine below and write my output to a vtk file and not vtu, the result is ok except the rotation of the elements nodes (the nodes rotation is not good for me and not saved comparing to gmsh file). </div><div><br></div><div><pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono",monospace">PetscViewer vtk<span style="color:rgb(204,120,50)">;<br></span>PetscViewerVTKOpen(FOX::Parallel::COMM_WORLD<span style="color:rgb(204,120,50)">,</span><span style="color:rgb(106,135,89)">"solution.vtk"</span><span style="color:rgb(204,120,50)">,</span>FILE_MODE_WRITE<span style="color:rgb(204,120,50)">,</span>&vtk)<span style="color:rgb(204,120,50)">;<br></span>VecView(solution<span style="color:rgb(204,120,50)">,</span>vtk)<span style="color:rgb(204,120,50)">;<br></span>PetscViewerDestroy(&vtk)<span style="color:rgb(204,120,50)">;</span></pre><div>I put here an example of a vtk file that I have generated </div></div><div><pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono",monospace"># vtk DataFile Version 2.0<br>Simplicial Mesh Example<br>ASCII<br>DATASET UNSTRUCTURED_GRID<br>POINTS 12 double<br>0.000000e+00 1.000000e+01 1.000000e+01<br>0.000000e+00 0.000000e+00 1.000000e+01<br>0.000000e+00 0.000000e+00 0.000000e+00<br>0.000000e+00 1.000000e+01 0.000000e+00<br>1.000000e+01 1.000000e+01 1.000000e+01<br>1.000000e+01 0.000000e+00 1.000000e+01<br>1.000000e+01 0.000000e+00 0.000000e+00<br>1.000000e+01 1.000000e+01 0.000000e+00<br>2.000000e+01 1.000000e+01 1.000000e+01<br>2.000000e+01 0.000000e+00 1.000000e+01<br>2.000000e+01 0.000000e+00 0.000000e+00<br>2.000000e+01 1.000000e+01 0.000000e+00<br>CELLS 2 18<br>8  0 3 2 1 4 5 6 7<br>8  4 7 6 5 8 9 10 11<br>CELL_TYPES 2<br>12<br>12<br>POINT_DATA 12<br>VECTORS dU_x double<br>2.754808e-10 -8.653846e-11 -8.653846e-11<br>2.754808e-10 8.653846e-11 -8.653846e-11<br>2.754808e-10 8.653846e-11 8.653846e-11<br>2.754808e-10 -8.653846e-11 8.653846e-11<br>4.678571e-01 -9.107143e-02 -9.107143e-02<br>4.678571e-01 9.107143e-02 -9.107143e-02<br>4.678571e-01 9.107143e-02 9.107143e-02<br>4.678571e-01 -9.107143e-02 9.107143e-02<br>1.000000e+00 -7.500000e-02 -7.500000e-02<br>1.000000e+00 7.500000e-02 -7.500000e-02<br>1.000000e+00 7.500000e-02 7.500000e-02<br>1.000000e+00 -7.500000e-02 7.500000e-02</pre><div><br></div></div><div><div>To obtain the good geometry, the two lines </div><div><pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono",monospace">8  0 3 2 1 4 5 6 7<br>8  4 7 6 5 8 9 10 11</pre><div> Should be like this in order to have a good geometry defined in the gmsh file.</div></div><div><pre style="background-color:rgb(43,43,43);color:rgb(169,183,198);font-family:"JetBrains Mono",monospace">8  0 1 2 3 4 5 6 7<br>8  4 5 6 7 8 9 10 11</pre></div></div><div><br></div><div>- - - > So I m trying now to compile my code with petsc 3.16, may be it solves the problem of the rotation order of nodes.</div><div><br></div><div>Thank you and have a good day,</div><div><br></div><div>Sami,</div><div></div></div></div><div style="overflow-wrap: break-word;"><div><div></div><div><br></div>

<div>
<div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">--</div><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">Dr. Sami BEN ELHAJ SALAH<br>Ingénieur de Recherche (CNRS)<br>Institut Pprime - ISAE - ENSMA<br>Mobile: 06.62.51.26.74<br><a href="mailto:sami.ben-elhaj-salah@ensma.fr" target="_blank">Email: sami.ben-elhaj-salah@ensma.fr</a></div><div dir="auto" style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><a href="https://samiben91.github.io/samibenelhajsalah/index.html" target="_blank">www.samibenelhajsalah.com</a><br><br><br></div></div></div></div>
</div>
<div><br><blockquote type="cite"><div>Le 8 juin 2022 à 17:57, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> a écrit :</div><br><div><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="ltr">On Wed, Jun 8, 2022 at 11:24 AM Sami BEN ELHAJ SALAH <<a href="mailto:sami.ben-elhaj-salah@ensma.fr" target="_blank">sami.ben-elhaj-salah@ensma.fr</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div>Yes, the file "sami.vtu" is loaded correctly in paraview and I have the good output like you.<div><br></div><div>In my code, I tried with the same command given in your last answer and I still have the wrong .vtu file.</div></div></blockquote><div><br></div><div>Hi Sami,</div><div><br></div><div>What do you mean by wrong?</div><div><br></div><div>Can you just use the simple procedure:</div><div><br></div><div>  PetscCall(DMCreate(comm, dm));<br>  PetscCall(DMSetType(*dm, DMPLEX));<br>  PetscCall(DMSetFromOptions(*dm));<br>  PetscCall(DMViewFromOptions(*dm, NULL, "-dm_view"));<br></div><div><br></div><div>This is the one that works for us. Then we can change it in your code one step at a time until you get what you need.</div><div><br></div><div>  Thanks,</div><div><br></div><div>    Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>I use this:<br><div>mpirun -np 1 /home/benelhasa/fox_petsc/build_test/bin/Debug/FoXtroT -snes_test_jacobian_view -snes_converged_reason -snes_monitor -ksp_monitor -ksp_xmonitor -dm_plex_filename cub_2C3D8_msh.msh -dm_view vtk:cub_2C3D8_msh.vtu cub_8C3D8.fxt</div><div><br></div><div><br></div><div>Thanks,</div><div>Sami,</div><div><br><div><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">--</div><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">Dr. Sami BEN ELHAJ SALAH<br>Ingénieur de Recherche (CNRS)<br>Institut Pprime - ISAE - ENSMA<br>Mobile: 06.62.51.26.74<br><a href="mailto:sami.ben-elhaj-salah@ensma.fr" target="_blank">Email: sami.ben-elhaj-salah@ensma.fr</a></div><div dir="auto" style="letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><a href="https://samiben91.github.io/samibenelhajsalah/index.html" target="_blank">www.samibenelhajsalah.com</a><br><br><br></div></div></div></div></div><div><br><blockquote type="cite"><div>Le 8 juin 2022 à 16:25, Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> a écrit :</div><br><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Does the file load in paraview? When I load your *.msh in a tutorial with -dm_plex_filename sami.msh -dm_view vtk:sami.vtu, I get this good output.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span id="gmail-m_8448251039212919971gmail-m_2080728392201155584cid:9141E41F-766F-4335-99D2-04F631D6CB6F"><sami.vtu></span><span id="gmail-m_8448251039212919971gmail-m_2080728392201155584cid:0CECECD3-7616-4FB0-A886-99D8B7F7FC11"><sami.png></span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">Sami BEN ELHAJ SALAH <</span><a href="mailto:sami.ben-elhaj-salah@ensma.fr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">sami.ben-elhaj-salah@ensma.fr</a><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline">> writes:</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">Hi Jed,<br><br>Thank you for your answer.<br><br>When I use a ‘’solution.vtu'', I obtain a wrong file.<span> </span><br><br><?xml version="1.0"?><br><VTKFile type="UnstructuredGrid" version="0.1" byte_order="LittleEndian"><br><UnstructuredGrid><br><Piece NumberOfPoints="12" NumberOfCells="2"><br><Points><br><DataArray type="Float64" Name="Position" NumberOfComponents="3" format="appended" offset="0" /><br></Points><br><Cells><br><DataArray type="Int32" Name="connectivity" NumberOfComponents="1" format="appended" offset="292" /><br><DataArray type="Int32" Name="offsets" NumberOfComponents="1" format="appended" offset="360" /><br><DataArray type="UInt8" Name="types" NumberOfComponents="1" format="appended" offset="372" /><br></Cells><br><CellData><br><DataArray type="Int32" Name="Rank" NumberOfComponents="1" format="appended" offset="378" /><br></CellData><br><PointData><br><DataArray type="Float64" Name="dU_x(null)" NumberOfComponents="3" format="appended" offset="390" /><br></PointData><br></Piece><br></UnstructuredGrid><br><AppendedData encoding="raw"><br>_ $@$@$@$@$@$@$@$@$@$@$@$@4@$@$@4@$@4@4@$@@<span> </span><span> </span><span style="white-space:pre-wrap">     </span><br>�p�O��=��sT��׽��sT��׽�p�O��=��sT���=��sT��׽�p�O��=��sT���=��sT���=�p�O��=��sT��׽��sT���=o _��?�� uP���� uP��o _��?�� uP�?�� uP��o _��?�� uP�?�� uP�?o _��?�� uP���� uP�?b#�����?�333����333��_#�����?<span style="white-space:pre-wrap">   </span>�333�?��333��b#�����?(�333�?'�333�?a#�����?�333��>�333�?<br></AppendedData><br></VTKFile><br><br><br>If I understand your answer, to solve my problem, should just upgrade all my software ?<br><br>Thanks,<br>Sami,<br><br><br>--<br>Dr. Sami BEN ELHAJ SALAH<br>Ingénieur de Recherche (CNRS)<br>Institut Pprime - ISAE - ENSMA<br>Mobile: 06.62.51.26.74<br><a href="mailto:sami.ben-elhaj-salah@ensma.fr" target="_blank">Email: sami.ben-elhaj-salah@ensma.fr</a><br><a href="http://www.samibenelhajsalah.com/" target="_blank">www.samibenelhajsalah.com</a><span> </span><<a href="https://samiben91.github.io/samibenelhajsalah/index.html" target="_blank">https://samiben91.github.io/samibenelhajsalah/index.html</a>><br><br><br><br><blockquote type="cite">Le 8 juin 2022 à 15:37, Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank">jed@jedbrown.org</a>> a écrit :<br><br>You're using pretty old versions of all software; I'd recommend upgrading. I recommend choosing the file name "solution.vtu" to use the modern (non-legacy) format. Does that work for you?<br><br>Sami BEN ELHAJ SALAH <<a href="mailto:sami.ben-elhaj-salah@ensma.fr" target="_blank">sami.ben-elhaj-salah@ensma.fr</a>> writes:<br><br><blockquote type="cite">Dear Petsc Developer team,<br><br>I solved a linear elastic problem in 3D using a DMPLEX. My system is converging, then I would like to write out my solution vector to a vtk file where I use unstructured mesh. Currently, I tried two algorithms and I have the same result.<br><br>1) Algorithm 1<span> </span><br>err = SNESSolve(_snes, bc_vec_test, solution);<br>CHKERRABORT(FOX::Parallel::COMM_WORLD,err);<br>PetscViewer vtk;<span> </span><br>PetscViewerVTKOpen(FOX::Parallel::COMM_WORLD,"solution.vtk",FILE_MODE_WRITE,&vtk);<span> </span><br>VecView(solution,vtk);<br>PetscViewerDestroy(&vtk);<br><br><br>2) Algorithm 2<br>err = SNESSolve(_snes, bc_vec_test, solution);<br>CHKERRABORT(FOX::Parallel::COMM_WORLD,err);<br>PetscViewer vtk;<span> </span><br>PetscViewerCreate(FOX::Parallel::COMM_WORLD, &vtk);<span> </span><br>PetscViewerSetType(vtk, PETSCVIEWERVTK);<span> </span><br>PetscViewerFileSetName(vtk, "sol.vtk");<span> </span><br>VecView(solution, vtk);<span> </span><br>PetscViewerDestroy(&vtk);<br><br>The result seems correct except for the rotation order of the nodes (see the red lines on gmsh and vtk file respectively). Then, I visualized my vtk file with paraview, and I remarked that my geometry is not correct and not conserved when comparing it with my gmsh file. So, I didn’t understand why the rotation order of nodes is not conserved when saving my result to a vtk file?<br><br>Other information used:<br>- gmsh format 2.2<span> </span><br>- Vtk version: 7.1.1<br>- Petsc version: 3.13/opt<span> </span><br><br>Below my two files gmsh and vtk:<br><br>Gmsh file:<br>$MeshFormat<br>2.2 0 8<br>$EndMeshFormat<br>$Nodes<br>12<br>1 0.0 10.0 10.0<br>2 0.0 0.0 10.0<br>3 0.0 0.0 0.0<br>4 0.0 10.0 0.0<br>5 10.0 10.0 10.0<br>6 10.0 0.0 10.0<br>7 10.0 0.0 0.0<br>8 10.0 10.0 0.0<br>9 20.0 10.0 10.0<br>10 20.0 0.0 10.0<br>11 20.0 0.0 0.0<br>12 20.0 10.0 0.0<br>$EndNodes<br>$Elements<br>2<br>1 5 2 68 60 1 2 3 4 5 6 7 8<br>2 5 2 68 60 5 6 7 8 9 10 11 12<br>$EndElements<br><br>Vtk file :<br># vtk DataFile Version 2.0<br>Simplicial Mesh Example<br>ASCII<br>DATASET UNSTRUCTURED_GRID<br>POINTS 12 double<br>0.000000e+00 1.000000e+01 1.000000e+01<br>0.000000e+00 0.000000e+00 1.000000e+01<br>0.000000e+00 0.000000e+00 0.000000e+00<br>0.000000e+00 1.000000e+01 0.000000e+00<br>1.000000e+01 1.000000e+01 1.000000e+01<br>1.000000e+01 0.000000e+00 1.000000e+01<br>1.000000e+01 0.000000e+00 0.000000e+00<br>1.000000e+01 1.000000e+01 0.000000e+00<br>2.000000e+01 1.000000e+01 1.000000e+01<br>2.000000e+01 0.000000e+00 1.000000e+01<br>2.000000e+01 0.000000e+00 0.000000e+00<br>2.000000e+01 1.000000e+01 0.000000e+00<br>CELLS 2 18<br>8 0 3 2 1 4 5 6 7<br>8 4 7 6 5 8 9 10 11<br>CELL_TYPES 2<br>12<br>12<br>POINT_DATA 12<br>VECTORS dU_x double<br>2.754808e-10 -8.653846e-11 -8.653846e-11<br>2.754808e-10 8.653846e-11 -8.653846e-11<br>2.754808e-10 8.653846e-11 8.653846e-11<br>2.754808e-10 -8.653846e-11 8.653846e-11<br>4.678571e-01 -9.107143e-02 -9.107143e-02<br>4.678571e-01 9.107143e-02 -9.107143e-02<br>4.678571e-01 9.107143e-02 9.107143e-02<br>4.678571e-01 -9.107143e-02 9.107143e-02<br>1.000000e+00 -7.500000e-02 -7.500000e-02<br>1.000000e+00 7.500000e-02 -7.500000e-02<br>1.000000e+00 7.500000e-02 7.500000e-02<br>1.000000e+00 -7.500000e-02 7.500000e-02<br><br>Thank you in advance and have a good day !<br><br>Sami,<br><br>--<br>Dr. Sami BEN ELHAJ SALAH<br>Ingénieur de Recherche (CNRS)<br>Institut Pprime - ISAE - ENSMA<br>Mobile: 06.62.51.26.74<br>Email:<span> </span><a href="mailto:sami.ben-elhaj-salah@ensma.fr" target="_blank">sami.ben-elhaj-salah@ensma.fr</a><br><a href="http://www.samibenelhajsalah.com/" target="_blank">www.samibenelhajsalah.com</a><span> </span><<a href="https://samiben91.github.io/samibenelhajsalah/index.html" target="_blank">https://samiben91.github.io/samibenelhajsalah/index.html</a>></blockquote></blockquote></blockquote></div></blockquote></div><br></div></div></div></blockquote></div><br clear="all"><div><br></div>--<span> </span><br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a></div></div></div></div></div></div></div></div></div></blockquote></div><br></div></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>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</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div>