fix uninitialized memory access issues. consolidate enumerators.

This commit is contained in:
Axel Kohlmeyer 2021-04-02 17:32:29 -04:00
parent 2a10b5ba69
commit abfe8bab59
No known key found for this signature in database
GPG Key ID: D9B44E93BF0C375A
3 changed files with 41 additions and 41 deletions

View File

@ -17,29 +17,25 @@
------------------------------------------------------------------------- */
#include "fix_wall_gran.h"
#include <cmath>
#include <cstring>
#include "atom.h"
#include "domain.h"
#include "update.h"
#include "error.h"
#include "force.h"
#include "modify.h"
#include "respa.h"
#include "math_const.h"
#include "memory.h"
#include "error.h"
#include "modify.h"
#include "neighbor.h"
#include "respa.h"
#include "update.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
using namespace MathConst;
// XYZ PLANE need to be 0,1,2
enum{XPLANE=0,YPLANE=1,ZPLANE=2,ZCYLINDER,REGION};
enum{HOOKE,HOOKE_HISTORY,HERTZ_HISTORY,GRANULAR};
enum{NONE,CONSTANT,EQUAL};
#define PI27SQ 266.47931882941264802866 // 27*PI**2
#define THREEROOT3 5.19615242270663202362 // 3*sqrt(3)
#define SIXROOT6 14.69693845669906728801 // 6*sqrt(6)
@ -48,18 +44,20 @@ enum{NONE,CONSTANT,EQUAL};
#define THREEQUARTERS 0.75 // 3/4
#define TWOPI 6.28318530717959 // 2*PI
#define EPSILON 1e-10
enum {NORMAL_HOOKE, NORMAL_HERTZ, HERTZ_MATERIAL, DMT, JKR};
enum {VELOCITY, MASS_VELOCITY, VISCOELASTIC, TSUJI};
enum {TANGENTIAL_NOHISTORY, TANGENTIAL_HISTORY,
TANGENTIAL_MINDLIN, TANGENTIAL_MINDLIN_RESCALE};
enum {TWIST_NONE, TWIST_SDS, TWIST_MARSHALL};
enum {ROLL_NONE, ROLL_SDS};
#define BIG 1.0e20
#define EPSILON 1e-10
// XYZ PLANE need to be 0,1,2
enum {XPLANE=0,YPLANE=1,ZPLANE=2,ZCYLINDER,REGION};
enum {NONE,CONSTANT,EQUAL};
enum {DAMPING_NONE, VELOCITY, MASS_VELOCITY, VISCOELASTIC, TSUJI};
enum {TANGENTIAL_NONE, TANGENTIAL_NOHISTORY, TANGENTIAL_HISTORY,
TANGENTIAL_MINDLIN, TANGENTIAL_MINDLIN_RESCALE};
enum {TWIST_NONE, TWIST_SDS, TWIST_MARSHALL};
enum {ROLL_NONE, ROLL_SDS};
/* ---------------------------------------------------------------------- */
FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
@ -84,6 +82,10 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
use_history = restart_peratom = 1;
if (pairstyle == HOOKE) use_history = restart_peratom = 0;
tangential_history = roll_history = twist_history = 0;
normal_model = NORMAL_NONE;
tangential_model = TANGENTIAL_NONE;
damping_model = DAMPING_NONE;
// wall/particle coefficients
@ -120,7 +122,6 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
iarg = 4;
damping_model = VISCOELASTIC;
roll_model = twist_model = NONE;
tangential_history = roll_history = twist_history = 0;
while (iarg < narg) {
if (strcmp(arg[iarg], "hooke") == 0) {
if (iarg + 2 >= narg)

View File

@ -26,6 +26,10 @@ namespace LAMMPS_NS {
class FixWallGran : public Fix {
public:
enum {HOOKE,HOOKE_HISTORY,HERTZ_HISTORY,GRANULAR};
enum {NORMAL_NONE, NORMAL_HOOKE, NORMAL_HERTZ, HERTZ_MATERIAL, DMT, JKR};
FixWallGran(class LAMMPS *, int, char **);
virtual ~FixWallGran();
int setmask();

View File

@ -16,26 +16,21 @@
------------------------------------------------------------------------- */
#include "fix_wall_gran_region.h"
#include <cstring>
#include "region.h"
#include "atom.h"
#include "domain.h"
#include "update.h"
#include "memory.h"
#include "error.h"
#include "comm.h"
#include "domain.h"
#include "error.h"
#include "memory.h"
#include "neighbor.h"
#include "region.h"
#include "update.h"
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
// same as FixWallGran
enum{HOOKE,HOOKE_HISTORY,HERTZ_HISTORY,GRANULAR};
enum {NORMAL_HOOKE, NORMAL_HERTZ, HERTZ_MATERIAL, DMT, JKR};
#define BIG 1.0e20
/* ---------------------------------------------------------------------- */
FixWallGranRegion::FixWallGranRegion(LAMMPS *lmp, int narg, char **arg) :
@ -186,7 +181,7 @@ void FixWallGranRegion::post_force(int /*vflag*/)
if (mask[i] & groupbit) {
if (!region->match(x[i][0],x[i][1],x[i][2])) continue;
if (pairstyle == GRANULAR && normal_model == JKR) {
if (pairstyle == FixWallGran::GRANULAR && normal_model == FixWallGran::JKR) {
nc = region->surface(x[i][0],x[i][1],x[i][2],
radius[i]+pulloff_distance(radius[i]));
}
@ -228,7 +223,7 @@ void FixWallGranRegion::post_force(int /*vflag*/)
rsq = region->contact[ic].r*region->contact[ic].r;
if (pairstyle == GRANULAR && normal_model == JKR) {
if (pairstyle == FixWallGran::GRANULAR && normal_model == FixWallGran::JKR) {
if (history_many[i][c2r[ic]][0] == 0.0 && rsq > radius[i]*radius[i]) {
for (m = 0; m < size_history; m++)
history_many[i][0][m] = 0.0;
@ -264,18 +259,18 @@ void FixWallGranRegion::post_force(int /*vflag*/)
else
contact = nullptr;
if (pairstyle == HOOKE)
if (pairstyle == FixWallGran::HOOKE)
hooke(rsq,dx,dy,dz,vwall,v[i],f[i],
omega[i],torque[i],radius[i],meff, contact);
else if (pairstyle == HOOKE_HISTORY)
else if (pairstyle == FixWallGran::HOOKE_HISTORY)
hooke_history(rsq,dx,dy,dz,vwall,v[i],f[i],
omega[i],torque[i],radius[i],meff,
history_many[i][c2r[ic]], contact);
else if (pairstyle == HERTZ_HISTORY)
else if (pairstyle == FixWallGran::HERTZ_HISTORY)
hertz_history(rsq,dx,dy,dz,vwall,region->contact[ic].radius,
v[i],f[i],omega[i],torque[i],
radius[i],meff,history_many[i][c2r[ic]], contact);
else if (pairstyle == GRANULAR)
else if (pairstyle == FixWallGran::GRANULAR)
granular(rsq,dx,dy,dz,vwall,region->contact[ic].radius,
v[i],f[i],omega[i],torque[i],
radius[i],meff,history_many[i][c2r[ic]],contact);