Merge pull request #3188 from njzjz/kspace_plugin

support kspace style plugin
This commit is contained in:
Axel Kohlmeyer
2022-03-28 11:58:40 -04:00
committed by GitHub
3 changed files with 18 additions and 3 deletions

View File

@ -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

View File

@ -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

View File

@ -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.