<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=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 15 Apr 2019, at 2:17 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div 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: normal; 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 Mon, Apr 15, 2019 at 5:03 AM Pierre Jolivet via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" class="">petsc-dev@mcs.anl.gov</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 style="word-wrap: break-word;" class="">OK, my solver is now working properly with a call to<div class="">PetscObjectCompose((PetscObject)isS, "pmat", (PetscObject) myS);</div><div class=""><br class=""></div><div class="">I have two follow-up questions:</div><div class="">1) am I supposed to call this, or is it the sign of something done wrong in my sequence of SNESSolve/KSPSetUp/KSPSetFromOptions/KSPSetOperators…?</div></div></blockquote><div class=""><br class=""></div><div class="">Yes, unfortunately. We want to let the user pass in preconditioning matrices for arbitrarily nested splits without pulling out</div><div class="">the objects explicitly, so we need a way to locate a particular split. I guess you could imagine using the prefix, which would</div><div class="">be an XML way of doing things. We are doing it by attaching things to the IS, since the Solver/Mat objects are created on the</div><div class="">fly. In fact, the IS is created on the fly by a DM sometimes, so you can attach to the DM (I do this for Plex).</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Indeed, I found — to my surprise one of the very few occurence of PetscObjectCompose((PetscObject)isS, “pmat”, …) — in dm/interface/dmi.c.</div><div class="">And actually, I realised later on that even for a “simple” example like snes/examples/tutorials/ex70.c with -user_ksp turned on, the call to KSPSetOperators(subksp[1], s->myS, s->myS) is not sufficient to avoid the call to MatCreateSubMatrix on the Schur complement. Which means (at least) this part of the solver is behaving like it should, thanks for making it clear to me.</div><br class=""><blockquote type="cite" class=""><div 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: normal; 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 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 style="word-wrap: break-word;" class=""><div class="">2) I have currently hardwired the split name I’m using when calling PCFieldSplitGetIS to get “isS” (from above) for debugging purposes. Could I create a PR with a new function like PCFieldSplitGetISByIndex(PC pc,const PetscInt n,IS *is) that will return the nth IS? Right now, I would need to get the KSP prefix followed up by some string comparison to get the actual IS prefix, whereas I know the position of the KSP in the PC_FieldSplitLink.</div></div></blockquote><div class=""><br class=""></div><div class="">That sounds fine to me.</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Done (PR #1544).</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Pierre</div><br class=""><blockquote type="cite" class=""><div 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: normal; 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 class="gmail_quote"><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 style="word-wrap: break-word;" class=""><div class="">Thanks,</div><div class="">Pierre<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 14 Apr 2019, at 10:54 PM, Pierre Jolivet via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" class="">petsc-dev@mcs.anl.gov</a>> wrote:</div><br class="gmail-m_1250767179641375552Apple-interchange-newline"><div class=""><div style="word-wrap: break-word;" class="">I think I figured out what my problem is _exactly_.<div class="">The Mat inside the MATNEST on which I’m using a PCFIELDSPLIT is unassembled before the first KSPSolve, except for the last field.</div><div class="">Matt, you nailed it, when I call KSPSetFromOptions on the global PCFIELDSPLIT, then KSPSetUp explicitly on the inner PCFIELDSPLIT, the matrices associated to all fields are created here: <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/impls/fieldsplit/fieldsplit.c.html#line656" target="_blank" class="">https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/impls/fieldsplit/fieldsplit.c.html#line656</a></div><div class="">Then, whatever I do with the matrix from the last field, currently trying MatCopy(myAssembledS, generatedS), before the first KSPSolve is reset by <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/impls/fieldsplit/fieldsplit.c.html#line688" target="_blank" class="">https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/impls/fieldsplit/fieldsplit.c.html#line688</a> and my solver fails…</div><div class=""><br class=""></div><div class="">So pretty simple question, how do I set a “pmat” for my last assembled field so that <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/impls/fieldsplit/fieldsplit.c.html#line646" target="_blank" class="">https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/impls/fieldsplit/fieldsplit.c.html#line646</a> and <a href="https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/impls/fieldsplit/fieldsplit.c.html#line686" target="_blank" class="">https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/pc/impls/fieldsplit/fieldsplit.c.html#line686</a> will return a non null pmat.</div><div class=""><br class=""></div><div class="">This may sound really trivial but I’m lost in limbo right now. When everything is not wrapped inside an outer PCFIELDSPLIT, everything just work.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Pierre</div><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 25 Mar 2019, at 6:57 PM, Pierre Jolivet via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" class="">petsc-dev@mcs.anl.gov</a>> wrote:</div><br class="gmail-m_1250767179641375552Apple-interchange-newline"><div class=""><div style="word-wrap: break-word;" class="">Thanks, this makes (slightly) more sense to me know.<div class="">For some reason my application is still not acting properly but I must be screwing somewhere else the nested FieldSplit…</div><div class=""><br class=""></div><div class="">Thank you,</div><div class="">Pierre<br class=""><div class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 24 Mar 2019, at 11:42 PM, Dave May via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" class="">petsc-dev@mcs.anl.gov</a>> wrote:</div><br class="gmail-m_1250767179641375552Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class=""><div dir="ltr" class="">Matt is right.<div class=""><br class=""></div><div class="">When you defined the operator S, you basically invalidate the operator N (in the sense that they are no longer consistent). Hence when you use KSP nest to solve your problem your A matrix looks like </div><div class=""><div class=""> <span class="Apple-converted-space"> </span>A = diag[1, 2, 4, 0, 8]</div></div><div class="">but the B matrix you have defined looks like</div><div class=""><div class=""> <span class="Apple-converted-space"> </span>B = diag[1, 2, 4, 0.00001]</div></div><div class=""><br class=""></div><div class="">The only way to obtain the correct answer with your code is thus to use the option</div><div class="">-ksp_type preonly<br class=""></div><div class=""><br class=""></div><div class="">Thanks</div><div class="">Dave</div><div class=""><br class=""><div class=""><br class=""></div></div></div></div></div></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 24 Mar 2019 at 22:09, Mark Adams via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" class="">petsc-dev@mcs.anl.gov</a>> wrote:<br 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="">I think he is saying that this line seems to have no effect (and the comment is hence wrong):<div class=""><br class=""></div><div class=""><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="font-family: "Courier New", Courier, monospace, arial, sans-serif; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; font-size: 14px;">KSPSetOperators(subksp[nsplits - 1], S, S);</pre></div><div class=""><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="margin-top: 0px; margin-bottom: 0px;"><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="font-family: "Courier New", Courier, monospace, arial, sans-serif; font-size: 14px; white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px;">// J2 = [[4, 0] ; [0, 0.00001]]</pre><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="font-family: "Courier New", Courier, monospace, arial, sans-serif; font-size: 14px; white-space: pre-wrap; margin-top: 0px; margin-bottom: 0px;"><br class=""></pre><font face="arial, helvetica, sans-serif" class="">J2 is a 2x2 but this block has been changed into two single equation fields. Does this KSPSetOperators supposed to copy this 1x1 S matrix into the (1,1) block of the "J2", or do some sort of correct mixing internally, to get what he wants?</font><br class=""></pre><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="margin-top: 0px; margin-bottom: 0px;"><font face="arial, helvetica, sans-serif" class=""><br class=""></font></pre><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="margin-top: 0px; margin-bottom: 0px;"><font face="arial, helvetica, sans-serif" class="">BTW, this line does not seem necessary to me so maybe I'm missing something.</font></pre><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="margin-top: 0px; margin-bottom: 0px;"><font face="arial, helvetica, sans-serif" class=""><br class=""></font></pre><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="margin-top: 0px; margin-bottom: 0px;"><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="font-family: "Courier New", Courier, monospace, arial, sans-serif; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; font-size: 14px;">KSPSetOperators(sub, J2, J2);</pre><pre class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-aLF-aPX-K0-aPE" style="font-family: "Courier New", Courier, monospace, arial, sans-serif; margin-top: 0px; margin-bottom: 0px; white-space: pre-wrap; font-size: 14px;"><br class=""></pre></pre></div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Mar 24, 2019 at 4:33 PM Matthew Knepley via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" class="">petsc-dev@mcs.anl.gov</a>> wrote:<br 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 dir="ltr" class="">On Sun, Mar 24, 2019 at 10:21 AM Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank" class="">pierre.jolivet@enseeiht.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="">It’s a 4x4 matrix.<div class="">The first 2x2 diagonal matrix is a field.<div class="">The second 2x2 diagonal matrix is another field.</div><div class="">In the second field, the first diagonal coefficient is a subfield.</div><div class="">In the second field, the second diagonal coefficient is another subfield.</div><div class="">I’m changing the operators from the second subfield (last diagonal coefficient of the matrix).</div><div class="">When I solve a system with the complete matrix (2 fields), I get a different “partial solution" than when I solve the “partial system” on just the second field (with the two subfields in which I modified the operators from the second one).</div></div></div></blockquote><div class=""><br class=""></div><div class="">I may understand waht you are doing.</div><div class="">Fieldsplit calls MatGetSubMatrix() which can copy values, depending on the implementation,</div><div class="">so changing values in the original matrix may or may not change it in the PC.</div><div class=""> </div><div class=""> Matt</div><div class=""><br 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="">I don’t know if this makes more or less sense… sorry :\</div><div class="">Thanks,</div><div class="">Pierre<br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On 24 Mar 2019, at 8:42 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" target="_blank" class="">knepley@gmail.com</a>> wrote:</div><br class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-m_4707396507371526411gmail-m_-4800910044753334158Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div dir="ltr" class="">On Sat, Mar 23, 2019 at 9:12 PM Pierre Jolivet via petsc-dev <<a href="mailto:petsc-dev@mcs.anl.gov" target="_blank" class="">petsc-dev@mcs.anl.gov</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;">I’m trying to figure out why both solutions are not consistent in the following example.<br class="">Is what I’m doing complete nonsense?<br class=""></blockquote><div class=""><br class=""></div><div class="">The code does not make clear what you are asking. I can see its a nested fieldsplit.</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;">Thanks in advance for your help,<br class="">Pierre<br class=""><br class=""></blockquote></div><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div dir="ltr" class="gmail-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-m_4707396507371526411gmail-m_-4800910044753334158gmail_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><br class=""></div></div></div></div></div></div></div></div></div></blockquote></div><br class=""></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-m_1250767179641375552gmail-m_8767326949575149941gmail-m_928777800623408844gmail-m_4707396507371526411gmail_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><br class=""></div></div></div></div></div></div></div></div></blockquote></div></blockquote></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></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>