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

This commit is contained in:
sjplimp
2010-08-19 15:16:31 +00:00
parent c85e34a881
commit ad1adc6474
9 changed files with 62 additions and 3 deletions

View File

@ -50,11 +50,16 @@ ComputeReduce::ComputeReduce(LAMMPS *lmp, int narg, char **arg) :
int iarg;
if (strcmp(style,"reduce") == 0) {
if (narg < 5) error->all("Illegal compute reduce command");
idregion = NULL;
iarg = 3;
} else if (strcmp(style,"reduce/region") == 0) {
if (narg < 6) error->all("Illegal compute reduce/region command");
iregion = domain->find_region(arg[3]);
if (iregion == -1) error->all("Compute reduce region ID does not exist");
if (iregion == -1)
error->all("Region ID for compute reduce/region does not exist");
int n = strlen(arg[3]) + 1;
idregion = new char[n];
strcpy(idregion,arg[3]);
iarg = 4;
}
@ -281,6 +286,7 @@ ComputeReduce::~ComputeReduce()
delete [] ids;
delete [] value2index;
delete [] replace;
delete [] idregion;
delete [] vector;
delete [] onevec;
@ -317,6 +323,12 @@ void ComputeReduce::init()
} else value2index[m] = -1;
}
// set index and check validity of region
iregion = domain->find_region(idregion);
if (iregion == -1)
error->all("Region ID for compute reduce/region does not exist");
}
/* ---------------------------------------------------------------------- */

View File

@ -41,6 +41,7 @@ class ComputeReduce : public Compute {
double *onevec;
int *replace,*indices,*owner;
int index;
char *idregion;
int maxatom;
double *varatom;

View File

@ -33,7 +33,11 @@ ComputeTempRegion::ComputeTempRegion(LAMMPS *lmp, int narg, char **arg) :
if (narg != 4) error->all("Illegal compute temp/region command");
iregion = domain->find_region(arg[3]);
if (iregion == -1) error->all("Temperature region ID does not exist");
if (iregion == -1)
error->all("Region ID for compute temp/region does not exist");
int n = strlen(arg[3]) + 1;
idregion = new char[n];
strcpy(idregion,arg[3]);
scalar_flag = vector_flag = 1;
size_vector = 6;
@ -51,6 +55,7 @@ ComputeTempRegion::ComputeTempRegion(LAMMPS *lmp, int narg, char **arg) :
ComputeTempRegion::~ComputeTempRegion()
{
delete [] idregion;
memory->destroy_2d_double_array(vbiasall);
delete [] vector;
}
@ -59,6 +64,12 @@ ComputeTempRegion::~ComputeTempRegion()
void ComputeTempRegion::init()
{
// set index and check validity of region
iregion = domain->find_region(idregion);
if (iregion == -1)
error->all("Region ID for temp reduce/region does not exist");
dof = 0.0;
}

View File

@ -41,6 +41,7 @@ class ComputeTempRegion : public Compute {
private:
int iregion;
char *idregion;
};
}

View File

@ -863,13 +863,18 @@ void Domain::set_lattice(int narg, char **arg)
}
/* ----------------------------------------------------------------------
create a new region
create a new region
------------------------------------------------------------------------- */
void Domain::add_region(int narg, char **arg)
{
if (narg < 2) error->all("Illegal region command");
if (strcmp(arg[1],"delete") == 0) {
delete_region(narg,arg);
return;
}
if (find_region(arg[0]) >= 0) error->all("Reuse of region ID");
// extend Region list if necessary
@ -896,6 +901,21 @@ void Domain::add_region(int narg, char **arg)
nregion++;
}
/* ----------------------------------------------------------------------
delete a region
------------------------------------------------------------------------- */
void Domain::delete_region(int narg, char **arg)
{
if (narg != 2) error->all("Illegal region command");
int iregion = find_region(arg[0]);
if (iregion == -1) error->all("Delete region ID does not exist");
regions[iregion] = regions[nregion-1];
nregion--;
}
/* ----------------------------------------------------------------------
return region index if name matches existing region ID
return -1 if no such region

View File

@ -101,6 +101,7 @@ class Domain : protected Pointers {
void minimum_image(double *);
void set_lattice(int, char **);
void add_region(int, char **);
void delete_region(int, char **);
int find_region(char *);
void set_boundary(int, char **);
void print_box(const char *);

View File

@ -180,6 +180,13 @@ void DumpCFG::init()
if (ivariable < 0) error->all("Could not find dump cfg variable name");
variable[i] = ivariable;
}
// set index and check validity of region
if (iregion >= 0) {
iregion = domain->find_region(idregion);
if (iregion == -1) error->all("Region ID for dump cfg does not exist");
}
}
/* ---------------------------------------------------------------------- */

View File

@ -60,6 +60,7 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
vtype = new int[nfield];
iregion = -1;
idregion = NULL;
nthresh = 0;
thresh_array = NULL;
thresh_op = NULL;
@ -127,6 +128,7 @@ DumpCustom::~DumpCustom()
memory->sfree(field2index);
memory->sfree(argindex);
delete [] idregion;
memory->sfree(thresh_array);
memory->sfree(thresh_op);
memory->sfree(thresh_value);
@ -1143,6 +1145,9 @@ int DumpCustom::modify_param(int narg, char **arg)
else {
iregion = domain->find_region(arg[1]);
if (iregion == -1) error->all("Dump_modify region ID does not exist");
int n = strlen(arg[1]) + 1;
idregion = new char[n];
strcpy(idregion,arg[1]);
}
return 2;

View File

@ -34,6 +34,7 @@ class DumpCustom : public Dump {
protected:
int nevery; // dump frequency to check Fix against
int iregion; // -1 if no region, else which region
char *idregion; // region ID
int nthresh; // # of defined threshholds
int *thresh_array; // array to threshhhold on for each nthresh
int *thresh_op; // threshhold operation for each nthresh