Qihan,

A word of caution about the WriteCheckpoint and ReadCheckpoint functions that 
Luning mentioned.  While these are indeed meant for restarting a simulation the 
way you intend to do, when I wrote them, I was only interested in 
reinitializing a granular dynamics simulation. As such, they are somewhat 
limited in what kind of systems they can be applied to.  If you look at them, 
you will see that they only extract and re-apply body states (position, 
orientation, linear and angular velocity).  This will not be enough for 
multibody systems that include other modeling elements that have states (such 
as ChShaft, or some of the motors in Chrono).

Arguably a better way of doing this reinitialization is by saving (and caching) 
the state vector for the entire system and then reapplying it when you want to 
reinitialize. I have not formalized this in Chrono, but you can see an example 
precisely doing that in the 
test_VEH_reinit_wheeled<https://github.com/rserban/chrono/blob/main/src/projects/vehicle/reinitialization/test_VEH_reinit_wheeled.cpp>
 in my own fork of the Chrono repository.  The two functions in that program 
you should look at are SaveCheckpoint and LoadCheckpoint.  They have some extra 
stuff specific to a vehicle model which you should discard (or else adapt) for 
your own problem.

By the way, adding proper formal support for checkpointing in Chrono, across 
all modules and system types, is on our todo list.

--Radu

From: [email protected] <[email protected]> On Behalf 
Of Luning Fang
Sent: Thursday, August 11, 2022 5:01 PM
To: ProjectChrono <[email protected]>
Subject: [chrono] Re: how to continue the simulation from the last time it 
ended?

Hello Qihan,

The functions that could be helpful are ReadCheckpoint(ChSystem* system, const 
std::string& filename) and WriteCheckpoint(ChSystem* system, const std::string& 
filename).

Take a look at "demo_MCORE_cratering.cpp" or "demo_VEH_Cosim_WheelRig.cpp" for 
example. You can always customize your own checkpoint file in if you need more 
information.

For people using Chrono::GPU,  the demo on checkpointing is 
demo_GPU_ballcosim.cpp.

Thank you,
Luning

On Wednesday, August 10, 2022 at 12:16:18 PM UTC-5 
[email protected]<mailto:[email protected]> wrote:
Hi,

I am going to run two simulations.
The second one is to continue the first simulation.

So I need to store the information of the last moment of the first simulation, 
and use it as the start status of the second one.

I know I can store all information like position, orientation, velocity, etc., 
and modify the codes to reset the initial status. But this way takes too much 
effort.

So, I am wondering is there an easier way to continue the second simulation?

Thanks,
Qihan
--
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/c5898d28-6d64-48b5-9a25-7a8617bcef98n%40googlegroups.com<https://groups.google.com/d/msgid/projectchrono/c5898d28-6d64-48b5-9a25-7a8617bcef98n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
You received this message because you are subscribed to the Google Groups 
"ProjectChrono" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/projectchrono/PH0PR06MB8237DA3DABB0375BCD41C7AEA7679%40PH0PR06MB8237.namprd06.prod.outlook.com.

Reply via email to