/* ---------------------------------------------------------------------- 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 "stdlib.h" #include "string.h" #include "region.h" #include "domain.h" #include "lattice.h" #include "error.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ Region::Region(LAMMPS *lmp, int narg, char **arg) : Pointers(lmp) { int n = strlen(arg[0]) + 1; id = new char[n]; strcpy(id,arg[0]); n = strlen(arg[1]) + 1; style = new char[n]; strcpy(style,arg[1]); } /* ---------------------------------------------------------------------- */ Region::~Region() { delete [] id; delete [] style; } /* ---------------------------------------------------------------------- parse optional parameters at end of region input line ------------------------------------------------------------------------- */ void Region::options(int narg, char **arg) { if (narg < 0) error->all("Illegal region command"); // option defaults interior = 1; scaleflag = 1; int iarg = 0; while (iarg < narg) { if (strcmp(arg[iarg],"units") == 0) { if (iarg+2 > narg) error->all("Illegal region command"); if (strcmp(arg[iarg+1],"box") == 0) scaleflag = 0; else if (strcmp(arg[iarg+1],"lattice") == 0) scaleflag = 1; else error->all("Illegal region command"); iarg += 2; } else if (strcmp(arg[iarg],"side") == 0) { if (iarg+2 > narg) error->all("Illegal region command"); if (strcmp(arg[iarg+1],"in") == 0) interior = 1; else if (strcmp(arg[iarg+1],"out") == 0) interior = 0; else error->all("Illegal region command"); iarg += 2; } else error->all("Illegal region command"); } // setup scaling if (scaleflag && domain->lattice == NULL) error->all("Use of region with undefined lattice"); if (scaleflag) { xscale = domain->lattice->xlattice; yscale = domain->lattice->ylattice; zscale = domain->lattice->zlattice; } else xscale = yscale = zscale = 1.0; }