<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=""><div class=""><div class="">Hello Isaac,</div><div class=""><br class=""></div><div class="">Thank you for your reply!</div><div class=""><br class=""></div><div class="">Let me confirm that when I use DMCreateMatrix() with the orig_dm, I got my jacobian_matrix. Also, I have succeeded to solve my system and my solution was converged<b class=""> by using one process</b>.</div><div class="">Let me give you some other information about my code. Currently, I am using my own discretization system and not the PetscDS object. Considering the nonlinear solver SNES, I use the following routines (like the basic snes usage):</div><div class="">- SNESSetFunction(snes,residual_vector,compute_residual ,(void*) _finite_element_formulation)</div><div class="">- SNESSetJacobian(snes, jacobian.matrix(), _jacobian_precond_matrix, compute_jacobian, (void*) _finite_element_formulation) </div><div class="">- SNESSolve(snes,NULL,x)</div><div class=""><br class=""></div><div class="">Regarding your last answer, I will try to reformulate my question as follows:</div><div class="">Using a distributed dm instead of the original dm (not distributed dm) and my own discretization system (not the PetscDS object), should I add something specific to get a distributed jacobian_matrix over processes?</div><div class="">I precise that I just replaced the orig_dm by a distributed mesh with the routine that I wrote in my first mail. So is it enough ?</div><div class=""> </div><div class="">Thank you and have a good day,</div><div class="">Sami,</div></div><div class=""><br class=""></div><br class=""><div class="">
<meta charset="UTF-8" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">--</div><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Dr. Sami BEN ELHAJ SALAH<br class="">Ingénieur de Recherche (CNRS)<br class="">Institut Pprime - ISAE - ENSMA<br class="">Mobile: 06.62.51.26.74<br class=""><a href="mailto:sami.ben-elhaj-salah@ensma.fr" class="">Email: sami.ben-elhaj-salah@ensma.fr</a></div><div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><a href="https://samiben91.github.io/samibenelhajsalah/index.html" class="">www.samibenelhajsalah.com</a><br class=""><br class=""><br class=""></div></div></div></div>
</div>
<div><br class=""><blockquote type="cite" class=""><div class="">Le 25 mai 2022 à 19:41, Toby Isaac <<a href="mailto:toby.isaac@gmail.com" class="">toby.isaac@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi Sami,<br class=""><br class="">Just to verify: if you call DMCreateMatrix() on orig_dm, do you get a<br class="">Jacobian matrix?<br class=""><br class="">The DMPlex must be told what kind of discretized fields you want a<br class="">matrix for and what equations you are discretizing. This is handled<br class="">by the PetscDS object. In snes/tutorials/ex59.c, see the code after<br class="">DMGetDS() for an example.<br class=""><br class="">- Toby<br class=""><br class="">On Wed, May 25, 2022 at 1:17 PM Sami BEN ELHAJ SALAH<br class=""><<a href="mailto:sami.ben-elhaj-salah@ensma.fr" class="">sami.ben-elhaj-salah@ensma.fr</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="">Dear PETSc developer team,<br class=""><br class="">I m trying to create à jacobian_matrix from distributed DM. I have followed the two examples (snes/tests/ex2.c and ex56.c). So I wrote this routine:<br class=""><br class="">PetscDM orig_dm;<br class="">PetscDM dist_dm = NULL;<br class="">PetscPartitioner part;<br class="">DMPlexGetPartitioner(orig_dm, &part);<br class="">PetscPartitionerSetType(part, PETSCPARTITIONERPARMETIS);<br class="">DMPlexDistribute(orig_dm, 0, NULL, &dist_dm);<br class=""><br class="">PetscErrorCode err = DMCreateMatrix(dist_dm, &jacobian_matrix);<br class="">PetscInt M, N, m, n;<br class="">MatGetSize(jacobian_matrix, &M, &N);<br class="">MatGetLocalSize(jacobian_matrix, &m, &n);<br class=""><br class="">Then I run my code with 2 processes and I obtained this result:<br class="">Size from jacobian_matrix: M=0 m =0 (this result is the same in all processes).<br class=""><br class="">I didn't understand if I forgot something in my code to obtain the correct values for the local and global sizes for the jacobean_matrix? (I mean if my code is missing something to obtain a distributed mesh over processes ?)<br class=""><br class="">Thank you in advance for any help!<br class="">Sami,<br class=""><br class=""><br class="">--<br class="">Dr. Sami BEN ELHAJ SALAH<br class="">Ingénieur de Recherche (CNRS)<br class="">Institut Pprime - ISAE - ENSMA<br class="">Mobile: 06.62.51.26.74<br class=""><a href="mailto:sami.ben-elhaj-salah@ensma.fr" class="">Email: sami.ben-elhaj-salah@ensma.fr</a><br class="">www.samibenelhajsalah.com<br class=""><br class=""><br class=""><br class=""></blockquote></div></div></blockquote></div><br class=""></body></html>