From 384330aff27e557959f8e86c0a16e73196f76c50 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Sat, 21 Aug 2021 20:31:02 -0400 Subject: [PATCH] update/correct extract function --- src/DIPOLE/pair_lj_cut_dipole_cut.cpp | 11 +++++++++++ src/DIPOLE/pair_lj_cut_dipole_cut.h | 1 + src/DIPOLE/pair_lj_cut_dipole_long.cpp | 18 +++++++++--------- src/DIPOLE/pair_lj_cut_dipole_long.h | 2 +- src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp | 2 +- src/pair.cpp | 3 +-- src/pair_lj_cut_coul_cut.cpp | 2 +- 7 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/DIPOLE/pair_lj_cut_dipole_cut.cpp b/src/DIPOLE/pair_lj_cut_dipole_cut.cpp index e4b9e592eb..0f8a7317c6 100644 --- a/src/DIPOLE/pair_lj_cut_dipole_cut.cpp +++ b/src/DIPOLE/pair_lj_cut_dipole_cut.cpp @@ -485,3 +485,14 @@ void PairLJCutDipoleCut::read_restart_settings(FILE *fp) MPI_Bcast(&offset_flag,1,MPI_INT,0,world); MPI_Bcast(&mix_flag,1,MPI_INT,0,world); } + +/* ---------------------------------------------------------------------- */ + +void *PairLJCutDipoleCut::extract(const char *str, int &dim) +{ + dim = 2; + if (strcmp(str,"cut_coul") == 0) return (void *) cut_coul; + if (strcmp(str,"epsilon") == 0) return (void *) epsilon; + if (strcmp(str,"sigma") == 0) return (void *) sigma; + return nullptr; +} diff --git a/src/DIPOLE/pair_lj_cut_dipole_cut.h b/src/DIPOLE/pair_lj_cut_dipole_cut.h index 11bc49f358..1999e1612e 100644 --- a/src/DIPOLE/pair_lj_cut_dipole_cut.h +++ b/src/DIPOLE/pair_lj_cut_dipole_cut.h @@ -37,6 +37,7 @@ class PairLJCutDipoleCut : public Pair { void read_restart(FILE *); void write_restart_settings(FILE *); void read_restart_settings(FILE *); + void *extract(const char *, int &); protected: double cut_lj_global, cut_coul_global; diff --git a/src/DIPOLE/pair_lj_cut_dipole_long.cpp b/src/DIPOLE/pair_lj_cut_dipole_long.cpp index e286568f31..b13e48b808 100644 --- a/src/DIPOLE/pair_lj_cut_dipole_long.cpp +++ b/src/DIPOLE/pair_lj_cut_dipole_long.cpp @@ -540,18 +540,18 @@ void PairLJCutDipoleLong::read_restart_settings(FILE *fp) void *PairLJCutDipoleLong::extract(const char *str, int &dim) { - if (strcmp(str,"cut_coul") == 0) { - dim = 0; - return (void *) &cut_coul; - } else if (strcmp(str,"ewald_order") == 0) { + dim = 0; + if (strcmp(str,"cut_coul") == 0) return (void *) &cut_coul; + else if (strcmp(str,"ewald_order") == 0) { ewald_order = 0; ewald_order |= 1<<1; ewald_order |= 1<<3; - dim = 0; return (void *) &ewald_order; - } else if (strcmp(str,"ewald_mix") == 0) { - dim = 0; - return (void *) &mix_flag; - } + } else if (strcmp(str,"ewald_mix") == 0) return (void *) &mix_flag; + + dim = 2; + if (strcmp(str,"epsilon") == 0) return (void *) epsilon; + else if (strcmp(str,"sigma") == 0) return (void *) sigma; + return nullptr; } diff --git a/src/DIPOLE/pair_lj_cut_dipole_long.h b/src/DIPOLE/pair_lj_cut_dipole_long.h index 26ff54f73e..bc9e3571da 100644 --- a/src/DIPOLE/pair_lj_cut_dipole_long.h +++ b/src/DIPOLE/pair_lj_cut_dipole_long.h @@ -40,6 +40,7 @@ class PairLJCutDipoleLong : public Pair { void read_restart(FILE *); void write_restart_settings(FILE *); void read_restart_settings(FILE *); + void *extract(const char *, int &); protected: double cut_lj_global; @@ -49,7 +50,6 @@ class PairLJCutDipoleLong : public Pair { double **lj1, **lj2, **lj3, **lj4, **offset; double g_ewald; int ewald_order; - virtual void *extract(const char *, int &); void allocate(); }; diff --git a/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp b/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp index de5bc7cf92..6c2dd433de 100644 --- a/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp +++ b/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp @@ -489,7 +489,7 @@ double PairNMCutCoulCut::single(int i, int j, int itype, int jtype, void *PairNMCutCoulCut::extract(const char *str, int &dim) { dim = 2; - if (strcmp(str,"cut_coul") == 0) return (void *) &cut_coul; + if (strcmp(str,"cut_coul") == 0) return (void *) cut_coul; if (strcmp(str,"e0") == 0) return (void *) e0; if (strcmp(str,"r0") == 0) return (void *) r0; if (strcmp(str,"nn") == 0) return (void *) nn; diff --git a/src/pair.cpp b/src/pair.cpp index 38c7922c17..16979f8023 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -77,8 +77,7 @@ Pair::Pair(LAMMPS *lmp) : Pointers(lmp) setflag = nullptr; cutsq = nullptr; - ewaldflag = pppmflag = msmflag = dispersionflag = - tip4pflag = dipoleflag = spinflag = 0; + ewaldflag = pppmflag = msmflag = dispersionflag = tip4pflag = dipoleflag = spinflag = 0; reinitflag = 1; centroidstressflag = CENTROID_SAME; diff --git a/src/pair_lj_cut_coul_cut.cpp b/src/pair_lj_cut_coul_cut.cpp index 8fdc47d5f1..4782a96fec 100644 --- a/src/pair_lj_cut_coul_cut.cpp +++ b/src/pair_lj_cut_coul_cut.cpp @@ -465,7 +465,7 @@ double PairLJCutCoulCut::single(int i, int j, int itype, int jtype, void *PairLJCutCoulCut::extract(const char *str, int &dim) { dim = 2; - if (strcmp(str,"cut_coul") == 0) return (void *) &cut_coul; + if (strcmp(str,"cut_coul") == 0) return (void *) cut_coul; if (strcmp(str,"epsilon") == 0) return (void *) epsilon; if (strcmp(str,"sigma") == 0) return (void *) sigma; return nullptr;