[petsc-users] Inquiry regarding DMAdaptLabel function

Zongze Yang yangzongze at gmail.com
Mon Feb 27 09:37:42 CST 2023


Yes, It seems that firedrake only works with DMPlex. Thanks.

Best wishes,
Zongze


On Mon, 27 Feb 2023 at 22:53, Matthew Knepley <knepley at gmail.com> wrote:

> On Mon, Feb 27, 2023 at 9:45 AM Zongze Yang <yangzongze at gmail.com> wrote:
>
>> Hi, Matt
>>
>> Thanks for your clarification. Can I change the type of DMPlex to
>> DMForest?
>>
>
> You can, however DMForest is for structured adaptive meshes using
> quadtrees, and I do not believe
> Firedrake works with that.
>
>   Thanks,
>
>     Matt
>
>
>> Best wishes,
>> Zongze
>>
>>
>> On Mon, 27 Feb 2023 at 20:18, Matthew Knepley <knepley at gmail.com> wrote:
>>
>>> On Sat, Feb 18, 2023 at 2:25 AM Zongze Yang <yangzongze at gmail.com>
>>> wrote:
>>>
>>>> Dear PETSc Group,
>>>>
>>>> I am writing to inquire about the function DMAdaptLabel in PETSc.
>>>> I am trying to use it coarse a mesh, but the resulting mesh is refined.
>>>>
>>>> In the following code, all of the `adpat` label values were set to 2
>>>> (DM_ADAPT_COARSEN).
>>>> There must be something wrong. Could you give some suggestions?
>>>>
>>>
>>> Sorry for the late reply. You are right, I need to put in error messages
>>> for this. Here is what is happening.
>>> PETSc tries to fallback if you do not have certain packages. In this
>>> case, you are not using DMForest,
>>> which responds to both coarsen and refine, so the
>>> mesh generator interprets all markers as refine (they
>>> cannot coarsen). I will add a check that fails on the coarsen marker.
>>>
>>> Coarsening is much more difficult in the presence of boundaries, which
>>> is why it is not implemented in
>>> most packages. For unstructured coarsening, I do not think there is any
>>> choice but MMG.
>>>
>>>   Thanks,
>>>
>>>      Matt
>>>
>>> ```python
>>>> from firedrake import *
>>>> from firedrake.petsc import PETSc
>>>>
>>>> def mark_all_cells(mesh):
>>>>     plex = mesh.topology_dm
>>>>     with PETSc.Log.Event("ADD_ADAPT_LABEL"):
>>>>         plex.createLabel('adapt')
>>>>         cs, ce = plex.getHeightStratum(0)
>>>>         for i in range(cs, ce):
>>>>             plex.setLabelValue('adapt', i, 2)
>>>>
>>>>     return plex
>>>>
>>>> mesh = RectangleMesh(10, 10, 1, 1)
>>>>
>>>> x = SpatialCoordinate(mesh)
>>>> V = FunctionSpace(mesh, 'CG', 1)
>>>> f = Function(V).interpolate(10 + 10*sin(x[0]))
>>>> triplot(mesh)
>>>>
>>>> plex = mark_all_cells(mesh)
>>>> new_plex = plex.adaptLabel('adapt')
>>>> mesh = Mesh(new_plex)
>>>> triplot(mesh)
>>>> ```
>>>>
>>>> Thank you very much for your time.
>>>>
>>>> Best wishes,
>>>> Zongze
>>>>
>>>
>>>
>>> --
>>> 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/20230227/9f088879/attachment.html>


More information about the petsc-users mailing list