git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@3633 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp
2010-01-08 22:54:13 +00:00
parent 654e03d382
commit e3c029753d
26 changed files with 2110 additions and 136 deletions

View File

@ -37,26 +37,92 @@ RegSphere::RegSphere(LAMMPS *lmp, int narg, char **arg) :
// extent of sphere
extent_xlo = xc - radius;
extent_xhi = xc + radius;
extent_ylo = yc - radius;
extent_yhi = yc + radius;
extent_zlo = zc - radius;
extent_zhi = zc + radius;
if (interior) {
bboxflag = 1;
extent_xlo = xc - radius;
extent_xhi = xc + radius;
extent_ylo = yc - radius;
extent_yhi = yc + radius;
extent_zlo = zc - radius;
extent_zhi = zc + radius;
} else bboxflag = 0;
cmax = 1;
contact = new Contact[cmax];
}
/* ---------------------------------------------------------------------- */
RegSphere::~RegSphere()
{
delete [] contact;
}
/* ----------------------------------------------------------------------
inside = 1 if x,y,z is inside or on surface
inside = 0 if x,y,z is outside and not on surface
------------------------------------------------------------------------- */
int RegSphere::match(double x, double y, double z)
{
double delx = x - xc;
double dely = y - yc;
double delz = z - zc;
double dist = sqrt(delx*delx + dely*dely + delz*delz);
double r = sqrt(delx*delx + dely*dely + delz*delz);
int inside;
if (dist <= radius) inside = 1;
else inside = 0;
int inside = 0;
if (r <= radius) inside = 1;
return !(inside ^ interior); // 1 if same, 0 if different
}
/* ----------------------------------------------------------------------
one contact if 0 <= x < cutoff away from inner surface of sphere
no contact if outside (possible if called from union/intersect)
delxyz = vector from nearest point on sphere to x
special case: no contact if x is at center of sphere
------------------------------------------------------------------------- */
int RegSphere::surface_interior(double *x, double cutoff)
{
double delx = x[0] - xc;
double dely = x[1] - yc;
double delz = x[2] - zc;
double r = sqrt(delx*delx + dely*dely + delz*delz);
if (r > radius || r == 0.0) return 0;
double delta = radius - r;
if (delta < cutoff) {
contact[0].r = delta;
contact[0].delx = delx*(1.0-radius/r);
contact[0].dely = dely*(1.0-radius/r);
contact[0].delz = delz*(1.0-radius/r);
return 1;
}
return 0;
}
/* ----------------------------------------------------------------------
one contact if 0 <= x < cutoff away from outer surface of sphere
no contact if inside (possible if called from union/intersect)
delxyz = vector from nearest point on sphere to x
------------------------------------------------------------------------- */
int RegSphere::surface_exterior(double *x, double cutoff)
{
double delx = x[0] - xc;
double dely = x[1] - yc;
double delz = x[2] - zc;
double r = sqrt(delx*delx + dely*dely + delz*delz);
if (r < radius) return 0;
double delta = r - radius;
if (delta < cutoff) {
contact[0].r = delta;
contact[0].delx = delx*(1.0-radius/r);
contact[0].dely = dely*(1.0-radius/r);
contact[0].delz = delz*(1.0-radius/r);
return 1;
}
return 0;
}