<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div>I think the attached is wrong. </div><div><br class=""></div><div><img apple-inline="yes" id="0CBE59D3-B236-43D8-B090-8C8A7B59C7F2" width="640" height="80" src="cid:B80716FB-0333-4D08-AE17-BEE7EA1EBC55" class=""></div><div><br class=""></div><div>The input to the matrix vector product for the Jacobian is always global vectors which means on each process the dimension is not the size of the DMGetLocalVector() it should be the VecGetLocalSize() of the DMGetGlobalVector()</div><div><br class=""></div><div>But you may be able to skip all this and have the DM create the shell matrix setting it sizes appropriately and you only need to supply the MATOP</div><div><br class=""></div><div>DMSetMatType(dm,MATSHELL);</div><div>DMCreateMatrix(dm,&A);</div><div><br class=""></div><div>In fact, I also don't understand the PetscJacobianFunction_JFKN() function It seems to be doing finite differencing on the DMPlexTSComputeRHSFunctionFVM() assuming the current function value is in usr->RHS_ref.   How is this different than just letting PETSc/SNES used finite differences to do the matrix-vector product. Your code seems rather complicated with the DMGlobalToLocal() which I don't understand what it is suppose to do there.  </div><div><div><br class=""></div><div>I think you can just call </div><div><br class=""></div><div>TSGetSNES()</div><div>SNESSetUseMatrixFree(snes,PETSC_TRUE,PETSC_FALSE);  </div><div><br class=""></div><div>and it will set up an internal matrix that does the finite differencing for you. Then you never need a shell matrix.</div><div><br class=""></div><div><br class=""></div></div><div>Also to create the preconditioner matrix B this should work </div><div><br class=""></div><div><div>DMSetMatType(dm,MATAIJ);</div><div>DMCreateMatrix(dm,&B);</div><div><br class=""></div><div>no need for you to figure out the sizes.</div><div><br class=""></div><div><br class=""></div><div>Note that both A and B need to have the same dimensions on each process as the global vectors which I don't think your current code has.</div><div><br class=""></div><div><br class=""></div><div><br class=""></div><div>Barry</div><div><br class=""></div><div><br class=""></div><div><br class=""></div></div><div><blockquote type="cite" class=""><div class="">On Aug 24, 2020, at 12:56 AM, Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" class="">thibault.bridelbertomeu@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div class=""><div class="">Barry, first of all, thank you very much for your detailed answer, I keep reading it to let it soak in - I might come back to you for more details if you do not mind.</div><div class=""><br class=""></div><div class="">In the meantime, to fuel the conversation, I attach to this e-mail two pdfs containing the pieces of the code that regard what we are discussing. In the *timedisc.pdf, you'll find how I handle the initialization of the TS object, and in the *petscdefs.pdf you'll find the method that calls the TSSolve as well as the methods that are linked to the TS (the timestep adapt, the jacobian etc ...). [Sorry for the quality, I cannot do better than that sort of pdf ...]</div><div class=""><br class=""></div><div class="">Based on what is in the structured code I sent you the other day, I rewrote the PetscJacobianFunction_JFNK. I think it should be all right, but although it compiles, execution raises a seg fault I think when I do</div><div class="">ierr = TSSetIJacobian(ts, A, A, PetscIJacobian, user);</div><div class="">saying that A does not have the right dimensions. It is quite new, I am still looking into where exactly the error is raised. What do you think of this implementation though, does it look correct in your expert eyes ?</div><div class="">As for what we really discussed so far, it's that PetscComputePreconMatImpl that I do not know how to implement (with the derivative of the jacobian based on the FVM object).</div><div class=""><br class=""></div><div class=""> I understand now that what I am showing you today might not be the right way to go if one wants to really use the PetscFV, but I just wanted to add those code lines to the conversation to have your feedback.</div><div class=""><br class=""></div><div class="">Thank you again for your help,</div><div class=""><br class=""></div><div class="">Thibault</div></div></div></div></div></div></div></div><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 21 août 2020 à 19:25, Barry Smith <<a href="mailto:bsmith@petsc.dev" class="">bsmith@petsc.dev</a>> a écrit :<br class=""></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;" class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Aug 21, 2020, at 10:58 AM, Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank" class="">thibault.bridelbertomeu@gmail.com</a>> wrote:</div><br class=""><div class=""><div class=""><div dir="auto" class="">Thank you Barry for the tip ! I’ll make sure to do that when everything is set. </div><div dir="auto" class="">What I also meant is that there will not be any more direct way to set the preconditioner than to go through SNESSetJacobian after having assembled everything by hand ? Like, in my case, or in the more general case of fluid dynamics equations, the preconditioner is not a fun matrix to assemble, because for every cell the derivative of the physical flux jacobian has to be taken and put in the right block in the matrix - finite element style if you want. Is there a way to do that with Petsc methods, maybe short-circuiting the FEM based methods ?</div></div></div></blockquote><div class=""><br class=""></div><div class="">  Thibault</div><div class=""><br class=""></div>   I am not sure what you mean but there are a couple of things that may be helpful.</div><div class=""><br class=""></div><div class="">   <a class="">PCSHELL https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCSHELL.html</a> allows you to build your own preconditioner (that can and often will use one or more of its own Mats, and KSP or PC inside it, or even use another PETScFV etc to build some of the sub matrices for you if it is appropriate), this approach means you never need to construct a "global" PETSc matrix from which PETSc builds the preconditioner. But you should only do this if the conventional approach is not reasonable for your problem.</div><div class=""> </div><div class="">   MATNEST <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MATNEST.html" target="_blank" class="">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MATNEST.html</a> allows you to build a global matrix by building parts of it separately and even skipping parts you decide you don't need in the preconditioner. Conceptually it is the same as just creating a global matrix and filling up but the process is a bit different and something suitable for "multi physics" or "multi-equation" type applications.</div><div class=""><br class=""></div><div class="">    Of course what you put into PCSHELL and MATNEST will affect the convergence of the nonlinear solver.  As Jed noted what you put in the "Jacobian" does not have to be directly the same mathematically as what you put into the TSSetI/RHSFunction with the caveat that it does have to appropriate spectral properties to result in a good preconditioner for the "true" Jacobian. </div><div class=""><br class=""></div><div class="">    Couple of other notes:</div><div class=""><br class=""></div><div class="">The entire business of "Jacobian" matrix-free or not (with for example -snes_fd_operator) is tricky because as Jed noted if your finite volume scheme has non-differential terms such as if () tests. There is a concept of sub-differential for this type of thing but I know absolutely nothing about that and probably not worth investigating. </div><div class=""><br class=""></div><div class="">In this situation you can avoid the "true" Jacobian completely (both for matrix-vector product and preconditioner) and use something else as Jed suggested a lower order scheme that is differentiable. This can work well for solving the nonlinear system or not depending on how suitable it is for your original "function" </div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">1) In theory at least you can have the Jacobian matrix-vector product computed directly using DMPLEX/PETScFV infrastructure (it would apply the Jacobian locally matrix-free using code similar to the code that evaluates the FV "function". I do no know if any of this code is written, it will be more efficient than -snes_mf_operator that evaluates the FV "function" and does traditional differencing to compute the Jacobian. Again it has the problem of non-differentialability if the function is not differential. But it could be done for a different (lower order scheme) that is differentiable.</div><div class=""><br class=""></div><div class="">2) You can have PETSc compute the  Jacobian explicitly coloring and from that build the preconditioner, this allows you to avoid the hassle of writing the code for the derivatives yourself. This uses finite differences on your function and coloring of the graph to compute many columns of the Jacobian simultaneously and can be pretty efficient. Again if the function is not differential there can be issues of what the result means and will it work in a nonlinear solver. SNESComputeJacobianDefaultColor <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESComputeJacobianDefaultColor.html" target="_blank" class="">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESComputeJacobianDefaultColor.html</a></div><div class=""><br class=""></div><div class="">3) Much more outlandish is to skip Newton and Jacobians completely and use the full approximation scheme SNESFAS <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNESFAS/SNESFAS.html" target="_blank" class="">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNESFAS/SNESFAS.html</a> this requires a grid hierarchy and appropriate way to interpolate up through the grid hierarchy your finite volume solutions. Probably not worth investigating unless you have lots of time on your hands and keen interest in this kind of stuff <a href="https://arxiv.org/pdf/1607.04254.pdf" target="_blank" class="">https://arxiv.org/pdf/1607.04254.pdf</a></div><div class=""><br class=""></div><div class="">So to summarize, and Matt and Jed can correct my mistakes. </div><div class=""><br class=""></div><div class="">1)   Form the full Jacobian from the original "function" using analytic approach use it for both the matrix-vector product and to build the preconditioner. Problem if full Jacobian not well defined mathematically. Tough to code, usually not practical.</div><div class=""><br class=""></div><div class="">2)   Do any matrix free (any way) for the full Jacobian and </div><div class=""><br class=""></div><div class=""> a) build another "approximate" Jacobian (using any technique analytic or finite differences using matrix coloring on a new "lower order" "function") Still can have trouble if this original Jacobian is no well defined</div><div class=""><br class=""></div><div class=""> b)   "write your own preconditioner" that internally can use anything in PETSc that approximately solves the Jacobian. Same potential problems if original Jacobian is not differential, plus convergence will depend on how good your own preconditioner approximates the inverse of the true Jacobian.</div><div class=""><br class=""></div><div class="">3) Use a lower Jacobian (computed anyway you want) for the matrix-vector product and the preconditioner. The problem of differentiability is gone but convergence of the nonlinear solver depends on how well lower order Jacobian is appropriate for the original "function"</div><div class="">  </div><div class="">    a) Form the "lower order" Jacobian analytically or with coloring and use for both matrix-vector product and building preconditioner. Note that switching between this and 2a is trivial.</div><div class=""><br class=""></div><div class="">     b) Do the "lower order" Jacobian matrix free and provide your own PCSHELL. Note that switching between this and 2b is trivial.</div><div class=""><br class=""></div><div class="">   Barry</div><div class=""><br class=""></div><div class="">I would first try competing the "true" Jacobian via coloring, if that works and give satisfactory results (fast enough) then stop. </div><div class=""><br class=""></div><div class="">Then I would do 2a/2b by writing my "function" using PETScFV  and writing the "lower order function" via PETScFV and use matrix coloring to get the Jacobian from the second "lower order function". If this works well (either with 2a or 3a or both) then stop or you can compute the "lower order" Jacobian analytically (again using PetscFV) for a more efficient evaluation of the Jacobian. </div><div class="">   </div><div class=""> <br class=""><blockquote type="cite" class=""><div class=""><div class=""><div dir="auto" class=""><br class=""></div><div dir="auto" class="">Thanks ! </div><div dir="auto" class=""><br class=""></div><div dir="auto" class="">Thibault</div></div><div class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 21 août 2020 à 17:22, Barry Smith <<a href="mailto:bsmith@petsc.dev" target="_blank" class="">bsmith@petsc.dev</a>> a écrit :<br class=""></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;" class=""><br class=""><div class=""></div></div><div style="overflow-wrap: break-word;" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On Aug 21, 2020, at 8:35 AM, Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank" class="">thibault.bridelbertomeu@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><br clear="all" class=""></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 21 août 2020 à 15:23, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" class="">knepley@gmail.com</a>> a écrit :<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div dir="ltr" class="">On Fri, Aug 21, 2020 at 9:10 AM Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank" class="">thibault.bridelbertomeu@gmail.com</a>> wrote:<br class=""></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 dir="ltr" class="">Sorry, I sent too soon, I hit the wrong key.<br clear="all" class=""><div class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><br class=""></div><div class="">I wanted to say that context.npoints is the local number of cells.</div><div class=""><br class=""></div><div class="">PetscRHSFunctionImpl allows to generate the hyperbolic part of the right hand side.</div><div class="">Then we have :<br class=""></div><div class=""><br class=""></div><div class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-weight:normal;font-size:13px;line-height:18px;white-space:pre-wrap;background-color:rgb(255,255,254)" class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscErrorCode</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscIJacobian</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                               </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">TS</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ts</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,        </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/*!< Time stepping object (see PETSc TS)*/</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                               </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscReal</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">t</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,  </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/*!< Current time */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                               </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">Vec</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">Y</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,        </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/*!< Solution vector */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                               </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">Vec</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">Ydot</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,     </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/*!< Time-derivative of solution vector */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                               </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscReal</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">a</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,  </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/*!< Shift */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                               </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">Mat</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">A</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,        </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/*!< Jacobian matrix */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                               </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">Mat</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">B</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,        </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/*!< Preconditioning matrix */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                               </span><span style="font-weight:bold;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(9,30,66)" class="">void</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> *</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ctxt</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/*!< Application context */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                             )</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">{</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETScContext</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> *</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = (</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETScContext</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">*) </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ctxt</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">HyPar</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">        *</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">solver</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">solver</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">_DECLARE_IERR_</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><br class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscFunctionBegin</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">solver</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">count_IJacobian</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">++;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">shift</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">a</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">waqt</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">t</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/* Construct preconditioning matrix */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-weight:bold;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(9,30,66)" class="">if</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> (</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">flag_use_precon</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">) { </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">IERR</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscComputePreconMatImpl</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">B</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">Y</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHECKERR</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); }</span></div><br class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">  </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscFunctionReturn</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(101,84,192)" class="">0</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">}</span></div></div></div></div></div></div></div></div></div><div class=""><br class=""></div><div class="">and<span style="color:rgb(32,32,32)" class=""> PetscJacobianFunction_JFNK which I bind to the matrix shell, computes the action of the jacobian on a vector : say U0 is the state of reference and Y the vector upon which to apply the JFNK method, then the PetscJacobianFunction_JFNK returns shift * Y - 1/epsilon * (F(U0 + epsilon*Y) - F(U0)) where F allows to evaluate the hyperbolic flux (shift comes from the TS).<br class=""></span></div><div class=""><span style="color:rgb(32,32,32)" class="">The preconditioning matrix I compute as an approximation to the actual jacobian, that is shift * Identity - Derivative(dF/dU) where dF/dU is, in each cell, a 4x4 matrix that is known exactly for the system of equations I am solving, i.e. Euler equations. For the structured grid, I can loop on the cells and do that 'Derivative' thing at first order by simply taking a finite-difference like approximation with the neighboring cells, Derivative(phi) = phi_i - phi_{i-1} and I assemble the B matrix block by block (JFunction is the dF/dU)<br class=""></span></div><div class=""><span style="color:rgb(32,32,32)" class=""><br class=""></span></div><div class=""><div class=""><span class="">/* diagonal element */</span></div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00123" class=""></a><span class=""> </span>      <span class="">for</span> (v=0; v<nvars; v++) { rows[v] = nvars*pg + v; cols[v] = nvars*pg + v; }</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00124" class=""></a><span class=""> </span>      ierr = solver-><a href="http://hypar.github.io/a00144.html#a25c87c7c874c7e08981688fe6c51167b" target="_blank" class="">JFunction</a>(values,(u+nvars*p),solver-><a href="http://hypar.github.io/a00144.html#a48e81a1806b5774943fd9a26e9a190f2" target="_blank" class="">physics</a>,dir,0);</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00125" class=""></a><span class=""> </span>       <a href="http://hypar.github.io/a00165.html#a1dab5f429ccd03c4a7fbb605d8ef75b6" target="_blank" class="">_ArrayScale1D_</a>(values,(dxinv*iblank),(nvars*nvars));</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00126" class=""></a><span class=""> </span>       ierr = MatSetValues(Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); CHKERRQ(ierr);</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00127" class=""></a><span class=""> </span> <br class=""></div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00128" class=""></a><span class=""> </span>       <span class="">/* left neighbor */</span></div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00129" class=""></a><span class=""> </span>       <span class="">if</span> (pgL >= 0) {</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00130" class=""></a><span class=""> </span>         <span class="">for</span> (v=0; v<nvars; v++) { rows[v] = nvars*pg + v; cols[v] = nvars*pgL + v; }</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00131" class=""></a><span class=""> </span>         ierr = solver-><a href="http://hypar.github.io/a00144.html#a25c87c7c874c7e08981688fe6c51167b" target="_blank" class="">JFunction</a>(values,(u+nvars*pL),solver-><a href="http://hypar.github.io/a00144.html#a48e81a1806b5774943fd9a26e9a190f2" target="_blank" class="">physics</a>,dir,1);</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00132" class=""></a><span class=""> </span>         <a href="http://hypar.github.io/a00165.html#a1dab5f429ccd03c4a7fbb605d8ef75b6" target="_blank" class="">_ArrayScale1D_</a>(values,(-dxinv*iblank),(nvars*nvars));</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00133" class=""></a><span class=""> </span>         ierr = MatSetValues(Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); CHKERRQ(ierr);</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00134" class=""></a><span class=""> </span>       }</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00135" class=""></a><span class=""> </span>       </div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00136" class=""></a><span class=""> </span>       <span class="">/* right neighbor */</span></div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00137" class=""></a><span class=""> </span>       <span class="">if</span> (pgR >= 0) {</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00138" class=""></a><span class=""> </span>         <span class="">for</span> (v=0; v<nvars; v++) { rows[v] = nvars*pg + v; cols[v] = nvars*pgR + v; }</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00139" class=""></a><span class=""> </span>         ierr = solver-><a href="http://hypar.github.io/a00144.html#a25c87c7c874c7e08981688fe6c51167b" target="_blank" class="">JFunction</a>(values,(u+nvars*pR),solver-><a href="http://hypar.github.io/a00144.html#a48e81a1806b5774943fd9a26e9a190f2" target="_blank" class="">physics</a>,dir,-1);</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00140" class=""></a><span class=""> </span>         <a href="http://hypar.github.io/a00165.html#a1dab5f429ccd03c4a7fbb605d8ef75b6" target="_blank" class="">_ArrayScale1D_</a>(values,(-dxinv*iblank),(nvars*nvars));</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00141" class=""></a><span class=""> </span>         ierr = MatSetValues(Pmat,nvars,rows,nvars,cols,values,ADD_VALUES); CHKERRQ(ierr);</div><br class=""><br class=""><div class=""><a name="m_1333392557926925099_m_1465256462669123407_m_-549060344189013999_m_-8102338331154726675_l00142" class=""></a><span class=""> </span>       }</div><span style="color:rgb(32,32,32)" class=""></span></div><div class=""><span style="color:rgb(32,32,32)" class=""><br class=""></span></div><div class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-weight:normal;font-size:13px;line-height:18px;white-space:pre-wrap;background-color:rgb(255,255,254)" class=""><br class=""></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-weight:normal;font-size:13px;line-height:18px;white-space:pre-wrap;background-color:rgb(255,255,254)" class=""><br class=""></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-weight:normal;font-size:13px;line-height:18px;white-space:pre-wrap;background-color:rgb(255,255,254)" class="">I do not know if I am clear here ...</div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-weight:normal;font-size:13px;line-height:18px;white-space:pre-wrap;background-color:rgb(255,255,254)" class="">Anyways, I am trying to figure out how to do this shell matrix and this preconditioner using all the FV and DMPlex artillery.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Okay, that is very clear. We should be able to get the JFNK just with -snes_mf_operator, and put the approximate J construction in DMPlexComputeJacobian_Internal().</div><div class="">There is an FV section already, and we could just add this. I would need to understand those entries in the pointwise Riemann sense that the other stuff is now.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Ok i had a quick look and if I understood correctly it would do the job. Setting the snes-mf-operator flag would mean however that we have to go through SNESSetJacobian to set the jacobian and the preconditioning matrix wouldn't it ?</div></div></div></div></blockquote><div class=""><br class=""></div></div></div><div style="overflow-wrap: break-word;" class=""><div class=""><div class="">  Thibault,</div><div class=""><br class=""></div>   Since the TS implicit methods end up using SNES internally the option should be available to you without requiring you to be calling the SNES routines directly</div><div class=""><br class=""></div><div class="">   Once you have finalized your approach and if for the implicit case you always work in the snes mf operator mode you can hardwire </div><div class=""><br class=""></div><div class="">    TSGetSNES(ts,&snes);</div><div class="">    SNESSetUseMatrixFree(snes,PETSC_TRUE,PETSC_FALSE);</div><div class=""><br class=""></div><div class="">    in your code so you don't need to always provide the option -snes-mf-operator </div></div><div style="overflow-wrap: break-word;" class=""><div class=""><br class=""></div><div class="">   Barry</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> <br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_quote"><div class="">There might be calls to the Riemann solver to evaluate the dRHS / dU part yes but maybe it's possible to re-use what was computed for the RHS^n ?<br class=""></div><div class="">In the FV section the jacobian is set to identity which I missed before, but it could explain why when I used the following :<br class=""><pre width="80" style="font-family:monospace" class="">TSSetType(ts, TSBEULER);<br class="">DMTSSetIFunctionLocal(dm, <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/DMPlexTSComputeIFunctionFEM.html#DMPlexTSComputeIFunctionFEM" style="font-family:monospace" target="_blank" class="">DMPlexTSComputeIFunctionFEM</a>, &ctx);<br class="">DMTSSetIJacobianLocal(dm, <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/TS/DMPlexTSComputeIJacobianFEM.html#DMPlexTSComputeIJacobianFEM" style="font-family:monospace" target="_blank" class="">DMPlexTSComputeIJacobianFEM</a>, &ctx);</pre></div><div class=""> with my FV discretization nothing happened, right ?</div><div class=""><br class=""></div><div class="">Thank you, <br class=""></div><div class=""><br class=""></div><div class="">Thibault<br class=""></div><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class="gmail_quote"><div class=""></div><div class="">  Thanks,</div><div class=""><br class=""></div><div class="">     Matt</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le ven. 21 août 2020 à 14:55, Thibault Bridel-Bertomeu <<a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank" class="">thibault.bridelbertomeu@gmail.com</a>> a écrit :<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr" class=""><div class="">Hi,</div><div class=""><br class=""></div><div class="">Thanks Matthew and Jed for your input.</div><div class="">I indeed envision an implicit solver in the sense Jed mentioned - Jiri Blazek's book is a nice intro to this concept.</div><div class=""><br class=""></div><div class="">Matthew, I do not know exactly what to change right now because although I understand globally what the DMPlexComputeXXXX_Internal methods do, I cannot say for sure line by line what is happening.<br class=""></div><div class="">In a structured code, I have a an implicit FVM solver with PETSc but I do not use any of the FV structure, not even a DM - I just use C arrays that I transform to PETSc Vec and Mat and build my IJacobian and my preconditioner and gives all that to a TS and it runs. I cannot figure out how to do it with the FV and the DM and all the underlying "shortcuts" that I want to use.</div><div class=""><br class=""></div><div class="">Here is the top method for the structured code :</div><div class=""><br class=""></div><div class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-weight:normal;font-size:13px;line-height:18px;white-space:pre-wrap;background-color:rgb(255,255,254)" class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;font-weight:normal;font-size:13px;line-height:18px;white-space:pre-wrap;background-color:rgb(255,255,254)" class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-weight:bold;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(9,30,66)" class="">int</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">total_size</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">.</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">npoints</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> * </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">solver</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">nvars</span></div></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">TSSetRHSFunction</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ts</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETSC_NULL</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscRHSFunctionImpl</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,&</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">SNES</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">     </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">snes</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">KSP</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">      </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ksp</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PC</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">       </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">pc</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">SNESType</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">snestype</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">TSGetSNES</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ts</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,&</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">snes</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">SNESGetType</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">snes</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,&</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">snestype</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><br class=""></span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class=""></span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">flag_mat_a</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(101,84,192)" class="">1</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">MatCreateShell</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">MPI_COMM_WORLD</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">total_size</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">total_size</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETSC_DETERMINE</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                          </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETSC_DETERMINE</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,&</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,&</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">A</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">.</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">jfnk_eps</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(101,84,192)" class="">1e-7</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscOptionsGetReal</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">NULL</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">NULL</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(191,38,0)" class="">"-jfnk_epsilon"</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,&</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">.</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">jfnk_eps</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">NULL</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">MatShellSetOperation</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">A</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">MATOP_MULT</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,(</span><span style="font-weight:bold;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(9,30,66)" class="">void</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> (*)(</span><span style="font-weight:bold;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(9,30,66)" class="">void</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">))</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscJacobianFunction_JFNK</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">MatSetUp</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">A</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><br class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">.</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">flag_use_precon</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(101,84,192)" class="">0</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscOptionsGetBool</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETSC_NULL</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETSC_NULL</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(191,38,0)" class="">"-with_pc"</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscBool</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">*)(&</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">.</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">flag_use_precon</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">),</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETSC_NULL</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><br class=""><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/* Set up preconditioner matrix */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">flag_mat_b</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(101,84,192)" class="">1</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">;</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">MatCreateAIJ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">MPI_COMM_WORLD</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">total_size</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">total_size</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETSC_DETERMINE</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PETSC_DETERMINE</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                        (</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">solver</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ndims</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">*</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(101,84,192)" class="">2</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">+</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(101,84,192)" class="">1</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">)*</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">solver</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">nvars</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">NULL</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">                        </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(101,84,192)" class="">2</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">*</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">solver</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ndims</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">*</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">solver</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">nvars</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">NULL</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,&</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">B</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">MatSetBlockSize</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">B</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">solver</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">-></span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">nvars</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-style:italic;font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(160,160,160)" class="">/* Set the RHSJacobian function for TS */</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">    </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""> = </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">TSSetIJacobian</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ts</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">A</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">B</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">PetscIJacobian</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">,&</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">context</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">); </span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">CHKERRQ</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">(</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace;color:rgb(32,32,32)" class="">ierr</span><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class="">);</span></div><div style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><span style="font-family:SFMono-Medium,"SF Mono","Segoe UI Mono","Roboto Mono","Ubuntu Mono",Menlo,monospace" class=""><br class=""></span></div></div></div><div class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class="">Thibault Bridel-Bertomeu<br class="">—<br class=""></div></div></div></div>Eng, MSc, PhD</div><div class="">Research Engineer</div><div class="">CEA/CESTA</div><div class="">33114 LE BARP</div><div class="">Tel.: (+33)557046924</div><div class="">Mob.: (+33)611025322<br class=""></div><div class="">Mail: <a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank" class="">thibault.bridelbertomeu@gmail.com</a><br class=""></div></div></div></div></div></div></div><br class=""></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le jeu. 20 août 2020 à 18:43, Jed Brown <<a href="mailto:jed@jedbrown.org" target="_blank" class="">jed@jedbrown.org</a>> a écrit :<br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" class="">knepley@gmail.com</a>> writes:<br class=""><br class=""><br class=""><br class=""><br class=""><br class="">> I could never get the FVM stuff to make sense to me for implicit methods.<br class=""><br class=""><br class="">> Here is my problem understanding. If you have an FVM method, it decides<br class=""><br class=""><br class="">> to move "stuff" from one cell to its neighboring cells depending on the<br class=""><br class=""><br class="">> solution to the Riemann problem on each face, which computed the flux. This<br class=""><br class=""><br class="">> is<br class=""><br class=""><br class="">> fine unless the timestep is so big that material can flow through into the<br class=""><br class=""><br class="">> cells beyond the neighbor. Then I should have considered the effect of the<br class=""><br class=""><br class="">> Riemann problem for those interfaces. That would be in the Jacobian, but I<br class=""><br class=""><br class="">> don't know how to compute that Jacobian. I guess you could do everything<br class=""><br class=""><br class="">> matrix-free, but without a preconditioner it seems hard.<br class=""><br class=""><br class=""><br class=""><br class=""><br class="">So long as we're using method of lines, the flux is just instantaneous flux, not integrated over some time step.  It has the same meaning for implicit and explicit.<br class=""><br class=""><br class=""><br class=""><br class=""><br class="">An explicit method would be unstable if you took such a large time step (CFL) and an implicit method will not simultaneously be SSP and higher than first order, but it's still a consistent discretization of the problem.<br class=""><br class=""><br class=""><br class=""><br class=""><br class="">It's common (done in FUN3D and others) to precondition with a first-order method, where gradient reconstruction/limiting is skipped.  That's what I'd recommend because limiting creates nasty nonlinearities and the resulting discretizations lack h-ellipticity which makes them very hard to solve.<br class=""><br class=""><br class=""></blockquote></div><br class=""><br class=""></blockquote></div><br class=""><br class=""></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br class="">-- Norbert Wiener</div><div class=""><br class=""></div><div class=""><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank" class="">https://www.cse.buffalo.edu/~knepley/</a><br class=""></div></div></div></div></div></div></div></div><br class=""><br class=""></blockquote></div></div><br class=""><br class=""></div></blockquote></div><br class=""></div></blockquote></div></div>-- <br class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class="">Thibault Bridel-Bertomeu<br class="">—<br class=""></div></div></div></div>Eng, MSc, PhD</div><div class="">Research Engineer</div><div class="">CEA/CESTA</div><div class="">33114 LE BARP</div><div class="">Tel.: (+33)557046924</div><div class="">Mob.: (+33)611025322<br class=""></div><div class="">Mail: <a href="mailto:thibault.bridelbertomeu@gmail.com" target="_blank" class="">thibault.bridelbertomeu@gmail.com</a><br class=""></div></div></div></div></div></div>
</div></blockquote></div><br class=""></div></blockquote></div>
<span id="cid:f_ke83r4ux1"><petsc_fvm_part_timedisc_v2.pdf></span><span id="cid:f_ke83r4uh0"><petsc_fvm_part_petscdefs_v2.pdf></span></div></blockquote></div><br class=""></body></html>