diff -Naur lammps-25Jun09/doc/region.html lammps-26Jun09/doc/region.html --- lammps-25Jun09/doc/region.html 2009-01-08 16:18:29.000000000 -0700 +++ lammps-26Jun09/doc/region.html 2009-06-23 11:19:47.000000000 -0600 @@ -17,24 +17,28 @@
block args = xlo xhi ylo yhi zlo zhi
- xlo,xhi,ylo,yhi,zlo,zhi = bounds of block in all
- dimensions (distance units)
+ block args = dim c1 c2 radlo radhi lo hi
+ xlo,xhi,ylo,yhi,zlo,zhi = bounds of block in all dimensions (distance units)
+ cone args = xlo xhi ylo yhi zlo zhi
+ dim = x or y or z = axis of cone
+ c1,c2 = coords of cone axis in other 2 dimensions (distance units)
+ radlo,radhi = cone radii at lo and hi end (distance units)
+ lo,hi = bounds of cone in dim (distance units)
cylinder args = dim c1 c2 radius lo hi
dim = x or y or z = axis of cylinder
c1,c2 = coords of cylinder axis in other 2 dimensions (distance units)
radius = cylinder radius (distance units)
lo,hi = bounds of cylinder in dim (distance units)
prism args = xlo xhi ylo yhi zlo zhi xy xz yz
- xlo,xhi,ylo,yhi,zlo,zhi = bounds of untilted prism (distance units)
- xy = distance to tilt y in x direction (distance units)
- xz = distance to tilt z in x direction (distance units)
- yz = distance to tilt z in y direction (distance units)
+ xlo,xhi,ylo,yhi,zlo,zhi = bounds of untilted prism (distance units)
+ xy = distance to tilt y in x direction (distance units)
+ xz = distance to tilt z in x direction (distance units)
+ yz = distance to tilt z in y direction (distance units)
sphere args = x y z radius
- x,y,z = center of sphere (distance units)
- radius = radius of sphere (distance units)
+ x,y,z = center of sphere (distance units)
+ radius = radius of sphere (distance units)
union args = N reg-ID1 reg-ID2 ...
N = # of regions to follow, must be 2 or greater
reg-ID1,reg-ID2, ... = IDs of regions to join together
@@ -71,21 +75,25 @@
in the region can be identified as a group via the group
command, or deleted via the delete_atoms command.
-The lo/hi values for block or cylinder or prism styles can be
-specified as EDGE or INF. EDGE means they extend all the way to the
-global simulation box boundary. Note that this is the current box
-boundary; if the box changes size during a simulation the region does
-not. INF means a large negative or positive number (1.0e20), so it
-should encompass the simulation box even if it changes size. If a
+
The lo/hi values for block or cone or cylinder or prism styles
+can be specified as EDGE or INF. EDGE means they extend all the way
+to the global simulation box boundary. Note that this is the current
+box boundary; if the box changes size during a simulation, the region
+does not. INF means a large negative or positive number (1.0e20), so
+it should encompass the simulation box even if it changes size. If a
region is defined before the simulation box has been created (via
create_box or read_data or
read_restart commands), then an EDGE or INF
parameter cannot be used.
-For style cylinder, the c1,c2 params are coordinates in the 2 other
-dimensions besides the cylinder axis dimension. For dim = x, c1/c2 =
-y/z; for dim = y, c1/c2 = x/z; for dim = z, c1/c2 = x/y. Thus the
-third example above specifies a cylinder with its axis in the
+
For style cone, an axis-aligned cone is defined which is like a
+cylinder except that two different radii (one at each end) can be
+defined.
+
+For style cone and cylinder, the c1,c2 params are coordinates in
+the 2 other dimensions besides the cylinder axis dimension. For dim =
+x, c1/c2 = y/z; for dim = y, c1/c2 = x/z; for dim = z, c1/c2 = x/y.
+Thus the third example above specifies a cylinder with its axis in the
y-direction located at x = 2.0 and z = 3.0, with a radius of 5.0, and
extending in the y-direction from -5.0 to the upper box boundary.
diff -Naur lammps-25Jun09/doc/region.txt lammps-26Jun09/doc/region.txt
--- lammps-25Jun09/doc/region.txt 2009-01-08 16:18:29.000000000 -0700
+++ lammps-26Jun09/doc/region.txt 2009-06-23 11:19:47.000000000 -0600
@@ -13,23 +13,27 @@
region ID style args keyword value ... :pre
ID = user-assigned name for the region :ulb,l
-style = {block} or {cylinder} or {prism} or {sphere} or {union} or {intersect} :l
- {block} args = xlo xhi ylo yhi zlo zhi
- xlo,xhi,ylo,yhi,zlo,zhi = bounds of block in all
- dimensions (distance units)
+style = {block} or {cone} or {cylinder} or {prism} or {sphere} or {union} or {intersect} :l
+ {block} args = dim c1 c2 radlo radhi lo hi
+ xlo,xhi,ylo,yhi,zlo,zhi = bounds of block in all dimensions (distance units)
+ {cone} args = xlo xhi ylo yhi zlo zhi
+ dim = {x} or {y} or {z} = axis of cone
+ c1,c2 = coords of cone axis in other 2 dimensions (distance units)
+ radlo,radhi = cone radii at lo and hi end (distance units)
+ lo,hi = bounds of cone in dim (distance units)
{cylinder} args = dim c1 c2 radius lo hi
dim = {x} or {y} or {z} = axis of cylinder
c1,c2 = coords of cylinder axis in other 2 dimensions (distance units)
radius = cylinder radius (distance units)
lo,hi = bounds of cylinder in dim (distance units)
{prism} args = xlo xhi ylo yhi zlo zhi xy xz yz
- xlo,xhi,ylo,yhi,zlo,zhi = bounds of untilted prism (distance units)
- xy = distance to tilt y in x direction (distance units)
- xz = distance to tilt z in x direction (distance units)
- yz = distance to tilt z in y direction (distance units)
+ xlo,xhi,ylo,yhi,zlo,zhi = bounds of untilted prism (distance units)
+ xy = distance to tilt y in x direction (distance units)
+ xz = distance to tilt z in x direction (distance units)
+ yz = distance to tilt z in y direction (distance units)
{sphere} args = x y z radius
- x,y,z = center of sphere (distance units)
- radius = radius of sphere (distance units)
+ x,y,z = center of sphere (distance units)
+ radius = radius of sphere (distance units)
{union} args = N reg-ID1 reg-ID2 ...
N = # of regions to follow, must be 2 or greater
reg-ID1,reg-ID2, ... = IDs of regions to join together
@@ -62,21 +66,25 @@
in the region can be identified as a group via the "group"_group.html
command, or deleted via the "delete_atoms"_delete_atoms.html command.
-The lo/hi values for {block} or {cylinder} or {prism} styles can be
-specified as EDGE or INF. EDGE means they extend all the way to the
-global simulation box boundary. Note that this is the current box
-boundary; if the box changes size during a simulation the region does
-not. INF means a large negative or positive number (1.0e20), so it
-should encompass the simulation box even if it changes size. If a
+The lo/hi values for {block} or {cone} or {cylinder} or {prism} styles
+can be specified as EDGE or INF. EDGE means they extend all the way
+to the global simulation box boundary. Note that this is the current
+box boundary; if the box changes size during a simulation, the region
+does not. INF means a large negative or positive number (1.0e20), so
+it should encompass the simulation box even if it changes size. If a
region is defined before the simulation box has been created (via
"create_box"_create_box.html or "read_data"_read_data.html or
"read_restart"_read_restart.html commands), then an EDGE or INF
parameter cannot be used.
-For style {cylinder}, the c1,c2 params are coordinates in the 2 other
-dimensions besides the cylinder axis dimension. For dim = x, c1/c2 =
-y/z; for dim = y, c1/c2 = x/z; for dim = z, c1/c2 = x/y. Thus the
-third example above specifies a cylinder with its axis in the
+For style {cone}, an axis-aligned cone is defined which is like a
+{cylinder} except that two different radii (one at each end) can be
+defined.
+
+For style {cone} and {cylinder}, the c1,c2 params are coordinates in
+the 2 other dimensions besides the cylinder axis dimension. For dim =
+x, c1/c2 = y/z; for dim = y, c1/c2 = x/z; for dim = z, c1/c2 = x/y.
+Thus the third example above specifies a cylinder with its axis in the
y-direction located at x = 2.0 and z = 3.0, with a radius of 5.0, and
extending in the y-direction from -5.0 to the upper box boundary.
diff -Naur lammps-25Jun09/src/region_cone.cpp lammps-26Jun09/src/region_cone.cpp
--- lammps-25Jun09/src/region_cone.cpp 1969-12-31 17:00:00.000000000 -0700
+++ lammps-26Jun09/src/region_cone.cpp 2009-06-23 11:14:26.000000000 -0600
@@ -0,0 +1,173 @@
+/* ----------------------------------------------------------------------
+ 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.
+------------------------------------------------------------------------- */
+
+/* ----------------------------------------------------------------------
+ Contributing author: Pim Schravendijk
+------------------------------------------------------------------------- */
+
+#include "math.h"
+#include "stdlib.h"
+#include "string.h"
+#include "region_cone.h"
+#include "domain.h"
+#include "error.h"
+
+using namespace LAMMPS_NS;
+
+#define BIG 1.0e20
+
+/* ---------------------------------------------------------------------- */
+
+RegCone::RegCone(LAMMPS *lmp, int narg, char **arg) :
+ Region(lmp, narg, arg)
+{
+ options(narg-9,&arg[9]);
+
+ if (strcmp(arg[2],"x") && strcmp(arg[2],"y") && strcmp(arg[2],"z"))
+ error->all("Illegal region cylinder command");
+ axis = arg[2][0];
+
+ if (axis == 'x') {
+ c1 = yscale*atof(arg[3]);
+ c2 = zscale*atof(arg[4]);
+ } else if (axis == 'y') {
+ c1 = xscale*atof(arg[3]);
+ c2 = zscale*atof(arg[4]);
+ } else if (axis == 'z') {
+ c1 = xscale*atof(arg[3]);
+ c2 = yscale*atof(arg[4]);
+ }
+ radiuslo = xscale*atof(arg[5]);
+ radiushi = xscale*atof(arg[6]);
+
+ if (strcmp(arg[7],"INF") == 0 || strcmp(arg[7],"EDGE") == 0) {
+ if (domain->box_exist == 0)
+ error->all("Cannot use region INF or EDGE when box does not exist");
+ if (axis == 'x') {
+ if (strcmp(arg[7],"INF") == 0) lo = -BIG;
+ else if (domain->triclinic == 0) lo = domain->boxlo[0];
+ else lo = domain->boxlo_bound[0];
+ }
+ if (axis == 'y') {
+ if (strcmp(arg[7],"INF") == 0) lo = -BIG;
+ else if (domain->triclinic == 0) lo = domain->boxlo[1];
+ else lo = domain->boxlo_bound[1];
+ }
+ if (axis == 'z') {
+ if (strcmp(arg[7],"INF") == 0) lo = -BIG;
+ else if (domain->triclinic == 0) lo = domain->boxlo[2];
+ else lo = domain->boxlo_bound[2];
+ }
+ } else {
+ if (axis == 'x') lo = xscale*atof(arg[7]);
+ if (axis == 'y') lo = yscale*atof(arg[7]);
+ if (axis == 'z') lo = zscale*atof(arg[7]);
+ }
+
+ if (strcmp(arg[8],"INF") == 0 || strcmp(arg[7],"EDGE") == 0) {
+ if (domain->box_exist == 0)
+ error->all("Cannot use region INF or EDGE when box does not exist");
+ if (axis == 'x') {
+ if (strcmp(arg[8],"INF") == 0) hi = BIG;
+ else if (domain->triclinic == 0) hi = domain->boxhi[0];
+ else hi = domain->boxhi_bound[0];
+ }
+ if (axis == 'y') {
+ if (strcmp(arg[8],"INF") == 0) hi = BIG;
+ if (domain->triclinic == 0) hi = domain->boxhi[1];
+ else hi = domain->boxhi_bound[1];
+ }
+ if (axis == 'z') {
+ if (strcmp(arg[8],"INF") == 0) hi = BIG;
+ else if (domain->triclinic == 0) hi = domain->boxhi[2];
+ else hi = domain->boxhi_bound[2];
+ }
+ } else {
+ if (axis == 'x') hi = xscale*atof(arg[8]);
+ if (axis == 'y') hi = yscale*atof(arg[8]);
+ if (axis == 'z') hi = zscale*atof(arg[8]);
+ }
+
+ // error check
+
+ if (radiuslo < 0.0) error->all("Illegal radius in region cone command");
+ if (radiushi < 0.0) error->all("Illegal radius in region cone command");
+ if (hi == lo) error->all("Illegal cone length in region cone command");
+
+ // extent of cone
+
+ double largestradius;
+ if (radiuslo > radiushi) largestradius = radiuslo;
+ else largestradius = radiushi;
+
+ if (axis == 'x') {
+ extent_xlo = lo;
+ extent_xhi = hi;
+ extent_ylo = c1 - largestradius;
+ extent_yhi = c1 + largestradius;
+ extent_zlo = c2 - largestradius;
+ extent_zhi = c2 + largestradius;
+ }
+ if (axis == 'y') {
+ extent_xlo = c1 - largestradius;
+ extent_xhi = c1 + largestradius;
+ extent_ylo = lo;
+ extent_yhi = hi;
+ extent_zlo = c2 - largestradius;
+ extent_zhi = c2 + largestradius;
+ }
+ if (axis == 'z') {
+ extent_xlo = c1 - largestradius;
+ extent_xhi = c1 + largestradius;
+ extent_ylo = c2 - largestradius;
+ extent_yhi = c2 + largestradius;
+ extent_zlo = lo;
+ extent_zhi = hi;
+ }
+}
+
+/* ---------------------------------------------------------------------- */
+
+int RegCone::match(double x, double y, double z)
+{
+ double del1,del2,dist;
+ int inside;
+ double currentradius;
+
+ if (axis == 'x') {
+ del1 = y - c1;
+ del2 = z - c2;
+ dist = sqrt(del1*del1 + del2*del2);
+ currentradius = radiuslo + (x-lo)*(radiushi-radiuslo)/(hi-lo);
+ if (dist <= currentradius && x >= lo && x <= hi) inside = 1;
+ else inside = 0;
+ }
+ if (axis == 'y') {
+ del1 = x - c1;
+ del2 = z - c2;
+ dist = sqrt(del1*del1 + del2*del2);
+ currentradius = radiuslo + (y-lo)*(radiushi-radiuslo)/(hi-lo);
+ if (dist <= currentradius && y >= lo && y <= hi) inside = 1;
+ else inside = 0;
+ }
+ if (axis == 'z') {
+ del1 = x - c1;
+ del2 = y - c2;
+ dist = sqrt(del1*del1 + del2*del2);
+ currentradius = radiuslo + (z-lo)*(radiushi-radiuslo)/(hi-lo);
+ if (dist <= currentradius && z >= lo && z <= hi) inside = 1;
+ else inside = 0;
+ }
+
+ return !(inside ^ interior); // 1 if same, 0 if different
+}
diff -Naur lammps-25Jun09/src/region_cone.h lammps-26Jun09/src/region_cone.h
--- lammps-25Jun09/src/region_cone.h 1969-12-31 17:00:00.000000000 -0700
+++ lammps-26Jun09/src/region_cone.h 2009-06-23 11:14:26.000000000 -0600
@@ -0,0 +1,35 @@
+/* ----------------------------------------------------------------------
+ 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.
+------------------------------------------------------------------------- */
+
+#ifndef REGION_CONE_H
+#define REGION_CONE_H
+
+#include "region.h"
+
+namespace LAMMPS_NS {
+
+class RegCone : public Region {
+ public:
+ RegCone(class LAMMPS *, int, char **);
+ int match(double, double, double);
+
+ private:
+ char axis;
+ double c1,c2;
+ double radiuslo,radiushi;
+ double lo,hi;
+};
+
+}
+
+#endif
diff -Naur lammps-25Jun09/src/style.h lammps-26Jun09/src/style.h
--- lammps-25Jun09/src/style.h 2009-04-29 10:54:06.000000000 -0600
+++ lammps-26Jun09/src/style.h 2009-06-23 11:14:26.000000000 -0600
@@ -343,6 +343,7 @@
#ifdef RegionInclude
#include "region_block.h"
+#include "region_cone.h"
#include "region_cylinder.h"
#include "region_intersect.h"
#include "region_prism.h"
@@ -352,6 +353,7 @@
#ifdef RegionClass
RegionStyle(block,RegBlock)
+RegionStyle(cone,RegCone)
RegionStyle(cylinder,RegCylinder)
RegionStyle(intersect,RegIntersect)
RegionStyle(prism,RegPrism)