[petsc-users] Inquiry regarding DMAdaptLabel function

Zongze Yang yangzongze at gmail.com
Sat Feb 18 01:24:51 CST 2023


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?

```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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230218/5b6b2277/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: old_plex.png
Type: image/png
Size: 71236 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230218/5b6b2277/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: new_plex.png
Type: image/png
Size: 68806 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230218/5b6b2277/attachment-0003.png>


More information about the petsc-users mailing list