diff --git a/doc/src/Developer_plugins.rst b/doc/src/Developer_plugins.rst index c4378b6c85..96bb872929 100644 --- a/doc/src/Developer_plugins.rst +++ b/doc/src/Developer_plugins.rst @@ -68,7 +68,7 @@ Members of ``lammpsplugin_t`` * - author - String with the name and email of the author * - creator.v1 - - Pointer to factory function for pair, bond, angle, dihedral, improper, command or kspace styles + - Pointer to factory function for pair, bond, angle, dihedral, improper, kspace, or command styles * - creator.v2 - Pointer to factory function for compute, fix, or region styles * - handle diff --git a/doc/src/plugin.rst b/doc/src/plugin.rst index 8f689e885a..83eea789d1 100644 --- a/doc/src/plugin.rst +++ b/doc/src/plugin.rst @@ -17,7 +17,7 @@ Syntax *load* file = load plugin(s) from shared object in *file* *unload* style name = unload plugin *name* of style *style* - *style* = *pair* or *bond* or *angle* or *dihedral* or *improper* or *compute* or *fix* or *region* or *command* or *kspace* + *style* = *pair* or *bond* or *angle* or *dihedral* or *improper* or *kspace* or *compute* or *fix* or *region* or *command* *list* = print a list of currently loaded plugins *clear* = unload all currently loaded plugins diff --git a/src/PLUGIN/plugin.cpp b/src/PLUGIN/plugin.cpp index 761b18760f..d651a16760 100644 --- a/src/PLUGIN/plugin.cpp +++ b/src/PLUGIN/plugin.cpp @@ -208,6 +208,14 @@ void plugin_register(lammpsplugin_t *plugin, void *ptr) } (*improper_map)[plugin->name] = (Force::ImproperCreator) plugin->creator.v1; + } else if (pstyle == "kspace") { + auto kspace_map = lmp->force->kspace_map; + if (kspace_map->find(plugin->name) != kspace_map->end()) { + if (lmp->comm->me == 0) + lmp->error->warning(FLERR, "Overriding built-in kspace style {} from plugin", plugin->name); + } + (*kspace_map)[plugin->name] = (Force::KSpaceCreator) plugin->creator.v1; + } else if (pstyle == "compute") { auto compute_map = lmp->modify->compute_map; if (compute_map->find(plugin->name) != compute_map->end()) { @@ -242,15 +250,6 @@ void plugin_register(lammpsplugin_t *plugin, void *ptr) } (*command_map)[plugin->name] = (Input::CommandCreator) plugin->creator.v1; - } else if (pstyle == "kspace") { - auto kspace_map = lmp->force->kspace_map; - if (kspace_map->find(plugin->name) != kspace_map->end()) { - if (lmp->comm->me == 0) - lmp->error->warning(FLERR, "Overriding built-in kspace style {} from plugin", - plugin->name); - } - (*kspace_map)[plugin->name] = (Force::KSpaceCreator) plugin->creator.v1; - } else { utils::logmesg(lmp, "Loading plugins for {} styles not yet implemented\n", pstyle); pluginlist.pop_back(); @@ -272,9 +271,9 @@ void plugin_unload(const char *style, const char *name, LAMMPS *lmp) // ignore unload request from unsupported style categories if ((strcmp(style, "pair") != 0) && (strcmp(style, "bond") != 0) && (strcmp(style, "angle") != 0) && (strcmp(style, "dihedral") != 0) && - (strcmp(style, "improper") != 0) && (strcmp(style, "compute") != 0) && - (strcmp(style, "fix") != 0) && (strcmp(style, "region") != 0) && - (strcmp(style, "command") != 0) && (strcmp(style, "kspace") != 0)) { + (strcmp(style, "improper") != 0) && (strcmp(style, "kspace") != 0) && + (strcmp(style, "compute") != 0) && (strcmp(style, "fix") != 0) && + (strcmp(style, "region") != 0) && (strcmp(style, "command") != 0)) { if (me == 0) utils::logmesg(lmp, "Ignoring unload: {} is not a supported plugin style\n", style); return; @@ -356,6 +355,12 @@ void plugin_unload(const char *style, const char *name, LAMMPS *lmp) if ((lmp->force->improper_style != nullptr) && (lmp->force->improper_match(name) != nullptr)) lmp->force->create_improper("none", 0); + } else if (pstyle == "kspace") { + + auto kspace_map = lmp->force->kspace_map; + auto found = kspace_map->find(name); + if (found != kspace_map->end()) kspace_map->erase(name); + } else if (pstyle == "compute") { auto compute_map = lmp->modify->compute_map; @@ -391,12 +396,6 @@ void plugin_unload(const char *style, const char *name, LAMMPS *lmp) auto command_map = lmp->input->command_map; auto found = command_map->find(name); if (found != command_map->end()) command_map->erase(name); - - } else if (pstyle == "kspace") { - - auto kspace_map = lmp->force->kspace_map; - auto found = kspace_map->find(name); - if (found != kspace_map->end()) kspace_map->erase(name); } // if reference count is down to zero, close DSO handle.