<div dir="ltr">Hi,<div><br></div><div>I get it done by adding one more field that contains all the dofs i need, and use DMGetSubDM and MatSetClosure with this subDM</div><div>VecSetClosure takes in data partitioned by field and rearrange them into sieve ordering. </div><div>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. </div><div><br></div><div>Thanks,</div><div>Josh</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Matthew Knepley <<a href="mailto:knepley@gmail.com">knepley@gmail.com</a>> 於 2019年5月20日 週一 上午5:52寫道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">On Fri, May 17, 2019 at 7:59 PM Josh L via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I have a DM that has 2 fields , and field #1 has 2 dofs and field #2 has 1 dof.</div><div>I only have dofs on vertex. </div><div><br></div><div>Can I use the following to assemble global stiffness matrix instead of using MatSetClosure(I am not integrating 2 field separately) </div><div><br></div><div>DMGetGlobalSection(dm,GlobalSection)</div><div>For cells</div><div>   calculate element stiffness matrix eleMat</div><div>   For vertex in cells </div><div>      PetscSectionGetOffset(GlobalSection, vertex, offset)</div><div>      loc=[offset_v1, offset_v1+1, offset_v1+2,  offset_v2, offset_v2+1.......]</div><div>    End </div><div>    MatSetValues(GlobalMat, n,loc,n,loc, eleMat, ADD_VALUES)</div><div>End</div><div>AssemblyBegin and End. </div><div><br></div><div>Basically use the offset from global section to have the global dof number.</div></div></blockquote><div><br></div><div>Yes, that is exactly what happens in MatSetClosure(). However, you have to be careful if you use</div><div>constraints (like Dirichlet conditions) in the Section to filter them out. I use negative indices to do that</div><div>since they are ignored by MatSetValues().</div><div><br></div><div>Are you doing this because you want to set one field at a time? If so, just call DMCreateSubDM() for that</div><div>field, and everything should work correctly with MatSetClosure().</div><div><br></div><div>  Thanks,</div><div><br></div><div>     Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thanks,</div><div>Josh</div><div><br></div><div><br></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail-m_-4921945734396352798gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>
</blockquote></div>