[petsc-users] Modifying Entries Tied to Specific Points in Finite Element Stiffness Matrix using DMPlex

Matthew Knepley knepley at gmail.com
Fri Dec 9 10:10:15 CST 2022


On Fri, Dec 9, 2022 at 10:51 AM Hongrui Yu <yuhongrui at utexas.edu> wrote:

> Thank you for your reply! Unfortunately yes.. I’ll need to modify
> stiffness between nodes on the boundary so most of them are going to be in
> completely general location.
>

Hmm, there is usually a better way to do this. This is a mesh and
discretization dependent way to impose boundary conditions. However, it is
possible.


> I can create an IS after distribution using DMPlexCreatePointNumbering()
> but they are Global numbering. Is there a way to get a map from Natural
> numbering to Global numbering? I assume this is used somewhere in
> DMPlexNaturalToGlobal()? This way I can find the correct entry to modify.
>

You can get the SF that maps global vectors to natural vectors:

  https://petsc.org/main/docs/manualpages/DM/DMGetNaturalSF/

and pull out the information

  https://petsc.org/main/docs/manualpages/PetscSF/PetscSFGetGraph/

The roots should be global dofs and the leaves should be natural dofs. So
you look through the ilocal leaves
for your natural dof and the corresponding remote will be your global dof
(but the local number, so you would
have to add the rStart to make it a true global dof).

  Thanks,

     MAtt


> Thanks,
> Kevin
>
> On Dec 9, 2022, at 09:10, Matthew Knepley <knepley at gmail.com> wrote:
>
> 
> On Thu, Dec 8, 2022 at 6:06 PM Hongrui Yu <yuhongrui at utexas.edu> wrote:
>
>> Hello! I’m trying to adapt a serial Finite Element code using PETSc. In
>> this code it reads in special stiffness terms between the boundary DoFs
>> from an input file, and add them to corresponding locations in the global
>> Jacobian matrix.
>>
>
> Hmm, so in completely general locations, or on the diagonal?
>
>
>> I currently use a DM Plex object to store the mesh information. My
>> understanding is that once the DM is distributed its points are renumbered
>> across different ranks.
>>
>
> That is true.
>
>
>> I wonder if there is a good way to find the corresponding entries that
>> needs to be modified in the global Jacobian matrix?
>>
>>
>>
>> For Vectors I’m currently creating a Natural Vector and simply do
>> DMPlexNaturalToGlobal. Is there a way to create a “Natural Mat” just like
>> “Natural Vector” and then do some sort of NaturalToGlobal for this Mat?
>>
>>
>>
>> Any help would be highly appreciated!
>>
>
> If it is completely general, this will take some coding.
>
>   Thanks,
>
>      Matt
>
>
>> Kevin
>>
>
>
> --
> 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/20221209/f5a2451a/attachment-0001.html>


More information about the petsc-users mailing list