[petsc-users] DMPlexSetRefinementFunction

David Fuentes fuentesdt at gmail.com
Sat Apr 13 08:29:41 CDT 2019


using this mesh sizing function defined on nodes of the background mesh was
the only way I could get it to work.

http://wias-berlin.de/software/tetgen/1.5/doc/manual/manual006.html#ff_mtr

On Sat, Apr 13, 2019 at 6:25 AM Matthew Knepley <knepley at gmail.com> wrote:

> On Sat, Apr 13, 2019 at 6:08 AM David Fuentes <fuentesdt at gmail.com> wrote:
>
>> this refinement seems to work pretty well for what I was looking for.
>> still testing... but tetgen seems to load these  background mesh files at
>> the higher resolution to guide the refinement?
>>
>
> Okay, I finally understand what the background mesh does. It gives the
> mesh sizing function.
>
>
>> $ tetgen -Vrmqk coarse.1.node
>> Opening coarse.1.node.
>> Opening coarse.1.ele.
>> Opening coarse.1.face.
>> Opening coarse.1.b.node.
>> Opening coarse.1.b.ele.
>> Opening coarse.1.b.mtr.
>>
>> do you think a reasonable approach would be for me work with two meshes
>> in petsc?
>>
>
> Sure, I can turn on that interface for you. I often have a few meshes in
> the code.
>
>
>> a coarse and fine mesh. and load a uniformly refined fine dmplex mesh as
>> the background mesh?
>>
>
> This is the only thing I dod not understand. If the background mesh is
> uniformly refined, can't you just
> use a cell volume limit? Maybe I am missing something in the terminology.
>
>    Matt
>
>
>
>>
>> https://bitbucket.org/petsc/ctetgen/src/8ca66eb7de95b82f7969984bab6aacada6626b1d/ctetgen.c?at=master&fileviewer=file-view-default#ctetgen.c-22245
>>
>> [image: Screen Shot 2019-04-13 at 4.50.06 AM.png]
>>
>> On Tue, Jan 8, 2019 at 11:29 AM David Fuentes <fuentesdt at gmail.com>
>> wrote:
>>
>>> sounds great! i've been working out of this guy -
>>> https://github.com/fuentesdt/thermoembo
>>>
>>> and loading vtk data for the segmentation:
>>> https://github.com/fuentesdt/thermoembo/blob/master/tutorials/exac.c#L50
>>>
>>> I can clean this up and separate into relevant directories ? or start an
>>> new repo? which ever you prefer.
>>>
>>>
>>>
>>> On Tue, Jan 8, 2019 at 11:20 AM Matthew Knepley <knepley at gmail.com>
>>> wrote:
>>>
>>>> On Mon, Jan 7, 2019 at 4:27 PM David Fuentes <fuentesdt at gmail.com>
>>>> wrote:
>>>>
>>>>> ha! thanks for you time on this Matt. I'm trying to generate a mesh
>>>>> from image segmentation data.
>>>>> I would like to use an image segmentation to guide the refinement.
>>>>> Figure 25 of this paper -
>>>>> https://www.ices.utexas.edu/media/reports/2017/1707.pdf
>>>>>
>>>>
>>>> Very cool. We can do that. Lets make an example and iterate. Want to
>>>> make a repo you control? I will
>>>> stick in a PETSc example that refines meshes (maybe Plex ex19), and we
>>>> can experiment with both p4est
>>>> and Pragmatic (installation of those is hardest part :) This sounds
>>>> great.
>>>>
>>>>    Matt
>>>>
>>>>
>>>>> On Mon, Jan 7, 2019 at 2:53 PM Matthew Knepley <knepley at gmail.com>
>>>>> wrote:
>>>>>
>>>>>> On Mon, Jan 7, 2019 at 11:41 AM David Fuentes <fuentesdt at gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>> thanks Matt,
>>>>>>>
>>>>>>> I posted a slightly modified example
>>>>>>>
>>>>>>> https://github.com/fuentesdt/dmplexrefinement/blob/master/ex45.c
>>>>>>>
>>>>>>> and changes from the orginal
>>>>>>>
>>>>>>>
>>>>>>> https://github.com/fuentesdt/dmplexrefinement/blob/master/refinement.diff
>>>>>>>
>>>>>>>
>>>>>>> This is what I'm seeing
>>>>>>>
>>>>>>>
>>>>>>> https://github.com/fuentesdt/dmplexrefinement/blob/master/paraview.png
>>>>>>>
>>>>>>>
>>>>>>> I'm refining based on this element centroid:
>>>>>>>
>>>>>>>
>>>>>>> https://github.com/fuentesdt/dmplexrefinement/blob/master/testcentroid.stl
>>>>>>>
>>>>>>> unrefined -
>>>>>>> https://github.com/fuentesdt/dmplexrefinement/blob/master/unrefined.vtu
>>>>>>>
>>>>>>> refined -
>>>>>>> https://github.com/fuentesdt/dmplexrefinement/blob/master/refined.vtu
>>>>>>>
>>>>>>>
>>>>>>> Maybe I don't understand the refinement algorithm, but the
>>>>>>> refinement is a little offset from what I was expecting.
>>>>>>>
>>>>>>
>>>>>> Okay, I have that working. I will make a branch and put this in it.
>>>>>> For right now, I attach ex45.c (but it will not run since I put in stuff to
>>>>>> take lower/upper from the command line). 3D refinement just sucks, but you
>>>>>> can see it is refining cell 7, not 8. Its just that refinement
>>>>>> propagates a long, long way.
>>>>>>
>>>>>> I have pretty much abandoned this type of refinement since it will
>>>>>> not work in parallel, and the mesh generator
>>>>>> interface is poor. I am transitioning everything to
>>>>>>
>>>>>>   - uniform refinement (ha!)
>>>>>>   - cell marking (p4est likes this)
>>>>>>   - metric tensor (Pragmatic likes this)
>>>>>>
>>>>>> I have some routines to convert marking <--> metric but they are not
>>>>>> perfect I think. I can try and help do what you want with
>>>>>> AMR if I have a better idea what it is.
>>>>>>
>>>>>>   Thanks,
>>>>>>
>>>>>>     Matt
>>>>>>
>>>>>>
>>>>>>>
>>>>>>> Also, can you pass an application context to the user refinement
>>>>>>> function ?
>>>>>>>
>>>>>>> https://github.com/fuentesdt/dmplexrefinement/blob/master/ex45.c#L119
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Jan 3, 2019 at 7:49 AM Matthew Knepley <knepley at gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> On Wed, Jan 2, 2019 at 7:28 PM David Fuentes via petsc-users <
>>>>>>>> petsc-users at mcs.anl.gov> wrote:
>>>>>>>>
>>>>>>>>> Hi,
>>>>>>>>>
>>>>>>>>> Starting with TS example 45
>>>>>>>>>
>>>>>>>>> $ pwd
>>>>>>>>> /opt/apps/PETSc/petsc-3.10.2
>>>>>>>>> $ ls src/ts/examples/tutorials/ex45.c
>>>>>>>>> src/ts/examples/tutorials/ex45.c
>>>>>>>>>
>>>>>>>>> petsc configured with: ./config/configure.py
>>>>>>>>> --with-shared-libraries --with-clanguage=c++ --CFLAGS='-g -O0'
>>>>>>>>> --CXXFLAGS='-g -O0'  --with-c2html=0 --download-ctetgen
>>>>>>>>> --download-triangle --with-debugging=yes --download-netcdf
>>>>>>>>> --download-zlib  --download-exodusii --download-hdf5 --download-pnetcdf
>>>>>>>>>
>>>>>>>>> I'm trying to refine the DMPlexCreateBoxMesh  with the
>>>>>>>>> DMPlexSetRefinementFunction.
>>>>>>>>> It generally seems to be working, except that the refined element
>>>>>>>>> is slightly offset from what I was expecting.
>>>>>>>>> Based on my application specific criteria, element id number 7 is
>>>>>>>>> flagged to be refined by the DMPlexSetRefinementFunction but when I open in
>>>>>>>>> paraview, it looks like element id number 8 is being refined. See attached
>>>>>>>>> pic.
>>>>>>>>>
>>>>>>>>> [image: Screen Shot 2019-01-02 at 6.02.02 PM.png]
>>>>>>>>> [image: Screen Shot 2019-01-02 at 6.02.11 PM.png]
>>>>>>>>>
>>>>>>>>> Is it possible that the maxVolumes array is 'off by one' when
>>>>>>>>> transfering to tetgen data structures somehow ?
>>>>>>>>>
>>>>>>>>
>>>>>>>> I looked through and cannot see it by eye. Could you send me your
>>>>>>>> modified example and I will walk through it with the
>>>>>>>> debugger?
>>>>>>>>
>>>>>>>>   Thanks,
>>>>>>>>
>>>>>>>>      Matt
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> https://bitbucket.org/petsc/petsc/src/bd27d3f284687498e4c4678d234c0e308a5bc236/src/dm/impls/plex/plexadapt.c?at=master&fileviewer=file-view-default#plexadapt.c-252
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> (gdb) bt
>>>>>>>>> #0  DMPlexRefine_CTetgen (dm=0x932180, maxVolumes=0x919710,
>>>>>>>>> dmRefined=0x7fffffffb938) at
>>>>>>>>> /opt/apps/PETSc/petsc-3.10.2/src/dm/impls/plex/generators/ctetgen/ctetgenerate.c:182
>>>>>>>>> #1  0x00007ffff6b76401 in DMPlexRefine_Internal (dm=0x932180,
>>>>>>>>> adaptLabel=0x0, dmRefined=0x7fffffffb938) at
>>>>>>>>> /opt/apps/PETSc/petsc-3.10.2/src/dm/impls/plex/plexadapt.c:252
>>>>>>>>> #2  0x00007ffff6b72720 in DMRefine_Plex (dm=0x932180, comm=0x6b,
>>>>>>>>> dmRefined=0x7fffffffb938) at
>>>>>>>>> /opt/apps/PETSc/petsc-3.10.2/src/dm/impls/plex/plexrefine.c:10361
>>>>>>>>> #3  0x00007ffff6dad8ff in DMRefine (dm=0x932180, comm=0x6b,
>>>>>>>>> dmf=0x7fffffffb938) at
>>>>>>>>> /opt/apps/PETSc/petsc-3.10.2/src/dm/interface/dm.c:1808
>>>>>>>>> #4  0x0000000000405274 in CreateMesh (comm=0x7ffff5891680
>>>>>>>>> <ompi_mpi_comm_world>, dm=0x7fffffffb9d0, ctx=0x7fffffffba00) at
>>>>>>>>> /rsrch1/ip/dtfuentes/github/thermoembo/tutorials/exac.c:253
>>>>>>>>> #5  0x00000000004063c4 in main (argc=32, argv=0x7fffffffdb68) at
>>>>>>>>> /rsrch1/ip/dtfuentes/github/thermoembo/tutorials/exac.c:336
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> 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/>
>>>>
>>>
>
> --
> 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/20190413/f1f8f131/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2019-04-13 at 4.50.06 AM.png
Type: image/png
Size: 84446 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190413/f1f8f131/attachment-0001.png>


More information about the petsc-users mailing list