Thanks guys, Yes, this looks like exactly what I need. Appreciate everyone’s help!
Best, Tyler From: Barry Smith <[email protected]> Date: Tuesday, December 13, 2022 at 9:56 AM To: [email protected] <[email protected]> Cc: Guglielmo, Tyler Hardy <[email protected]>, PETSc users list <[email protected]> Subject: Re: [petsc-users] Saving solution with monitor function It is also possible to read the solutions back from the trajectory object from your running code. It is not just for saving to files. On Dec 13, 2022, at 12:51 PM, Zhang, Hong via petsc-users <[email protected]> wrote: Tyler, 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. -ts_save_trajectory -ts_trajectory_type visualization The folder name and the file name can be customized with -ts_trajectory_dirname and -ts_trajectory_file_template. 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. The python versions of these scripts are available in lib/petsc/bin/. Hong(Mr.) On Dec 13, 2022, at 12:14 AM, Guglielmo, Tyler Hardy via petsc-users <[email protected]<mailto:[email protected]>> wrote: Hi all, 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!). 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. 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! Thanks for your time, Tyler +++++++++++++++++++++++++++++ Tyler Guglielmo Postdoctoral Researcher Lawrence Livermore National Lab Office: 925-423-6186 Cell: 210-480-8000 +++++++++++++++++++++++++++++
