From a1a9f34c1857c842e3033b0628b8fa1dfa8630df Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer <akohlmey@gmail.com> Date: Thu, 4 Oct 2018 12:18:28 +0200 Subject: [PATCH] pair style deprecated now functional and compatible with hybrid pair styles --- src/pair_deprecated.cpp | 52 ++++++++++++++++++++++++----------------- src/pair_deprecated.h | 10 ++++---- src/pair_hybrid.h | 1 + 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/pair_deprecated.cpp b/src/pair_deprecated.cpp index a383f390cf..e64c4913e4 100644 --- a/src/pair_deprecated.cpp +++ b/src/pair_deprecated.cpp @@ -23,31 +23,39 @@ using namespace LAMMPS_NS; +static void writemsg(LAMMPS *lmp, const char *msg, int abend=1) +{ + if (lmp->comm->me == 0) { + if (lmp->screen) fputs(msg,lmp->screen); + if (lmp->logfile) fputs(msg,lmp->logfile); + } + if (abend) + lmp->error->all(FLERR,"This pair_style is no longer available"); +} + + /* ---------------------------------------------------------------------- */ -PairDeprecated::PairDeprecated(LAMMPS *lmp) : Pair(lmp) +void PairDeprecated::settings(int, char **) { - if (strcmp(force->pair_style,"deprecated") == 0) { - const char *message = "\n" - "NOTE: The pair style 'deprecated' is a dummy fix style that was added to\n" - "LAMMPS in order to print suitable error messages for deleted features.\n\n"; - - if (comm->me == 0) { - if (screen) fputs(message,screen); - if (logfile) fputs(message,logfile); - } + const char *my_style = force->pair_style; + + // hybrid substyles are created in PairHybrid::settings(), so when this is + // called, our style was just added at the end of the list of substyles + if (strncmp(my_style,"hybrid",6) == 0) { + PairHybrid *hybrid = (PairHybrid *)force->pair; + my_style = hybrid->keywords[hybrid->nstyles]; } - if (strncmp(force->pair_style,"reax",11) == 0) { - const char *message = "\n" - "NOTE: The pair style 'reax' has been removed from LAMMPS after the\n" - "## November 2018 stable release. Its functionality has long before\n" - "been superseded by pair styles 'reax/c' and 'reax/c/kk'\n\n"; - - if (comm->me == 0) { - if (screen) fputs(message,screen); - if (logfile) fputs(message,logfile); - } + + if (strcmp(my_style,"deprecated") == 0) { + writemsg(lmp,"\nPair style 'deprecated' is a dummy pair style\n\n",0); + + } else if (strcmp(my_style,"reax") == 0) { + writemsg(lmp, "\nPair style 'reax' has been removed from LAMMPS " + "after the\n## November 2018 stable release. Its " + "functionality has long before\nbeen superseded by pair " + "styles 'reax/c' and 'reax/c/kk'\n\n"); } - error->all(FLERR,"This pair_style command has been removed from LAMMPS"); -} +} + diff --git a/src/pair_deprecated.h b/src/pair_deprecated.h index 4201b3453d..163b2a8f1b 100644 --- a/src/pair_deprecated.h +++ b/src/pair_deprecated.h @@ -26,12 +26,12 @@ namespace LAMMPS_NS { class PairDeprecated : public Pair { public: - PairDeprecated(class LAMMPS *); - virtual ~PairDeprecated() {}; + PairDeprecated(class LAMMPS *lmp) : Pair(lmp) {} + virtual ~PairDeprecated() {} - virtual void compute(int, int) {}; - virtual void settings(int, char **) {}; - virtual void coeff(int, char **) {}; + virtual void compute(int, int) {} + virtual void settings(int, char **); + virtual void coeff(int, char **) {} }; diff --git a/src/pair_hybrid.h b/src/pair_hybrid.h index 08f5a574df..e313e16f18 100644 --- a/src/pair_hybrid.h +++ b/src/pair_hybrid.h @@ -32,6 +32,7 @@ class PairHybrid : public Pair { friend class Force; friend class Respa; friend class Info; + friend class PairDeprecated; public: PairHybrid(class LAMMPS *); virtual ~PairHybrid(); -- GitLab