add Pair::extract_atom() method
This commit is contained in:
@ -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_pentic") == 0) return (void *) &opbend_pentic;
|
||||||
if (strcmp(str,"opbend_sextic") == 0) return (void *) &opbend_sextic;
|
if (strcmp(str,"opbend_sextic") == 0) return (void *) &opbend_sextic;
|
||||||
|
|
||||||
// peratom requests from FixPair
|
return nullptr;
|
||||||
// return dim = # of quantites per atom
|
}
|
||||||
// 0 = per-atom vector
|
|
||||||
// 1 or more = # of columns in per-atom array
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
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) {
|
if (strcmp(str,"uind") == 0) {
|
||||||
dim = 3;
|
ncol = 3;
|
||||||
return (void *) uind;
|
return (void *) uind;
|
||||||
} else if (strcmp(str,"uinp") == 0) {
|
} else if (strcmp(str,"uinp") == 0) {
|
||||||
dim = 3;
|
ncol = 3;
|
||||||
return (void *) uinp;
|
return (void *) uinp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,6 +50,7 @@ class PairAmoeba : public Pair {
|
|||||||
void unpack_reverse_grid(int, void *, int, int *) override;
|
void unpack_reverse_grid(int, void *, int, int *) override;
|
||||||
|
|
||||||
void *extract(const char *, int &) override;
|
void *extract(const char *, int &) override;
|
||||||
|
void *extract_peratom(const char *, int &) override;
|
||||||
double memory_usage() override;
|
double memory_usage() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@ -934,16 +934,25 @@ void *PairEAM::extract(const char *str, int &dim)
|
|||||||
dim = 2;
|
dim = 2;
|
||||||
if (strcmp(str,"scale") == 0) return (void *) scale;
|
if (strcmp(str,"scale") == 0) return (void *) scale;
|
||||||
|
|
||||||
// peratom requests from FixPair
|
return nullptr;
|
||||||
// return dim = # of quantites per atom
|
}
|
||||||
// 0 = per-atom vector
|
|
||||||
// 1 or more = # of columns in per-atom array
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
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) {
|
if (strcmp(str,"rho") == 0) {
|
||||||
dim = 0;
|
ncol = 0;
|
||||||
return (void *) rho;
|
return (void *) rho;
|
||||||
} else if (strcmp(str,"fp") == 0) {
|
} else if (strcmp(str,"fp") == 0) {
|
||||||
dim = 0;
|
ncol = 0;
|
||||||
return (void *) fp;
|
return (void *) fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -53,6 +53,7 @@ class PairEAM : public Pair {
|
|||||||
double init_one(int, int) override;
|
double init_one(int, int) override;
|
||||||
double single(int, int, int, int, double, double, double, double &) override;
|
double single(int, int, int, int, double, double, double, double &) override;
|
||||||
void *extract(const char *, int &) override;
|
void *extract(const char *, int &) override;
|
||||||
|
void *extract_peratom(const char *, int &) override;
|
||||||
|
|
||||||
int pack_forward_comm(int, int *, double *, int, int *) override;
|
int pack_forward_comm(int, int *, double *, int, int *) override;
|
||||||
void unpack_forward_comm(int, int, double *) override;
|
void unpack_forward_comm(int, int, double *) override;
|
||||||
|
|||||||
@ -83,15 +83,15 @@ FixPair::FixPair(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
triggerptr = new int*[nfield];
|
triggerptr = new int*[nfield];
|
||||||
|
|
||||||
int dim;
|
|
||||||
ncols = 0;
|
ncols = 0;
|
||||||
|
|
||||||
for (int ifield = 0; ifield < nfield; ifield++) {
|
for (int ifield = 0; ifield < nfield; ifield++) {
|
||||||
int columns = 0; // set in case fieldname not recognized by pstyle
|
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;
|
if (columns) ncols += columns;
|
||||||
else ncols++;
|
else ncols++;
|
||||||
if (trigger[ifield]) {
|
if (trigger[ifield]) {
|
||||||
|
int dim;
|
||||||
triggerptr[ifield] = (int *) pstyle->extract(triggername[ifield],dim);
|
triggerptr[ifield] = (int *) pstyle->extract(triggername[ifield],dim);
|
||||||
if (!triggerptr[ifield])
|
if (!triggerptr[ifield])
|
||||||
error->all(FLERR,"Fix pair pair style cannot extract {}",
|
error->all(FLERR,"Fix pair pair style cannot extract {}",
|
||||||
@ -222,7 +222,7 @@ void FixPair::post_force(int /*vflag*/)
|
|||||||
int columns;
|
int columns;
|
||||||
|
|
||||||
for (int ifield = 0; ifield < nfield; ifield++) {
|
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)
|
if (pvoid == nullptr)
|
||||||
error->all(FLERR,"Fix pair pair style cannot extract {}",fieldname[ifield]);
|
error->all(FLERR,"Fix pair pair style cannot extract {}",fieldname[ifield]);
|
||||||
|
|
||||||
|
|||||||
@ -215,6 +215,7 @@ class Pair : protected Pointers {
|
|||||||
// specific child-class methods for certain Pair styles
|
// specific child-class methods for certain Pair styles
|
||||||
|
|
||||||
virtual void *extract(const char *, int &) { return nullptr; }
|
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 swap_eam(double *, double **) {}
|
||||||
virtual void reset_dt() {}
|
virtual void reset_dt() {}
|
||||||
virtual void min_xf_pointers(int, double **, double **) {}
|
virtual void min_xf_pointers(int, double **, double **) {}
|
||||||
|
|||||||
Reference in New Issue
Block a user