<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body>
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Hi Matt,</p>
<p><br>
</p>
<p>Thanks for the reply. </p>
<p>I tested the following flags. </p>
<p><br>
</p>
<p>- With <span style="font-size: 12pt;">-snes_fd_color and -snes_fd_color_use_mat</span></p>
<p>I got a segmentation violation. I was able to get the call stack as I am using a debugger: </p>
<p>MatCreateSubmatrix_MPIAIJ_All</p>
<p>MatGetSeqNonzeroStructure_MPIAIJ</p>
<p>MatGetSeqNonzeroStructure</p>
<p>MatColoringApply_SL</p>
<p>MatColoringApply </p>
<p>SNESComputeJacobianDefaultColor</p>
<p><br>
</p>
<p>- With -snes_fd_color -snes_fd_color_use_mat -mat_coloring_type greedy -mat_coloring_weight_type lf , I get this error message: </p>
<p>[0]PETSC ERROR: Object is in wrong state</p>
<p>[0]PETSC ERROR: Not for unassembled matrix</p>
<p>[0]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.</p>
<p>[0]PETSC ERROR: Petsc Release Version 3.15.0, unknown </p>
<p>[0]PETSC ERROR: /global/u1/z/zjorti/Gitlab_repos/runaway_develop/runaway/cutcell/MFDsolver/QuasiStatic_Normalized/main on a arch-linux-c-debug named nid00223 by zjorti Mon Dec 13 09:14:12 2021</p>
<p>[0]PETSC ERROR: Configure options CC=cc CXX=CC FC=ftn COPTFLAGS=-g CXXOPTFLAGS=-g FOPTFLAGS=-g --download-superlu_dist --download-scalapack --download-mumps --download-hypre --with-debugging=1 --with-cxx-dialect=C++11</p>
<p>[0]PETSC ERROR: #1 MatIncreaseOverlap() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/interface/matrix.c:7302</p>
<p>[0]PETSC ERROR: #2 MatColoringGetDegrees() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/utils/weights.c:59</p>
<p>[0]PETSC ERROR: #3 MatColoringCreateLargestFirstWeights() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/utils/weights.c:131</p>
<p>[0]PETSC ERROR: #4 MatColoringCreateWeights() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/utils/weights.c:347</p>
<p>[0]PETSC ERROR: #5 MatColoringApply_Greedy() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/impls/greedy/greedy.c:563</p>
<p>[0]PETSC ERROR: #6 MatColoringApply() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/interface/matcoloring.c:355</p>
<p>[0]PETSC ERROR: #7 SNESComputeJacobianDefaultColor() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/snes/interface/snesj2.c:86</p>
<p>[0]PETSC ERROR: #8 SNESComputeJacobian() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/snes/interface/snes.c:2713</p>
<p>[0]PETSC ERROR: #9 SNESSolve_NEWTONLS() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/snes/impls/ls/ls.c:222</p>
<p>[0]PETSC ERROR: #10 SNESSolve() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/snes/interface/snes.c:4653</p>
<p>[0]PETSC ERROR: #11 TSStep_ARKIMEX() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/ts/impls/arkimex/arkimex.c:845</p>
<p>[0]PETSC ERROR: #12 TSStep() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/ts/interface/ts.c:3777</p>
<p>[0]PETSC ERROR: #13 TSSolve() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/ts/interface/ts.c:4174</p>
<p><br>
</p>
<p>- With -snes_fd_color -snes_fd_color_use_mat -mat_coloring_type greedy, there is this error: </p>
<p>[8]PETSC ERROR: Null argument, when expecting valid pointer</p>
<p>[8]PETSC ERROR: Null Object: Parameter # 1</p>
<p>[8]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.</p>
<p>[8]PETSC ERROR: Petsc Release Version 3.15.0, unknown </p>
<p>[8]PETSC ERROR: /global/u1/z/zjorti/Gitlab_repos/runaway_develop/runaway/cutcell/MFDsolver/QuasiStatic_Normalized/main on a arch-linux-c-debug named nid00223 by zjorti Mon Dec 13 09:27:11 2021</p>
<p>[8]PETSC ERROR: Configure options CC=cc CXX=CC FC=ftn COPTFLAGS=-g CXXOPTFLAGS=-g FOPTFLAGS=-g --download-superlu_dist --download-scalapack --download-mumps --download-hypre --with-debugging=1 --with-cxx-dialect=C++11</p>
<p>[8]PETSC ERROR: #1 VecGetLocalSize() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/vec/vec/interface/vector.c:688</p>
<p>[8]PETSC ERROR: #2 GreedyColoringLocalDistanceTwo_Private() at /global/project/projectdirs/m3016/Master_PETSc/Debug_PETSc/petsc/src/mat/color/impls/greedy/greedy.c:258</p>
<p><br>
</p>
<p><br>
</p>
<p>Besides, I found this thread "Questions about residual function can't be reduced" (<a href="https://www.mail-archive.com/search?l=petsc-users@mcs.anl.gov&q=subject:%22%5C%5Bpetsc%5C-users%5C%5D+questions%22&o=newest&f=1" class="OWAAutoLink" id="LPlnk179183" previewremoved="true">https://www.mail-archive.com/search?l=petsc-users@mcs.anl.gov&q=subject:%22%5C%5Bpetsc%5C-users%5C%5D+questions%22&o=newest&f=1</a>)
 where you are saying that the user needs to preallocate the Jacobian matrix correctly. Is it true only for user provided Jacobian matrix, or also for finite difference approximation with coloring? In the latter case, how can we do that? </p>
<p>Many thanks.</p>
<p><br>
</p>
<p>Zakariae</p>
<div><br>
</div>
</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>From:</b> petsc-users <petsc-users-bounces@mcs.anl.gov> on behalf of Matthew Knepley <knepley@gmail.com><br>
<b>Sent:</b> Saturday, December 11, 2021 2:28:33 PM<br>
<b>To:</b> Tang, Qi<br>
<b>Cc:</b> petsc-users@mcs.anl.gov<br>
<b>Subject:</b> [EXTERNAL] Re: [petsc-users] Finite difference approximation of Jacobian</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">On Sat, Dec 11, 2021 at 1:58 PM Tang, Qi <<a href="mailto:tangqi@msu.edu">tangqi@msu.edu</a>> wrote:<br>
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;">
<div>
<div>Hi,</div>
<div>Does anyone have comment on finite difference coloring with DMStag? We are using DMStag and TS to evolve some nonlinear equations implicitly. It would be helpful to have the coloring Jacobian option with that.</div>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Since DMStag produces the Jacobian connectivity, you can use -snes_fd_color_use_mat. It has many options. Here is an example of us using that:</div>
<div><br>
</div>
<div>  <a href="https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/ex19.c#L898">https://gitlab.com/petsc/petsc/-/blob/main/src/snes/tutorials/ex19.c#L898</a></div>
<div><br>
</div>
<div>  Thanks,</div>
<div><br>
</div>
<div>     Matt</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div style="overflow-wrap: break-word;">
<div>
<div>Thanks,</div>
<div>Qi</div>
<br>
</div>
<div><br>
<blockquote type="cite">
<div>On Oct 15, 2021, at 3:07 PM, Jorti, Zakariae via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank">petsc-users@mcs.anl.gov</a>> wrote:</div>
<br>
<div>
<div id="gmail-m_5615423000566682887divtagdefaultwrapper" dir="ltr" style="font-size:12pt;font-style:normal;font-variant-caps:normal;font-weight:normal;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">
<div style="margin-top:0px;margin-bottom:0px">Hello,</div>
<div style="margin-top:0px;margin-bottom:0px"><br>
</div>
<div style="margin-top:0px;margin-bottom:0px">Does the Jacobian approximation <span style="font-size:12pt">using coloring and finite differencing of the function evaluation work in DMStag? </span><span style="font-size:12pt">  </span></div>
<div style="margin-top:0px;margin-bottom:0px">Thank you.</div>
<div style="margin-top:0px;margin-bottom:0px">Best regards,</div>
<div style="margin-top:0px;margin-bottom:0px"><br>
</div>
<div style="margin-top:0px;margin-bottom:0px">Zakariae </div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</blockquote>
</div>
<br clear="all">
<div><br>
</div>
-- <br>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr">
<div>
<div dir="ltr">
<div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>
-- Norbert Wiener</div>
<div><br>
</div>
<div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>