/* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator http://lammps.sandia.gov, Sandia National Laboratories Steve Plimpton, sjplimp@sandia.gov Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ #include "math.h" #include "stdlib.h" #include "string.h" #include "fix_Ktest.h" #include "atom.h" #include "domain.h" #include "force.h" #include "modify.h" #include "angle.h" #include "memory.h" #include "error.h" #include "update.h" #include "iostream" using namespace LAMMPS_NS; using namespace FixConst; #define BIG 1.0e10 /* ---------------------------------------------------------------------- */ FixKTest::FixKTest(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) { if (narg != 5) error->all(FLERR,"Illegal fix Ktest command"); nevery = force->inumeric(FLERR,arg[3]); if (nevery <= 0) error->all(FLERR,"Illegal fix Ktest command: incorrect Nevery values"); InputSomething = force->inumeric(FLERR, arg[4]); scalar_flag = 1; global_freq = nevery; //extscalar = 0; } /* ---------------------------------------------------------------------- */ FixKTest::~FixKTest() { nevery = 0; InputSomething = 0; } /* Fix is invoked after end of step */ int FixKTest::setmask() { int mask = 0; mask |= END_OF_STEP; return mask; } /* ---------------------------------------------------------------------- */ void FixKTest::init() { LocalCounter = ReturnSomething(InputSomething); } /* ---------------------------------------------------------------------- */ void FixKTest::end_of_step() { //MPI_Status status; //struct { // double value; // int proc; //} mine[2],all[2]; LocalCounter = ReturnSomething(InputSomething+1); } /* ---------------------------------------------------------------------- */ double FixKTest::compute_scalar() { LocalCounter = ReturnSomething(InputSomething+1); GlobalCounter = 0.0; MPI_Allreduce( &LocalCounter, &GlobalCounter, 1, MPI_DOUBLE, MPI_SUM, world ); return GlobalCounter; } double FixKTest::ReturnSomething(int Something) { return (int(Something)); }