So I found a workaround (not the nicest way though, but it works): There is
no routine which deletes the elements in the host_data inside the
data_manager inside ChSystemMulticore. So I added one:
void ChSystemMulticore::ResetDataManager() {
if (data_manager) {
// Reset to default values
data_manager->host_data = host_container();
data_manager->num_bilaterals = 0;
data_manager->num_constraints = 0;
data_manager->num_dof = 0;
data_manager->num_fluid_bodies = 0;
data_manager->num_linmotors = 0;
data_manager->num_motors = 0;
data_manager->num_rigid_bodies = 0;
data_manager->num_rotmotors = 0;
data_manager->num_shafts = 0;
data_manager->num_unilaterals = 0;
}
}
I call this function after calling Clear(). Works fine for now.
For removing one specific element I guess one has to remove this specific
element from host_data and reduce the associated counter...
Best,
Frank
Frank Poerner schrieb am Freitag, 17. März 2023 um 15:03:48 UTC+1:
> Hi everybody,
>
> I have a problem when removing a ChBody from ChSystemMulticore at Runtime.
> At the moment I am trying to bring my physics simulation from single core
> to multicore and however I run into some runtime crashes when I try the
> following:
>
> I create some ChBodies which are connected with some ChLinks - all are
> added to ChSystemMulticore. This works perfectly fine. However at some
> point I am removing ALL elements from the simulation calling:
>
> mySystem.Clear() -> This calls ChSystem.Clear();
>
> However if I try to continue my simulation after adding another ChBodies I
> run into a runtime exception in ChSystemMulticore::ClearForceVariables()
> (namly a vector-out-of-range-error):
>
> for (int i = 0; i < (signed)data_manager->num_rigid_bodies; i++) {
> assembly.bodylist[i]->VariablesFbReset();
> }
>
>
> I did some debugging and the reason is, that after calling
> ChSystem.Clear() the data_manager of ChSystemMulticore still has
> num_rigid_bodies > 0.
> This looks like a bug to me?
>
> I tried to simply set num_rigid_bodies = 0 after calling Clear(), but this
> is obviously a stupid idea and let to some other crashes...
>
>
> I am not that deep into Project Chrono, but is there a nice way to delete
> elements from a ChSystemMulticore Class? Maybe if somebody can give me a
> hint what I need to delete inside the data_manager I might be able to fix
> it myself.
>
>
> Thanks,
> Frank
>
>
--
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/c109bc4b-e8e6-43ea-a036-b045ba32bb32n%40googlegroups.com.