Deserialization of a ChSystem object

23 views
Skip to first unread message

kurt.e...@nasa.gov

unread,
May 15, 2015, 2:12:12 PM5/15/15
to projec...@googlegroups.com
I'd like to serialize a ChSystem object that contains a number of ChSharedBodyPtr objects, inserted by the AddBody() method.   These latter shared pointers are also stored elsewhere in my own objects, perhaps in an array ChSharedBodyPtr ch_bodies[].   I'd like to serialize these latter objects, too.   When I independently deserialize the ChSystem and the ChSharedBodyPtr array, will the relationships between all of the bodies be preserved (the ChSharedBodyPtrs in the ChSystem and those in the array point to exactly the same ChBody objects)?

Thanks, Kurt

Justin Madsen

unread,
May 18, 2015, 3:57:06 PM5/18/15
to projec...@googlegroups.com
Hi Kurt,

I think that since ChSharedBodyPtr is just a ChSharedPtr<ChBody> type, as long as you're using the shared pointers to keep references elsewhere in your own objects (and don't use AddBody() or Remove() ), those arrays will serialize correctly. What I'm not sure will work is a proper serialization of ChBody objects themselves, e.g. the body collision model. 

Justin

Alessandro Tasora

unread,
May 19, 2015, 5:47:36 AM5/19/15
to projec...@googlegroups.com
Hi Kurt,
  the current serialization methods in C::E are not finished.
We are in the middle of a process that will lead to a new serialization mechanism that can work either with binary or JSON, and that will manage lists and vectors automatically.

best regards,

Alessandro Tasora
--
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 projectchron...@googlegroups.com.
To post to this group, send email to projec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kurt.e...@nasa.gov

unread,
May 19, 2015, 1:05:00 PM5/19/15
to projec...@googlegroups.com, tas...@ied.unipr.it
Thanks Justin and Alessandro,

My question is not so much whether vectors or lists are handled correctly, but if two ChSharedBodyPtrs, each stored in different locations (such as within a ChSystem and another place), but pointing to the same ChBody object, will be serialized and deserialzed as a single unique ChBody object.

Thanks, Kurt



Justin Madsen

unread,
May 19, 2015, 2:26:50 PM5/19/15
to Kurt E. Mccall (JSC-EG411), Alessandro Tasora, projec...@googlegroups.com

Yes, storing that type in multiple places increments the ChSharedPtr<> counter but never allocates memory for more than one of the template objects, resulting in a unique ChBody. So that should lead to unique instances of each body in the ChSystem.

Justin

Reply all
Reply to author
Forward
0 new messages