do not allow access to rigid body properties before they are fully set up

This commit is contained in:
Axel Kohlmeyer
2020-10-31 11:48:29 -04:00
parent 980fce06de
commit 66ed16760f
2 changed files with 8 additions and 0 deletions

View File

@ -2710,11 +2710,15 @@ double FixRigid::compute_scalar()
void *FixRigid::extract(const char *str, int &dim) void *FixRigid::extract(const char *str, int &dim)
{ {
dim = 0;
if (strcmp(str,"body") == 0) { if (strcmp(str,"body") == 0) {
if (!setupflag) return nullptr;
dim = 1; dim = 1;
return body; return body;
} }
if (strcmp(str,"masstotal") == 0) { if (strcmp(str,"masstotal") == 0) {
if (!setupflag) return nullptr;
dim = 1; dim = 1;
return masstotal; return masstotal;
} }

View File

@ -3424,7 +3424,10 @@ int FixRigidSmall::modify_param(int narg, char **arg)
void *FixRigidSmall::extract(const char *str, int &dim) void *FixRigidSmall::extract(const char *str, int &dim)
{ {
dim = 0;
if (strcmp(str,"body") == 0) { if (strcmp(str,"body") == 0) {
if (!setupflag) return nullptr;
dim = 1; dim = 1;
return atom2body; return atom2body;
} }
@ -3438,6 +3441,7 @@ void *FixRigidSmall::extract(const char *str, int &dim)
// used by granular pair styles, indexed by atom2body // used by granular pair styles, indexed by atom2body
if (strcmp(str,"masstotal") == 0) { if (strcmp(str,"masstotal") == 0) {
if (!setupflag) return nullptr;
dim = 1; dim = 1;
if (nmax_mass < nmax_body) { if (nmax_mass < nmax_body) {