complete region handling refactor
This commit is contained in:
@ -40,8 +40,8 @@
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
#define MAX_GROUP 32
|
||||
#define EPSILON 1.0e-6
|
||||
static constexpr int MAX_GROUP = 32;
|
||||
static constexpr double EPSILON = 1.0e-6;
|
||||
|
||||
enum{NONE,TYPE,MOLECULE,ID};
|
||||
enum{LT,LE,GT,GE,EQ,NEQ,BETWEEN};
|
||||
@ -176,13 +176,13 @@ void Group::assign(int narg, char **arg)
|
||||
|
||||
if (narg != 3) error->all(FLERR,"Illegal group command");
|
||||
|
||||
int iregion = domain->find_region(arg[2]);
|
||||
if (iregion == -1) error->all(FLERR,"Group region ID does not exist");
|
||||
domain->regions[iregion]->init();
|
||||
domain->regions[iregion]->prematch();
|
||||
auto region = domain->get_region_by_id(arg[2]);
|
||||
if (!region) error->all(FLERR,"Group region {} does not exist", arg[2]);
|
||||
region->init();
|
||||
region->prematch();
|
||||
|
||||
for (i = 0; i < nlocal; i++)
|
||||
if (domain->regions[iregion]->match(x[i][0],x[i][1],x[i][2]))
|
||||
if (region->match(x[i][0],x[i][1],x[i][2]))
|
||||
mask[i] |= bit;
|
||||
|
||||
// create an empty group
|
||||
@ -813,15 +813,6 @@ bigint Group::count(int igroup, Region *region)
|
||||
return nall;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
count atoms in group and region
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
bigint Group::count(int igroup, int iregion)
|
||||
{
|
||||
return count(igroup, domain->regions[iregion]);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute the total mass of group of atoms
|
||||
use either per-type mass or per-atom rmass
|
||||
@ -886,16 +877,6 @@ double Group::mass(int igroup, Region *region)
|
||||
return all;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute the total mass of group of atoms in region
|
||||
use either per-type mass or per-atom rmass
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double Group::mass(int igroup, int iregion)
|
||||
{
|
||||
return mass(igroup, domain->regions[iregion]);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute the total charge of group of atoms
|
||||
------------------------------------------------------------------------- */
|
||||
@ -921,10 +902,9 @@ double Group::charge(int igroup)
|
||||
compute the total charge of group of atoms in region
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double Group::charge(int igroup, int iregion)
|
||||
double Group::charge(int igroup, Region *region)
|
||||
{
|
||||
int groupbit = bitmask[igroup];
|
||||
Region *region = domain->regions[iregion];
|
||||
region->prematch();
|
||||
|
||||
double **x = atom->x;
|
||||
@ -990,10 +970,9 @@ void Group::bounds(int igroup, double *minmax)
|
||||
periodic images are not considered, so atoms are NOT unwrapped
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Group::bounds(int igroup, double *minmax, int iregion)
|
||||
void Group::bounds(int igroup, double *minmax, Region *region)
|
||||
{
|
||||
int groupbit = bitmask[igroup];
|
||||
Region *region = domain->regions[iregion];
|
||||
region->prematch();
|
||||
|
||||
double extent[6];
|
||||
@ -1090,10 +1069,9 @@ void Group::xcm(int igroup, double masstotal, double *cm)
|
||||
must unwrap atoms to compute center-of-mass correctly
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Group::xcm(int igroup, double masstotal, double *cm, int iregion)
|
||||
void Group::xcm(int igroup, double masstotal, double *cm, Region *region)
|
||||
{
|
||||
int groupbit = bitmask[igroup];
|
||||
Region *region = domain->regions[iregion];
|
||||
region->prematch();
|
||||
|
||||
double **x = atom->x;
|
||||
@ -1232,17 +1210,6 @@ void Group::vcm(int igroup, double masstotal, double *cm, Region *region)
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute the center-of-mass velocity of group of atoms in region
|
||||
masstotal = total mass
|
||||
return center-of-mass velocity in cm[]
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Group::vcm(int igroup, double masstotal, double *cm, int iregion)
|
||||
{
|
||||
vcm(igroup, masstotal, cm, domain->regions[iregion]);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute the total force on group of atoms
|
||||
------------------------------------------------------------------------- */
|
||||
@ -1272,10 +1239,9 @@ void Group::fcm(int igroup, double *cm)
|
||||
compute the total force on group of atoms in region
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Group::fcm(int igroup, double *cm, int iregion)
|
||||
void Group::fcm(int igroup, double *cm, Region *region)
|
||||
{
|
||||
int groupbit = bitmask[igroup];
|
||||
Region *region = domain->regions[iregion];
|
||||
region->prematch();
|
||||
|
||||
double **x = atom->x;
|
||||
@ -1368,15 +1334,6 @@ double Group::ke(int igroup, Region *region)
|
||||
return all;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute the total kinetic energy of group of atoms in region and return it
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double Group::ke(int igroup, int iregion)
|
||||
{
|
||||
return ke(igroup, domain->regions[iregion]);
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
compute the radius-of-gyration of group of atoms
|
||||
around center-of-mass cm
|
||||
@ -1422,10 +1379,9 @@ double Group::gyration(int igroup, double masstotal, double *cm)
|
||||
must unwrap atoms to compute Rg correctly
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double Group::gyration(int igroup, double masstotal, double *cm, int iregion)
|
||||
double Group::gyration(int igroup, double masstotal, double *cm, Region *region)
|
||||
{
|
||||
int groupbit = bitmask[igroup];
|
||||
Region *region = domain->regions[iregion];
|
||||
region->prematch();
|
||||
|
||||
double **x = atom->x;
|
||||
@ -1504,10 +1460,9 @@ void Group::angmom(int igroup, double *cm, double *lmom)
|
||||
must unwrap atoms to compute L correctly
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Group::angmom(int igroup, double *cm, double *lmom, int iregion)
|
||||
void Group::angmom(int igroup, double *cm, double *lmom, Region *region)
|
||||
{
|
||||
int groupbit = bitmask[igroup];
|
||||
Region *region = domain->regions[iregion];
|
||||
region->prematch();
|
||||
|
||||
double **x = atom->x;
|
||||
@ -1583,10 +1538,9 @@ void Group::torque(int igroup, double *cm, double *tq)
|
||||
must unwrap atoms to compute T correctly
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Group::torque(int igroup, double *cm, double *tq, int iregion)
|
||||
void Group::torque(int igroup, double *cm, double *tq, Region *region)
|
||||
{
|
||||
int groupbit = bitmask[igroup];
|
||||
Region *region = domain->regions[iregion];
|
||||
region->prematch();
|
||||
|
||||
double **x = atom->x;
|
||||
@ -1669,12 +1623,11 @@ void Group::inertia(int igroup, double *cm, double itensor[3][3])
|
||||
must unwrap atoms to compute itensor correctly
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void Group::inertia(int igroup, double *cm, double itensor[3][3], int iregion)
|
||||
void Group::inertia(int igroup, double *cm, double itensor[3][3], Region *region)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
int groupbit = bitmask[igroup];
|
||||
Region *region = domain->regions[iregion];
|
||||
region->prematch();
|
||||
|
||||
double **x = atom->x;
|
||||
|
||||
Reference in New Issue
Block a user