<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="">Hi Matthew,</div><div class="">Thank you for this example. It seems exactly what I am looking for.</div><div class="">Thank you again for your help and have a good day.</div><div class="">Sami,</div><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 28 mai 2022 à 20:20, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta charset="UTF-8" class=""><div dir="ltr" style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;" class=""><div dir="ltr" class="">On Sat, May 28, 2022 at 2:19 PM Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:<br class=""></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div dir="ltr" class="">On Sat, May 28, 2022 at 1:35 PM Sami BEN ELHAJ SALAH <<a href="mailto:sami.ben-elhaj-salah@ensma.fr" target="_blank" class="">sami.ben-elhaj-salah@ensma.fr</a>> wrote:<br class=""></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class=""><div class="">Hi Matthew,</div><div class=""><br class=""></div><div class="">Thank you for your response.</div><div class=""><br class=""></div><div class="">I don't have that. My DM object is not linked to PetscSection yet. I'll try that. </div><div class="">Is there any example that manages this case? (DMPlexDistribute & PetscSection) or any guideline will be helpful.</div><div class=""></div></div></blockquote><div class=""><br class=""></div><div class="">Here is an example where we create a section without DS.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Forgot the link: <a href="https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/plex/tutorials/ex14.c" class="">https://gitlab.com/petsc/petsc/-/blob/main/src/dm/impls/plex/tutorials/ex14.c</a></div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div dir="ltr" class=""><div class="gmail_quote"><div class=""> <span class="Apple-converted-space"> </span>THanks,</div><div class=""><br class=""></div><div class="">   <span class="Apple-converted-space"> </span>Matt</div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class=""><div class="">Thanks in advance,</div><div class=""><br class=""></div><div class="">Sami,</div><div class=""><br class=""></div><div class=""><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class=""><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class=""><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class=""><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class="">--</div><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" 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" target="_blank" class="">Email: sami.ben-elhaj-salah@ensma.fr</a></div><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class=""><a href="https://samiben91.github.io/samibenelhajsalah/index.html" target="_blank" class="">www.samibenelhajsalah.com</a><br class=""><br class=""><br class=""></div></div></div></div></div><div class=""><br class=""><blockquote type="cite" class=""><div class="">Le 27 mai 2022 à 20:45, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" class="">knepley@gmail.com</a>> a écrit :</div><br class=""><div class=""><div dir="ltr" class=""><div dir="ltr" class="">On Fri, May 27, 2022 at 9:42 AM Sami BEN ELHAJ SALAH <<a href="mailto:sami.ben-elhaj-salah@ensma.fr" target="_blank" class="">sami.ben-elhaj-salah@ensma.fr</a>> wrote:<br class=""></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div 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=""><span class="Apple-converted-space"> </span>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),</div></div></div></blockquote><div class=""><br class=""></div><div class="">You do not have to use PetscDS, but the DM does need to a PetscSection in order to compute sizes and sparsity patterns. Do you have that?</div><div class=""><br class=""></div><div class=""> <span class="Apple-converted-space"> </span>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-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div class=""><div class=""><div class="">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=""><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class=""><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class=""><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class=""><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class="">--</div><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" 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" target="_blank" class="">Email: sami.ben-elhaj-salah@ensma.fr</a></div><div dir="auto" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; text-decoration: none;" class=""><a href="https://samiben91.github.io/samibenelhajsalah/index.html" target="_blank" class="">www.samibenelhajsalah.com</a><br class=""><br class=""><br class=""></div></div></div></div></div><div class=""><br class=""><blockquote type="cite" class=""><div class="">Le 25 mai 2022 à 19:41, Toby Isaac <<a href="mailto:toby.isaac@gmail.com" target="_blank" class="">toby.isaac@gmail.com</a>> a écrit :</div><br class=""><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" target="_blank" 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" target="_blank" class="">Email: sami.ben-elhaj-salah@ensma.fr</a><br class=""><a href="http://www.samibenelhajsalah.com/" target="_blank" class="">www.samibenelhajsalah.com</a><br class=""><br class=""><br class=""><br class=""></blockquote></div></div></blockquote></div><br class=""></div></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><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></div></blockquote></div><br class=""></div></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><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></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div dir="ltr" class="gmail_signature"><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></div></div></div></div></div></div></div></div></div></blockquote></div><br class=""></div></body></html>