[petsc-users] DMPlex assembly global stiffness matrix

Josh L ysjosh.lo at gmail.com
Mon May 20 11:15:29 CDT 2019


Hi,

I get it done by adding one more field that contains all the dofs i need,
and use DMGetSubDM and MatSetClosure with this subDM
VecSetClosure takes in data partitioned by field and rearrange them into
sieve ordering.
I think MatSetClosure does the same thing, but my stiffness matrix is not
partitioned by field, so I only want to have one field with all my dofs on
it.

Thanks,
Josh


Matthew Knepley <knepley at gmail.com> 於 2019年5月20日 週一 上午5:52寫道:

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


More information about the petsc-users mailing list