Skip to content
Snippets Groups Projects
Commit 1c13b30a authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

small cleanup and generalization of fix flow/gauss

- remove unused or unneeded class members
- make the code compatible with per-atom masses
- test for and abend in case of an invalid group mass

(cherry picked from commit e017b3389839ff45bc4b5c24c2c7eab1522ff528)
parent 1ab3891c
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,9 @@ FixFlowGauss::FixFlowGauss(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, a
if (narg < 6) error->all(FLERR,"Not enough input arguments");
dynamic_group_allow = 0; //group which conserves momentum must also conserve particle number
// a group which conserves momentum must also conserve particle number
dynamic_group_allow = 0;
scalar_flag = 1;
vector_flag = 1;
extscalar = 1;
......@@ -118,6 +120,8 @@ void FixFlowGauss::setup(int vflag)
//get total mass of group
mTot=group->mass(igroup);
if (mTot <= 0.0)
error->all(FLERR,"Invalid group mass in fix flow/gauss");
post_force(vflag);
}
......@@ -134,6 +138,7 @@ void FixFlowGauss::post_force(int vflag)
int *mask = atom->mask;
int *type = atom->type;
double *mass = atom->mass;
double *rmass = atom->rmass;
int nlocal = atom->nlocal;
......@@ -162,12 +167,18 @@ void FixFlowGauss::post_force(int vflag)
//apply added accelleration to each atom
double f_app[3];
peAdded=0.0;
double peAdded=0.0;
for( ii = 0; ii<nlocal; ii++)
if (mask[ii] & groupbit) {
f_app[0] = a_app[0]*mass[type[ii]];
f_app[1] = a_app[1]*mass[type[ii]];
f_app[2] = a_app[2]*mass[type[ii]];
if (rmass) {
f_app[0] = a_app[0]*rmass[ii];
f_app[1] = a_app[1]*rmass[ii];
f_app[2] = a_app[2]*rmass[ii];
} else {
f_app[0] = a_app[0]*mass[type[ii]];
f_app[1] = a_app[1]*mass[type[ii]];
f_app[2] = a_app[2]*mass[type[ii]];
}
f[ii][0] += f_app[0]; //f_app[jj] is 0 if flow[jj] is false
f[ii][1] += f_app[1];
......
......@@ -41,9 +41,7 @@ FixStyle(flow/gauss,FixFlowGauss)
double a_app[3]; //applied acceleration
double mTot; //total mass of constrained group
double f_tot[3]; //total applied force
double peAdded; //total added energy per proc
double pe_tot; //total added energy
bool force_flag; //if force has been computed this timestep already
double dt; //timestep
bool workflag; //if calculate work done by fix
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment