From 441180782ea51df30f2b7418d067c6caf0b35346 Mon Sep 17 00:00:00 2001 From: athomps Date: Thu, 17 Jun 2010 01:34:38 +0000 Subject: [PATCH] Moved compute_vsum into fix_msst git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@4282 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/SHOCK/Install.sh | 4 -- src/SHOCK/compute_vsum.cpp | 77 -------------------------------------- src/SHOCK/compute_vsum.h | 42 --------------------- src/SHOCK/fix_msst.cpp | 48 ++++++++++++------------ src/SHOCK/fix_msst.h | 4 +- 5 files changed, 26 insertions(+), 149 deletions(-) delete mode 100644 src/SHOCK/compute_vsum.cpp delete mode 100644 src/SHOCK/compute_vsum.h diff --git a/src/SHOCK/Install.sh b/src/SHOCK/Install.sh index 9f4456e934..9ebc5ab040 100644 --- a/src/SHOCK/Install.sh +++ b/src/SHOCK/Install.sh @@ -3,17 +3,13 @@ if (test $1 = 1) then cp fix_msst.cpp .. - cp compute_vsum.cpp .. cp fix_msst.h .. - cp compute_vsum.h .. elif (test $1 = 0) then rm ../fix_msst.cpp - rm ../compute_vsum.cpp rm ../fix_msst.h - rm ../compute_vsum.h fi diff --git a/src/SHOCK/compute_vsum.cpp b/src/SHOCK/compute_vsum.cpp deleted file mode 100644 index c1c05552ba..0000000000 --- a/src/SHOCK/compute_vsum.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* ---------------------------------------------------------------------- - 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 "mpi.h" -#include "compute_vsum.h" -#include "atom.h" -#include "force.h" -#include "modify.h" -#include "fix.h" -#include "group.h" -#include "error.h" - -using namespace LAMMPS_NS; - -/* ---------------------------------------------------------------------- */ - -ComputeVsum::ComputeVsum(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg) -{ - if (narg != 3) error->all("Illegal compute temp command"); - - scalar_flag = vector_flag = 1; - size_vector = 6; - extscalar = 0; - tempflag = 1; - - vector = new double[6]; -} - -/* ---------------------------------------------------------------------- */ - -ComputeVsum::~ComputeVsum() -{ - delete [] vector; -} - -/* ---------------------------------------------------------------------- */ - -void ComputeVsum::init() -{ - ; -} - -/* ---------------------------------------------------------------------- */ - -/* ---------------------------------------------------------------------- */ - -double ComputeVsum::compute_scalar() -{ - double **v = atom->v; - int *mask = atom->mask; - int nlocal = atom->nlocal; - - double t = 0.0; - - for (int i = 0; i < nlocal; i++) { - if (mask[i] & groupbit) { - t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) ; - } - } - - MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); - return scalar; -} - -/* ---------------------------------------------------------------------- */ - diff --git a/src/SHOCK/compute_vsum.h b/src/SHOCK/compute_vsum.h deleted file mode 100644 index d17ee432d6..0000000000 --- a/src/SHOCK/compute_vsum.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ---------------------------------------------------------------------- - 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. -------------------------------------------------------------------------- */ - -// Compute the sum of the squared velocities, without usual mass terms -// for the kinetic energy. This is used for the MSST (Larry Fried). - -#ifdef COMPUTE_CLASS - -ComputeStyle(vsum,ComputeVsum) - -#else - -#ifndef COMPUTE_VSUM_H -#define COMPUTE_VSUM_H - -#include "compute.h" - -namespace LAMMPS_NS { - -class ComputeVsum : public Compute { - public: - ComputeVsum(class LAMMPS *, int, char **); - ~ComputeVsum(); - void init(); - double compute_scalar(); - -}; - -} - -#endif -#endif diff --git a/src/SHOCK/fix_msst.cpp b/src/SHOCK/fix_msst.cpp index 81ad7a508d..67b08fb015 100644 --- a/src/SHOCK/fix_msst.cpp +++ b/src/SHOCK/fix_msst.cpp @@ -247,20 +247,6 @@ FixMSST::FixMSST(LAMMPS *lmp, int narg, char **arg) : delete [] newarg; peflag = 1; - // add a compute for the sum of the squared velocities. - - n = strlen(id) + 6; - id_vsum = new char[n]; - strcpy(id_vsum,id); - strcat(id_vsum,"_vsum"); - newarg = new char*[3]; - newarg[0] = id_vsum; - newarg[1] = "all"; - newarg[2] = "vsum"; - modify->add_compute(3,newarg); - delete [] newarg; - vsflag = 1; - // initialize the time derivative of the volume. omega[0] = omega[1] = omega[2] = 0.0; @@ -286,12 +272,10 @@ FixMSST::~FixMSST() if (tflag) modify->delete_compute(id_temp); if (pflag) modify->delete_compute(id_press); if (peflag) modify->delete_compute(id_pe); - if (vsflag) modify->delete_compute(id_vsum); delete [] id_temp; delete [] id_press; delete [] id_pe; - delete [] id_vsum; for ( int j = 0; j < atoms_allocated; j++ ) { delete [] old_velocity[j]; @@ -332,10 +316,6 @@ void FixMSST::init() if (icompute < 0) error->all("PE ID for fix msst does not exist"); pe = modify->compute[icompute]; - icompute = modify->find_compute(id_vsum); - if ( icompute < 0 ) error->all("Vsum ID for fix msst does not exist"); - vsum = modify->compute[icompute]; - dtv = update->dt; dtf = 0.5 * update->dt * force->ftm2v; dthalf = 0.5 * update->dt; @@ -383,7 +363,7 @@ void FixMSST::setup(int vflag) temperature->compute_vector(); pressure->compute_vector(); couple(); - velocity_sum = vsum->compute_scalar(); + velocity_sum = compute_vsum(); if ( v0_set == 0 ) { v0 = compute_vol(); @@ -531,7 +511,7 @@ void FixMSST::initial_integrate(int vflag) // propagate velocity sum 1/2 step by // temporarily propagating the velocities. - velocity_sum = vsum->compute_scalar(); + velocity_sum = compute_vsum(); for (i = 0; i < nlocal; i++) { if (mask[i] & groupbit) { for ( k = 0; k < 3; k++ ) { @@ -552,7 +532,7 @@ void FixMSST::initial_integrate(int vflag) } } } - velocity_sum = vsum->compute_scalar(); + velocity_sum = compute_vsum(); // reset the velocities. @@ -665,7 +645,7 @@ void FixMSST::final_integrate() pressure->compute_vector(); couple(); - velocity_sum = vsum->compute_scalar(); + velocity_sum = compute_vsum(); vol = compute_vol(); // propagate the time derivative of the volume 1/2 step at fixed V, r, rdot. @@ -1025,3 +1005,23 @@ void FixMSST::check_alloc(int n) } } +double FixMSST::compute_vsum() +{ + double vsum; + + double **v = atom->v; + int *mask = atom->mask; + int nlocal = atom->nlocal; + + double t = 0.0; + + for (int i = 0; i < nlocal; i++) { + if (mask[i] & groupbit) { + t += (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]) ; + } + } + + MPI_Allreduce(&t,&vsum,1,MPI_DOUBLE,MPI_SUM,world); + return vsum; +} + diff --git a/src/SHOCK/fix_msst.h b/src/SHOCK/fix_msst.h index fb4a009fa7..22d7fe13cf 100644 --- a/src/SHOCK/fix_msst.h +++ b/src/SHOCK/fix_msst.h @@ -66,11 +66,10 @@ class FixMSST : public Fix { int *rfix; // indices of rigid fixes char *id_temp,*id_press; // Strings with identifiers of - char *id_vsum, *id_pe; // created computes. + char *id_pe; // created computes. class Compute *temperature; // Computes created to evaluate class Compute *pressure; // thermodynamic quantities. - class Compute *vsum; class Compute *pe; int tflag,pflag,vsflag,peflag; // Flags to keep track of computes that // were created. @@ -100,6 +99,7 @@ class FixMSST : public Fix { double compute_rayleigh(); double compute_lagrangian_speed(); double compute_lagrangian_position(); + double compute_vsum(); }; }