[petsc-users] local/global DMPlex Vec output

Matthew Knepley knepley at gmail.com
Thu Oct 24 15:20:03 CDT 2024


I just looked at the code. The VTK code is very old, and does not check for
cell overlap.

We have been recommending that people use either HDF5 or CGNS, both of
which work in this case
I believe. I can fix VTK if that is what you want, but it might take me a
little while as it is very busy at
work right now. However, if you output HDF5, then you can run

  ./lib/petsc/bin/petsc_gen_xdmf.py mesh.h5

and it will generate an XDMF file so you can load it into ParaView. Or you
can output CGNS which I think
ParaView understands.

  Thanks,

     Matt

On Thu, Oct 24, 2024 at 4:02 PM Semplice Matteo <
matteo.semplice at uninsubria.it> wrote:

> Hi,
> I tried again today and have (re?)discovered this example
> https://urldefense.us/v3/__https://petsc.org/release/src/dm/impls/plex/tutorials/ex14.c.html__;!!G_uCfscf7eWS!djj05CUxAKqqqzrdcdpxybBp4r8LCeoh2YHKGXWZBrw8af69K7SN2w0jfqyuP3lDKjRWhw4qzK7MlWA5PAGG$ , but I
> cannot understand if in my case I should call PetscSFCreateSectionSF
> <https://urldefense.us/v3/__https://petsc.org/release/manualpages/PetscSF/PetscSFCreateSectionSF/__;!!G_uCfscf7eWS!djj05CUxAKqqqzrdcdpxybBp4r8LCeoh2YHKGXWZBrw8af69K7SN2w0jfqyuP3lDKjRWhw4qzK7MlU1YEd13$ > and,
> if so, how should I then activate the returned SF.
> Matteo
> ------------------------------
> *Da:* Semplice Matteo
> *Inviato:* martedì 22 ottobre 2024 00:24
> *A:* Matthew Knepley <knepley at gmail.com>
> *Cc:* PETSc <petsc-users at mcs.anl.gov>
> *Oggetto:* Re: [petsc-users] local/global DMPlex Vec output
>
>
> Dear Matt,
>
>     I guess you're right: thresholding by rank==0 and rank==1 in paraview
> reveals that it is indeed the overlap cells that are appear twice in the
> output.
>
> The attached file is not exactly minimal but hopefully short enough. If I
> run it in serial, all is ok, but with
>
>     mpirun -np 2 ./saveDemo
>
> it creates a 10x10 grid, but I get "output.vtu" with a total of 120 cells.
> However the pointSF of the DMPlex seems correct.
>
> Thanks
>
>     Matteo
> Il 21/10/24 19:15, Matthew Knepley ha scritto:
>
> On Mon, Oct 21, 2024 at 12:22 PM Matteo Semplice via petsc-users <
> petsc-users at mcs.anl.gov> wrote:
>
> Dear petsc-users,
>
>     I am having issues with output of parallel data attached to a DMPlex
> (or maybe more fundamental ones about DMPlex...).
>
> So I currently
>
>    1. create a DMPlex (DMPlexCreateGmshFromFile or DMPlexCreateBoxMesh)
>    2. partition it
>    3. and create a section for my data layout with
>    DMPlexCreateSection(ctx.dmMesh, NULL, numComp, numDof, numBC, NULL, NULL,
>    NULL, NULL, &sUavg)
>    4. DMSetLocalSection(ctx.dmMesh, sUavg)
>    5. create solLoc and solGlob vectors with DMCreateGlobalVector and
>    DMCreateLocalVector
>    6. solve ....
>    7. VecView(ctx.solGlob, vtkViewer) on a .vtu file
>
> but when I load data in ParaView I get more cells than expected and it is
> as if the cells in the halo are put twice in output. (I could create a MWE
> if the above is not clear)
>
> I think we need an MWE here, because from the explanation above, it should
> work.
>
> However, I can try to guess the problem. When you partition the mesh, I am
> guessing that you have cells in the overlap. These cells
> must be in the point SF in order for the global section to give them a
> unique owner. Perhaps something has gone wrong here.
>
>   Thanks,
>
>      Matt
>
> I guess that the culprit is point (4), but if I replace it with
> DMSetGlobalSection then I cannot create the local vector at point (5).
>
> How should I handle this properly? In my code I need to create both local
> and global vectors, to perform at least GlobalToLocal and to save the
> global data.
>
> (On a side note, I tried also HDF5 but then it complains about the DM not
> having a DS...; really, any working solution that allows data to be
> explored with Paraview is fine)
>
> Thanks for any advice!
>
> Matteo Semplice
>
>
>
> --
> 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://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!djj05CUxAKqqqzrdcdpxybBp4r8LCeoh2YHKGXWZBrw8af69K7SN2w0jfqyuP3lDKjRWhw4qzK7MlTV94teN$ 
> <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!djj05CUxAKqqqzrdcdpxybBp4r8LCeoh2YHKGXWZBrw8af69K7SN2w0jfqyuP3lDKjRWhw4qzK7MldQcq8Tb$ >
>
> --
> ---
> Professore Associato in Analisi Numerica
> Dipartimento di Scienza e Alta Tecnologia
> Università degli Studi dell'Insubria
> Via Valleggio, 11 - Como
>
>

-- 
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://urldefense.us/v3/__https://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!djj05CUxAKqqqzrdcdpxybBp4r8LCeoh2YHKGXWZBrw8af69K7SN2w0jfqyuP3lDKjRWhw4qzK7MlTV94teN$  <https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!djj05CUxAKqqqzrdcdpxybBp4r8LCeoh2YHKGXWZBrw8af69K7SN2w0jfqyuP3lDKjRWhw4qzK7MldQcq8Tb$ >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20241024/1992a9ec/attachment-0001.html>


More information about the petsc-users mailing list