<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Dear Barry,</p>
    <p>    sorry for jumping into this.</p>
    <p><br>
    </p>
    <p>I am wondering if your reply is related to DMDA or to DM in
      general. I have at least one code where I do something similar to
      what Samuele did in his sample code: create a DMPlex, create a
      section on this DMPlex, create two SNES solving for Vecs defined
      on that same section and attach to each of them a different
      SNESFunction and SNESJacobian (one solves a predictor and the
      other is a corrector). Everything seems fine, but I am wondering
      if that code is somewhat weak and should be changed by DMCloning
      the plex as you suggested to Samuele.</p>
    <p><br>
    </p>
    <p>Thanks</p>
    <p>    Matteo</p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 06/11/2025 07:49, Samuele Ferri
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:ZR2P278MB110071BCFDD63127A5C9D7B68EC2A@ZR2P278MB1100.CHEP278.PROD.OUTLOOK.COM">
      
      <style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
      <table border="0" cellspacing="0" cellpadding="0" width="100%" style=" aspect-ratio: revert !important; background: revert !important; block-size: revert !important; border: revert !important; bottom: revert !important; color: revert !important; color-scheme: revert !important; content-visibility: revert !important; cursor: revert !important; direction: revert !important; display: revert !important; font-size: revert !important; height: revert !important; hyphens: revert !important; letter-spacing: revert !important; line-height: revert !important; margin: revert !important; opacity: revert !important; order: revert !important; outline: revert !important; overflow: revert !important; padding: revert !important; position: revert !important; resize: revert !important; rotate: revert !important; scale: revert !important; tab-size: revert !important; table-layout: revert !important; text-align: revert !important; text-indent: revert !important; text-orientation: revert !important; text-overflow: revert !important; text-shadow: revert !important; text-transform: revert !important; text-wrap: revert !important; top: revert !important; transition: revert !important; user-select: revert !important; vertical-align: revert !important; visibility: revert !important; white-space: revert !important; width: revert !important; word-break: revert !important; word-spacing: revert !important; writing-mode: revert !important; zoom: revert !important; cellpadding: 0 !important; border: 0 !important; cellspacing: 0 !important; display: table !important; width: 100% !important; table-layout: fixed !important; border-collapse: seperate !important; float: none !important; border-spacing: 0px 0px !important; " align="left">
        <tbody style=" aspect-ratio: revert !important; background: revert !important; block-size: revert !important; border: revert !important; bottom: revert !important; color: revert !important; color-scheme: revert !important; content-visibility: revert !important; cursor: revert !important; direction: revert !important; display: revert !important; font-size: revert !important; height: revert !important; hyphens: revert !important; letter-spacing: revert !important; line-height: revert !important; margin: revert !important; opacity: revert !important; order: revert !important; outline: revert !important; overflow: revert !important; padding: revert !important; position: revert !important; resize: revert !important; rotate: revert !important; scale: revert !important; tab-size: revert !important; table-layout: revert !important; text-align: revert !important; text-indent: revert !important; text-orientation: revert !important; text-overflow: revert !important; text-shadow: revert !important; text-transform: revert !important; text-wrap: revert !important; top: revert !important; transition: revert !important; user-select: revert !important; vertical-align: revert !important; visibility: revert !important; white-space: revert !important; width: revert !important; word-break: revert !important; word-spacing: revert !important; writing-mode: revert !important; zoom: revert !important; display: block !important; ">
          <tr style=" aspect-ratio: revert !important; background: revert !important; block-size: revert !important; border: revert !important; bottom: revert !important; color: revert !important; color-scheme: revert !important; content-visibility: revert !important; cursor: revert !important; direction: revert !important; display: revert !important; font-size: revert !important; height: revert !important; hyphens: revert !important; letter-spacing: revert !important; line-height: revert !important; margin: revert !important; opacity: revert !important; order: revert !important; outline: revert !important; overflow: revert !important; padding: revert !important; position: revert !important; resize: revert !important; rotate: revert !important; scale: revert !important; tab-size: revert !important; table-layout: revert !important; text-align: revert !important; text-indent: revert !important; text-orientation: revert !important; text-overflow: revert !important; text-shadow: revert !important; text-transform: revert !important; text-wrap: revert !important; top: revert !important; transition: revert !important; user-select: revert !important; vertical-align: revert !important; visibility: revert !important; white-space: revert !important; width: revert !important; word-break: revert !important; word-spacing: revert !important; writing-mode: revert !important; zoom: revert !important; ">
            <td valign="middle" width="1px" bgcolor="#A6A6A6" cellpadding="7px 2px 7px 2px" style=" aspect-ratio: revert !important; background: revert !important; block-size: revert !important; border: revert !important; bottom: revert !important; color: revert !important; color-scheme: revert !important; content-visibility: revert !important; cursor: revert !important; direction: revert !important; display: revert !important; font-size: revert !important; height: revert !important; hyphens: revert !important; letter-spacing: revert !important; line-height: revert !important; margin: revert !important; opacity: revert !important; order: revert !important; outline: revert !important; overflow: revert !important; padding: revert !important; position: revert !important; resize: revert !important; rotate: revert !important; scale: revert !important; tab-size: revert !important; table-layout: revert !important; text-align: revert !important; text-indent: revert !important; text-orientation: revert !important; text-overflow: revert !important; text-shadow: revert !important; text-transform: revert !important; text-wrap: revert !important; top: revert !important; transition: revert !important; user-select: revert !important; vertical-align: revert !important; visibility: revert !important; white-space: revert !important; width: revert !important; word-break: revert !important; word-spacing: revert !important; writing-mode: revert !important; zoom: revert !important; padding: 7px 2px 7px 2px !important; background-color: #A6A6A6 !important; valign: middle !important; width: 0px !important; "><br>
            </td>
            <td valign="middle" width="100%" bgcolor="#EAEAEA" cellpadding="7px 5px 7px 15px" color="#212121" style=" aspect-ratio: revert !important; background: revert !important; block-size: revert !important; border: revert !important; bottom: revert !important; color: revert !important; color-scheme: revert !important; content-visibility: revert !important; cursor: revert !important; direction: revert !important; display: revert !important; font-size: revert !important; height: revert !important; hyphens: revert !important; letter-spacing: revert !important; line-height: revert !important; margin: revert !important; opacity: revert !important; order: revert !important; outline: revert !important; overflow: revert !important; padding: revert !important; position: revert !important; resize: revert !important; rotate: revert !important; scale: revert !important; tab-size: revert !important; table-layout: revert !important; text-align: revert !important; text-indent: revert !important; text-orientation: revert !important; text-overflow: revert !important; text-shadow: revert !important; text-transform: revert !important; text-wrap: revert !important; top: revert !important; transition: revert !important; user-select: revert !important; vertical-align: revert !important; visibility: revert !important; white-space: revert !important; width: revert !important; word-break: revert !important; word-spacing: revert !important; writing-mode: revert !important; zoom: revert !important; width: 100% !important; background-color: #EAEAEA !important; padding: 7px 5px 7px 15px !important; font-family: wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif !important; font-size: 12px !important; font-weight: normal !important; color: #212121 !important; text-align: left !important; word-wrap: break-word !important; ">
              <div style=" aspect-ratio: revert !important; background: revert !important; block-size: revert !important; border: revert !important; bottom: revert !important; color: revert !important; color-scheme: revert !important; content-visibility: revert !important; cursor: revert !important; direction: revert !important; display: revert !important; font-size: revert !important; height: revert !important; hyphens: revert !important; letter-spacing: revert !important; line-height: revert !important; margin: revert !important; opacity: revert !important; order: revert !important; outline: revert !important; overflow: revert !important; padding: revert !important; position: revert !important; resize: revert !important; rotate: revert !important; scale: revert !important; tab-size: revert !important; table-layout: revert !important; text-align: revert !important; text-indent: revert !important; text-orientation: revert !important; text-overflow: revert !important; text-shadow: revert !important; text-transform: revert !important; text-wrap: revert !important; top: revert !important; transition: revert !important; user-select: revert !important; vertical-align: revert !important; visibility: revert !important; white-space: revert !important; width: revert !important; word-break: revert !important; word-spacing: revert !important; writing-mode: revert !important; zoom: revert !important; ">
                <a class="moz-txt-link-abbreviated" href="mailto:sale987@live.com">sale987@live.com</a> sembra simile a un utente che in
                precedenza ti ha inviato un messaggio di posta
                elettronica, ma potrebbe non essere lo stesso.
                <a href="https://urldefense.us/v3/__https://aka.ms/LearnAboutSenderIdentification__;!!G_uCfscf7eWS!d2x1h3Pt9OqhfeBcqW8pR0dbGy3bRw6bM-p0DxGAaY0CXWkqH3lpsuXiob9mOqfsy-aRVJXUig3819n2CWpYyFn4FDaTAWRxNDXZsA$" style="background: revert !important;color: revert !important;content-visibility: revert !important;direction: revert !important;display: revert !important;font-size: revert !important;opacity: revert !important;rotate: revert !important;scale: revert !important;visibility: revert !important;" moz-do-not-send="true">
                  Scopri perché potrebbe trattarsi di un rischio</a> </div>
            </td>
            <td valign="middle" align="left" width="75px" bgcolor="#EAEAEA" cellpadding="7px 5px 7px 5px" color="#212121" style=" aspect-ratio: revert !important; background: revert !important; block-size: revert !important; border: revert !important; bottom: revert !important; color: revert !important; color-scheme: revert !important; content-visibility: revert !important; cursor: revert !important; direction: revert !important; display: revert !important; font-size: revert !important; height: revert !important; hyphens: revert !important; letter-spacing: revert !important; line-height: revert !important; margin: revert !important; opacity: revert !important; order: revert !important; outline: revert !important; overflow: revert !important; padding: revert !important; position: revert !important; resize: revert !important; rotate: revert !important; scale: revert !important; tab-size: revert !important; table-layout: revert !important; text-align: revert !important; text-indent: revert !important; text-orientation: revert !important; text-overflow: revert !important; text-shadow: revert !important; text-transform: revert !important; text-wrap: revert !important; top: revert !important; transition: revert !important; user-select: revert !important; vertical-align: revert !important; visibility: revert !important; white-space: revert !important; width: revert !important; word-break: revert !important; word-spacing: revert !important; writing-mode: revert !important; zoom: revert !important; width: 75px !important; background-color: #EAEAEA !important; padding: 7px 5px 7px 5px !important; font-family: wf_segoe-ui_normal, Segoe UI, Segoe WP, Tahoma, Arial, sans-serif !important; font-size: 12px !important; font-weight: normal !important; color: #212121 !important; text-align: left !important; word-wrap: break-word !important; align: left !important; "><br>
            </td>
          </tr>
        </tbody>
      </table>
      <div>
        <div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
          Dear Barry,</div>
        <div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
          <br>
        </div>
        <div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
          thank you for your reply. Now everything works fine.</div>
        <div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
          <br>
        </div>
        <div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
          Best regards</div>
        <div class="elementToProof" style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
          Samuele</div>
        <hr style="display:inline-block;width:98%" tabindex="-1">
        <div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Da:</b> Barry Smith
            <a class="moz-txt-link-rfc2396E" href="mailto:bsmith@petsc.dev"><bsmith@petsc.dev></a><br>
            <b>Inviato:</b> mercoledì 5 novembre 2025 15:47<br>
            <b>A:</b> Samuele Ferri <a class="moz-txt-link-rfc2396E" href="mailto:sale987@live.com"><sale987@live.com></a><br>
            <b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>
            <a class="moz-txt-link-rfc2396E" href="mailto:petsc-users@mcs.anl.gov"><petsc-users@mcs.anl.gov></a><br>
            <b>Oggetto:</b> Re: [petsc-users] Two SNES on the same DM
            not working</font>
          <div> </div>
        </div>
        <div style="line-break:after-white-space">
          <div><br>
          </div>
             This is not supported. Duplicate your DM.<br id="x_lineBreakAtBeginningOfMessage">
          <div><br>
            <blockquote type="cite">
              <div>On Nov 5, 2025, at 9:17 AM, Samuele Ferri
                <a class="moz-txt-link-rfc2396E" href="mailto:sale987@live.com"><sale987@live.com></a> wrote:</div>
              <br class="x_Apple-interchange-newline">
              <div>
                <div class="x_elementToProof" style="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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  Dear petsc users,</div>
                <div class="x_elementToProof" style="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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  in petsc version 3.24, I'm trying to create two snes
                  over the same DM, but with different functions and
                  jacobians. Despite making different calls to
                  SNESSetFunction it happens the second snes uses the
                  same function of the first.</div>
                <div class="x_elementToProof" style="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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  Can you help me finding the problem, please?</div>
                <div class="x_elementToProof" style="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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  Here below there is a minimal working example showing
                  the issue:</div>
                <div class="x_elementToProof" style="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; text-decoration:none; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none">
                  <div class="x_elementToProof" style="line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                    static char help[] = "Test SNES.\n";</div>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  #include <petscsys.h></div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  #include <petscdmda.h></div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  #include <petscsnes.h><br>
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  PetscErrorCode Jac_1(SNES<span class="x_Apple-converted-space"> </span><i>snes</i>,
                  Vec<span class="x_Apple-converted-space"> </span><i>x</i>,
                  Mat<span class="x_Apple-converted-space"> </span><i>J</i>,
                  Mat<span class="x_Apple-converted-space"> </span><i>B</i>,
                  void *){</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionBegin;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      printf("Jac 1\n");</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionReturn(PETSC_SUCCESS);</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  }</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  PetscErrorCode Function_1(SNES<span class="x_Apple-converted-space"> </span><i>snes</i>,
                  Vec<span class="x_Apple-converted-space"> </span><i>x</i>,
                  Vec<span class="x_Apple-converted-space"> </span><i>f</i>,
                  void *){</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionBegin;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      printf("Function 1\n");</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionReturn(PETSC_SUCCESS);</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  }</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  PetscErrorCode Jac_2(SNES<span class="x_Apple-converted-space"> </span><i>snes</i>,
                  Vec<span class="x_Apple-converted-space"> </span><i>x</i>,
                  Mat<span class="x_Apple-converted-space"> </span><i>J</i>,
                  Mat<span class="x_Apple-converted-space"> </span><i>B</i>,
                  void *){</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionBegin;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      printf("Jac 2\n");</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionReturn(PETSC_SUCCESS);</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  }</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  PetscErrorCode Function_2(SNES<span class="x_Apple-converted-space"> </span><i>snes</i>,
                  Vec<span class="x_Apple-converted-space"> </span><i>x</i>,
                  Vec<span class="x_Apple-converted-space"> </span><i>f</i>,
                  void *){</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionBegin;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      printf("Function 2\n");</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionReturn(PETSC_SUCCESS);</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  }<br>
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  int main(int<span class="x_Apple-converted-space"> </span><i>argc</i>,
                  char **<i>argv</i>) {</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionBeginUser;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(PetscInitialize(&<i>argc</i>, &<i>argv</i>,
                  NULL, help));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      DM dm;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(DMDACreate1d(PETSC_COMM_WORLD,
                  DM_BOUNDARY_NONE, 100, 1, 1, NULL, &dm));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(DMSetFromOptions(dm));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(DMSetUp(dm));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      SNES snes1, snes2;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      Vec r1,r2;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      Mat J1, J2;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(DMCreateGlobalVector(dm, &r1));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(DMCreateGlobalVector(dm, &r2))</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(DMCreateMatrix(dm, &J1));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(DMCreateMatrix(dm, &J2));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESCreate(PETSC_COMM_WORLD,
                  &snes1));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESCreate(PETSC_COMM_WORLD,
                  &snes2));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetType(snes1, SNESNEWTONLS));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetType(snes2, SNESNEWTONLS));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetFromOptions(snes1));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetFromOptions(snes2));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetFunction(snes1, r1, Function_1,
                  NULL));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetFunction(snes2, r2, Function_2,
                  NULL));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetJacobian(snes1, J1, J1, Jac_1,
                  NULL));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetJacobian(snes2, J2, J2, Jac_2,
                  NULL));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetDM(snes1, dm));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSetDM(snes2, dm));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSolve(snes1, NULL, NULL));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESSolve(snes2, NULL, NULL));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      printf("snes1 %p; snes2 %p\n", snes1, snes2);</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  <br>
                </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      SNESFunctionFn *p;</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESGetFunction(snes1, NULL, &p,
                  NULL));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      printf("snes1: pointer %p, true function %p\n",
                  *p, Function_1);</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(SNESGetFunction(snes2, NULL, &p,
                  NULL));</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      printf("snes2: pointer %p, true function %p\n",
                  *p, Function_2);</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                     </div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscCall(PetscFinalize());</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                      PetscFunctionReturn(PETSC_SUCCESS);</div>
                <div class="x_elementToProof" style="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; text-decoration:none; line-height:22px; font-family:Calibri,Helvetica,sans-serif; font-size:12pt">
                  }</div>
              </div>
            </blockquote>
          </div>
          <br>
        </div>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Prof. Matteo Semplice
Università degli Studi dell’Insubria
Dipartimento di Scienza e Alta Tecnologia – DiSAT
Professore Associato
Via Valleggio, 11 – 22100 Como (CO) – Italia
tel.: +39 031 2386316</pre>
  </body>
</html>