[petsc-users] DMPlex assembly global stiffness matrix

Matthew Knepley knepley at gmail.com
Mon May 20 05:52:04 CDT 2019


On Fri, May 17, 2019 at 7:59 PM Josh L via petsc-users <
petsc-users at mcs.anl.gov> wrote:

> Hi,
>
> I have a DM that has 2 fields , and field #1 has 2 dofs and field #2 has 1
> dof.
> I only have dofs on vertex.
>
> Can I use the following to assemble global stiffness matrix instead of
> using MatSetClosure(I am not integrating 2 field separately)
>
> DMGetGlobalSection(dm,GlobalSection)
> For cells
>    calculate element stiffness matrix eleMat
>    For vertex in cells
>       PetscSectionGetOffset(GlobalSection, vertex, offset)
>       loc=[offset_v1, offset_v1+1, offset_v1+2,  offset_v2,
> offset_v2+1.......]
>     End
>     MatSetValues(GlobalMat, n,loc,n,loc, eleMat, ADD_VALUES)
> End
> AssemblyBegin and End.
>
> Basically use the offset from global section to have the global dof number.
>

Yes, that is exactly what happens in MatSetClosure(). However, you have to
be careful if you use
constraints (like Dirichlet conditions) in the Section to filter them out.
I use negative indices to do that
since they are ignored by MatSetValues().

Are you doing this because you want to set one field at a time? If so, just
call DMCreateSubDM() for that
field, and everything should work correctly with MatSetClosure().

  Thanks,

     Matt


> Thanks,
> Josh
>
>
>

-- 
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/20190520/7491df88/attachment.html>


More information about the petsc-users mailing list