Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "fix_set.h"
- #include "mpi.h"
- #include "math.h"
- #include "stdio.h"
- #include "string.h"
- #include "stdlib.h"
- #include "atom.h"
- #include "domain.h"
- #include "region.h"
- #include "update.h"
- #include "respa.h"
- #include "modify.h"
- #include "force.h"
- #include "output.h"
- #include "group.h"
- #include "comm.h"
- #include "memory.h"
- #include "error.h"
- #include "variable.h"
- #include "input.h"
- using namespace LAMMPS_NS;
- using namespace FixConst; //needed for L2.x
- #define MIN(A,B) ((A) < (B)) ? (A) : (B)
- #define MAX(A,B) ((A) > (B)) ? (A) : (B)
- FixSet::FixSet(LAMMPS *lmp, int narg, char **arg) :
- Fix(lmp, narg, arg)
- {
- vector_flag = 1;
- global_freq = 1;
- extvector = 1;
- int i=0;
- //parse command-line args
- if (narg < 9) error->all(FLERR,"Illegal fix SET command, usage: fix ID GRP set {EVERY} vx vy vz region {ID}"); //FLERR,
- nevery = atoi(arg[3]); //every n-th TS
- fprintf(screen,"FixSet %d : %s %s %s %s\n",narg, arg[0],arg[1],arg[2],arg[3],arg[4],arg[5],arg[6],arg[7],arg[8]);
- char *id;
- vx=atof(arg[4]);
- vy=atof(arg[5]);
- vz=atof(arg[6]);
- int n = strlen(arg[8]) + 1;
- id = new char[n];
- strcpy(id,arg[8]);
- iregion = domain->find_region(id);
- if (iregion == -1) error->all(FLERR,"Set region ID does not exist");
- delete [] id;
- }
- FixSet::~FixSet()
- {
- if (atom) atom->delete_callback(id,0);
- }
- //tell the pipeline which functions should be invoked during run
- int FixSet::setmask()
- {
- int mask=0;
- mask |= END_OF_STEP; //needed for "nevery"
- return mask;
- }
- //runs every nevery steps
- void FixSet::end_of_step()
- {
- modify->addstep_compute(update->ntimestep + nevery);
- //do something
- int n=atom->nlocal;
- int cc=0;
- double **x = atom->x;
- for (int i = 0; i < n; i++)
- if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2])) {
- atom->v[i][0] = vx; //todo use v_ID here
- atom->v[i][1] = vy; //todo use v_ID here
- atom->v[i][2] = vz; //todo use v_ID here
- cc++;
- }
- //if (cc>0) printf("Hallo @step %d, seting %d/%d to %f atoms\n",update->ntimestep,cc,n,vz);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement