[petsc-users] Define sub-dm from original dm and vector mapping

Matthew Knepley knepley at gmail.com
Wed Apr 5 14:07:31 CDT 2023


On Wed, Apr 5, 2023 at 3:04 PM Mike Michell <mi.mike1021 at gmail.com> wrote:

> Dear PETSc developer team,
>
> Hi, this is a follow-up question regarding generating sub-dm for surface
> from the original volumetric dm (
> https://lists.mcs.anl.gov/pipermail/petsc-users/2023-March/048263.html).
>
> I have created a short code as written below as a piece of it 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)
> -------------------------------------
>
> Now I can define a vector on dm_sub and view it via PETSc_Viewer. However,
> it is unclear how to map a vector defined on the volumetric dm (dm_wall)
> into a vector defined on the surface dm (dm_sub). I guess label_sub created
> via DMPlexGetSubpointMap() can help with it, but it is difficult to get a
> solid picture without an example. Could I get a comment for it?
>

I would use DMProjectField(). This would project a vector field in some FEM
space on the volumetric mesh (the input U), into a vector field defined in
some FEM space on the surface (the input dm _and_ the output vector). This
should work correctly. Let me know if this does not make sense to code.

  Thanks,

     Matt


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

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/20230405/53049410/attachment.html>


More information about the petsc-users mailing list