diff --git a/doc/src/Developer_plugins.rst b/doc/src/Developer_plugins.rst index 264a77ed5b..c4378b6c85 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 or command styles + - Pointer to factory function for pair, bond, angle, dihedral, improper, command or kspace 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 3ce9e41870..8f689e885a 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* + *style* = *pair* or *bond* or *angle* or *dihedral* or *improper* or *compute* or *fix* or *region* or *command* or *kspace* *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 3b28a32dbf..761b18760f 100644 --- a/src/PLUGIN/plugin.cpp +++ b/src/PLUGIN/plugin.cpp @@ -242,6 +242,15 @@ 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(); @@ -265,7 +274,7 @@ void plugin_unload(const char *style, const char *name, LAMMPS *lmp) (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, "command") != 0) && (strcmp(style, "kspace") != 0)) { if (me == 0) utils::logmesg(lmp, "Ignoring unload: {} is not a supported plugin style\n", style); return; @@ -382,6 +391,12 @@ 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.