<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Yup, implemented that with DM.  Works as desired.  Thanks.<div class=""><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;  ">-gideon</span>

</div>
<br class=""><div style=""><blockquote type="cite" class=""><div class="">On Feb 13, 2017, at 8:03 AM, 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="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="gmail_extra"><div class="gmail_quote">On Sun, Feb 12, 2017 at 3:21 PM, Barry Smith<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:bsmith@mcs.anl.gov" target="_blank" class="">bsmith@mcs.anl.gov</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><span class=""><br class="">> On Feb 12, 2017, at 11:30 AM, Gideon Simpson <<a href="mailto:gideon.simpson@gmail.com" class="">gideon.simpson@gmail.com</a>> wrote:<br class="">><br class="">> I’ve begun working on implementing a projected time stepping method for solving y’ = f(y), where g(y(t)) is an invariant of the flow.  Per a previous email exchange, it was suggested that I use TSSetPostStep to perform the projection routine, calling TSGetSolution obtain the current iterate, which will be corrected with the projection.  However, I noticed two things:<br class="">><br class="">> 1.  The documentation for TSGetSolution says "This vector not changed until the solution at the next timestep has been calculated.”  Does that mean that if I make a change to the solution in a PostStep function, it won’t be captured until the next step?<br class=""><br class=""></span>   No.<br class=""><span class=""><br class="">>  What happens at the final time step?<br class=""><br class=""></span>   Your function should still get called.<br class=""><span class=""><br class="">><br class="">> 2.  The projection is nonlinear, requiring the use of a SNES.  I had originally thought that I would create/configure/destroy the SNES within the main routine of the code, and pass this to the PostStep through a user data structure.  However, the TSSetPostStep function seems to only take functions which are exclusively functions of the TS.  Likewise, I would need to create a residual vector, r, for the SNESSetFunction.  Is there a way to pass these data structures, so that they can be reused. or would they have to be created/destroyed within the PostStep function at each iterate?  How costly would that be?<br class=""><br class=""></span>   After you create the SNES and the TS call PetscObjectCompose() to attach the SNES to the TS then inside your post-step you can use PetscObjectQuery() or if you want to pass in more than a SNES use PetscContainerCreate().<br class=""></blockquote><div class=""><br class=""></div><div class="">An alternative to what Barry suggests, which will definitely work, is to use the DM.</div><div class=""><br class=""></div><div class="">  DMCreateShell(comm, &dm);</div><div class="">  DMSetApplicationContext(dm, ctx);</div><div class="">  TSSetDM(ts, dm);</div><div class=""><br class=""></div><div class="">In your function</div><div class=""><br class=""></div><div class="">  TSGetDM(ts, &dm);</div><div class="">  DMGetApplicationContext(dm, &ctx);</div><div class=""><br class=""></div><div class="">I prefer this to the Container route.</div><div class=""><br 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-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">><br class="">><br class="">> -gideon<br class="">><br class=""><br class=""></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>--<span class="Apple-converted-space"> </span><br class=""><div class="gmail_signature" data-smartmail="gmail_signature">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></div></div></blockquote></div><br class=""></div></body></html>