<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-ligatures:none;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hello everyone,<o:p></o:p></p>
<p class="MsoNormal">I am running into an issue with SNES solver where the residual in the first iteration gets calculated fine, but on the 2<sup>nd</sup> iteration, even though it is getting calculated locally, it doesn’t seem to be “assigned” to the residual
 vector correctly.<o:p></o:p></p>
<p class="MsoNormal">The residual vector here is referred to as petsc_PVector which is defined in a type (struct). It seems like the first iteration, it behaves as expected and that petsc_PVector gets updated, 2<sup>nd</sup> iteration however seems like there
 are 2 versions of it; one that is being passed into FormFunctionU, and another that exists in the type (struct). This result in the residual on the 2<sup>nd</sup> iteration to be exactly = 0 and convergence.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Any insights, suggestions, or experiences you can share regarding this issue would be immensely appreciated. I'm particularly interested in understanding why the residual vector behaves differently in the second iteration.<o:p></o:p></p>
<p class="MsoNormal">Best,<o:p></o:p></p>
<p class="MsoNormal">Khaled<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The following is a snapshot of how I initialize and use SNES:<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">   
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">subroutine</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">set_function_jacobian_to_solver_u</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">variable_node_u</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">),</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">target</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">,</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">intent</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">inout</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">)</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nlU<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        PetscErrorCode::ierr<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">variable_node_part</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">),</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">pointer</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">var_nd_part<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">integer</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">ipart<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#6A9955">! external FormFunctionU,FormJacobianU</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"><o:p> </o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">do</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"> ipart</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">=</span><span style="font-size:10.5pt;font-family:Consolas;color:#B5CEA8">1</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">,nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">variable_node</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">npart<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">            var_nd_part</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">=></span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">variable_node</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">parts(ipart)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">            PetscCallA(SNESSetFunction(var_nd_part</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_snes,var_nd_part</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_PVector,FormFunctionU,nlU,ierr))<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">            PetscCallA(SNESSetJacobian(var_nd_part</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_snes,var_nd_part</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_KMatrix,var_nd_part</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_KMatrix,FormJacobianU,nlU,ierr))<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">            PetscCallA(SNESSetFromOptions(var_nd_part</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_snes,ierr))<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">end do</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        var_nd_part</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">=></span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">null</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">   
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">end subroutine</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">set_function_jacobian_to_solver_u</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">   
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">subroutine</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">FormFunctionU</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">petsc_snes</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">,</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">petsc_vector</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">,</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">petsc_PVector</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">,</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">,</span><span style="font-size:10.5pt;font-family:Consolas;color:#9CDCFE">ierr</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">tSNES</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">)</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_snes<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">tVec</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">)</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_vector<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">tVec</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">)</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_PVector<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">PetscScalar</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">),</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">pointer</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">vec_ptr_a(:),vec_ptr_b(:)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        PetscErrorCode::ierr<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">variable_node_u</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">),</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">target</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nlU<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">PetscScalar</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">),</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">pointer</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">val_petsc_PVector(:)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">parameter</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">),</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">pointer</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">para_data<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">mesh</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">),</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">pointer</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">mesh_data<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">type</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(</span><span style="font-size:10.5pt;font-family:Consolas;color:#4EC9B0">element</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">),</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">pointer</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">eles(:)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">integer</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">::</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">k,i,flag,pid<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        PetscInt::its<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        para_data</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">=></span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">para_data<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        mesh_data</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">=></span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">mesh_data<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        eles</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">=></span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">eles<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">call</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">MPI_Comm_rank</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(MPI_COMM_WORLD, pid, ierr)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">call</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">update_data_by_petsc_vector</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">variable_node,petsc_vector)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">call</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">set_petsc_PVector_to_zero</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">variable_node)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">call</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">update_petsc_PVector</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">variable_node)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        flag
</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">=</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#B5CEA8">0</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">do</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"> k</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">=</span><span style="font-size:10.5pt;font-family:Consolas;color:#B5CEA8">1</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">,mesh_data</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nel<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">           
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">call</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">get_element_value</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">data_e,
 eles(k)</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nnd_e, mesh_data</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">elements(:,k),
 nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nvar_total, nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">data)
            <o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">           
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">call</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">cal_element_ResidualU</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">PVector_e,
 eles(k), nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">data_e, para_data)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">           
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">call</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">set_petsc_PVector_values_by_element</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">variable_node,
 nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">PVector_e, eles(k)</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">nnd_e,
 mesh_data</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">elements(:,k))<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">end do</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">call</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">update_petsc_PVector</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">variable_node)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        para_data</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">=></span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">null</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        mesh_data</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">=></span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">null</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">        eles</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">=></span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">null</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">       
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">return</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">   
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">end subroutine</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">FormFunctionU</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC"><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1F1F1F"><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">               
</span><span style="font-size:10.5pt;font-family:Consolas;color:#C586C0">call</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">
</span><span style="font-size:10.5pt;font-family:Consolas;color:#DCDCAA">SNESSolve</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">(nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">variable_node</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_snes,PETSC_NULL_VEC,
 nlU</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">variable_node</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">%</span><span style="font-size:10.5pt;font-family:Consolas;color:#CCCCCC">petsc_vector,error_petsc)<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>