<div dir="ltr"><div dir="ltr">On Fri, Jul 7, 2023 at 3:59 PM Hongrui Yu <<a href="mailto:yuhongrui@utexas.edu">yuhongrui@utexas.edu</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 class="msg6872135393471167864"><div lang="EN-US" style="overflow-wrap: break-word;"><div class="m_6872135393471167864WordSection1"><p class="MsoNormal">Thanks Matt. To clarify, were you referring to the following section in DMPlexCreateBoxMesh_Tensor_SFC_Periodicity_Private()?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">  PetscCall(DMPlexSetIsoperiodicFaceSF(dm, sfper));<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New""><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">  PetscScalar t[4][4] = {{0}};<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">  t[0][0]             = 1;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">  t[1][1]             = 1;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">  t[2][2]             = 1;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">  t[3][3]             = 1;<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">  for (PetscInt i = 0; i < dim; i++)<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">    if (periodicity[i] == DM_BOUNDARY_PERIODIC) t[i][3] = upper[i] - lower[i];<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:10pt;font-family:"Courier New"">  PetscCall(DMPlexSetIsoperiodicFaceTransform(dm, &t[0][0]));<u></u><u></u></span></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">In my understanding, DMPlexSetIsoperiodicFaceSF() defines the points where the constrains exists. The constrains are specified in t matrix and set by calling DMPlexSetIsoperiodicFaceTransform(). Is this correct?</p></div></div></div></blockquote><div><br></div><div>The t matrix is an affine transform to apply to the field before matching. Here it is just the identity, which is what I think you want.</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 class="msg6872135393471167864"><div lang="EN-US" style="overflow-wrap: break-word;"><div class="m_6872135393471167864WordSection1"><p class="MsoNormal">Does constraints set by this also apply to non-displacement DoFs? Our application is of phase-field fracture in elasticity so we have a scalar DoF on each vertices in addition to displacement field. In other words, the section has two fields, where displacement field has 2 DoFs and phase-field has 1 DoF.</p></div></div></div></blockquote><div><br></div><div>It should just work.</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 class="msg6872135393471167864"><div lang="EN-US" style="overflow-wrap: break-word;"><div class="m_6872135393471167864WordSection1"><p class="MsoNormal">Thanks,<u></u><u></u></p><p class="MsoNormal">Hongrui<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in"><p class="MsoNormal"><b>From:</b> Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank">knepley@gmail.com</a>> <br><b>Sent:</b> Thursday, July 6, 2023 3:34 PM<br><b>To:</b> Hongrui Yu <<a href="mailto:yuhongrui@utexas.edu" target="_blank">yuhongrui@utexas.edu</a>><br><b>Cc:</b> <a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a><br><b>Subject:</b> Re: [petsc-users] Applying Multi-Point-Constraints with SNES<u></u><u></u></p></div><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">On Thu, Jul 6, 2023 at 3:40 PM Hongrui Yu <<a href="mailto:yuhongrui@utexas.edu" target="_blank">yuhongrui@utexas.edu</a>> wrote:<u></u><u></u></p></div><div><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in"><div><div><div><p class="MsoNormal">Hello PETSc users,<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">In our Finite Element application we would like to apply Multi-Point-Constraints to some vertices. In these Multi-Point-Constraints we force certain DoF in the following nodes to be the same as those in controlling nodes. We use DMPlex to store our mesh. I’m wondering what would be a good way to implement this together with SNES? Or is there an example that does similar thing?<u></u><u></u></p></div></div></div></blockquote><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">There is a simple thing that Jed implemented call "isoperiodicity" in plexsfc.c, and you can see<u></u><u></u></p></div><div><p class="MsoNormal">him using it to define a periodic box in<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">  DMPlexCreateBoxMesh_Tensor_SFC_Periodicity_Private()<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">You could use exactly this to define an affine relation between two dofs.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in"><div><div><div><p class="MsoNormal">Currently both right-hand-side and solution vectors in out application are created using DMCreateGlobalVec(). And we tried (unsuccessfully) to modify solution within FormRHS or FormJacobian routines but the solution vector seems to be read-only (for good reason). Is there a way to tell SNES about these constraints? Or perhaps one can somehow create a vector with only a subset of the DoFs (the actual “unknowns”)?<u></u><u></u></p></div></div></div></blockquote><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Doing it as above will eliminate the constrained unknowns from the SNES automatically, so this will not be a concern.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">  Thanks,<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">     Matt<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in"><div><div><div><p class="MsoNormal">Thank you in advance for any help or advice!<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">Hongrui<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p></div></div></div></blockquote></div><p class="MsoNormal"><br clear="all"><u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal"><span class="m_6872135393471167864gmailsignatureprefix">-- </span><u></u><u></u></p><div><div><div><div><div><div><div><p class="MsoNormal">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<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><u></u><u></u></p></div></div></div></div></div></div></div></div></div></div></div></blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_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>