fix uninitialized memory access issues. consolidate enumerators.
This commit is contained in:
@ -17,29 +17,25 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "fix_wall_gran.h"
|
#include "fix_wall_gran.h"
|
||||||
#include <cmath>
|
|
||||||
#include <cstring>
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "domain.h"
|
#include "domain.h"
|
||||||
#include "update.h"
|
#include "error.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "modify.h"
|
|
||||||
#include "respa.h"
|
|
||||||
#include "math_const.h"
|
#include "math_const.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
#include "error.h"
|
#include "modify.h"
|
||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
|
#include "respa.h"
|
||||||
|
#include "update.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
using namespace FixConst;
|
||||||
using namespace MathConst;
|
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 PI27SQ 266.47931882941264802866 // 27*PI**2
|
||||||
#define THREEROOT3 5.19615242270663202362 // 3*sqrt(3)
|
#define THREEROOT3 5.19615242270663202362 // 3*sqrt(3)
|
||||||
#define SIXROOT6 14.69693845669906728801 // 6*sqrt(6)
|
#define SIXROOT6 14.69693845669906728801 // 6*sqrt(6)
|
||||||
@ -48,18 +44,20 @@ enum{NONE,CONSTANT,EQUAL};
|
|||||||
#define THREEQUARTERS 0.75 // 3/4
|
#define THREEQUARTERS 0.75 // 3/4
|
||||||
#define TWOPI 6.28318530717959 // 2*PI
|
#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 BIG 1.0e20
|
||||||
#define EPSILON 1e-10
|
#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) :
|
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;
|
use_history = restart_peratom = 1;
|
||||||
if (pairstyle == HOOKE) use_history = restart_peratom = 0;
|
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
|
// wall/particle coefficients
|
||||||
|
|
||||||
@ -120,7 +122,6 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
iarg = 4;
|
iarg = 4;
|
||||||
damping_model = VISCOELASTIC;
|
damping_model = VISCOELASTIC;
|
||||||
roll_model = twist_model = NONE;
|
roll_model = twist_model = NONE;
|
||||||
tangential_history = roll_history = twist_history = 0;
|
|
||||||
while (iarg < narg) {
|
while (iarg < narg) {
|
||||||
if (strcmp(arg[iarg], "hooke") == 0) {
|
if (strcmp(arg[iarg], "hooke") == 0) {
|
||||||
if (iarg + 2 >= narg)
|
if (iarg + 2 >= narg)
|
||||||
|
|||||||
@ -26,6 +26,10 @@ namespace LAMMPS_NS {
|
|||||||
|
|
||||||
class FixWallGran : public Fix {
|
class FixWallGran : public Fix {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum {HOOKE,HOOKE_HISTORY,HERTZ_HISTORY,GRANULAR};
|
||||||
|
enum {NORMAL_NONE, NORMAL_HOOKE, NORMAL_HERTZ, HERTZ_MATERIAL, DMT, JKR};
|
||||||
|
|
||||||
FixWallGran(class LAMMPS *, int, char **);
|
FixWallGran(class LAMMPS *, int, char **);
|
||||||
virtual ~FixWallGran();
|
virtual ~FixWallGran();
|
||||||
int setmask();
|
int setmask();
|
||||||
|
|||||||
@ -16,26 +16,21 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "fix_wall_gran_region.h"
|
#include "fix_wall_gran_region.h"
|
||||||
#include <cstring>
|
|
||||||
#include "region.h"
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "domain.h"
|
|
||||||
#include "update.h"
|
|
||||||
#include "memory.h"
|
|
||||||
#include "error.h"
|
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
|
#include "domain.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "memory.h"
|
||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
|
#include "region.h"
|
||||||
|
#include "update.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
using namespace FixConst;
|
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) :
|
FixWallGranRegion::FixWallGranRegion(LAMMPS *lmp, int narg, char **arg) :
|
||||||
@ -186,7 +181,7 @@ void FixWallGranRegion::post_force(int /*vflag*/)
|
|||||||
if (mask[i] & groupbit) {
|
if (mask[i] & groupbit) {
|
||||||
if (!region->match(x[i][0],x[i][1],x[i][2])) continue;
|
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],
|
nc = region->surface(x[i][0],x[i][1],x[i][2],
|
||||||
radius[i]+pulloff_distance(radius[i]));
|
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;
|
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]) {
|
if (history_many[i][c2r[ic]][0] == 0.0 && rsq > radius[i]*radius[i]) {
|
||||||
for (m = 0; m < size_history; m++)
|
for (m = 0; m < size_history; m++)
|
||||||
history_many[i][0][m] = 0.0;
|
history_many[i][0][m] = 0.0;
|
||||||
@ -264,18 +259,18 @@ void FixWallGranRegion::post_force(int /*vflag*/)
|
|||||||
else
|
else
|
||||||
contact = nullptr;
|
contact = nullptr;
|
||||||
|
|
||||||
if (pairstyle == HOOKE)
|
if (pairstyle == FixWallGran::HOOKE)
|
||||||
hooke(rsq,dx,dy,dz,vwall,v[i],f[i],
|
hooke(rsq,dx,dy,dz,vwall,v[i],f[i],
|
||||||
omega[i],torque[i],radius[i],meff, contact);
|
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],
|
hooke_history(rsq,dx,dy,dz,vwall,v[i],f[i],
|
||||||
omega[i],torque[i],radius[i],meff,
|
omega[i],torque[i],radius[i],meff,
|
||||||
history_many[i][c2r[ic]], contact);
|
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,
|
hertz_history(rsq,dx,dy,dz,vwall,region->contact[ic].radius,
|
||||||
v[i],f[i],omega[i],torque[i],
|
v[i],f[i],omega[i],torque[i],
|
||||||
radius[i],meff,history_many[i][c2r[ic]], contact);
|
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,
|
granular(rsq,dx,dy,dz,vwall,region->contact[ic].radius,
|
||||||
v[i],f[i],omega[i],torque[i],
|
v[i],f[i],omega[i],torque[i],
|
||||||
radius[i],meff,history_many[i][c2r[ic]],contact);
|
radius[i],meff,history_many[i][c2r[ic]],contact);
|
||||||
|
|||||||
Reference in New Issue
Block a user