Hi Haifei,

Peng Chao is correct, but his answer may be a bit confusing.

Indeed, since there are no structural changes to your system (e.g., addition or 
removal of components), all you need to do is save the state of the system and 
restore it when needed.
>From the functions Peng Chao listed, you only need the positions and 
>velocities (those completely define the state of the system, with 
>accelerations and Lagrange multipliers calculated during integration).  Keep 
>also in mind that the “integrable” you are dealing with here is the ChSystem 
>object itself.

With that, and assuming sys is your ChSystem object, you should be able to do 
what you need with something like the following:


  1.  When saving the state (checkpoint):

double t = sys.GetChTime();
ChState X(sys.GetNumCoordsPosLevel(), &sys);

ChStateDelta V(sys.GetNumCoordsVelLevel(), &sys);

sys.StateGather(X, V, t);


  1.  When reloading the state:

sys.SetChTime(t);

sys.StateScatter(X, V, t, true);


Note that the above code uses the very latest code in the main branch of the 
Chrono repository (after a large refactoring that was merged just a while ago). 
 Assuming you are using an older version of the Chrono code, you will need to 
replace the functions ChSystem::GetNumCoordsPosLevel() and 
GetNumCoordsVelLevel() with their older names.

Note that, since currently all Chrono solvers and integrators are memory-less 
(i.e., they do not use cached information from previous steps), without any 
other changes (e.g. in loading conditions or solver/integrator settings), this 
approach should allow you to exactly reproduce the original sequence of steps 
starting from the checkpoint.  This may change in the future if we make any 
changes so that past information is used in the time stepping (one such example 
could be contact history which would be difficult/expensive to cache).

--Radu

From: [email protected] <[email protected]> On Behalf 
Of chao peng
Sent: Tuesday, March 26, 2024 10:11 AM
To: ProjectChrono <[email protected]>
Subject: [chrono] Re: Restore ChSystem state to previous time step

Hello Haifei,

We can restore and recover the system state via simply mimicking the operations 
in time steppers. Taking the HHT stepper as example, to restore the system 
state at time instant T, we can do:

    ChIntegrableIIorder* mintegrable = 
(ChIntegrableIIorder*)hht_stepper->GetIntegrable();
    // Setup main vectors
    mintegrable->StateSetup(X, V, A);
    L.setZero(mintegrable->GetNumConstraints());
    // State at current time T
    mintegrable->StateGather(X, V, T);        // state <- system
    mintegrable->StateGatherAcceleration(A);  // <- system
    mintegrable->StateGatherReactions(L);     // <- system

After one time step, or in fact at any time instant as you like, to recover the 
system state, you can do:

    // Scatter state -> system doing a full update
    mintegrable->StateScatter(X, V, T, true);

    // Scatter auxiliary data (A and L) -> system
    mintegrable->StateScatterAcceleration(A);
    mintegrable->StateScatterReactions(L);


Best regards,
PENG Chao


在2024年3月25日星期一 UTC+1 23:03:42<[email protected]<mailto:[email protected]>> 写道:

Hello Chrono developers,



To ensure a tighter coupling between (mesh or particle-based ) CFD solver and 
Chrono, it may be necessary to conduct several iterations per time step. Is 
there a function in ChSystem that can simply restore the system state (bodies, 
links, FEA, contact, etc) to the previous time step?



The current archives and (de)serialization write the system to an external file 
(binary, json, xml), which I suppose supports a restart simulation. 
https://api.projectchrono.org/tutorial_demo_archive.html<https://urldefense.com/v3/__https:/api.projectchrono.org/tutorial_demo_archive.html__;!!Mak6IKo!PKEVeLKdkk8DqfnvXel7-bjMwRYkwle5ytv_QFk4FoZFeQ7MArkYSQv7QlZPjQDXmnvG7vng07pY_-A6$>

Every time a system state is deserialized through such a file, the predefined 
bodies and links are, however, not restored to the previous time step. Could 
the Chrono system be serialized directly into the memory, or even better, can 
the system restore the states of all its children to a previous time step, 
while still using all of the children’s predefined pointers/references? Is this 
possible, or did I misunderstand something?



I notice that the current FSI module adopts a loose coupling approach. No 
fluid-solid iteration is to be performed within every time step.



Thank you,

Haifei

--
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/ce445fcb-8714-42fd-a51e-2b10a73876bfn%40googlegroups.com<https://urldefense.com/v3/__https:/groups.google.com/d/msgid/projectchrono/ce445fcb-8714-42fd-a51e-2b10a73876bfn*40googlegroups.com?utm_medium=email&utm_source=footer__;JQ!!Mak6IKo!PKEVeLKdkk8DqfnvXel7-bjMwRYkwle5ytv_QFk4FoZFeQ7MArkYSQv7QlZPjQDXmnvG7vng08KZhpQB$>.

-- 
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/PH0PR06MB823724A35022402C539E20B0A7352%40PH0PR06MB8237.namprd06.prod.outlook.com.

Reply via email to