diff --git a/src/GRANULAR/fix_freeze.cpp b/src/GRANULAR/fix_freeze.cpp index d839d975b2..d706a7a782 100644 --- a/src/GRANULAR/fix_freeze.cpp +++ b/src/GRANULAR/fix_freeze.cpp @@ -14,8 +14,10 @@ #include "string.h" #include "fix_freeze.h" #include "atom.h" +#include "update.h" #include "modify.h" #include "comm.h" +#include "respa.h" #include "error.h" using namespace LAMMPS_NS; @@ -37,6 +39,7 @@ int FixFreeze::setmask() { int mask = 0; mask |= POST_FORCE; + mask |= POST_FORCE_RESPA; return mask; } @@ -57,7 +60,16 @@ void FixFreeze::init() void FixFreeze::setup(int vflag) { - post_force(vflag); + if (strcmp(update->integrate_style,"verlet") == 0) + post_force(vflag); + else { + int nlevels_respa = ((Respa *) update->integrate)->nlevels; + for (int ilevel = 0; ilevel < nlevels_respa; ilevel++) { + ((Respa *) update->integrate)->copy_flevel_f(ilevel); + post_force_respa(vflag,ilevel,0); + ((Respa *) update->integrate)->copy_f_flevel(ilevel); + } + } } /* ---------------------------------------------------------------------- */ @@ -80,3 +92,11 @@ void FixFreeze::post_force(int vflag) torque[i][2] = 0.0; } } + +/* ---------------------------------------------------------------------- */ + +void FixFreeze::post_force_respa(int vflag, int ilevel, int iloop) +{ + post_force(vflag); +} + diff --git a/src/GRANULAR/fix_freeze.h b/src/GRANULAR/fix_freeze.h index a003e79b62..dfff30508a 100644 --- a/src/GRANULAR/fix_freeze.h +++ b/src/GRANULAR/fix_freeze.h @@ -25,6 +25,7 @@ class FixFreeze : public Fix { void init(); void setup(int); void post_force(int); + void post_force_respa(int, int, int); }; } diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp index bef55bbb5b..27f9890c09 100644 --- a/src/GRANULAR/fix_wall_gran.cpp +++ b/src/GRANULAR/fix_wall_gran.cpp @@ -25,6 +25,7 @@ #include "force.h" #include "pair.h" #include "modify.h" +#include "respa.h" #include "memory.h" #include "error.h" @@ -202,6 +203,7 @@ int FixWallGran::setmask() { int mask = 0; mask |= POST_FORCE; + mask |= POST_FORCE_RESPA; return mask; } @@ -211,6 +213,9 @@ void FixWallGran::init() { dt = update->dt; + if (strcmp(update->integrate_style,"respa") == 0) + nlevels_respa = ((Respa *) update->integrate)->nlevels; + // set pairstyle from granular pair style if (force->pair_match("gran/hooke",1)) @@ -226,7 +231,13 @@ void FixWallGran::init() void FixWallGran::setup(int vflag) { - post_force(vflag); + if (strcmp(update->integrate_style,"verlet") == 0) + post_force(vflag); + else { + ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + post_force_respa(vflag,nlevels_respa-1,0); + ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + } } /* ---------------------------------------------------------------------- */ @@ -328,6 +339,13 @@ void FixWallGran::post_force(int vflag) /* ---------------------------------------------------------------------- */ +void FixWallGran::post_force_respa(int vflag, int ilevel, int iloop) +{ + if (ilevel == nlevels_respa-1) post_force(vflag); +} + +/* ---------------------------------------------------------------------- */ + void FixWallGran::hooke(double rsq, double dx, double dy, double dz, double *vwall, double *v, double *f, double *omega, double *torque, diff --git a/src/GRANULAR/fix_wall_gran.h b/src/GRANULAR/fix_wall_gran.h index c76387222c..e843cf0022 100644 --- a/src/GRANULAR/fix_wall_gran.h +++ b/src/GRANULAR/fix_wall_gran.h @@ -26,6 +26,7 @@ class FixWallGran : public Fix { void init(); void setup(int); void post_force(int); + void post_force_respa(int, int, int); double memory_usage(); void grow_arrays(int); @@ -44,6 +45,7 @@ class FixWallGran : public Fix { double lo,hi,cylradius; double amplitude,period,omega,time_origin,vshear; double dt; + int nlevels_respa; int *touch; double **shear; diff --git a/src/fix_gravity.cpp b/src/fix_gravity.cpp index 17b0f5bd51..87dea960ba 100644 --- a/src/fix_gravity.cpp +++ b/src/fix_gravity.cpp @@ -19,6 +19,7 @@ #include "atom.h" #include "update.h" #include "domain.h" +#include "respa.h" #include "error.h" using namespace LAMMPS_NS; @@ -97,6 +98,7 @@ int FixGravity::setmask() { int mask = 0; mask |= POST_FORCE; + mask |= POST_FORCE_RESPA; return mask; } @@ -104,6 +106,9 @@ int FixGravity::setmask() void FixGravity::init() { + if (strcmp(update->integrate_style,"respa") == 0) + nlevels_respa = ((Respa *) update->integrate)->nlevels; + dt = update->dt; xacc = magnitude*xgrav; @@ -115,7 +120,13 @@ void FixGravity::init() void FixGravity::setup(int vflag) { - post_force(vflag); + if (strcmp(update->integrate_style,"verlet") == 0) + post_force(vflag); + else { + ((Respa *) update->integrate)->copy_flevel_f(nlevels_respa-1); + post_force_respa(vflag,nlevels_respa-1,0); + ((Respa *) update->integrate)->copy_f_flevel(nlevels_respa-1); + } } /* ---------------------------------------------------------------------- */ @@ -170,3 +181,10 @@ void FixGravity::post_force(int vflag) } } } + +/* ---------------------------------------------------------------------- */ + +void FixGravity::post_force_respa(int vflag, int ilevel, int iloop) +{ + if (ilevel == nlevels_respa-1) post_force(vflag); +} diff --git a/src/fix_gravity.h b/src/fix_gravity.h index 017a5246ff..0933d27ae8 100644 --- a/src/fix_gravity.h +++ b/src/fix_gravity.h @@ -27,6 +27,7 @@ class FixGravity : public Fix { void init(); void setup(int); void post_force(int); + void post_force_respa(int, int, int); private: int style,time_initial; @@ -35,6 +36,7 @@ class FixGravity : public Fix { double xdir,ydir,zdir; double xgrav,ygrav,zgrav,xacc,yacc,zacc; double degree2rad; + int nlevels_respa; }; }