<head><!-- BaNnErBlUrFlE-HeAdEr-start -->
<style>
#pfptBannereoipd5m { all: revert !important; display: block !important;
visibility: visible !important; opacity: 1 !important;
background-color: #D0D8DC !important;
max-width: none !important; max-height: none !important }
.pfptPrimaryButtoneoipd5m:hover, .pfptPrimaryButtoneoipd5m:focus {
background-color: #b4c1c7 !important; }
.pfptPrimaryButtoneoipd5m:active {
background-color: #90a4ae !important; }
</style>
<!-- BaNnErBlUrFlE-HeAdEr-end -->
</head><!-- BaNnErBlUrFlE-BoDy-start -->
<!-- Preheader Text : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">
On Sat, Mar 23, 2024 at 8: 03 AM Gong Yujie <yc17470@ connect. um. edu. mo> wrote: Dear PETSc group, I'm reading the DS part for the discretization start from SNES ex17. c which is a demo for solving linear elasticity problem. I have two
</div>
<!-- Preheader Text : END -->
<!-- Email Banner : BEGIN -->
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerStart</div>
<!--[if ((ie)|(mso))]>
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="padding: 16px 0px 16px 0px; direction: ltr" ><tr><td>
<table border="0" cellspacing="0" cellpadding="0" style="padding: 0px 10px 5px 6px; width: 100%; border-radius:4px; border-top:4px solid #90a4ae;background-color:#D0D8DC;"><tr><td valign="top">
<table align="left" border="0" cellspacing="0" cellpadding="0" style="padding: 4px 8px 4px 8px">
<tr><td style="color:#000000; font-family: 'Arial', sans-serif; font-weight:bold; font-size:14px; direction: ltr">
This Message Is From an External Sender
</td></tr>
<tr><td style="color:#000000; font-weight:normal; font-family: 'Arial', sans-serif; font-size:12px; direction: ltr">
This message came from outside your organization.
</td></tr>
</table>
</td></tr></table>
</td></tr></table>
<![endif]-->
<![if !((ie)|(mso))]>
<div dir="ltr" id="pfptBannereoipd5m" style="all: revert !important; display:block !important; text-align: left !important; margin:16px 0px 16px 0px !important; padding:8px 16px 8px 16px !important; border-radius: 4px !important; min-width: 200px !important; background-color: #D0D8DC !important; background-color: #D0D8DC; border-top: 4px solid #90a4ae !important; border-top: 4px solid #90a4ae;">
<div id="pfptBannereoipd5m" style="all: unset !important; float:left !important; display:block !important; margin: 0px 0px 1px 0px !important; max-width: 600px !important;">
<div id="pfptBannereoipd5m" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-weight:bold !important; font-weight:bold; font-size:14px !important; line-height:18px !important; line-height:18px">
This Message Is From an External Sender
</div>
<div id="pfptBannereoipd5m" style="all: unset !important; display:block !important; visibility: visible !important; background-color: #D0D8DC !important; color:#000000 !important; color:#000000; font-weight:normal; font-family: 'Arial', sans-serif !important; font-family: 'Arial', sans-serif; font-size:12px !important; line-height:18px !important; line-height:18px; margin-top:2px !important;">
This message came from outside your organization.
</div>
</div>
<div style="clear: both !important; display: block !important; visibility: hidden !important; line-height: 0 !important; font-size: 0.01px !important; height: 0px"> </div>
</div>
<![endif]>
<div style="display:none !important;display:none;visibility:hidden;mso-hide:all;font-size:1px;color:#ffffff;line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;">ZjQcmQRYFpfptBannerEnd</div>
<!-- Email Banner : END -->
<!-- BaNnErBlUrFlE-BoDy-end -->
<div dir="ltr"><div dir="ltr">On Sat, Mar 23, 2024 at 8:03 AM Gong Yujie <<a href="mailto:yc17470@connect.um.edu.mo">yc17470@connect.um.edu.mo</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="msg-2410095949325827100">
<div style="font-size:1px;color:rgb(255,255,255);line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;display:none">
Dear PETSc group, I'm reading the DS part for the discretization start from SNES ex17. c which is a demo for solving linear elasticity problem. I have two questions for the details. The first question is for the residual function. Is the residual
</div>
<div style="font-size:1px;color:rgb(255,255,255);line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;display:none">ZjQcmQRYFpfptBannerStart</div>
<u></u>
<div dir="ltr" id="m_-2410095949325827100pfptBannernnzwwir" style="display:block;text-align:left;margin:16px 0px;padding:8px 16px;border-radius:4px;min-width:200px;background-color:rgb(208,216,220);border-top:4px solid rgb(144,164,174)">
<div id="m_-2410095949325827100pfptBannernnzwwir" style="float:left;display:block;margin:0px 0px 1px;max-width:600px">
<div id="m_-2410095949325827100pfptBannernnzwwir" style="display:block;background-color:rgb(208,216,220);color:rgb(0,0,0);font-family:Arial,sans-serif;font-weight:bold;font-size:14px;line-height:18px">
This Message Is From an External Sender
</div>
<div id="m_-2410095949325827100pfptBannernnzwwir" style="font-weight:normal;display:block;background-color:rgb(208,216,220);color:rgb(0,0,0);font-family:Arial,sans-serif;font-size:12px;line-height:18px;margin-top:2px">
This message came from outside your organization.
</div>
</div>
<div style="height:0px;clear:both;display:block;line-height:0;font-size:0.01px"> </div>
</div>
<u></u>
<div style="font-size:1px;color:rgb(255,255,255);line-height:1px;height:0px;max-height:0px;opacity:0;overflow:hidden;display:none">ZjQcmQRYFpfptBannerEnd</div>
<div dir="ltr">
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Dear PETSc group,</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I'm reading the DS part for the discretization start from SNES ex17.c which is a demo for solving linear elasticity problem. I have two questions for the details.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
The first question is for the residual function. Is the residual calculated as this? The dot product is a little weird because of the dimension of the result.</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<img size="34587" style="max-width: 1598px;" src="cid:ii_18e6c1bb3e9cb971f161"></div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Here \sigma is the stress tensor, \phi_i is the test function for the i-th function (Linear elasticity in 3D contains three equations).</div></div></div></blockquote><div><br></div><div>The stress term in the momentum equation is</div><div><br></div><div> (-div sigma) . psi = d_i sigma_{ij} psi_j</div><div><br></div><div>which is then integrated by parts</div><div><br></div><div> sigma_{ij} d_i psi_j</div><div><br></div><div>This is linear isotropic elasticity, so</div><div><br></div><div> sigma = \mu (d_i u_j + d_j u_i) + \lambda \delta_{ij} sigma_{kk}</div><div><br></div><div>In PETSc, we phrase the term in the weak form as</div><div><br></div><div> f^1_{ij} d_i psi_j</div><div><br></div><div>so f1[i * dim + j] below is sigma_{ij}, from line 298 of ex17.c</div><div><br></div><div> for (PetscInt c = 0; c < Nc; ++c) {<br> for (PetscInt d = 0; d < dim; ++d) {<br> f1[c * dim + d] += mu * (u_x[c * dim + d] + u_x[d * dim + c]);<br> f1[c * dim + c] += lambda * u_x[d * dim + d];<br> }<br> }<br></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="msg-2410095949325827100"><div dir="ltr">
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
The second question is how to derive the Jacobian of the system (line 330 in ex17.c). As shown in the PetscDSSetJacobian, we need to provide function g3() which I think is a 4th-order tensor with size 3*3*3*3 in this linear elasticity case. I'm not sure how
to get it. Are there any references on how to get this Jacobian?</div></div></div></blockquote><div><br></div><div>The Jacobian indices are shown here: <a href="https://urldefense.us/v3/__https://petsc.org/main/manualpages/FE/PetscFEIntegrateJacobian/__;!!G_uCfscf7eWS!eNdXZ9QpzXPTMCtLneeS7td5OYVeKmhdOrw_fswDze2u7v2JaO7kBmFTVakyHDmWJOCHjf-0GrqGc53QKQec$">https://petsc.org/main/manualpages/FE/PetscFEIntegrateJacobian/</a></div><div>where the g3 term is</div><div><br></div><div> \nabla\psi^{fc}_f(q) \cdot g3_{fc,gc,df,dg}(u, \nabla u) \nabla\phi^{gc}_g(q)</div><div><br></div><div>To get the Jacobian, we use u = \sum_i u_i psi_i, where psi_i is a vector, and then differentiate the expression with respect to the coefficient u_i. Since the operator is already linear,this is just matching indices</div><div><br></div><div> for (PetscInt c = 0; c < Nc; ++c) {<br> for (PetscInt d = 0; d < dim; ++d) {<br> g3[((c * Nc + c) * dim + d) * dim + d] += mu;<br> g3[((c * Nc + d) * dim + d) * dim + c] += mu;<br> g3[((c * Nc + d) * dim + c) * dim + d] += lambda;<br> }<br> }<br></div><div><br></div><div>Take the first mu term, mu (d_c u_d ) (d_c psi_d). We know that fc == gc and df == dg, so we get</div><div><br></div><div> g3[((c * Nc + c) * dim + d) * dim + d] += mu;<br></div><div><br></div><div>For the second term, we transpose grad u, so fc == dg and gc == df,</div><div><br></div> g3[((c * Nc + d) * dim + d) * dim + c] += mu;<br><div><br></div><div>Finally, for the lambda term, fc == df and gc == dg because we are matching terms in the sum</div><div><br></div> g3[((c * Nc + d) * dim + c) * dim + d] += lambda;</div><div class="gmail_quote"><br></div><div class="gmail_quote"> Thanks,</div><div class="gmail_quote"><br></div><div class="gmail_quote"> Matt<br><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="msg-2410095949325827100"><div dir="ltr">
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif">
<span style="font-size:12pt;color:rgb(0,0,0)">I've checked about the comment before this Jacobian function (</span><span style="font-size:16px;color:rgb(0,0,0);background-color:rgb(255,255,255)">line 330 in ex17.c</span><span style="font-size:12pt;color:rgb(0,0,0)">)
but don't know how to get this.</span></div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thanks in advance!</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Best Regards,</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Yujie</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="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!eNdXZ9QpzXPTMCtLneeS7td5OYVeKmhdOrw_fswDze2u7v2JaO7kBmFTVakyHDmWJOCHjf-0GrqGcwApR5ek$" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>