<!-- 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;">
Are you forming the Jacobian for the first and second order cases inside of Newton? You can run both with -log_view to see how much time is spent in the various events (compute function, compute Jacobian, linear solve, .. . ) for the two cases
</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="pfptBannerfknv3ma" 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="pfptBannerfknv3ma" style="all: unset !important; float:left !important; display:block !important; margin: 0px 0px 1px 0px !important; max-width: 600px !important;">
<div id="pfptBannerfknv3ma" 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="pfptBannerfknv3ma" 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 -->
<html><head><!-- BaNnErBlUrFlE-HeAdEr-start -->
<style>
#pfptBannerfknv3ma { all: revert !important; display: block !important;
visibility: visible !important; opacity: 1 !important;
background-color: #D0D8DC !important;
max-width: none !important; max-height: none !important }
.pfptPrimaryButtonfknv3ma:hover, .pfptPrimaryButtonfknv3ma:focus {
background-color: #b4c1c7 !important; }
.pfptPrimaryButtonfknv3ma:active {
background-color: #90a4ae !important; }
</style>
<!-- BaNnErBlUrFlE-HeAdEr-end -->
<meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div> Are you forming the Jacobian for the first and second order cases inside of Newton?<div><br></div><div> You can run both with -log_view to see how much time is spent in the various events (compute function, compute Jacobian, linear solve, ...) for the two cases and compare them.</div><div><br></div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Mar 3, 2024, at 11:42 AM, Zou, Ling via petsc-users <petsc-users@mcs.anl.gov> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Original email may have been sent to the incorrect place.<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">See below.<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">-Ling<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"><o:p> </o:p></span></div><div id="mail-editor-reference-message-container"><div><div style="border-width: 1pt medium medium; border-style: solid none none; border-color: rgb(181, 196, 223) currentcolor currentcolor; border-image: none; padding: 3pt 0in 0in;"><p class="MsoNormal" style="margin: 0in 0in 12pt; font-size: 10pt; font-family: Calibri, sans-serif;"><b><span style="font-size: 12pt; font-family: Aptos, sans-serif;">From:<span class="Apple-converted-space"> </span></span></b><span style="font-size: 12pt; font-family: Aptos, sans-serif;">Zou, Ling <<a href="mailto:lzou@anl.gov">lzou@anl.gov</a>><br><b>Date:<span class="Apple-converted-space"> </span></b>Sunday, March 3, 2024 at 10:34 AM<br><b>To:<span class="Apple-converted-space"> </span></b>petsc-users <<a href="mailto:petsc-users-bounces@mcs.anl.gov">petsc-users-bounces@mcs.anl.gov</a>><br><b>Subject:<span class="Apple-converted-space"> </span></b>'Preconditioning' with lower-order method<o:p></o:p></span></p></div><div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Hi all,<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">I am solving a PDE system over a spatial domain. Numerical methods are:<o:p></o:p></span></div><ul type="disc" style="margin-bottom: 0in; margin-top: 0in;"><li class="MsoListParagraph" style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Finite volume method (both 1<sup>st</sup><span class="Apple-converted-space"> </span>and 2<sup>nd</sup><span class="Apple-converted-space"> </span>order implemented)<o:p></o:p></span></li><li class="MsoListParagraph" style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">BDF1 and BDF2 for time integration.<o:p></o:p></span></li></ul><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">What I have noticed is that 1<sup>st</sup><span class="Apple-converted-space"> </span>order FVM converges much faster than 2<sup>nd</sup><span class="Apple-converted-space"> </span>order FVM, regardless the time integration scheme. Well, not surprising since 2<sup>nd</sup><span class="Apple-converted-space"> </span>order FVM introduces additional non-linearity.<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">I’m thinking about two possible ways to speed up 2<sup>nd</sup><span class="Apple-converted-space"> </span>order FVM, and would like to get some thoughts or community knowledge before jumping into code implementation.<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Say, let the 2<sup>nd</sup><span class="Apple-converted-space"> </span>order FVM residual function be<span class="Apple-converted-space"> </span><b><i>F</i></b><sub>2</sub>(<b><i>x</i></b>) = 0; and the 1<sup>st</sup><span class="Apple-converted-space"> </span>order FVM residual function be<span class="Apple-converted-space"> </span><b><i>F</i></b><sub>1</sub>(<b><i>x</i></b>) = 0.<o:p></o:p></span></div><ol start="1" type="1" style="margin-bottom: 0in; margin-top: 0in;"><li class="MsoListParagraph" style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Option – 1, multi-step for each time step<o:p></o:p></span></li></ol><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Step 1: solving<span class="Apple-converted-space"> </span><b><i>F</i></b><sub>1</sub>(<b><i>x</i></b>) = 0 to obtain a temporary solution<span class="Apple-converted-space"> </span><b><i>x</i></b><sub>1</sub><o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Step 2: feed<span class="Apple-converted-space"> </span><b><i>x</i></b><sub>1</sub><span class="Apple-converted-space"> </span>as an initial guess to solve<span class="Apple-converted-space"> </span><b><i>F</i></b><sub>2</sub>(<b><i>x</i></b>) = 0 to obtain the final solution.<o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">[Not sure if gain any saving at all]<o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div><ol start="2" type="1" style="margin-bottom: 0in; margin-top: 0in;"><li class="MsoListParagraph" style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">Option -2, dynamically changing residual function F(x)<o:p></o:p></span></li></ol><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">In pseudo code, would be something like.<o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;"> <o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;">snesFormFunction(SNES snes, Vec u, Vec f, void *)</span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;">{</span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;"> if (snes.nl_it_no < 4) // 4 being arbitrary here</span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;"> f = F1(u);</span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;"> else</span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;"> f = F2(u);</span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;">}</span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;"> </span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in 0in 0in 0.5in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-size: 11pt;">I know this might be a bit crazy since it may crash after switching residual function, still, any thoughts?<o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;"> </span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;">Best,</span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;"> </span><span style="font-size: 11pt;"><o:p></o:p></span></div><div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;"><span style="font-family: Monaco;">-Ling</span></div></div></div></div></div></div></blockquote></div><br></div></body></html>