<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="">
<span class="">It seems that you do not intend to do an offline analysis on the solutions. If the goal is just to get the solutions at each step on the fly, you can probably also try </span><span class="">TSSetTimeSpan() and </span><span class="">TSGetTimeSpanSolutions</span><span class="">().
They can give you an array of solution vectors at the time points you specify beforehand. </span>
<div class=""><br class="">
</div>
<span class="">
<div class="">
<div class=""><a href="https://petsc.org/main/docs/manualpages/TS/TSSetTimeSpan/" class="">https://petsc.org/main/docs/manualpages/TS/TSSetTimeSpan/</a></div>
<div class=""><br class="">
</div>
Hong (Mr.)<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Dec 14, 2022, at 12:07 PM, Guglielmo, Tyler Hardy via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Verdana; font-size: 14px; 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="WordSection1">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Thanks Matt,<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">I’m a bit confused on where the trajectory is being stored in the TSTrajectory object.<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Basically I have run<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">TSSetSaveTrajectory(ts);<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">…<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">TSSolve(ts, x);<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">TSTrajectory tj;<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">TSGetTrajectory(ts, &tj);<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">TSTrajectorySetType(tj, ts, TSTRAJECTORYMEMORY);<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">How is the object supposed to be accessed to find the entire trajectory? I couldn’t find a clear example of where this is laid out in the documentation.<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">The TSTrajectory object looks like some complicated struct, but parsing which pointer is pointing to the solution has alluded me.<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Thanks for your time!<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Best,<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Tyler<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
<div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(181, 196, 223); padding: 3pt 0in 0in;" class="">
<p style="margin: 0in 0in 12pt; font-size: 10pt; font-family: Calibri, sans-serif;" class="MsoNormal">
<b class=""><span style="font-size: 12pt;" class="">From:<span class="Apple-converted-space"> </span></span></b><span style="font-size: 12pt;" class="">Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>><br class="">
<b class="">Date:<span class="Apple-converted-space"> </span></b>Tuesday, December 13, 2022 at 6:41 AM<br class="">
<b class="">To:<span class="Apple-converted-space"> </span></b>Guglielmo, Tyler Hardy <<a href="mailto:guglielmo2@llnl.gov" class="">guglielmo2@llnl.gov</a>><br class="">
<b class="">Cc:<span class="Apple-converted-space"> </span></b><a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a> <<a href="mailto:petsc-users@mcs.anl.gov" class="">petsc-users@mcs.anl.gov</a>><br class="">
<b class="">Subject:<span class="Apple-converted-space"> </span></b>Re: [petsc-users] Saving solution with monitor function<o:p class=""></o:p></span></p>
</div>
<div class="">
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">On Tue, Dec 13, 2022 at 8:40 AM Guglielmo, Tyler Hardy via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov" style="color: blue; text-decoration: underline;" class="">petsc-users@mcs.anl.gov</a>> wrote:<o:p class=""></o:p></span></div>
</div>
<div class="">
<blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;" class="">
<div class="">
<div class="">
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Hi all,<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""> <o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">I am a new PETSc user (and new to MPI in general), and was wondering if someone could help me out with what I am sure is a basic question (if this is not the appropriate email list or there is a better place please let
me know!).<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""> <o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Basically, I am writing a code that requires a solution to an ODE that will be used later on during runtime. I have written the basic ODE solver using TSRK, however I haven’t thought of a good way to store the actual
solution at all time steps throughout the time evolution. I would like to avoid writing each time step to a file through the monitor function, and instead just plug each time step into an array.<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""> <o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">How is this usually done? I suppose the user defined struct that gets passed into the monitor function could contain a pointer to an array in main? This is how I would do this if the program wasn’t of the MPI variety,
but I am not sure how to properly declare a pointer to an array declared as Vec and built through the usual PETSc process. Any tips are greatly appreciated<o:p class=""></o:p></span></div>
</div>
</div>
</div>
</blockquote>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
</div>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">I think this is what TSTrajectory is for. I believe you want <a href="https://urldefense.us/v3/__https:/petsc.org/main/docs/manualpages/TS/TSTRAJECTORYMEMORY/__;!!G2kpM7uM-TzIFchu!irkbXWpYDosRslumKjVGCqxHkKyU-riye4i1dWe58HYH_sFxImRj33gOkhB2sgd_duk$" style="color: blue; text-decoration: underline;" class="">https://petsc.org/main/docs/manualpages/TS/TSTRAJECTORYMEMORY/</a><o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
</div>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""> Thanks,<o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
</div>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""> Matt<o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""> <o:p class=""></o:p></span></div>
</div>
<blockquote style="border-style: none none none solid; border-left-width: 1pt; border-left-color: rgb(204, 204, 204); padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;" class="">
<div class="">
<div class="">
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Thanks for your time,<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Tyler<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""> <o:p class=""></o:p></span></div>
<div class="">
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">+++++++++++++++++++++++++++++<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Tyler Guglielmo<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Postdoctoral Researcher<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Lawrence Livermore National Lab<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Office: 925-423-6186<o:p class=""></o:p></span></div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">Cell: 210-480-8000<o:p class=""></o:p></span></div>
</div>
</div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">+++++++++++++++++++++++++++++<o:p class=""></o:p></span></div>
</div>
</div>
</div>
</blockquote>
</div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><br clear="all" class="">
<o:p class=""></o:p></span></div>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
</div>
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class="">--<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div>
<div class="">
<div class="">
<div class="">
<div class="">
<div class="">
<div class="">
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" 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<o:p class=""></o:p></span></div>
</div>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><o:p class=""> </o:p></span></div>
</div>
<div class="">
<div style="margin: 0in; font-size: 10pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 11pt;" class=""><a href="https://urldefense.us/v3/__http:/www.cse.buffalo.edu/*knepley/__;fg!!G2kpM7uM-TzIFchu!irkbXWpYDosRslumKjVGCqxHkKyU-riye4i1dWe58HYH_sFxImRj33gOkhB27-uscIw$" target="_blank" style="color: blue; text-decoration: underline;" class="">https://www.cse.buffalo.edu/~knepley/</a></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</span>
</body>
</html>