Hi Matt, this is a follow-up to the previous question:

I have created a short code as below to create a sub-dm on the surface, extracted from the original volume dmplex:

-------------------------------------
    call DMClone(dm_origin, dm_wall, ierr);CHKERRA(ierr)

    ! label for face sets
    call DMGetLabel(dm_wall, "Face Sets", label_facesets, ierr);CHKERRA(ierr)
    call DMPlexLabelComplete(dm_wall, label_facesets, ierr);CHKERRA(ierr)

    ! label for vertex on surface
    call DMCreateLabel(dm_wall, "Wall", ierr);CHKERRA(ierr)
    call DMGetLabel(dm_wall, "Wall", label_surf, ierr);CHKERRA(ierr)
    call DMPlexGetChart(dm_wall, ist, iend, ierr);CHKERRA(ierr)
    do i=ist,iend
      call DMLabelGetValue(label_facesets, i, val, ierr);CHKERRA(ierr)
      if(val .eq. ID_wall) then
        call DMLabelSetValue(label_surf, i, ID_wall, ierr);CHKERRA(ierr)
      endif
    enddo
    call DMPlexLabelComplete(dm_wall, label_surf, ierr);CHKERRA(ierr)

    ! create submesh
    call DMPlexCreateSubmesh(dm_wall, label_surf, ID_wall, PETSC_TRUE, dm_sub, ierr);CHKERRA(ierr)
    call DMPlexGetSubpointMap(dm_sub, label_sub, ierr);CHKERRA(ierr)
-------------------------------------

It is a bit unclear how to map the vector on each vertex of the original volume dm (dm_wall) into the subdm (dm_sub). The function DMPlexGetSubpointMap() seems to create a subpointMap (label_sub) for this mapping, but it is hard to get an idea how to use that DMLabel for the mapping. Shall I create DMCreateInterpolation()? But it uses Mat and Vec to define mapping rule. Could I ask for any comments?

Thanks,
Mike


Yes, you can use DMPlexCreateSubmesh() (and friends depending on exactly what kind of submesh you want). This will allow you to create a vector over only this mesh, and map your volumetric solution to that subvector. Then you can view the subvector (which pulls in the submesh).

  Thanks,

     Matt

On Mon, Aug 1, 2022 at 10:59 PM Jed Brown <jed@jedbrown.org> wrote:
I would create a sub-DM containing only the part you want to view.

Mike Michell <mi.mike1021@gmail.com> writes:

> Hi,
>
> I am a user of DMPlex object in 3D grid topology. Currently the solution
> field is printed out using viewer PETSCVIEWERVTK in .vtu format. By doing
> that the entire volume components are written in the file. I was wondering
> if there is an option that I can tell PETSc viewer to print out only
> surface component, instead of the entire volume.
>
> Best,
> Mike


--
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