<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=""><span class="">Tyler,</span></div>
<span class="">
<div class=""><span class=""><br class="">
</span></div>
The quickest solution is to use TSTrajectory as Matt mentioned. You can add the following command line options to save the solution into a binary file under a folder at each time step.<br class="">
</span><span class=""><br class="">
</span><span class="">-ts_save_trajectory -ts_trajectory_type visualization </span><span class=""><br class="">
</span><span class=""><br class="">
The folder name and the file name can be customized with </span><span class="">-ts_trajectory_dirname and -ts_trajectory_file_template.<br class="">
<br class="">
</span><span class="">If you want to load these files into Matlab, you can use some scripts in share/petsc/matlab/ such as PetscReadBinaryTrajectory.m and PetscBinaryRead.m.<br class="">
</span><span class=""><br class="">
</span><span class="">The python versions of these scripts are available in lib/petsc/bin/.<br class="">
</span><span class=""><br class="">
</span><span class="">Hong(Mr.)<br class="">
</span>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Dec 13, 2022, at 12:14 AM, 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 class="WordSection1" 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;">
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Hi all,<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" 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></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" 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></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" 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></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Thanks for your time,<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Tyler<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div class="">
<div class="">
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
+++++++++++++++++++++++++++++<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Tyler Guglielmo<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Postdoctoral Researcher<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Lawrence Livermore National Lab<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Office: 925-423-6186<o:p class=""></o:p></div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Cell: 210-480-8000<o:p class=""></o:p></div>
</div>
</div>
<div style="margin: 0in; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
+++++++++++++++++++++++++++++</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</body>
</html>