ParticulateFlow / LIGGGHTS-PFM

This is an academic adaptation of the LIGGGHTS software package, released by the Department of Particulate Flow Modelling at Johannes Kepler University in Linz, Austria http://www.jku.at/pfm
GNU General Public License v2.0
47 stars 39 forks source link

Segmentation Fault Error when using Balance with granular bonds #3

Closed schrummy14 closed 3 years ago

schrummy14 commented 3 years ago

Hello, I have come across the above issue while testing out the bond code with the fix balance command. I have tracked the issue down to the segmentation fault happening in atom_vec_bond_gran.cpp where values are attempted to be set in the bond history variable. The issue comes down to how the atom class is initialized. By default, the class initializes with 0 bond history values. Then later on the code sets that the history values are now greater than 0 but no call is made to reinitialize the atom class, leading to this error. I have made a hot fix on my local copy by setting the n_bondhist value to 13 in atom.cpp.

Attached is the chute wear example with the bond calls and fix balance call added. chute_wear.zip

danielque commented 3 years ago

Thanks for the report, we will look into it.

danielque commented 3 years ago

OK the issue here is that at startup, LIGGGHTS/LAMMPS immediately creates an atom vector of length 1, no matter if there are any particles or not. At this point, however, nothing in the input script has been parsed, especially not the bond_style command which sets the size of the bond history in the Atom class and n_bondhist still has its default value 0. Thus there exists an atom vector which has no bond history array and in your test case this causes an access violation as soon as the first particle is moved from the partition that initially has all atoms to the partition which initially has no atoms. So IMO, the proper solution is to allocate the bond history array when setting the size of of the bond history entries in Bond::n_granhistory by calling if (atom->nmax) atom->avec->grow(atom->nmax);

schrummy14 commented 3 years ago

I have added a pull request that applies the fix if you would like to look at it. I needed to add an additional header (atom_vec.h).

danielque commented 3 years ago

Thanks, but I've already applied the fix in our internal development version so that it will be included in the upcoming release.

schrummy14 commented 3 years ago

No worries. Thank you.

On Tue, Mar 16, 2021, 2:54 AM Daniel @.***> wrote:

Thanks, but I've already applied the fix in our internal development version so that it will be included in the upcoming release.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ParticulateFlow/LIGGGHTS-PFM/issues/3#issuecomment-800038632, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGARTE7DYPKIVDH2MPU6PLDTD4FC3ANCNFSM4TNN43OA .

danielque commented 3 years ago

Should be fixed in bc143209779067bbf16539393f3a09c592af4614