add Pair::extract_atom() method

This commit is contained in:
Steve Plimpton
2022-07-29 10:54:42 -06:00
parent 842b5b365e
commit ec4c458c7e
6 changed files with 36 additions and 15 deletions

View File

@ -2077,16 +2077,25 @@ void *PairAmoeba::extract(const char *str, int &dim)
if (strcmp(str,"opbend_pentic") == 0) return (void *) &opbend_pentic;
if (strcmp(str,"opbend_sextic") == 0) return (void *) &opbend_sextic;
// peratom requests from FixPair
// return dim = # of quantites per atom
// 0 = per-atom vector
// 1 or more = # of columns in per-atom array
return nullptr;
}
/* ----------------------------------------------------------------------
peratom requests from FixPair
return ptr to requested data
also return ncol = # of quantites per atom
0 = per-atom vector
1 or more = # of columns in per-atom array
return NULL if str is not recognized
---------------------------------------------------------------------- */
void *PairAmoeba::extract_peratom(const char *str, int &ncol)
{
if (strcmp(str,"uind") == 0) {
dim = 3;
ncol = 3;
return (void *) uind;
} else if (strcmp(str,"uinp") == 0) {
dim = 3;
ncol = 3;
return (void *) uinp;
}

View File

@ -50,6 +50,7 @@ class PairAmoeba : public Pair {
void unpack_reverse_grid(int, void *, int, int *) override;
void *extract(const char *, int &) override;
void *extract_peratom(const char *, int &) override;
double memory_usage() override;
protected:

View File

@ -934,16 +934,25 @@ void *PairEAM::extract(const char *str, int &dim)
dim = 2;
if (strcmp(str,"scale") == 0) return (void *) scale;
// peratom requests from FixPair
// return dim = # of quantites per atom
// 0 = per-atom vector
// 1 or more = # of columns in per-atom array
return nullptr;
}
/* ----------------------------------------------------------------------
peratom requests from FixPair
return ptr to requested data
also return ncol = # of quantites per atom
0 = per-atom vector
1 or more = # of columns in per-atom array
return NULL if str is not recognized
---------------------------------------------------------------------- */
void *PairEAM::extract_peratom(const char *str, int &ncol)
{
if (strcmp(str,"rho") == 0) {
dim = 0;
ncol = 0;
return (void *) rho;
} else if (strcmp(str,"fp") == 0) {
dim = 0;
ncol = 0;
return (void *) fp;
}

View File

@ -53,6 +53,7 @@ class PairEAM : public Pair {
double init_one(int, int) override;
double single(int, int, int, int, double, double, double, double &) override;
void *extract(const char *, int &) override;
void *extract_peratom(const char *, int &) override;
int pack_forward_comm(int, int *, double *, int, int *) override;
void unpack_forward_comm(int, int, double *) override;

View File

@ -83,15 +83,15 @@ FixPair::FixPair(LAMMPS *lmp, int narg, char **arg) :
triggerptr = new int*[nfield];
int dim;
ncols = 0;
for (int ifield = 0; ifield < nfield; ifield++) {
int columns = 0; // set in case fieldname not recognized by pstyle
void *pvoid = pstyle->extract(fieldname[ifield],columns);
void *pvoid = pstyle->extract_peratom(fieldname[ifield],columns);
if (columns) ncols += columns;
else ncols++;
if (trigger[ifield]) {
int dim;
triggerptr[ifield] = (int *) pstyle->extract(triggername[ifield],dim);
if (!triggerptr[ifield])
error->all(FLERR,"Fix pair pair style cannot extract {}",
@ -222,7 +222,7 @@ void FixPair::post_force(int /*vflag*/)
int columns;
for (int ifield = 0; ifield < nfield; ifield++) {
void *pvoid = pstyle->extract(fieldname[ifield],columns);
void *pvoid = pstyle->extract_peratom(fieldname[ifield],columns);
if (pvoid == nullptr)
error->all(FLERR,"Fix pair pair style cannot extract {}",fieldname[ifield]);

View File

@ -215,6 +215,7 @@ class Pair : protected Pointers {
// specific child-class methods for certain Pair styles
virtual void *extract(const char *, int &) { return nullptr; }
virtual void *extract_peratom(const char *, int &) { return nullptr; }
virtual void swap_eam(double *, double **) {}
virtual void reset_dt() {}
virtual void min_xf_pointers(int, double **, double **) {}