[petsc-users] How to output VTK file with Vec associating with DMPLEX

Tsung-Hsing Chen barrydog505 at gmail.com
Sun Dec 9 19:47:23 CST 2018


Oh! I see.
I don't know it can be created like this.
I will try it. :)

Thanks,
Barry

Matthew Knepley <knepley at gmail.com> 於 2018年12月10日 週一 上午9:31寫道:

> On Sun, Dec 9, 2018 at 7:47 PM Tsung-Hsing Chen <barrydog505 at gmail.com>
> wrote:
>
>> So I need to manually create a PetscSection by using
>> DMPlexCreateSection().
>> Am I right?
>>
>
> No, you create it directly
>
> DMPlexGetDepthStratum(dm, 0, &vStart, &vEnd);
> PetscSectionCreate(PETSC_COMM_SELF, &s)
> for (v = vStart; v < vEnd; ++v) {
>   PetscSectionSetDof(s, v, 1);
> }
> DMSetSection(dm, s);
> PetscSectionDestroy(&s);
>
>    Matt
>
>
>> Thanks,
>> Barry
>>
>> Matthew Knepley <knepley at gmail.com> 於 2018年12月10日 週一 上午8:40寫道:
>>
>>> On Sun, Dec 9, 2018 at 7:31 PM Tsung-Hsing Chen <barrydog505 at gmail.com>
>>> wrote:
>>>
>>>> Vertex-based is what I want.
>>>> Here I don't think I have created any PetscSection yet.
>>>> Do I need to create the PetscSection,
>>>>
>>>
>>> Yes. There is a manual chapter with this in it.
>>>
>>>
>>>> if I already have a mesh file from gmsh?
>>>>
>>>
>>> That is just topology and geometry. It says nothing about data layout.
>>>
>>>
>>>> or just I simply use DMPlexGetConeSection() to get vertex-based vector?
>>>>
>>>
>>> That is a Section which describes the layout of topology data.
>>>
>>>   Thanks,
>>>
>>>      Matt
>>>
>>>
>>>> Thanks,
>>>> Barry
>>>>
>>>>
>>>> Matthew Knepley <knepley at gmail.com> 於 2018年12月10日 週一 上午7:27寫道:
>>>>
>>>>> On Sun, Dec 9, 2018 at 5:47 PM Tsung-Hsing Chen via petsc-users <
>>>>> petsc-users at mcs.anl.gov> wrote:
>>>>>
>>>>>> Hi,
>>>>>> I want to output a VTK file containing Vec which associate with
>>>>>> DMPLEX, but I keep getting some errors.
>>>>>>
>>>>>
>>>>> The really easy way is to put
>>>>>
>>>>>   ierr = VecViewFromOptions(x, NULL, "-myvec_view");CHKERRQ(ierr);
>>>>>
>>>>> in your code and then give
>>>>>
>>>>>   -myvec_view vtk:sol.vtk
>>>>>
>>>>> on the command line.
>>>>>
>>>>>
>>>>>> I use PetscViewerVTKOpen() to create the vtk file.
>>>>>> Then I saw many examples just use DMCreateGlobalVector() to create
>>>>>> the Vec associate with DM.
>>>>>> However, almost all of them aren't DMPLEX but are DMDA.
>>>>>> I don't know whether it will cause some problems.
>>>>>> These is what I write:
>>>>>>
>>>>>
>>>>> 1) ALWAYS check return values. Your VecSetValue is failing.
>>>>>
>>>>> 2) VTK can only display two kinds of information, vertex-based and
>>>>> cell-based. DMDA only allows vertex based
>>>>>     information in Vecs. Since DMPLEX allows any kind of distribution,
>>>>> when we output VTK we need to determine
>>>>>     what kind of vector we have, vertex-based or cell-based. Here I
>>>>> cannot determine it, probably because your
>>>>>     PetscSection is not setup correctly. How is data supposed to be
>>>>> laid out on the Plex?
>>>>>
>>>>>   Thanks,
>>>>>
>>>>>      Matt
>>>>>
>>>>>
>>>>>>   PetscViewerCreate(PETSC_COMM_WORLD, &viewer);
>>>>>>   PetscViewerVTKOpen(PETSC_COMM_WORLD, "vtk_output_test.vtk",
>>>>>> FILE_MODE_WRITE, &viewer);
>>>>>>   DMCreateGlobalVector(dm, &x);
>>>>>>   VecSetValue();   //Set value for x
>>>>>>   VecView(x, viewer);
>>>>>>
>>>>>> Here is the error output:
>>>>>> [0]PETSC ERROR: --------------------- Error Message
>>>>>> --------------------------------------------------------------
>>>>>> [0]PETSC ERROR: Argument out of range
>>>>>> [0]PETSC ERROR: Out of range index value 1 maximum 0
>>>>>> [0]PETSC ERROR: See
>>>>>> http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble
>>>>>> shooting.
>>>>>> [0]PETSC ERROR: Petsc Release Version 3.10.2, unknown
>>>>>> [0]PETSC ERROR: ./test3 on a arch-linux2-c-debug named
>>>>>> barry-PhysioMech by barry Mon Dec 10 05:52:19 2018
>>>>>> [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++
>>>>>> --with-fc=gfortran --download-mpich --download-fblaslapack --download-mumps
>>>>>> --download-scalapack --download-ctetgen
>>>>>> [0]PETSC ERROR: #3 VecSetValues_Seq() line 726 in
>>>>>> /home/barry/petsc/src/vec/vec/impls/seq/bvec2.c
>>>>>> [0]PETSC ERROR: #4 VecSetValues() line 856 in
>>>>>> /home/barry/petsc/src/vec/vec/interface/rvector.c
>>>>>>
>>>>>> [0]PETSC ERROR: --------------------- Error Message
>>>>>> --------------------------------------------------------------
>>>>>> [0]PETSC ERROR: Invalid argument
>>>>>> [0]PETSC ERROR: Could not classify input Vec for VTK
>>>>>> [0]PETSC ERROR: See
>>>>>> http://www.mcs.anl.gov/petsc/documentation/faq.html for trouble
>>>>>> shooting.
>>>>>> [0]PETSC ERROR: Petsc Release Version 3.10.2, unknown
>>>>>> [0]PETSC ERROR: ./test3 on a arch-linux2-c-debug named
>>>>>> barry-PhysioMech by barry Mon Dec 10 05:52:19 2018
>>>>>> [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++
>>>>>> --with-fc=gfortran --download-mpich --download-fblaslapack --download-mumps
>>>>>> --download-scalapack --download-ctetgen
>>>>>> [0]PETSC ERROR: #17 DMPlexGetFieldType_Internal() line 134 in
>>>>>> /home/barry/petsc/src/dm/impls/plex/plex.c
>>>>>> [0]PETSC ERROR: #18 VecView_Plex_Local_VTK() line 294 in
>>>>>> /home/barry/petsc/src/dm/impls/plex/plex.c
>>>>>> [0]PETSC ERROR: #19 VecView_Plex_Local() line 335 in
>>>>>> /home/barry/petsc/src/dm/impls/plex/plex.c
>>>>>> [0]PETSC ERROR: #20 VecView_Plex() line 382 in
>>>>>> /home/barry/petsc/src/dm/impls/plex/plex.c
>>>>>> [0]PETSC ERROR: #21 VecView() line 590 in
>>>>>> /home/barry/petsc/src/vec/vec/interface/vector.c
>>>>>>
>>>>>> I think the first part of the error comes from VecSetValue(), but I
>>>>>> don't know how to fix it.
>>>>>> And I totally don't know what its mean in the second part of the
>>>>>> error.
>>>>>>
>>>>>> Thank you,
>>>>>> Barry
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> 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/>
>>>>>
>>>>
>>>
>>> --
>>> 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/>
>>>
>>
>
> --
> 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/>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181210/1cf8dd39/attachment.html>


More information about the petsc-users mailing list