Merge branch 'develop' into collected-small-changes

This commit is contained in:
Axel Kohlmeyer
2022-11-30 08:52:13 -05:00
52 changed files with 988 additions and 571 deletions

View File

@ -89,8 +89,7 @@ table above.
* :doc:`region <region>` * :doc:`region <region>`
* :doc:`replicate <replicate>` * :doc:`replicate <replicate>`
* :doc:`rerun <rerun>` * :doc:`rerun <rerun>`
* :doc:`reset_atom_ids <reset_atom_ids>` * :doc:`reset_atoms <reset_atoms>`
* :doc:`reset_mol_ids <reset_mol_ids>`
* :doc:`reset_timestep <reset_timestep>` * :doc:`reset_timestep <reset_timestep>`
* :doc:`restart <restart>` * :doc:`restart <restart>`
* :doc:`run <run>` * :doc:`run <run>`

View File

@ -26,10 +26,15 @@ Box command
The *box* command has been removed and the LAMMPS code changed so it won't The *box* command has been removed and the LAMMPS code changed so it won't
be needed. If present, LAMMPS will ignore the command and print a warning. be needed. If present, LAMMPS will ignore the command and print a warning.
Reset_ids command Reset_ids, reset_atom_ids, reset_mol_ids commands
----------------- -------------------------------------------------
The reset_ids command has been renamed to :doc:`reset_atom_ids <reset_atom_ids>`. .. deprecated:: TBD
The *reset_ids*, *reset_atom_ids*, and *reset_mol_ids* commands have
been folded into the :doc:`reset_atoms <reset_atoms>` command. If
present, LAMMPS will replace the commands accordingly and print a
warning.
MEAM package MEAM package
------------ ------------
@ -39,18 +44,21 @@ The code in the :ref:`MEAM package <PKG-MEAM>` is a translation of the
Fortran code of MEAM into C++, which removes several restrictions Fortran code of MEAM into C++, which removes several restrictions
(e.g. there can be multiple instances in hybrid pair styles) and allows (e.g. there can be multiple instances in hybrid pair styles) and allows
for some optimizations leading to better performance. The pair style for some optimizations leading to better performance. The pair style
:doc:`meam <pair_meam>` has the exact same syntax. :doc:`meam <pair_meam>` has the exact same syntax. For a transition
period the C++ version of MEAM was called USER-MEAMC so it could
coexist with the Fortran version.
REAX package REAX package
------------ ------------
The REAX package has been removed since it was superseded by the The REAX package has been removed since it was superseded by the
:ref:`REAXFF package <PKG-REAXFF>`. The REAXFF :ref:`REAXFF package <PKG-REAXFF>`. The REAXFF package has been tested
package has been tested to yield equivalent results to the REAX package, to yield equivalent results to the REAX package, offers better
offers better performance, supports OpenMP multi-threading via OPENMP, performance, supports OpenMP multi-threading via OPENMP, and GPU and
and GPU and threading parallelization through KOKKOS. The new pair styles threading parallelization through KOKKOS. The new pair styles are not
are not syntax compatible with the removed reax pair style, so input syntax compatible with the removed reax pair style, so input files will
files will have to be adapted. have to be adapted. The REAXFF package was originally called
USER-REAXC.
USER-CUDA package USER-CUDA package
----------------- -----------------
@ -69,5 +77,6 @@ restart2data tool
The functionality of the restart2data tool has been folded into the The functionality of the restart2data tool has been folded into the
LAMMPS executable directly instead of having a separate tool. A LAMMPS executable directly instead of having a separate tool. A
combination of the commands :doc:`read_restart <read_restart>` and combination of the commands :doc:`read_restart <read_restart>` and
:doc:`write_data <write_data>` can be used to the same effect. For added :doc:`write_data <write_data>` can be used to the same effect. For
convenience this conversion can also be triggered by :doc:`command line flags <Run_options>` added convenience this conversion can also be triggered by
:doc:`command line flags <Run_options>`

View File

@ -226,9 +226,9 @@ The following test programs are currently available:
* - ``test_kim_commands.cpp`` * - ``test_kim_commands.cpp``
- KimCommands - KimCommands
- Tests for several commands from the :ref:`KIM package <PKG-KIM>` - Tests for several commands from the :ref:`KIM package <PKG-KIM>`
* - ``test_reset_ids.cpp`` * - ``test_reset_atoms.cpp``
- ResetIDs - ResetAtoms
- Tests to validate the :doc:`reset_atom_ids <reset_atom_ids>` and :doc:`reset_mol_ids <reset_mol_ids>` commands - Tests to validate the :doc:`reset_atoms <reset_atoms>` sub-commands
Tests for the C-style library interface Tests for the C-style library interface

View File

@ -89,8 +89,7 @@ Commands
region region
replicate replicate
rerun rerun
reset_atom_ids reset_atoms
reset_mol_ids
reset_timestep reset_timestep
restart restart
run run

View File

@ -135,7 +135,7 @@ number of atoms in the system. Note that this is not done for
molecular systems (see the :doc:`atom_style <atom_style>` command), molecular systems (see the :doc:`atom_style <atom_style>` command),
regardless of the *compress* setting, since it would foul up the bond regardless of the *compress* setting, since it would foul up the bond
connectivity that has already been assigned. However, the connectivity that has already been assigned. However, the
:doc:`reset_atom_ids <reset_atom_ids>` command can be used after this :doc:`reset_atoms id <reset_atoms>` command can be used after this
command to accomplish the same thing. command to accomplish the same thing.
Note that the re-assignment of IDs is not really a compression, where Note that the re-assignment of IDs is not really a compression, where
@ -203,7 +203,7 @@ using molecule template files via the :doc:`molecule <molecule>` and
Related commands Related commands
"""""""""""""""" """"""""""""""""
:doc:`create_atoms <create_atoms>`, :doc:`reset_atom_ids <reset_atom_ids>` :doc:`create_atoms <create_atoms>`, :doc:`reset_atoms id <reset_atoms>`
Default Default
""""""" """""""

View File

@ -177,12 +177,12 @@ due to the internal dynamic grouping performed by fix bond/react.
If the group-ID is an existing static group, react-group-IDs If the group-ID is an existing static group, react-group-IDs
should also be specified as this static group or a subset. should also be specified as this static group or a subset.
The *reset_mol_ids* keyword invokes the :doc:`reset_mol_ids <reset_mol_ids>` The *reset_mol_ids* keyword invokes the :doc:`reset_atoms mol
command after a reaction occurs, to ensure that molecule IDs are <reset_atoms>` command after a reaction occurs, to ensure that
consistent with the new bond topology. The group-ID used for molecule IDs are consistent with the new bond topology. The group-ID
:doc:`reset_mol_ids <reset_mol_ids>` is the group-ID for this fix. used for :doc:`reset_atoms mol <reset_atoms>` is the group-ID for this
Resetting molecule IDs is necessarily a global operation, so it can fix. Resetting molecule IDs is necessarily a global operation, so it
be slow for very large systems. can be slow for very large systems.
The following comments pertain to each *react* argument (in other The following comments pertain to each *react* argument (in other
words, they can be customized for each reaction, or reaction step): words, they can be customized for each reaction, or reaction step):

View File

@ -1,94 +0,0 @@
.. index:: reset_atom_ids
reset_atom_ids command
======================
Syntax
""""""
.. code-block:: LAMMPS
reset_atom_ids keyword values ...
* zero or more keyword/value pairs may be appended
* keyword = *sort*
.. parsed-literal::
*sort* value = *yes* or *no*
Examples
""""""""
.. code-block:: LAMMPS
reset_atom_ids
reset_atom_ids sort yes
Description
"""""""""""
Reset atom IDs for the system, including all the global IDs stored
for bond, angle, dihedral, improper topology data. This will
create a set of IDs that are numbered contiguously from 1 to N
for a N atoms system.
This can be useful to do after performing a "delete_atoms" command for
a molecular system. The delete_atoms compress yes option will not
perform this operation due to the existence of bond topology. It can
also be useful to do after any simulation which has lost atoms,
e.g. due to atoms moving outside a simulation box with fixed
boundaries (see the "boundary command"), or due to evaporation (see
the "fix evaporate" command).
If the *sort* keyword is used with a setting of *yes*, then the
assignment of new atom IDs will be the same no matter how many
processors LAMMPS is running on. This is done by first doing a
spatial sort of all the atoms into bins and sorting them within each
bin. Because the set of bins is independent of the number of
processors, this enables a consistent assignment of new IDs to each
atom.
This can be useful to do after using the "create_atoms" command and/or
"replicate" command. In general those commands do not guarantee
assignment of the same atom ID to the same physical atom when LAMMPS
is run on different numbers of processors. Enforcing consistent IDs
can be useful for debugging or comparing output from two different
runs.
Note that the spatial sort requires communication of atom IDs and
coordinates between processors in an all-to-all manner. This is done
efficiently in LAMMPS, but it is more expensive than how atom IDs are
reset without sorting.
Note that whether sorting or not, the resetting of IDs is not a
compression, where gaps in atom IDs are removed by decrementing atom
IDs that are larger. Instead the IDs for all atoms are erased, and
new IDs are assigned so that the atoms owned by an individual
processor have consecutive IDs, as the :doc:`create_atoms
<create_atoms>` command explains.
.. note::
If this command is used before a :doc:`pair style <pair_style>` is
defined, an error about bond topology atom IDs not being found may
result. This is because the cutoff distance for ghost atom
communication was not sufficient to find atoms in bonds, angles, etc
that are owned by other processors. The :doc:`comm_modify cutoff <comm_modify>` command can be used to correct this issue.
Or you can define a pair style before using this command. If you do
the former, you should unset the comm_modify cutoff after using
reset_atom_ids so that subsequent communication is not inefficient.
Restrictions
""""""""""""
none
Related commands
""""""""""""""""
:doc:`delete_atoms <delete_atoms>`
Default
"""""""
By default, *sort* is no.

283
doc/src/reset_atoms.rst Normal file
View File

@ -0,0 +1,283 @@
.. index:: reset_atoms
reset_atoms command
===================
Syntax
""""""
.. code-block:: LAMMPS
reset_atoms property arguments ...
* property = *id* or *image* or *mol*
* additional arguments depend on the property
.. code-block:: LAMMPS
reset_atoms id keyword value ...
* zero or more keyword/value pairs can be appended
* keyword = *sort*
.. parsed-literal::
*sort* value = *yes* or *no*
.. code-block:: LAMMPS
reset_atoms image group-ID
* group-ID = ID of group of atoms whose image flags will be reset
.. code-block:: LAMMPS
reset atoms mol group-ID keyword value ...
* group-ID = ID of group of atoms whose molecule IDs will be reset
* zero or more keyword/value pairs can be appended
* keyword = *compress* or *offset* or *single*
.. parsed-literal::
*compress* value = *yes* or *no*
*offset* value = *Noffset* >= -1
*single* value = *yes* or *no* to treat single atoms (no bonds) as molecules
Examples
""""""""
.. code-block:: LAMMPS
reset_atoms id
reset_atoms id sort yes
reset_atoms image all
reset_atoms image mobile
reset_atoms mol all
reset_atoms mol all offset 10 single yes
reset_atoms mol solvent compress yes offset 100
reset_atoms mol solvent compress no
Description
"""""""""""
.. versionadded:: TBD
The *reset_atoms* command resets the values of a specified atom
property. In contrast to the set command, it does this in a
collective manner which resets the values for many atoms in a
self-consistent way. This is often useful when the simulated system
has undergone significant modifications like adding or removing atoms
or molecules, joining data files, changing bonds, or large-scale
diffusion.
The new values can be thought of as a *reset*, similar to values atoms
would have if a new data file were being read or a new simulation
performed. Note that the set command also resets atom properties to
new values, but it treats each atom independently.
The *property* setting can be *id* or *image* or *mol*. For *id*, the
IDs of all the atoms are reset to contiguous values. For *image*, the
image flags of atoms in the specified *group-ID* are reset so that at
least one atom in each molecule is in the simulation box (image flag =
0). For *mol*, the molecule IDs of all atoms are reset to contiguous
values.
More details on these operations and their arguments or optional
keyword/value settings are given below.
----------
*Property id*
Reset atom IDs for the entire system, including all the global IDs
stored for bond, angle, dihedral, improper topology data. This will
create a set of IDs that are numbered contiguously from 1 to N for a N
atoms system.
This can be useful to do after performing a "delete_atoms" command for
a molecular system. The delete_atoms compress yes option will not
perform this operation due to the existence of bond topology. It can
also be useful to do after any simulation which has lost atoms,
e.g. due to atoms moving outside a simulation box with fixed
boundaries (see the "boundary command"), or due to evaporation (see
the "fix evaporate" command).
If the *sort* keyword is used with a setting of *yes*, then the
assignment of new atom IDs will be the same no matter how many
processors LAMMPS is running on. This is done by first doing a
spatial sort of all the atoms into bins and sorting them within each
bin. Because the set of bins is independent of the number of
processors, this enables a consistent assignment of new IDs to each
atom.
This can be useful to do after using the "create_atoms" command and/or
"replicate" command. In general those commands do not guarantee
assignment of the same atom ID to the same physical atom when LAMMPS
is run on different numbers of processors. Enforcing consistent IDs
can be useful for debugging or comparing output from two different
runs.
Note that the spatial sort requires communication of atom IDs and
coordinates between processors in an all-to-all manner. This is done
efficiently in LAMMPS, but it is more expensive than how atom IDs are
reset without sorting.
Note that whether sorting or not, the resetting of IDs is not a
compression, where gaps in atom IDs are removed by decrementing atom
IDs that are larger. Instead the IDs for all atoms are erased, and
new IDs are assigned so that the atoms owned by an individual
processor have consecutive IDs, as the :doc:`create_atoms
<create_atoms>` command explains.
.. note::
If this command is used before a :doc:`pair style <pair_style>` is
defined, an error about bond topology atom IDs not being found may
result. This is because the cutoff distance for ghost atom
communication was not sufficient to find atoms in bonds, angles, etc
that are owned by other processors. The :doc:`comm_modify cutoff
<comm_modify>` command can be used to correct this issue. Or you can
define a pair style before using this command. If you do the former,
you should unset the *comm_modify cutoff* after using *reset
atoms id* so that subsequent communication is not inefficient.
----------
*Property image*
Reset the image flags of atoms so that at least one atom in each
molecule has an image flag of 0. Molecular topology is respected so
that if the molecule straddles a periodic simulation box boundary, the
images flags of all atoms in the molecule will be consistent. This
avoids inconsistent image flags that could result from resetting all
image flags to zero with the :doc:`set <set>` command.
.. note::
If the system has no bonds, there is no reason to use this command,
since image flags for different atoms do not need to be
consistent. Use the :doc:`set <set>` command with its *image*
keyword instead.
Only image flags for atoms in the specified *group-ID* are reset; all
others remain unchanged. No check is made for whether the group
covers complete molecule fragments and thus whether the command will
result in inconsistent image flags.
Molecular fragments are identified by the algorithm used by the
:doc:`compute fragment/atom <compute_cluster_atom>` command. For each
fragment the average of the largest and the smallest image flag in
each direction across all atoms in the fragment is computed and
subtracted from the current image flag in the same direction.
This can be a useful operation to perform after running longer
equilibration runs of mobile systems where molecules would pass
through the system multiple times and thus produce non-zero image
flags.
.. note::
Same as explained for the :doc:`compute fragment/atom
<compute_cluster_atom>` command, molecules are identified using the
current bond topology. This will **not** account for bonds broken by
the :doc:`bond_style quartic <bond_quartic>` command, because this
bond style does not perform a full update of the bond topology data
structures within LAMMPS. In that case, using the :doc:`delete_bonds
all bond 0 remove <delete_bonds>` will permanently delete such
broken bonds and should thus be used first.
----------
*Property mol*
Reset molecule IDs for a specified group of atoms based on current
bond connectivity. This will typically create a new set of molecule
IDs for atoms in the group. Only molecule IDs for atoms in the
specified *group-ID* are reset; molecule IDs for atoms not in the
group are not changed.
For purposes of this operation, molecules are identified by the current
bond connectivity in the system, which may or may not be consistent with
the current molecule IDs. A molecule in this context is a set of atoms
connected to each other with explicit bonds. The specific algorithm
used is the one of :doc:`compute fragment/atom <compute_cluster_atom>`
Once the molecules are identified and a new molecule ID computed for
each, this command will update the current molecule ID for all atoms in
the group with the new molecule ID. Note that if the group excludes
atoms within molecules, one (physical) molecule may become two or more
(logical) molecules. For example if the group excludes atoms in the
middle of a linear chain, then each end of the chain is considered an
independent molecule and will be assigned a different molecule ID.
This can be a useful operation to perform after running reactive
molecular dynamics run with :doc:`fix bond/react <fix_bond_react>`,
:doc:`fix bond/create <fix_bond_create>`, or :doc:`fix bond/break
<fix_bond_break>`, all of which can change molecule topologies. It can
also be useful after molecules have been deleted with the
:doc:`delete_atoms <delete_atoms>` command or after a simulation which
has lost molecules, e.g. via the :doc:`fix evaporate <fix_evaporate>`
command.
The *compress* keyword determines how new molecule IDs are computed. If
the setting is *yes* (the default) and there are N molecules in the
group, the new molecule IDs will be a set of N contiguous values. See
the *offset* keyword for details on selecting the range of these values.
If the setting is *no*, the molecule ID of every atom in the molecule
will be set to the smallest atom ID of any atom in the molecule.
The *single* keyword determines whether single atoms (not bonded to
another atom) are treated as one-atom molecules or not, based on the
*yes* or *no* setting. If the setting is *no* (the default), their
molecule IDs are set to 0. This setting can be important if the new
molecule IDs will be used as input to other commands such as
:doc:`compute chunk/atom molecule <compute_chunk_atom>` or :doc:`fix
rigid molecule <fix_rigid>`.
The *offset* keyword is only used if the *compress* setting is *yes*.
Its default value is *Noffset* = -1. In that case, if the specified
group is *all*, then the new compressed molecule IDs will range from 1
to N. If the specified group is not *all* and the largest molecule ID
of atoms outside that group is M, then the new compressed molecule IDs will
range from M+1 to M+N, to avoid collision with existing molecule
IDs. If an *Noffset* >= 0 is specified, then the new compressed
molecule IDs will range from *Noffset*\ +1 to *Noffset*\ +N. If the group
is not *all* there may be collisions with the molecule IDs of other atoms.
.. note::
Same as explained for the :doc:`compute fragment/atom
<compute_cluster_atom>` command, molecules are identified using the
current bond topology. This will **not** account for bonds broken by
the :doc:`bond_style quartic <bond_quartic>` command, because this
bond style does not perform a full update of the bond topology data
structures within LAMMPS. In that case, using the :doc:`delete_bonds
all bond 0 remove <delete_bonds>` will permanently delete such broken
bonds and should thus be used first.
Restrictions
""""""""""""
The *image* property can only be used when the atom style supports bonds.
Related commands
""""""""""""""""
:doc:`compute fragment/atom <compute_cluster_atom>`
:doc:`fix bond/react <fix_bond_react>`,
:doc:`fix bond/create <fix_bond_create>`,
:doc:`fix bond/break <fix_bond_break>`,
:doc:`fix evaporate <fix_evaporate>`,
:doc:`delete_atoms <delete_atoms>`,
:doc:`delete_bonds <delete_bonds>`
Defaults
""""""""
For property *id*, the default keyword setting is sort = no.
For property *mol*, the default keyword settings are compress = yes,
single = no, and offset = -1.

View File

@ -1,116 +0,0 @@
.. index:: reset_mol_ids
reset_mol_ids command
=====================
Syntax
""""""
.. parsed-literal::
reset_mol_ids group-ID keyword value ...
* group-ID = ID of group of atoms whose molecule IDs will be reset
* zero or more keyword/value pairs may be appended
* keyword = *compress* or *offset* or *single*
.. parsed-literal::
*compress* value = *yes* or *no*
*offset* value = *Noffset* >= -1
*single* value = *yes* or *no* to treat single atoms (no bonds) as molecules
Examples
""""""""
.. code-block:: LAMMPS
reset_mol_ids all
reset_mol_ids all offset 10 single yes
reset_mol_ids solvent compress yes offset 100
reset_mol_ids solvent compress no
Description
"""""""""""
Reset molecule IDs for a group of atoms based on current bond
connectivity. This will typically create a new set of molecule IDs
for atoms in the group. Only molecule IDs for atoms in the specified
group are reset; molecule IDs for atoms not in the group are not
changed.
For purposes of this operation, molecules are identified by the current
bond connectivity in the system, which may or may not be consistent with
the current molecule IDs. A molecule in this context is a set of atoms
connected to each other with explicit bonds. The specific algorithm
used is the one of :doc:`compute fragment/atom <compute_cluster_atom>`
Once the molecules are identified and a new molecule ID computed for
each, this command will update the current molecule ID for all atoms in
the group with the new molecule ID. Note that if the group excludes
atoms within molecules, one (physical) molecule may become two or more
(logical) molecules. For example if the group excludes atoms in the
middle of a linear chain, then each end of the chain is considered an
independent molecule and will be assigned a different molecule ID.
This can be a useful operation to perform after running reactive
molecular dynamics run with :doc:`fix bond/react <fix_bond_react>`,
:doc:`fix bond/create <fix_bond_create>`, or :doc:`fix bond/break
<fix_bond_break>`, all of which can change molecule topologies. It can
also be useful after molecules have been deleted with the
:doc:`delete_atoms <delete_atoms>` command or after a simulation which
has lost molecules, e.g. via the :doc:`fix evaporate <fix_evaporate>`
command.
The *compress* keyword determines how new molecule IDs are computed. If
the setting is *yes* (the default) and there are N molecules in the
group, the new molecule IDs will be a set of N contiguous values. See
the *offset* keyword for details on selecting the range of these values.
If the setting is *no*, the molecule ID of every atom in the molecule
will be set to the smallest atom ID of any atom in the molecule.
The *single* keyword determines whether single atoms (not bonded to
another atom) are treated as one-atom molecules or not, based on the
*yes* or *no* setting. If the setting is *no* (the default), their
molecule IDs are set to 0. This setting can be important if the new
molecule IDs will be used as input to other commands such as
:doc:`compute chunk/atom molecule <compute_chunk_atom>` or :doc:`fix
rigid molecule <fix_rigid>`.
The *offset* keyword is only used if the *compress* setting is *yes*.
Its default value is *Noffset* = -1. In that case, if the specified
group is *all*, then the new compressed molecule IDs will range from 1
to N. If the specified group is not *all* and the largest molecule ID
of atoms outside that group is M, then the new compressed molecule IDs will
range from M+1 to M+N, to avoid collision with existing molecule
IDs. If an *Noffset* >= 0 is specified, then the new compressed
molecule IDs will range from *Noffset*\ +1 to *Noffset*\ +N. If the group
is not *all* there may be collisions with the molecule IDs of other atoms.
.. note::
The same as explained for the :doc:`compute fragment/atom
<compute_cluster_atom>` command, molecules are identified using the
current bond topology. This will not account for bonds broken by
the :doc:`bond_style quartic <bond_quartic>` command because it
does not perform a full update of the bond topology data structures
within LAMMPS.
Restrictions
""""""""""""
none
Related commands
""""""""""""""""
:doc:`reset_atom_ids <reset_atom_ids>`, :doc:`fix bond/react <fix_bond_react>`,
:doc:`fix bond/create <fix_bond_create>`,
:doc:`fix bond/break <fix_bond_break>`,
:doc:`fix evaporate <fix_evaporate>`,
:doc:`delete_atoms <delete_atoms>`,
:doc:`compute fragment/atom <compute_cluster_atom>`
Default
"""""""
The default keyword settings are compress = yes, single = no, and
offset = -1.

View File

@ -20,6 +20,7 @@
#include "modify.h" #include "modify.h"
#include "neigh_list_kokkos.h" #include "neigh_list_kokkos.h"
#include "pair_kokkos.h" #include "pair_kokkos.h"
#include "atom_masks.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -170,6 +171,7 @@ template <class DeviceType>
void FixNeighHistoryKokkos<DeviceType>::post_neighbor() void FixNeighHistoryKokkos<DeviceType>::post_neighbor()
{ {
tag = atomKK->k_tag.view<DeviceType>(); tag = atomKK->k_tag.view<DeviceType>();
atomKK->sync(execution_space,TAG_MASK);
k_firstflag.sync<DeviceType>(); k_firstflag.sync<DeviceType>();
k_firstvalue.sync<DeviceType>(); k_firstvalue.sync<DeviceType>();

View File

@ -111,7 +111,6 @@ void PairADPKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
x = atomKK->k_x.view<DeviceType>(); x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -120,7 +120,6 @@ class PairADPKokkos : public PairADP, public KokkosBase
typename AT::t_x_array x; typename AT::t_x_array x;
typename AT::t_f_array f; typename AT::t_f_array f;
typename AT::t_int_1d type; typename AT::t_int_1d type;
typename AT::t_tagint_1d tag;
DAT::tdual_efloat_1d k_eatom; DAT::tdual_efloat_1d k_eatom;
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;

View File

@ -98,7 +98,6 @@ void PairBuckKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
c_x = atomKK->k_x.view<DeviceType>(); c_x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -74,7 +74,6 @@ class PairBuckKokkos : public PairBuck {
typename AT::t_x_array c_x; typename AT::t_x_array c_x;
typename AT::t_f_array f; typename AT::t_f_array f;
typename AT::t_int_1d_randomread type; typename AT::t_int_1d_randomread type;
typename AT::t_tagint_1d tag;
DAT::tdual_efloat_1d k_eatom; DAT::tdual_efloat_1d k_eatom;
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;

View File

@ -110,7 +110,6 @@ void PairEAMAlloyKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
x = atomKK->k_x.view<DeviceType>(); x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -119,7 +119,6 @@ class PairEAMAlloyKokkos : public PairEAM, public KokkosBase {
typename AT::t_x_array x; typename AT::t_x_array x;
typename AT::t_f_array f; typename AT::t_f_array f;
typename AT::t_int_1d type; typename AT::t_int_1d type;
typename AT::t_tagint_1d tag;
DAT::tdual_efloat_1d k_eatom; DAT::tdual_efloat_1d k_eatom;
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;

View File

@ -110,7 +110,6 @@ void PairEAMFSKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
x = atomKK->k_x.view<DeviceType>(); x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -119,7 +119,6 @@ class PairEAMFSKokkos : public PairEAM, public KokkosBase {
typename AT::t_x_array x; typename AT::t_x_array x;
typename AT::t_f_array f; typename AT::t_f_array f;
typename AT::t_int_1d type; typename AT::t_int_1d type;
typename AT::t_tagint_1d tag;
DAT::tdual_efloat_1d k_eatom; DAT::tdual_efloat_1d k_eatom;
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;

View File

@ -105,7 +105,6 @@ void PairEAMKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
x = atomKK->k_x.view<DeviceType>(); x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -115,7 +115,6 @@ class PairEAMKokkos : public PairEAM, public KokkosBase {
typename AT::t_x_array x; typename AT::t_x_array x;
typename AT::t_f_array f; typename AT::t_f_array f;
typename AT::t_int_1d type; typename AT::t_int_1d type;
typename AT::t_tagint_1d tag;
DAT::tdual_efloat_1d k_eatom; DAT::tdual_efloat_1d k_eatom;
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;

View File

@ -134,7 +134,6 @@ void PairGranHookeHistoryKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
torque = atomKK->k_torque.view<DeviceType>(); torque = atomKK->k_torque.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
mask = atomKK->k_mask.view<DeviceType>(); mask = atomKK->k_mask.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
rmass = atomKK->k_rmass.view<DeviceType>(); rmass = atomKK->k_rmass.view<DeviceType>();
radius = atomKK->k_radius.view<DeviceType>(); radius = atomKK->k_radius.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;

View File

@ -86,7 +86,6 @@ class PairGranHookeHistoryKokkos : public PairGranHookeHistory {
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;
typename AT::t_efloat_1d d_eatom; typename AT::t_efloat_1d d_eatom;
typename AT::t_virial_array d_vatom; typename AT::t_virial_array d_vatom;
typename AT::t_tagint_1d tag;
typename AT::t_neighbors_2d d_neighbors; typename AT::t_neighbors_2d d_neighbors;
typename AT::t_int_1d_randomread d_ilist; typename AT::t_int_1d_randomread d_ilist;

View File

@ -99,7 +99,6 @@ void PairLJClass2Kokkos<DeviceType>::compute(int eflag_in, int vflag_in)
c_x = atomKK->k_x.view<DeviceType>(); c_x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -80,7 +80,6 @@ class PairLJClass2Kokkos : public PairLJClass2 {
typename AT::t_x_array c_x; typename AT::t_x_array c_x;
typename AT::t_f_array f; typename AT::t_f_array f;
typename AT::t_int_1d_randomread type; typename AT::t_int_1d_randomread type;
typename AT::t_tagint_1d tag;
DAT::tdual_efloat_1d k_eatom; DAT::tdual_efloat_1d k_eatom;
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;

View File

@ -94,7 +94,6 @@ void PairLJCutKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
c_x = atomKK->k_x.view<DeviceType>(); c_x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -80,7 +80,6 @@ class PairLJCutKokkos : public PairLJCut {
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;
typename AT::t_efloat_1d d_eatom; typename AT::t_efloat_1d d_eatom;
typename AT::t_virial_array d_vatom; typename AT::t_virial_array d_vatom;
typename AT::t_tagint_1d tag;
int newton_pair; int newton_pair;
double special_lj[4]; double special_lj[4];

View File

@ -98,7 +98,6 @@ void PairLJExpandKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
c_x = atomKK->k_x.view<DeviceType>(); c_x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -80,7 +80,6 @@ class PairLJExpandKokkos : public PairLJExpand {
typename AT::t_x_array c_x; typename AT::t_x_array c_x;
typename AT::t_f_array f; typename AT::t_f_array f;
typename AT::t_int_1d_randomread type; typename AT::t_int_1d_randomread type;
typename AT::t_tagint_1d tag;
DAT::tdual_efloat_1d k_eatom; DAT::tdual_efloat_1d k_eatom;
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;

View File

@ -98,7 +98,6 @@ void PairLJSPICAKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
c_x = atomKK->k_x.view<DeviceType>(); c_x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -80,7 +80,6 @@ class PairLJSPICAKokkos : public PairLJSPICA {
typename AT::t_x_array c_x; typename AT::t_x_array c_x;
typename AT::t_f_array f; typename AT::t_f_array f;
typename AT::t_int_1d_randomread type; typename AT::t_int_1d_randomread type;
typename AT::t_tagint_1d tag;
DAT::tdual_efloat_1d k_eatom; DAT::tdual_efloat_1d k_eatom;
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;

View File

@ -101,7 +101,6 @@ void PairMorseKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
c_x = atomKK->k_x.view<DeviceType>(); c_x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -80,7 +80,6 @@ class PairMorseKokkos : public PairMorse {
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;
typename ArrayTypes<DeviceType>::t_efloat_1d d_eatom; typename ArrayTypes<DeviceType>::t_efloat_1d d_eatom;
typename ArrayTypes<DeviceType>::t_virial_array d_vatom; typename ArrayTypes<DeviceType>::t_virial_array d_vatom;
typename ArrayTypes<DeviceType>::t_tagint_1d tag;
int newton_pair; int newton_pair;
double special_lj[4]; double special_lj[4];

View File

@ -63,7 +63,7 @@ PairReaxFFKokkos<DeviceType>::PairReaxFFKokkos(LAMMPS *lmp) : PairReaxFF(lmp)
kokkosable = 1; kokkosable = 1;
atomKK = (AtomKokkos *) atom; atomKK = (AtomKokkos *) atom;
execution_space = ExecutionSpaceFromDevice<DeviceType>::space; execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
datamask_read = X_MASK | Q_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; datamask_read = X_MASK | Q_MASK | F_MASK | TAG_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK;
datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK; datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK;
k_resize_bo = DAT::tdual_int_scalar("pair:resize_bo"); k_resize_bo = DAT::tdual_int_scalar("pair:resize_bo");

View File

@ -70,7 +70,7 @@ PairTersoffKokkos<DeviceType>::PairTersoffKokkos(LAMMPS *lmp) : PairTersoff(lmp)
kokkosable = 1; kokkosable = 1;
atomKK = (AtomKokkos *) atom; atomKK = (AtomKokkos *) atom;
execution_space = ExecutionSpaceFromDevice<DeviceType>::space; execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; datamask_read = X_MASK | F_MASK | TAG_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK;
datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK; datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK;
} }

View File

@ -60,7 +60,7 @@ PairTersoffMODKokkos<DeviceType>::PairTersoffMODKokkos(LAMMPS *lmp) : PairTersof
kokkosable = 1; kokkosable = 1;
atomKK = (AtomKokkos *) atom; atomKK = (AtomKokkos *) atom;
execution_space = ExecutionSpaceFromDevice<DeviceType>::space; execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; datamask_read = X_MASK | F_MASK | TAG_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK;
datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK; datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK;
} }

View File

@ -62,7 +62,7 @@ PairTersoffZBLKokkos<DeviceType>::PairTersoffZBLKokkos(LAMMPS *lmp) : PairTersof
kokkosable = 1; kokkosable = 1;
atomKK = (AtomKokkos *) atom; atomKK = (AtomKokkos *) atom;
execution_space = ExecutionSpaceFromDevice<DeviceType>::space; execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
datamask_read = X_MASK | F_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK; datamask_read = X_MASK | F_MASK | TAG_MASK | TYPE_MASK | ENERGY_MASK | VIRIAL_MASK;
datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK; datamask_modify = F_MASK | ENERGY_MASK | VIRIAL_MASK;
if (strcmp(update->unit_style,"metal") == 0) { if (strcmp(update->unit_style,"metal") == 0) {

View File

@ -173,7 +173,6 @@ void PairYukawaKokkos<DeviceType>::compute(int eflag_in, int vflag_in)
c_x = atomKK->k_x.view<DeviceType>(); c_x = atomKK->k_x.view<DeviceType>();
f = atomKK->k_f.view<DeviceType>(); f = atomKK->k_f.view<DeviceType>();
type = atomKK->k_type.view<DeviceType>(); type = atomKK->k_type.view<DeviceType>();
tag = atomKK->k_tag.view<DeviceType>();
nlocal = atom->nlocal; nlocal = atom->nlocal;
nall = atom->nlocal + atom->nghost; nall = atom->nlocal + atom->nghost;
newton_pair = force->newton_pair; newton_pair = force->newton_pair;

View File

@ -83,7 +83,6 @@ class PairYukawaKokkos : public PairYukawa {
DAT::tdual_virial_array k_vatom; DAT::tdual_virial_array k_vatom;
typename AT::t_efloat_1d d_eatom; typename AT::t_efloat_1d d_eatom;
typename AT::t_virial_array d_vatom; typename AT::t_virial_array d_vatom;
typename AT::t_tagint_1d tag;
int newton_pair; int newton_pair;
double special_lj[4]; double special_lj[4];

View File

@ -39,7 +39,7 @@ Contributing Author: Jacob Gissinger (jacob.r.gissinger@gmail.com)
#include "neighbor.h" #include "neighbor.h"
#include "pair.h" #include "pair.h"
#include "random_mars.h" #include "random_mars.h"
#include "reset_mol_ids.h" #include "reset_atoms_mol.h"
#include "respa.h" #include "respa.h"
#include "update.h" #include "update.h"
#include "variable.h" #include "variable.h"
@ -207,7 +207,7 @@ FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) :
if (reset_mol_ids_flag) { if (reset_mol_ids_flag) {
delete reset_mol_ids; delete reset_mol_ids;
reset_mol_ids = new ResetMolIDs(lmp); reset_mol_ids = new ResetAtomsMol(lmp);
reset_mol_ids->create_computes(id,group->names[igroup]); reset_mol_ids->create_computes(id,group->names[igroup]);
} }

View File

@ -110,7 +110,7 @@ class FixBondReact : public Fix {
class RanMars **random; // random number for 'prob' keyword class RanMars **random; // random number for 'prob' keyword
class RanMars **rrhandom; // random number for Arrhenius constraint class RanMars **rrhandom; // random number for Arrhenius constraint
class NeighList *list; class NeighList *list;
class ResetMolIDs *reset_mol_ids; // class for resetting mol IDs class ResetAtomsMol *reset_mol_ids; // class for resetting mol IDs
int *reacted_mol, *unreacted_mol; int *reacted_mol, *unreacted_mol;
int *limit_duration; // indicates how long to relax int *limit_duration; // indicates how long to relax

View File

@ -36,16 +36,25 @@ void Deprecated::command(int narg, char **arg)
if (lmp->comm->me == 0) if (lmp->comm->me == 0)
utils::logmesg(lmp, "\nThe 'box' command has been removed and will be ignored\n\n"); utils::logmesg(lmp, "\nThe 'box' command has been removed and will be ignored\n\n");
return; return;
} else if (cmd == "reset_ids") {
if (lmp->comm->me == 0)
utils::logmesg(lmp, "\n'reset_ids' has been renamed to 'reset_atom_ids'\n\n");
} else if (utils::strmatch(cmd, "^kim_")) { } else if (utils::strmatch(cmd, "^kim_")) {
if (lmp->comm->me == 0)
utils::logmesg(lmp,
"\nWARNING: 'kim_<command>' has been renamed to 'kim <command>'. "
"Please update your input.\n\n");
std::string newcmd("kim"); std::string newcmd("kim");
newcmd += " " + cmd.substr(4); newcmd += " " + cmd.substr(4);
if (lmp->comm->me == 0)
utils::logmesg(lmp, "\nWARNING: '{}' has been renamed to '{}'. Please update your input.\n\n",
cmd, newcmd);
for (int i = 0; i < narg; ++i) {
newcmd.append(1, ' ');
newcmd.append(arg[i]);
}
input->one(newcmd);
return;
} else if (utils::strmatch(cmd, "^reset_")) {
std::string newcmd("reset_atoms");
if ((cmd == "reset_ids") || (cmd == "reset_atom_ids")) newcmd += " id";
if (cmd == "reset_mol_ids") newcmd += " mol";
if (lmp->comm->me == 0)
utils::logmesg(lmp, "\nWARNING: '{}' has been renamed to '{}'. Please update your input.\n\n",
cmd, newcmd);
for (int i = 0; i < narg; ++i) { for (int i = 0; i < narg; ++i) {
newcmd.append(1, ' '); newcmd.append(1, ' ');
newcmd.append(arg[i]); newcmd.append(arg[i]);

View File

@ -15,12 +15,14 @@
// clang-format off // clang-format off
CommandStyle(DEPRECATED,Deprecated); CommandStyle(DEPRECATED,Deprecated);
CommandStyle(box,Deprecated); CommandStyle(box,Deprecated);
CommandStyle(reset_ids,Deprecated);
CommandStyle(kim_init,Deprecated); CommandStyle(kim_init,Deprecated);
CommandStyle(kim_interactions,Deprecated); CommandStyle(kim_interactions,Deprecated);
CommandStyle(kim_param,Deprecated); CommandStyle(kim_param,Deprecated);
CommandStyle(kim_property,Deprecated); CommandStyle(kim_property,Deprecated);
CommandStyle(kim_query,Deprecated); CommandStyle(kim_query,Deprecated);
CommandStyle(reset_ids,Deprecated);
CommandStyle(reset_atom_ids,Deprecated);
CommandStyle(reset_mol_ids,Deprecated);
CommandStyle(message,Deprecated); CommandStyle(message,Deprecated);
CommandStyle(server,Deprecated); CommandStyle(server,Deprecated);
// clang-format on // clang-format on

View File

@ -749,76 +749,77 @@ int Input::execute_command()
{ {
int flag = 1; int flag = 1;
if (!strcmp(command,"clear")) clear(); std::string mycmd = command;
else if (!strcmp(command,"echo")) echo(); if (mycmd == "clear") clear();
else if (!strcmp(command,"if")) ifthenelse(); else if (mycmd == "echo") echo();
else if (!strcmp(command,"include")) include(); else if (mycmd == "if") ifthenelse();
else if (!strcmp(command,"jump")) jump(); else if (mycmd == "include") include();
else if (!strcmp(command,"label")) label(); else if (mycmd == "jump") jump();
else if (!strcmp(command,"log")) log(); else if (mycmd == "label") label();
else if (!strcmp(command,"next")) next_command(); else if (mycmd == "log") log();
else if (!strcmp(command,"partition")) partition(); else if (mycmd == "next") next_command();
else if (!strcmp(command,"print")) print(); else if (mycmd == "partition") partition();
else if (!strcmp(command,"python")) python(); else if (mycmd == "print") print();
else if (!strcmp(command,"quit")) quit(); else if (mycmd == "python") python();
else if (!strcmp(command,"shell")) shell(); else if (mycmd == "quit") quit();
else if (!strcmp(command,"variable")) variable_command(); else if (mycmd == "shell") shell();
else if (mycmd == "variable") variable_command();
else if (!strcmp(command,"angle_coeff")) angle_coeff(); else if (mycmd == "angle_coeff") angle_coeff();
else if (!strcmp(command,"angle_style")) angle_style(); else if (mycmd == "angle_style") angle_style();
else if (!strcmp(command,"atom_modify")) atom_modify(); else if (mycmd == "atom_modify") atom_modify();
else if (!strcmp(command,"atom_style")) atom_style(); else if (mycmd == "atom_style") atom_style();
else if (!strcmp(command,"bond_coeff")) bond_coeff(); else if (mycmd == "bond_coeff") bond_coeff();
else if (!strcmp(command,"bond_style")) bond_style(); else if (mycmd == "bond_style") bond_style();
else if (!strcmp(command,"bond_write")) bond_write(); else if (mycmd == "bond_write") bond_write();
else if (!strcmp(command,"boundary")) boundary(); else if (mycmd == "boundary") boundary();
else if (!strcmp(command,"comm_modify")) comm_modify(); else if (mycmd == "comm_modify") comm_modify();
else if (!strcmp(command,"comm_style")) comm_style(); else if (mycmd == "comm_style") comm_style();
else if (!strcmp(command,"compute")) compute(); else if (mycmd == "compute") compute();
else if (!strcmp(command,"compute_modify")) compute_modify(); else if (mycmd == "compute_modify") compute_modify();
else if (!strcmp(command,"dielectric")) dielectric(); else if (mycmd == "dielectric") dielectric();
else if (!strcmp(command,"dihedral_coeff")) dihedral_coeff(); else if (mycmd == "dihedral_coeff") dihedral_coeff();
else if (!strcmp(command,"dihedral_style")) dihedral_style(); else if (mycmd == "dihedral_style") dihedral_style();
else if (!strcmp(command,"dimension")) dimension(); else if (mycmd == "dimension") dimension();
else if (!strcmp(command,"dump")) dump(); else if (mycmd == "dump") dump();
else if (!strcmp(command,"dump_modify")) dump_modify(); else if (mycmd == "dump_modify") dump_modify();
else if (!strcmp(command,"fix")) fix(); else if (mycmd == "fix") fix();
else if (!strcmp(command,"fix_modify")) fix_modify(); else if (mycmd == "fix_modify") fix_modify();
else if (!strcmp(command,"group")) group_command(); else if (mycmd == "group") group_command();
else if (!strcmp(command,"improper_coeff")) improper_coeff(); else if (mycmd == "improper_coeff") improper_coeff();
else if (!strcmp(command,"improper_style")) improper_style(); else if (mycmd == "improper_style") improper_style();
else if (!strcmp(command,"kspace_modify")) kspace_modify(); else if (mycmd == "kspace_modify") kspace_modify();
else if (!strcmp(command,"kspace_style")) kspace_style(); else if (mycmd == "kspace_style") kspace_style();
else if (!strcmp(command,"labelmap")) labelmap(); else if (mycmd == "labelmap") labelmap();
else if (!strcmp(command,"lattice")) lattice(); else if (mycmd == "lattice") lattice();
else if (!strcmp(command,"mass")) mass(); else if (mycmd == "mass") mass();
else if (!strcmp(command,"min_modify")) min_modify(); else if (mycmd == "min_modify") min_modify();
else if (!strcmp(command,"min_style")) min_style(); else if (mycmd == "min_style") min_style();
else if (!strcmp(command,"molecule")) molecule(); else if (mycmd == "molecule") molecule();
else if (!strcmp(command,"neigh_modify")) neigh_modify(); else if (mycmd == "neigh_modify") neigh_modify();
else if (!strcmp(command,"neighbor")) neighbor_command(); else if (mycmd == "neighbor") neighbor_command();
else if (!strcmp(command,"newton")) newton(); else if (mycmd == "newton") newton();
else if (!strcmp(command,"package")) package(); else if (mycmd == "package") package();
else if (!strcmp(command,"pair_coeff")) pair_coeff(); else if (mycmd == "pair_coeff") pair_coeff();
else if (!strcmp(command,"pair_modify")) pair_modify(); else if (mycmd == "pair_modify") pair_modify();
else if (!strcmp(command,"pair_style")) pair_style(); else if (mycmd == "pair_style") pair_style();
else if (!strcmp(command,"pair_write")) pair_write(); else if (mycmd == "pair_write") pair_write();
else if (!strcmp(command,"processors")) processors(); else if (mycmd == "processors") processors();
else if (!strcmp(command,"region")) region(); else if (mycmd == "region") region();
else if (!strcmp(command,"reset_timestep")) reset_timestep(); else if (mycmd == "reset_timestep") reset_timestep();
else if (!strcmp(command,"restart")) restart(); else if (mycmd == "restart") restart();
else if (!strcmp(command,"run_style")) run_style(); else if (mycmd == "run_style") run_style();
else if (!strcmp(command,"special_bonds")) special_bonds(); else if (mycmd == "special_bonds") special_bonds();
else if (!strcmp(command,"suffix")) suffix(); else if (mycmd == "suffix") suffix();
else if (!strcmp(command,"thermo")) thermo(); else if (mycmd == "thermo") thermo();
else if (!strcmp(command,"thermo_modify")) thermo_modify(); else if (mycmd == "thermo_modify") thermo_modify();
else if (!strcmp(command,"thermo_style")) thermo_style(); else if (mycmd == "thermo_style") thermo_style();
else if (!strcmp(command,"timestep")) timestep(); else if (mycmd == "timestep") timestep();
else if (!strcmp(command,"timer")) timer_command(); else if (mycmd == "timer") timer_command();
else if (!strcmp(command,"uncompute")) uncompute(); else if (mycmd == "uncompute") uncompute();
else if (!strcmp(command,"undump")) undump(); else if (mycmd == "undump") undump();
else if (!strcmp(command,"unfix")) unfix(); else if (mycmd == "unfix") unfix();
else if (!strcmp(command,"units")) units(); else if (mycmd == "units") units();
else flag = 0; else flag = 0;
@ -826,10 +827,15 @@ int Input::execute_command()
if (flag) return 0; if (flag) return 0;
// process "meta-commands", i.e. commands that may have sub-commands
// they return 1 if there was a match and 0 if not
if (mycmd == "reset_atoms") flag = meta(mycmd);
if (flag) return 0;
// invoke commands added via style_command.h // invoke commands added via style_command.h
// try suffixed version first // try suffixed version first
std::string mycmd = command;
if (lmp->suffix_enable && lmp->non_pair_suffix()) { if (lmp->suffix_enable && lmp->non_pair_suffix()) {
mycmd = command + std::string("/") + lmp->non_pair_suffix(); mycmd = command + std::string("/") + lmp->non_pair_suffix();
if (command_map->find(mycmd) == command_map->end()) { if (command_map->find(mycmd) == command_map->end()) {
@ -1978,3 +1984,21 @@ void Input::units()
error->all(FLERR,"Units command after simulation box is defined"); error->all(FLERR,"Units command after simulation box is defined");
update->set_units(arg[0]); update->set_units(arg[0]);
} }
/* ---------------------------------------------------------------------- */
/* ----------------------------------------------------------------------
function for meta commands
------------------------------------------------------------------------- */
/* ---------------------------------------------------------------------- */
int Input::meta(const std::string &prefix)
{
auto mycmd = fmt::format("{}_{}", utils::uppercase(prefix), utils::uppercase(arg[0]));
if (command_map->find(mycmd) != command_map->end()) {
CommandCreator &command_creator = (*command_map)[mycmd];
Command *cmd = command_creator(lmp);
cmd->command(narg-1,arg+1);
delete cmd;
return 1;
} else return 0;
}

View File

@ -70,6 +70,8 @@ class Input : protected Pointers {
void reallocate(char *&, int &, int); // reallocate a char string void reallocate(char *&, int &, int); // reallocate a char string
int execute_command(); // execute a single command int execute_command(); // execute a single command
int meta(const std::string &); // process meta-commands
void clear(); // input script commands void clear(); // input script commands
void echo(); void echo();
void ifthenelse(); void ifthenelse();
@ -142,7 +144,5 @@ class Input : protected Pointers {
void unfix(); void unfix();
void units(); void units();
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS
#endif #endif

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -12,7 +11,7 @@
See the README file in the top-level LAMMPS directory. See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "reset_atom_ids.h" #include "reset_atoms_id.h"
#include "atom.h" #include "atom.h"
#include "atom_vec.h" #include "atom_vec.h"
@ -32,7 +31,7 @@ using namespace LAMMPS_NS;
#if defined(LMP_QSORT) #if defined(LMP_QSORT)
// allocate space for static class variable // allocate space for static class variable
// prototype for non-class function // prototype for non-class function
ResetIDs::AtomRvous *ResetIDs::sortrvous; ResetAtomsID::AtomRvous *ResetAtomsID::sortrvous;
static int compare_coords(const void *, const void *); static int compare_coords(const void *, const void *);
#else #else
// prototype for non-class function // prototype for non-class function
@ -44,22 +43,21 @@ static int compare_coords(const int, const int, void *);
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ResetIDs::ResetIDs(LAMMPS *lmp) : Command(lmp) {} ResetAtomsID::ResetAtomsID(LAMMPS *lmp) : Command(lmp) {}
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void ResetIDs::command(int narg, char **arg) void ResetAtomsID::command(int narg, char **arg)
{ {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR,"Reset_ids command before simulation box is defined"); error->all(FLERR, "Reset_atoms id command before simulation box is defined");
if (atom->tag_enable == 0) if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset_atoms id unless atoms have IDs");
error->all(FLERR,"Cannot use reset_atom_ids unless atoms have IDs");
for (int i = 0; i < modify->nfix; i++) for (int i = 0; i < modify->nfix; i++)
if (modify->fix[i]->stores_ids) if (modify->fix[i]->stores_ids)
error->all(FLERR,"Cannot use reset_atom_ids when a fix exists that stores atom IDs"); error->all(FLERR, "Cannot use reset_atoms id when a fix exists that stores atom IDs");
if (comm->me == 0) utils::logmesg(lmp,"Resetting atom IDs ...\n"); if (comm->me == 0) utils::logmesg(lmp, "Resetting atom IDs ...\n");
// process args // process args
@ -67,11 +65,12 @@ void ResetIDs::command(int narg, char **arg)
int iarg = 0; int iarg = 0;
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg],"sort") == 0) { if (strcmp(arg[iarg], "sort") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_atom_ids command"); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset_atoms id", error);
sortflag = utils::logical(FLERR,arg[iarg+1],false,lmp); sortflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else error->all(FLERR,"Illegal reset_atom_ids command"); } else
error->all(FLERR, "Unknown reset_atoms id keyword: {}", arg[iarg]);
} }
// create an atom map if one doesn't exist already // create an atom map if one doesn't exist already
@ -99,7 +98,7 @@ void ResetIDs::command(int narg, char **arg)
comm->setup(); comm->setup();
comm->exchange(); comm->exchange();
comm->borders(); comm->borders();
if (domain->triclinic) domain->lamda2x(atom->nlocal+atom->nghost); if (domain->triclinic) domain->lamda2x(atom->nlocal + atom->nghost);
// oldIDs = copy of current owned IDs // oldIDs = copy of current owned IDs
@ -108,7 +107,7 @@ void ResetIDs::command(int narg, char **arg)
int nall = nlocal + atom->nghost; int nall = nlocal + atom->nghost;
tagint *oldIDs; tagint *oldIDs;
memory->create(oldIDs,nlocal,"reset_atom_ids:oldIDs"); memory->create(oldIDs, nlocal, "reset_atom_ids:oldIDs");
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
oldIDs[i] = tag[i]; oldIDs[i] = tag[i];
@ -119,22 +118,24 @@ void ResetIDs::command(int narg, char **arg)
// if sortflag = no: use fast tag_extend() // if sortflag = no: use fast tag_extend()
// if sortflag = yes: use slower full spatial sort plus rendezvous comm // if sortflag = yes: use slower full spatial sort plus rendezvous comm
if (sortflag == 0) atom->tag_extend(); if (sortflag == 0)
else sort(); atom->tag_extend();
else
sort();
// newIDs = copy of new IDs // newIDs = copy of new IDs
// restore old IDs, consistent with existing atom map // restore old IDs, consistent with existing atom map
// forward_comm_array acquires new IDs for ghost atoms // forward_comm_array acquires new IDs for ghost atoms
double **newIDs; double **newIDs;
memory->create(newIDs,nall,1,"reset_atom_ids:newIDs"); memory->create(newIDs, nall, 1, "reset_atom_ids:newIDs");
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
newIDs[i][0] = ubuf(tag[i]).d; newIDs[i][0] = ubuf(tag[i]).d;
tag[i] = oldIDs[i]; tag[i] = oldIDs[i];
} }
comm->forward_comm_array(1,newIDs); comm->forward_comm_array(1, newIDs);
// loop over bonds, angles, etc and reset IDs in stored topology arrays // loop over bonds, angles, etc and reset IDs in stored topology arrays
// only necessary for molecular = Atom::MOLECULAR, not molecular = Atom::TEMPLATE // only necessary for molecular = Atom::MOLECULAR, not molecular = Atom::TEMPLATE
@ -143,7 +144,7 @@ void ResetIDs::command(int narg, char **arg)
int badcount = 0; int badcount = 0;
if (atom->molecular == Atom::MOLECULAR) { if (atom->molecular == Atom::MOLECULAR) {
int j,m; int j, m;
tagint oldID; tagint oldID;
if (atom->avec->bonds_allow) { if (atom->avec->bonds_allow) {
@ -153,8 +154,10 @@ void ResetIDs::command(int narg, char **arg)
for (j = 0; j < num_bond[i]; j++) { for (j = 0; j < num_bond[i]; j++) {
oldID = bond_atom[i][j]; oldID = bond_atom[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) bond_atom[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; bond_atom[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
} }
} }
} }
@ -168,18 +171,24 @@ void ResetIDs::command(int narg, char **arg)
for (j = 0; j < num_angle[i]; j++) { for (j = 0; j < num_angle[i]; j++) {
oldID = angle_atom1[i][j]; oldID = angle_atom1[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) angle_atom1[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; angle_atom1[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
oldID = angle_atom2[i][j]; oldID = angle_atom2[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) angle_atom2[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; angle_atom2[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
oldID = angle_atom3[i][j]; oldID = angle_atom3[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) angle_atom3[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; angle_atom3[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
} }
} }
} }
@ -194,23 +203,31 @@ void ResetIDs::command(int narg, char **arg)
for (j = 0; j < num_dihedral[i]; j++) { for (j = 0; j < num_dihedral[i]; j++) {
oldID = dihedral_atom1[i][j]; oldID = dihedral_atom1[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) dihedral_atom1[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; dihedral_atom1[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
oldID = dihedral_atom2[i][j]; oldID = dihedral_atom2[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) dihedral_atom2[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; dihedral_atom2[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
oldID = dihedral_atom3[i][j]; oldID = dihedral_atom3[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) dihedral_atom3[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; dihedral_atom3[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
oldID = dihedral_atom4[i][j]; oldID = dihedral_atom4[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) dihedral_atom4[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; dihedral_atom4[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
} }
} }
} }
@ -225,23 +242,31 @@ void ResetIDs::command(int narg, char **arg)
for (j = 0; j < num_improper[i]; j++) { for (j = 0; j < num_improper[i]; j++) {
oldID = improper_atom1[i][j]; oldID = improper_atom1[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) improper_atom1[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; improper_atom1[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
oldID = improper_atom2[i][j]; oldID = improper_atom2[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) improper_atom2[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; improper_atom2[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
oldID = improper_atom3[i][j]; oldID = improper_atom3[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) improper_atom3[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; improper_atom3[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
oldID = improper_atom4[i][j]; oldID = improper_atom4[i][j];
m = atom->map(oldID); m = atom->map(oldID);
if (m >= 0) improper_atom4[i][j] = (tagint) ubuf(newIDs[m][0]).i; if (m >= 0)
else badcount++; improper_atom4[i][j] = (tagint) ubuf(newIDs[m][0]).i;
else
badcount++;
} }
} }
} }
@ -250,10 +275,10 @@ void ResetIDs::command(int narg, char **arg)
// error check // error check
int all; int all;
MPI_Allreduce(&badcount,&all,1,MPI_INT,MPI_SUM,world); MPI_Allreduce(&badcount, &all, 1, MPI_INT, MPI_SUM, world);
if (all) if (all)
error->all(FLERR,"Reset_ids missing {} bond topology atom IDs - " error->all(FLERR,
"use comm_modify cutoff",all); "reset_atoms id is missing {} bond topology atom IDs - use comm_modify cutoff", all);
// reset IDs and atom map for owned atoms // reset IDs and atom map for owned atoms
@ -287,9 +312,9 @@ void ResetIDs::command(int narg, char **arg)
spatial sort of atoms followed by rendezvous comm to reset atom IDs spatial sort of atoms followed by rendezvous comm to reset atom IDs
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void ResetIDs::sort() void ResetAtomsID::sort()
{ {
double mylo[3],myhi[3],bboxlo[3],bboxhi[3]; double mylo[3], myhi[3], bboxlo[3], bboxhi[3];
int me = comm->me; int me = comm->me;
int nprocs = comm->nprocs; int nprocs = comm->nprocs;
@ -306,12 +331,12 @@ void ResetIDs::sort()
myhi[0] = myhi[1] = myhi[2] = -BIG; myhi[0] = myhi[1] = myhi[2] = -BIG;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
mylo[0] = MIN(mylo[0],x[i][0]); mylo[0] = MIN(mylo[0], x[i][0]);
mylo[1] = MIN(mylo[1],x[i][1]); mylo[1] = MIN(mylo[1], x[i][1]);
mylo[2] = MIN(mylo[2],x[i][2]); mylo[2] = MIN(mylo[2], x[i][2]);
myhi[0] = MAX(myhi[0],x[i][0]); myhi[0] = MAX(myhi[0], x[i][0]);
myhi[1] = MAX(myhi[1],x[i][1]); myhi[1] = MAX(myhi[1], x[i][1]);
myhi[2] = MAX(myhi[2],x[i][2]); myhi[2] = MAX(myhi[2], x[i][2]);
} }
if (dim == 2) mylo[2] = myhi[2] = 0.0; if (dim == 2) mylo[2] = myhi[2] = 0.0;
@ -325,15 +350,15 @@ void ResetIDs::sort()
} }
} }
MPI_Allreduce(mylo,bboxlo,3,MPI_DOUBLE,MPI_MIN,world); MPI_Allreduce(mylo, bboxlo, 3, MPI_DOUBLE, MPI_MIN, world);
MPI_Allreduce(myhi,bboxhi,3,MPI_DOUBLE,MPI_MAX,world); MPI_Allreduce(myhi, bboxhi, 3, MPI_DOUBLE, MPI_MAX, world);
bboxlo[0] -= 0.0001 * (bboxhi[0]-bboxlo[0]); bboxlo[0] -= 0.0001 * (bboxhi[0] - bboxlo[0]);
bboxlo[1] -= 0.0001 * (bboxhi[1]-bboxlo[1]); bboxlo[1] -= 0.0001 * (bboxhi[1] - bboxlo[1]);
bboxlo[2] -= 0.0001 * (bboxhi[2]-bboxlo[2]); bboxlo[2] -= 0.0001 * (bboxhi[2] - bboxlo[2]);
bboxhi[0] += 0.0001 * (bboxhi[0]-bboxlo[0]); bboxhi[0] += 0.0001 * (bboxhi[0] - bboxlo[0]);
bboxhi[1] += 0.0001 * (bboxhi[1]-bboxlo[1]); bboxhi[1] += 0.0001 * (bboxhi[1] - bboxlo[1]);
bboxhi[2] += 0.0001 * (bboxhi[2]-bboxlo[2]); bboxhi[2] += 0.0001 * (bboxhi[2] - bboxlo[2]);
// nbin_estimate = estimate of total number of bins, each with PERBIN atoms // nbin_estimate = estimate of total number of bins, each with PERBIN atoms
// binsize = edge length of a cubic bin // binsize = edge length of a cubic bin
@ -342,19 +367,23 @@ void ResetIDs::sort()
bigint nbin_estimate = atom->natoms / PERBIN + 1; bigint nbin_estimate = atom->natoms / PERBIN + 1;
double vol; double vol;
if (dim == 2) vol = (bboxhi[0]-bboxlo[0]) * (bboxhi[1]-bboxlo[1]); if (dim == 2)
else vol = (bboxhi[0]-bboxlo[0]) * (bboxhi[1]-bboxlo[1]) * (bboxhi[2]-bboxlo[2]); vol = (bboxhi[0] - bboxlo[0]) * (bboxhi[1] - bboxlo[1]);
double binsize = pow(vol/nbin_estimate,1.0/dim); else
vol = (bboxhi[0] - bboxlo[0]) * (bboxhi[1] - bboxlo[1]) * (bboxhi[2] - bboxlo[2]);
double binsize = pow(vol / nbin_estimate, 1.0 / dim);
int nbinx = static_cast<int> ((bboxhi[0]-bboxlo[0]) / binsize) + 1; int nbinx = static_cast<int>((bboxhi[0] - bboxlo[0]) / binsize) + 1;
int nbiny = static_cast<int> ((bboxhi[1]-bboxlo[1]) / binsize) + 1; int nbiny = static_cast<int>((bboxhi[1] - bboxlo[1]) / binsize) + 1;
int nbinz = static_cast<int> ((bboxhi[2]-bboxlo[2]) / binsize) + 1; int nbinz = static_cast<int>((bboxhi[2] - bboxlo[2]) / binsize) + 1;
double invx = 1.0 / (bboxhi[0]-bboxlo[0]); double invx = 1.0 / (bboxhi[0] - bboxlo[0]);
double invy = 1.0 / (bboxhi[1]-bboxlo[1]); double invy = 1.0 / (bboxhi[1] - bboxlo[1]);
double invz; double invz;
if (dim == 2) invz = 0.0; if (dim == 2)
else invz = 1.0 / (bboxhi[2]-bboxlo[2]); invz = 0.0;
else
invz = 1.0 / (bboxhi[2] - bboxlo[2]);
// nbins = actual total number of bins // nbins = actual total number of bins
// bins are split evenly across procs // bins are split evenly across procs
@ -366,18 +395,18 @@ void ResetIDs::sort()
// binlo to binhi-1 = bin indices this proc will own in Rvous decomp // binlo to binhi-1 = bin indices this proc will own in Rvous decomp
// bins are numbered from 0 to Nbins-1 // bins are numbered from 0 to Nbins-1
bigint nbins = (bigint) nbinx*nbiny*nbinz; bigint nbins = (bigint) nbinx * nbiny * nbinz;
bigint nlo = nbins / nprocs; bigint nlo = nbins / nprocs;
bigint nhi = nlo + 1; bigint nhi = nlo + 1;
bigint nplo = nprocs - (nbins % nprocs); bigint nplo = nprocs - (nbins % nprocs);
bigint nbinlo = nplo*nlo; bigint nbinlo = nplo * nlo;
if (me < nplo) { if (me < nplo) {
binlo = me * nlo; binlo = me * nlo;
binhi = (me+1) * nlo; binhi = (me + 1) * nlo;
} else { } else {
binlo = nbinlo + (me-nplo) * nhi; binlo = nbinlo + (me - nplo) * nhi;
binhi = nbinlo + (me+1-nplo) * nhi; binhi = nbinlo + (me + 1 - nplo) * nhi;
} }
// fill atombuf with info on my atoms // fill atombuf with info on my atoms
@ -385,20 +414,23 @@ void ResetIDs::sort()
// proclist = proc that owns ibin // proclist = proc that owns ibin
int *proclist; int *proclist;
memory->create(proclist,nlocal,"special:proclist"); memory->create(proclist, nlocal, "special:proclist");
auto atombuf = (AtomRvous *) memory->smalloc((bigint) nlocal*sizeof(AtomRvous),"resetIDs:idbuf"); auto atombuf =
(AtomRvous *) memory->smalloc((bigint) nlocal * sizeof(AtomRvous), "resetIDs:idbuf");
int ibinx,ibiny,ibinz,iproc; int ibinx, ibiny, ibinz, iproc;
bigint ibin; bigint ibin;
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
ibinx = static_cast<int> ((x[i][0]-bboxlo[0])*invx * nbinx); ibinx = static_cast<int>((x[i][0] - bboxlo[0]) * invx * nbinx);
ibiny = static_cast<int> ((x[i][1]-bboxlo[1])*invy * nbiny); ibiny = static_cast<int>((x[i][1] - bboxlo[1]) * invy * nbiny);
ibinz = static_cast<int> ((x[i][2]-bboxlo[2])*invz * nbinz); ibinz = static_cast<int>((x[i][2] - bboxlo[2]) * invz * nbinz);
ibin = (bigint) ibinz*nbiny*nbinx + (bigint) ibiny*nbinx + ibinx; ibin = (bigint) ibinz * nbiny * nbinx + (bigint) ibiny * nbinx + ibinx;
if (ibin < nbinlo) iproc = ibin / nlo; if (ibin < nbinlo)
else iproc = nplo + (ibin-nbinlo) / nhi; iproc = ibin / nlo;
else
iproc = nplo + (ibin - nbinlo) / nhi;
proclist[i] = iproc; proclist[i] = iproc;
atombuf[i].ibin = ibin; atombuf[i].ibin = ibin;
@ -412,8 +444,8 @@ void ResetIDs::sort()
// perform rendezvous operation, send atombuf to other procs // perform rendezvous operation, send atombuf to other procs
char *buf; char *buf;
int nreturn = comm->rendezvous(1,nlocal,(char *) atombuf,sizeof(AtomRvous),0,proclist, int nreturn = comm->rendezvous(1, nlocal, (char *) atombuf, sizeof(AtomRvous), 0, proclist,
sort_bins,0,buf,sizeof(IDRvous),(void *) this); sort_bins, 0, buf, sizeof(IDRvous), (void *) this);
auto outbuf = (IDRvous *) buf; auto outbuf = (IDRvous *) buf;
memory->destroy(proclist); memory->destroy(proclist);
@ -437,11 +469,11 @@ void ResetIDs::sort()
outbuf = list of N IDRvous datums, sent back to sending proc outbuf = list of N IDRvous datums, sent back to sending proc
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int ResetIDs::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&outbuf, void *ptr) int ResetAtomsID::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&outbuf, void *ptr)
{ {
int i,ibin,index; int i, ibin, index;
auto rptr = (ResetIDs *) ptr; auto rptr = (ResetAtomsID *) ptr;
Memory *memory = rptr->memory; Memory *memory = rptr->memory;
Error *error = rptr->error; Error *error = rptr->error;
MPI_Comm world = rptr->world; MPI_Comm world = rptr->world;
@ -451,13 +483,13 @@ int ResetIDs::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&ou
// nbins = my subset of bins from binlo to binhi-1 // nbins = my subset of bins from binlo to binhi-1
// initialize linked lists of my Rvous atoms in each bin // initialize linked lists of my Rvous atoms in each bin
int *next,*head,*last,*count; int *next, *head, *last, *count;
int nbins = binhi - binlo; int nbins = binhi - binlo;
memory->create(next,n,"resetIDs:next"); memory->create(next, n, "resetIDs:next");
memory->create(head,nbins,"resetIDs:head"); memory->create(head, nbins, "resetIDs:head");
memory->create(last,nbins,"resetIDs:last"); memory->create(last, nbins, "resetIDs:last");
memory->create(count,nbins,"resetIDs:count"); memory->create(count, nbins, "resetIDs:count");
for (i = 0; i < n; i++) next[i] = -1; for (i = 0; i < n; i++) next[i] = -1;
@ -472,7 +504,7 @@ int ResetIDs::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&ou
if (in[i].ibin < binlo || in[i].ibin >= binhi) { if (in[i].ibin < binlo || in[i].ibin >= binhi) {
//printf("BAD me %d i %d %d ibin %d binlohi %d %d\n", //printf("BAD me %d i %d %d ibin %d binlohi %d %d\n",
// rptr->comm->me,i,n,in[i].ibin,binlo,binhi); // rptr->comm->me,i,n,in[i].ibin,binlo,binhi);
error->one(FLERR,"Bad spatial bin assignment in reset_atom_ids sort"); error->one(FLERR, "Bad spatial bin assignment in reset_atoms id sort");
} }
ibin = in[i].ibin - binlo; ibin = in[i].ibin - binlo;
if (head[ibin] < 0) head[ibin] = i; if (head[ibin] < 0) head[ibin] = i;
@ -482,11 +514,10 @@ int ResetIDs::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&ou
} }
int maxcount = 0; int maxcount = 0;
for (ibin = 0; ibin < nbins; ibin++) for (ibin = 0; ibin < nbins; ibin++) maxcount = MAX(maxcount, count[ibin]);
maxcount = MAX(maxcount,count[ibin]);
int *order; int *order;
memory->create(order,maxcount,"resetIDs:order"); memory->create(order, maxcount, "resetIDs:order");
// sort atoms in each bin by their spatial position // sort atoms in each bin by their spatial position
// recreate linked list for each bin based on sorted order // recreate linked list for each bin based on sorted order
@ -498,12 +529,11 @@ int ResetIDs::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&ou
index = next[index]; index = next[index];
} }
#if defined(LMP_QSORT) #if defined(LMP_QSORT)
sortrvous = in; sortrvous = in;
qsort(order,count[ibin],sizeof(int),compare_coords); qsort(order, count[ibin], sizeof(int), compare_coords);
#else #else
utils::merge_sort(order,count[ibin],(void *) in,compare_coords); utils::merge_sort(order, count[ibin], (void *) in, compare_coords);
#endif #endif
head[ibin] = last[ibin] = -1; head[ibin] = last[ibin] = -1;
@ -518,15 +548,15 @@ int ResetIDs::sort_bins(int n, char *inbuf, int &flag, int *&proclist, char *&ou
tagint ntag = n; tagint ntag = n;
tagint nprev; tagint nprev;
MPI_Scan(&ntag,&nprev,1,MPI_LMP_TAGINT,MPI_SUM,world); MPI_Scan(&ntag, &nprev, 1, MPI_LMP_TAGINT, MPI_SUM, world);
nprev -= n; nprev -= n;
// loop over bins and sorted atoms in each bin, reset ids to be consecutive // loop over bins and sorted atoms in each bin, reset ids to be consecutive
// pass outbuf of IDRvous datums back to comm->rendezvous // pass outbuf of IDRvous datums back to comm->rendezvous
int nout = n; int nout = n;
memory->create(proclist,nout,"resetIDs:proclist"); memory->create(proclist, nout, "resetIDs:proclist");
auto out = (IDRvous *) memory->smalloc(nout*sizeof(IDRvous),"resetIDs:out"); auto out = (IDRvous *) memory->smalloc(nout * sizeof(IDRvous), "resetIDs:out");
tagint one = nprev + 1; tagint one = nprev + 1;
for (ibin = 0; ibin < nbins; ibin++) { for (ibin = 0; ibin < nbins; ibin++) {
@ -567,7 +597,7 @@ int compare_coords(const void *iptr, const void *jptr)
{ {
int i = *((int *) iptr); int i = *((int *) iptr);
int j = *((int *) jptr); int j = *((int *) jptr);
ResetIDs::AtomRvous *rvous = ResetIDs::sortrvous; ResetAtomsID::AtomRvous *rvous = ResetAtomsID::sortrvous;
double *xi = rvous[i].x; double *xi = rvous[i].x;
double *xj = rvous[j].x; double *xj = rvous[j].x;
if (xi[0] < xj[0]) return -1; if (xi[0] < xj[0]) return -1;
@ -588,7 +618,7 @@ int compare_coords(const void *iptr, const void *jptr)
int compare_coords(const int i, const int j, void *ptr) int compare_coords(const int i, const int j, void *ptr)
{ {
auto rvous = (ResetIDs::AtomRvous *) ptr; auto rvous = (ResetAtomsID::AtomRvous *) ptr;
double *xi = rvous[i].x; double *xi = rvous[i].x;
double *xj = rvous[j].x; double *xj = rvous[j].x;
if (xi[0] < xj[0]) return -1; if (xi[0] < xj[0]) return -1;

View File

@ -13,18 +13,18 @@
#ifdef COMMAND_CLASS #ifdef COMMAND_CLASS
// clang-format off // clang-format off
CommandStyle(reset_atom_ids,ResetIDs); CommandStyle(RESET_ATOMS_ID,ResetAtomsID);
// clang-format on // clang-format on
#else #else
#ifndef LMP_RESET_IDS_H #ifndef LMP_RESET_ATOMS_ID_H
#define LMP_RESET_IDS_H #define LMP_RESET_ATOMS_ID_H
#include "command.h" #include "command.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class ResetIDs : public Command { class ResetAtomsID : public Command {
public: public:
struct AtomRvous { struct AtomRvous {
bigint ibin; bigint ibin;
@ -42,7 +42,7 @@ class ResetIDs : public Command {
static AtomRvous *sortrvous; static AtomRvous *sortrvous;
#endif #endif
ResetIDs(class LAMMPS *); ResetAtomsID(class LAMMPS *);
void command(int, char **) override; void command(int, char **) override;
private: private:
@ -54,8 +54,6 @@ class ResetIDs : public Command {
void sort(); void sort();
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS
#endif #endif
#endif #endif

141
src/reset_atoms_image.cpp Normal file
View File

@ -0,0 +1,141 @@
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
LAMMPS development team: developers@lammps.org
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "reset_atoms_image.h"
#include "atom.h"
#include "atom_vec.h"
#include "comm.h"
#include "compute.h"
#include "domain.h"
#include "error.h"
#include "group.h"
#include "input.h"
#include "modify.h"
#include "variable.h"
#include <cmath>
#include <cstring>
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ResetAtomsImage::ResetAtomsImage(LAMMPS *lmp) : Command(lmp) {}
/* ----------------------------------------------------------------------
called as reset_atoms image command in input script
------------------------------------------------------------------------- */
void ResetAtomsImage::command(int narg, char **arg)
{
if (domain->box_exist == 0)
error->all(FLERR, "Reset_atoms image command before simulation box is defined");
if (atom->tag_enable == 0)
error->all(FLERR, "Cannot use reset_atoms image unless atoms have IDs");
if (atom->avec->bonds_allow == 0)
error->all(FLERR, "Cannot use reset_atoms image used when bonds are not allowed");
// process args
if (narg < 1) utils::missing_cmd_args(FLERR, "reset_atoms image", error);
if (narg > 1) error->all(FLERR, "Unknown reset_atoms image keyword: {}", arg[1]);
int igroup = group->find(arg[0]);
if (igroup < 0) error->all(FLERR, "Could not find reset_atoms image group {}", arg[0]);
int groupbit = group->bitmask[igroup];
if (comm->me == 0) utils::logmesg(lmp, "Resetting image flags ...\n");
// record wall time for resetting molecule IDs
MPI_Barrier(world);
double time1 = platform::walltime();
// initialize system since comm->borders() will be invoked
lmp->init();
// setup domain, communication
// exchange will clear map, borders will reset
// this is the map needed to lookup current global IDs for bond topology
if (domain->triclinic) domain->x2lamda(atom->nlocal);
domain->pbc();
domain->reset_box();
comm->setup();
comm->exchange();
comm->borders();
if (domain->triclinic) domain->lamda2x(atom->nlocal + atom->nghost);
// create computes and variables
auto frags = modify->add_compute("frags_r_i_f all fragment/atom single yes");
auto chunk = modify->add_compute("chunk_r_i_f all chunk/atom c_frags_r_i_f compress yes");
auto flags = modify->add_compute("flags_r_i_f all property/atom ix iy iz");
input->variable->set("ix_r_i_f atom c_flags_r_i_f[1]");
input->variable->set("iy_r_i_f atom c_flags_r_i_f[2]");
input->variable->set("iz_r_i_f atom c_flags_r_i_f[3]");
auto ifmin = modify->add_compute("ifmin_r_i_f all reduce/chunk chunk_r_i_f min "
"v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f");
auto ifmax = modify->add_compute("ifmax_r_i_f all reduce/chunk chunk_r_i_f max "
"v_ix_r_i_f v_iy_r_i_f v_iz_r_i_f");
auto cdist = modify->add_compute("cdist_r_i_f all chunk/spread/atom chunk_r_i_f "
"c_ifmax_r_i_f[*] c_ifmin_r_i_f[*]");
// trigger computes
frags->compute_peratom();
chunk->compute_peratom();
flags->compute_peratom();
ifmin->compute_array();
ifmax->compute_array();
cdist->compute_peratom();
// reset image flags for atoms in group
const int *const mask = atom->mask;
const int nlocal = atom->nlocal;
imageint *image = atom->image;
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
int ix = (image[i] & IMGMASK) - IMGMAX;
int iy = (image[i] >> IMGBITS & IMGMASK) - IMGMAX;
int iz = (image[i] >> IMG2BITS) - IMGMAX;
ix -= (int) floor(0.5 * (cdist->array_atom[i][0] + cdist->array_atom[i][3]));
iy -= (int) floor(0.5 * (cdist->array_atom[i][1] + cdist->array_atom[i][4]));
iz -= (int) floor(0.5 * (cdist->array_atom[i][2] + cdist->array_atom[i][5]));
image[i] = ((imageint) (ix + IMGMAX) & IMGMASK) |
(((imageint) (iy + IMGMAX) & IMGMASK) << IMGBITS) |
(((imageint) (iz + IMGMAX) & IMGMASK) << IMG2BITS);
}
}
// cleanup
modify->delete_compute("cdist_r_i_f");
modify->delete_compute("ifmax_r_i_f");
modify->delete_compute("ifmin_r_i_f");
modify->delete_compute("flags_r_i_f");
modify->delete_compute("chunk_r_i_f");
modify->delete_compute("frags_r_i_f");
input->variable->set("ix_r_i_f delete");
input->variable->set("iy_r_i_f delete");
input->variable->set("iz_r_i_f delete");
// total time
MPI_Barrier(world);
if (comm->me == 0)
utils::logmesg(lmp, " reset_atoms image CPU = {:.3f} seconds\n", platform::walltime() - time1);
}

34
src/reset_atoms_image.h Normal file
View File

@ -0,0 +1,34 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
LAMMPS development team: developers@lammps.org
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#ifdef COMMAND_CLASS
// clang-format off
CommandStyle(RESET_ATOMS_IMAGE,ResetAtomsImage);
// clang-format on
#else
#ifndef LMP_RESET_ATOMS_IMAGE_H
#define LMP_RESET_ATOMS_IMAGE_H
#include "command.h"
namespace LAMMPS_NS {
class ResetAtomsImage : public Command {
public:
ResetAtomsImage(class LAMMPS *);
void command(int, char **) override;
};
} // namespace LAMMPS_NS
#endif
#endif

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -16,7 +15,7 @@
Contributing author: Jacob Gissinger (jacob.gissinger@colorado.edu) Contributing author: Jacob Gissinger (jacob.gissinger@colorado.edu)
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
#include "reset_mol_ids.h" #include "reset_atoms_mol.h"
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
@ -33,10 +32,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ResetMolIDs::ResetMolIDs(LAMMPS *lmp) : Command(lmp) { ResetAtomsMol::ResetAtomsMol(LAMMPS *lmp) : Command(lmp), cfa(nullptr), cca(nullptr)
cfa = nullptr; {
cca = nullptr;
// default settings // default settings
compressflag = 1; compressflag = 1;
@ -49,49 +46,49 @@ ResetMolIDs::ResetMolIDs(LAMMPS *lmp) : Command(lmp) {
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ResetMolIDs::~ResetMolIDs() ResetAtomsMol::~ResetAtomsMol()
{ {
if (!idfrag.empty()) modify->delete_compute(idfrag); if (!idfrag.empty()) modify->delete_compute(idfrag);
if (compressflag && !idchunk.empty()) modify->delete_compute(idchunk); if (compressflag && !idchunk.empty()) modify->delete_compute(idchunk);
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
called as reset_mol_ids command in input script called as reset_atoms mol command in input script
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void ResetMolIDs::command(int narg, char **arg) void ResetAtomsMol::command(int narg, char **arg)
{ {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR,"Reset_mol_ids command before simulation box is defined"); error->all(FLERR, "Reset_atoms mol command before simulation box is defined");
if (atom->tag_enable == 0) if (atom->tag_enable == 0) error->all(FLERR, "Cannot use reset_atoms mol unless atoms have IDs");
error->all(FLERR,"Cannot use reset_mol_ids unless atoms have IDs");
if (atom->molecular != Atom::MOLECULAR) if (atom->molecular != Atom::MOLECULAR)
error->all(FLERR,"Can only use reset_mol_ids on molecular systems"); error->all(FLERR, "Can only use reset_atoms mol on molecular systems");
// process args // process args
if (narg < 1) error->all(FLERR,"Illegal reset_mol_ids command"); if (narg < 1) utils::missing_cmd_args(FLERR, "reset_atoms mol", error);
char *groupid = arg[0]; char *groupid = arg[0];
int iarg = 1; int iarg = 1;
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg],"compress") == 0) { if (strcmp(arg[iarg], "compress") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset_atoms mol compress", error);
compressflag = utils::logical(FLERR,arg[iarg+1],false,lmp); compressflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"single") == 0) { } else if (strcmp(arg[iarg], "single") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset_atoms mol single", error);
singleflag = utils::logical(FLERR,arg[iarg+1],false,lmp); singleflag = utils::logical(FLERR, arg[iarg + 1], false, lmp);
iarg += 2; iarg += 2;
} else if (strcmp(arg[iarg],"offset") == 0) { } else if (strcmp(arg[iarg], "offset") == 0) {
if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "reset_atoms mol offset", error);
offset = utils::tnumeric(FLERR,arg[iarg+1],true,lmp); offset = utils::tnumeric(FLERR, arg[iarg + 1], true, lmp);
if (offset < -1) error->all(FLERR,"Illegal reset_mol_ids command"); if (offset < -1) error->all(FLERR, "Illegal reset_atoms mol offset: {}", offset);
iarg += 2; iarg += 2;
} else error->all(FLERR,"Illegal reset_mol_ids command"); } else
error->all(FLERR, "Unknown reset_atoms mol keyword: {}", arg[iarg]);
} }
if (comm->me == 0) utils::logmesg(lmp,"Resetting molecule IDs ...\n"); if (comm->me == 0) utils::logmesg(lmp, "Resetting molecule IDs ...\n");
// record wall time for resetting molecule IDs // record wall time for resetting molecule IDs
@ -112,11 +109,11 @@ void ResetMolIDs::command(int narg, char **arg)
comm->setup(); comm->setup();
comm->exchange(); comm->exchange();
comm->borders(); comm->borders();
if (domain->triclinic) domain->lamda2x(atom->nlocal+atom->nghost); if (domain->triclinic) domain->lamda2x(atom->nlocal + atom->nghost);
// create computes // create computes
create_computes((char *) "COMMAND",groupid); create_computes((char *) "COMMAND", groupid);
// reset molecule IDs // reset molecule IDs
@ -128,44 +125,43 @@ void ResetMolIDs::command(int narg, char **arg)
if (comm->me == 0) { if (comm->me == 0) {
if (nchunk < 0) if (nchunk < 0)
utils::logmesg(lmp," number of new molecule IDs = unknown\n"); utils::logmesg(lmp, " number of new molecule IDs = unknown\n");
else else
utils::logmesg(lmp," number of new molecule IDs = {}\n",nchunk); utils::logmesg(lmp, " number of new molecule IDs = {}\n", nchunk);
utils::logmesg(lmp," reset_mol_ids CPU = {:.3f} seconds\n", utils::logmesg(lmp, " reset_atoms mol CPU = {:.3f} seconds\n", platform::walltime() - time1);
platform::walltime()-time1);
} }
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
create computes used by reset_mol_ids create computes used by reset_atoms_mol
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void ResetMolIDs::create_computes(char *fixid, char *groupid) void ResetAtomsMol::create_computes(char *fixid, char *groupid)
{ {
int igroup = group->find(groupid); int igroup = group->find(groupid);
if (igroup == -1) error->all(FLERR,"Could not find reset_mol_ids group ID"); if (igroup < 0) error->all(FLERR, "Could not find reset_atoms mol group {}", groupid);
groupbit = group->bitmask[igroup]; groupbit = group->bitmask[igroup];
// create instances of compute fragment/atom, compute reduce (if needed), // create instances of compute fragment/atom, compute reduce (if needed),
// and compute chunk/atom. all use the group-ID for this command. // and compute chunk/atom. all use the group-ID for this command.
// 'fixid' allows for creating independent instances of the computes // 'fixid' allows for creating independent instances of the computes
idfrag = fmt::format("{}_reset_mol_ids_FRAGMENT_ATOM",fixid); idfrag = fmt::format("{}_reset_atoms_mol_FRAGMENT_ATOM", fixid);
auto use_single = singleflag ? "yes" : "no"; auto use_single = singleflag ? "yes" : "no";
cfa = dynamic_cast<ComputeFragmentAtom *>( cfa = dynamic_cast<ComputeFragmentAtom *>(modify->add_compute(
modify->add_compute(fmt::format("{} {} fragment/atom single {}",idfrag,groupid,use_single))); fmt::format("{} {} fragment/atom single {}", idfrag, groupid, use_single)));
idchunk = fmt::format("{}_reset_mol_ids_CHUNK_ATOM",fixid); idchunk = fmt::format("{}_reset_atoms_mol_CHUNK_ATOM", fixid);
if (compressflag) if (compressflag)
cca = dynamic_cast<ComputeChunkAtom *>( cca = dynamic_cast<ComputeChunkAtom *>(modify->add_compute(
modify->add_compute(fmt::format("{} {} chunk/atom molecule compress yes",idchunk,groupid))); fmt::format("{} {} chunk/atom molecule compress yes", idchunk, groupid)));
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
called from command() and directly from fixes that update molecules called from command() and directly from fixes that update molecules
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void ResetMolIDs::reset() void ResetAtomsMol::reset()
{ {
// invoke peratom method of compute fragment/atom // invoke peratom method of compute fragment/atom
// walks bond connectivity and assigns each atom a fragment ID // walks bond connectivity and assigns each atom a fragment ID
@ -181,8 +177,7 @@ void ResetMolIDs::reset()
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) if (mask[i] & groupbit) molecule[i] = static_cast<tagint>(fragIDs[i]);
molecule[i] = static_cast<tagint> (fragIDs[i]);
// if compressflag = 0, done // if compressflag = 0, done
// set nchunk = -1 since cannot easily determine # of new molecule IDs // set nchunk = -1 since cannot easily determine # of new molecule IDs
@ -208,7 +203,7 @@ void ResetMolIDs::reset()
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) if (mask[i] & groupbit)
if (fragIDs[i] == 0.0) mysingle = 1; if (fragIDs[i] == 0.0) mysingle = 1;
MPI_Allreduce(&mysingle,&singleexist,1,MPI_INT,MPI_MAX,world); MPI_Allreduce(&mysingle, &singleexist, 1, MPI_INT, MPI_MAX, world);
if (singleexist) nchunk--; if (singleexist) nchunk--;
} }
@ -220,10 +215,10 @@ void ResetMolIDs::reset()
if (groupbit != 1) { if (groupbit != 1) {
tagint mymol = 0; tagint mymol = 0;
for (int i = 0; i < nlocal; i++) for (int i = 0; i < nlocal; i++)
if (!(mask[i] & groupbit)) if (!(mask[i] & groupbit)) mymol = MAX(mymol, molecule[i]);
mymol = MAX(mymol,molecule[i]); MPI_Allreduce(&mymol, &offset, 1, MPI_LMP_TAGINT, MPI_MAX, world);
MPI_Allreduce(&mymol,&offset,1,MPI_LMP_TAGINT,MPI_MAX,world); } else
} else offset = 0; offset = 0;
} }
// reset molecule ID for all atoms in group // reset molecule ID for all atoms in group
@ -231,11 +226,14 @@ void ResetMolIDs::reset()
for (int i = 0; i < nlocal; i++) { for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) { if (mask[i] & groupbit) {
auto newid = static_cast<tagint>(chunkIDs[i]); auto newid = static_cast<tagint>(chunkIDs[i]);
if (singleexist) { if (singleexist) {
if (newid == 1) newid = 0; if (newid == 1)
else newid += offset - 1; newid = 0;
} else newid += offset; else
newid += offset - 1;
} else
newid += offset;
molecule[i] = newid; molecule[i] = newid;
} }
} }

View File

@ -13,21 +13,21 @@
#ifdef COMMAND_CLASS #ifdef COMMAND_CLASS
// clang-format off // clang-format off
CommandStyle(reset_mol_ids,ResetMolIDs); CommandStyle(RESET_ATOMS_MOL,ResetAtomsMol);
// clang-format on // clang-format on
#else #else
#ifndef LMP_RESET_MOL_IDS_H #ifndef LMP_RESET_ATOMS_MOL_H
#define LMP_RESET_MOL_IDS_H #define LMP_RESET_ATOMS_MOL_H
#include "command.h" #include "command.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class ResetMolIDs : public Command { class ResetAtomsMol : public Command {
public: public:
ResetMolIDs(class LAMMPS *); ResetAtomsMol(class LAMMPS *);
~ResetMolIDs() override; ~ResetAtomsMol() override;
void command(int, char **) override; void command(int, char **) override;
void create_computes(char *, char *); void create_computes(char *, char *);
void reset(); void reset();
@ -43,7 +43,6 @@ class ResetMolIDs : public Command {
class ComputeFragmentAtom *cfa; class ComputeFragmentAtom *cfa;
class ComputeChunkAtom *cca; class ComputeChunkAtom *cca;
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS
#endif #endif

View File

@ -53,10 +53,10 @@ endif()
target_link_libraries(test_kim_commands PRIVATE lammps GTest::GMock) target_link_libraries(test_kim_commands PRIVATE lammps GTest::GMock)
add_test(NAME KimCommands COMMAND test_kim_commands) add_test(NAME KimCommands COMMAND test_kim_commands)
add_executable(test_reset_ids test_reset_ids.cpp) add_executable(test_reset_atoms test_reset_atoms.cpp)
target_compile_definitions(test_reset_ids PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR}) target_compile_definitions(test_reset_atoms PRIVATE -DTEST_INPUT_FOLDER=${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(test_reset_ids PRIVATE lammps GTest::GMock) target_link_libraries(test_reset_atoms PRIVATE lammps GTest::GMock)
add_test(NAME ResetIDs COMMAND test_reset_ids) add_test(NAME ResetAtoms COMMAND test_reset_atoms)
if(PKG_MOLECULE) if(PKG_MOLECULE)
add_executable(test_compute_global test_compute_global.cpp) add_executable(test_compute_global test_compute_global.cpp)

View File

@ -17,6 +17,7 @@
#include "info.h" #include "info.h"
#include "input.h" #include "input.h"
#include "lammps.h" #include "lammps.h"
#include "library.h"
#include "output.h" #include "output.h"
#include "update.h" #include "update.h"
#include "utils.h" #include "utils.h"
@ -36,11 +37,11 @@ namespace LAMMPS_NS {
#define STRINGIFY(val) XSTR(val) #define STRINGIFY(val) XSTR(val)
#define XSTR(val) #val #define XSTR(val) #val
class ResetIDsTest : public LAMMPSTest { class ResetAtomsIDTest : public LAMMPSTest {
protected: protected:
void SetUp() override void SetUp() override
{ {
testbinary = "ResetIDsTest"; testbinary = "ResetAtomsIDTest";
LAMMPSTest::SetUp(); LAMMPSTest::SetUp();
if (info->has_style("atom", "full")) { if (info->has_style("atom", "full")) {
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
@ -51,7 +52,7 @@ protected:
} }
}; };
TEST_F(ResetIDsTest, MolIDAll) TEST_F(ResetAtomsIDTest, MolIDAll)
{ {
if (lmp->atom->natoms == 0) GTEST_SKIP(); if (lmp->atom->natoms == 0) GTEST_SKIP();
@ -89,7 +90,7 @@ TEST_F(ResetIDsTest, MolIDAll)
// the original data file has two different molecule IDs // the original data file has two different molecule IDs
// for two residues of the same molecule/fragment. // for two residues of the same molecule/fragment.
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("reset_mol_ids all"); command("reset_atoms mol all");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(molid[GETIDX(1)], 1); ASSERT_EQ(molid[GETIDX(1)], 1);
@ -123,7 +124,7 @@ TEST_F(ResetIDsTest, MolIDAll)
ASSERT_EQ(molid[GETIDX(29)], 5); ASSERT_EQ(molid[GETIDX(29)], 5);
} }
TEST_F(ResetIDsTest, DeletePlusAtomID) TEST_F(ResetAtomsIDTest, DeletePlusAtomID)
{ {
if (lmp->atom->natoms == 0) GTEST_SKIP(); if (lmp->atom->natoms == 0) GTEST_SKIP();
@ -134,7 +135,7 @@ TEST_F(ResetIDsTest, DeletePlusAtomID)
command("group allwater molecule 3:6"); command("group allwater molecule 3:6");
command("group twowater molecule 4:6:2"); command("group twowater molecule 4:6:2");
command("delete_atoms group twowater compress no bond yes"); command("delete_atoms group twowater compress no bond yes");
command("reset_mol_ids all"); command("reset_atoms mol all");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(lmp->atom->natoms, 23); ASSERT_EQ(lmp->atom->natoms, 23);
ASSERT_EQ(lmp->atom->map_tag_max, 26); ASSERT_EQ(lmp->atom->map_tag_max, 26);
@ -193,7 +194,7 @@ TEST_F(ResetIDsTest, DeletePlusAtomID)
ASSERT_GE(GETIDX(26), 0); ASSERT_GE(GETIDX(26), 0);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("reset_atom_ids"); command("reset_atoms id");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(lmp->atom->map_tag_max, 23); ASSERT_EQ(lmp->atom->map_tag_max, 23);
@ -201,7 +202,7 @@ TEST_F(ResetIDsTest, DeletePlusAtomID)
ASSERT_GE(GETIDX(i), 0); ASSERT_GE(GETIDX(i), 0);
} }
TEST_F(ResetIDsTest, PartialOffset) TEST_F(ResetAtomsIDTest, PartialOffset)
{ {
if (lmp->atom->natoms == 0) GTEST_SKIP(); if (lmp->atom->natoms == 0) GTEST_SKIP();
@ -211,7 +212,7 @@ TEST_F(ResetIDsTest, PartialOffset)
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("group allwater molecule 3:6"); command("group allwater molecule 3:6");
command("group nowater subtract all allwater"); command("group nowater subtract all allwater");
command("reset_mol_ids allwater offset 4"); command("reset_atoms mol allwater offset 4");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(lmp->atom->natoms, 29); ASSERT_EQ(lmp->atom->natoms, 29);
ASSERT_EQ(lmp->atom->map_tag_max, 29); ASSERT_EQ(lmp->atom->map_tag_max, 29);
@ -247,7 +248,7 @@ TEST_F(ResetIDsTest, PartialOffset)
ASSERT_EQ(molid[GETIDX(29)], 8); ASSERT_EQ(molid[GETIDX(29)], 8);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("reset_mol_ids nowater offset 0"); command("reset_atoms mol nowater offset 0");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(molid[GETIDX(1)], 1); ASSERT_EQ(molid[GETIDX(1)], 1);
@ -281,7 +282,7 @@ TEST_F(ResetIDsTest, PartialOffset)
ASSERT_EQ(molid[GETIDX(29)], 8); ASSERT_EQ(molid[GETIDX(29)], 8);
} }
TEST_F(ResetIDsTest, DeleteAdd) TEST_F(ResetAtomsIDTest, DeleteAdd)
{ {
if (lmp->atom->natoms == 0) GTEST_SKIP(); if (lmp->atom->natoms == 0) GTEST_SKIP();
@ -293,7 +294,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
command("group twowater molecule 4:6:2"); command("group twowater molecule 4:6:2");
command("group nowater subtract all allwater"); command("group nowater subtract all allwater");
command("delete_atoms group twowater compress no bond yes mol yes"); command("delete_atoms group twowater compress no bond yes mol yes");
command("reset_mol_ids allwater"); command("reset_atoms mol allwater");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(lmp->atom->natoms, 23); ASSERT_EQ(lmp->atom->natoms, 23);
ASSERT_EQ(lmp->atom->map_tag_max, 26); ASSERT_EQ(lmp->atom->map_tag_max, 26);
@ -352,7 +353,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_GE(GETIDX(26), 0); ASSERT_GE(GETIDX(26), 0);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("reset_atom_ids sort yes"); command("reset_atoms id sort yes");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(lmp->atom->map_tag_max, 23); ASSERT_EQ(lmp->atom->map_tag_max, 23);
@ -360,7 +361,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_GE(GETIDX(i), 0); ASSERT_GE(GETIDX(i), 0);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("reset_mol_ids nowater offset 1"); command("reset_atoms mol nowater offset 1");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(molid[GETIDX(1)], 2); ASSERT_EQ(molid[GETIDX(1)], 2);
@ -392,7 +393,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
command("create_atoms 2 single 1.0 0.0 0.0"); command("create_atoms 2 single 1.0 0.0 0.0");
command("create_atoms 3 single 2.0 0.0 0.0"); command("create_atoms 3 single 2.0 0.0 0.0");
command("create_atoms 4 single 3.0 0.0 0.0"); command("create_atoms 4 single 3.0 0.0 0.0");
command("reset_mol_ids all single yes"); command("reset_atoms mol all single yes");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(lmp->atom->natoms, 27); ASSERT_EQ(lmp->atom->natoms, 27);
ASSERT_EQ(lmp->atom->map_tag_max, 27); ASSERT_EQ(lmp->atom->map_tag_max, 27);
@ -406,7 +407,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_EQ(molid[GETIDX(27)], 7); ASSERT_EQ(molid[GETIDX(27)], 7);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("reset_mol_ids all single no"); command("reset_atoms mol all single no");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(molid[GETIDX(21)], 3); ASSERT_EQ(molid[GETIDX(21)], 3);
@ -418,7 +419,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_EQ(molid[GETIDX(27)], 0); ASSERT_EQ(molid[GETIDX(27)], 0);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("reset_mol_ids all compress no single yes"); command("reset_atoms mol all compress no single yes");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
ASSERT_EQ(molid[GETIDX(21)], 21); ASSERT_EQ(molid[GETIDX(21)], 21);
@ -430,7 +431,7 @@ TEST_F(ResetIDsTest, DeleteAdd)
ASSERT_EQ(molid[GETIDX(27)], 27); ASSERT_EQ(molid[GETIDX(27)], 27);
} }
TEST_F(ResetIDsTest, TopologyData) TEST_F(ResetAtomsIDTest, TopologyData)
{ {
if (lmp->atom->natoms == 0) GTEST_SKIP(); if (lmp->atom->natoms == 0) GTEST_SKIP();
@ -525,7 +526,7 @@ TEST_F(ResetIDsTest, TopologyData)
ASSERT_EQ(angle_atom3[GETIDX(24)][0], 26); ASSERT_EQ(angle_atom3[GETIDX(24)][0], 26);
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("reset_atom_ids sort yes"); command("reset_atoms id sort yes");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
num_bond = lmp->atom->num_bond; num_bond = lmp->atom->num_bond;
@ -618,63 +619,186 @@ TEST_F(ResetIDsTest, TopologyData)
ASSERT_EQ(angle_atom3[GETIDX(22)][0], 23); ASSERT_EQ(angle_atom3[GETIDX(22)][0], 23);
} }
TEST_F(ResetIDsTest, DeathTests) TEST_F(ResetAtomsIDTest, DeathTests)
{ {
if (lmp->atom->natoms == 0) GTEST_SKIP(); if (lmp->atom->natoms == 0) GTEST_SKIP();
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids");); TEST_FAILURE(".*ERROR: Illegal reset_atoms mol command.*", command("reset_atoms mol"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", TEST_FAILURE(".*ERROR: Unknown reset_atoms mol keyword: 1.*",
command("reset_mol_ids all offset 1 1");); command("reset_atoms mol all offset 1 1"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", TEST_FAILURE(".*ERROR: Illegal reset_atoms mol offset: -2.*",
command("reset_mol_ids all offset -2");); command("reset_atoms mol all offset -2"););
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*", command("reset_mol_ids all offset xxx"););
TEST_FAILURE(".*ERROR on proc 0: Expected integer.*", TEST_FAILURE(".*ERROR on proc 0: Expected integer.*",
command("reset_mol_ids all compress yes single no offset xxx");); command("reset_atoms mol all offset xxx"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids all offset");); TEST_FAILURE(".*ERROR on proc 0: Expected integer.*",
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_atoms mol all compress yes single no offset xxx"););
command("reset_mol_ids all compress");); TEST_FAILURE(".*ERROR: Illegal reset_atoms mol offset command: missing argument.*",
command("reset_atoms mol all offset"););
TEST_FAILURE(".*ERROR: Illegal reset_atoms mol compress command: missing argument.*",
command("reset_atoms mol all compress"););
TEST_FAILURE(".*ERROR: Expected boolean parameter instead of 'xxx'.*", TEST_FAILURE(".*ERROR: Expected boolean parameter instead of 'xxx'.*",
command("reset_mol_ids all compress xxx");); command("reset_atoms mol all compress xxx"););
TEST_FAILURE(".*ERROR: Illegal reset_mol_ids command.*", command("reset_mol_ids all single");); TEST_FAILURE(".*ERROR: Illegal reset_atoms mol single command: missing argument.*",
command("reset_atoms mol all single"););
TEST_FAILURE(".*ERROR: Expected boolean parameter instead of 'xxx'.*", TEST_FAILURE(".*ERROR: Expected boolean parameter instead of 'xxx'.*",
command("reset_mol_ids all single xxx");); command("reset_atoms mol all single xxx"););
TEST_FAILURE(".*ERROR: Illegal reset_atoms image command: missing argument.*",
command("reset_atoms image"););
TEST_FAILURE(".*ERROR: Unknown reset_atoms image keyword: xxx.*",
command("reset_atoms image all xxx"););
TEST_FAILURE(".*ERROR: Could not find reset_atoms image group xxx.*",
command("reset_atoms image xxx"););
} }
class ResetMolIDsTest : public LAMMPSTest { class ResetAtomsMolTest : public LAMMPSTest {
protected: protected:
void SetUp() override void SetUp() override
{ {
testbinary = "ResetIDsTest"; testbinary = "ResetAtomsMolTest";
LAMMPSTest::SetUp(); LAMMPSTest::SetUp();
} }
}; };
TEST_F(ResetMolIDsTest, FailBeforeBox) TEST_F(ResetAtomsMolTest, FailBeforeBox)
{ {
TEST_FAILURE(".*ERROR: Reset_mol_ids command before simulation box is.*", TEST_FAILURE(".*ERROR: Reset_atoms id command before simulation box is.*",
command("reset_mol_ids all");); command("reset_atoms id"););
TEST_FAILURE(".*ERROR: Reset_atoms mol command before simulation box is.*",
command("reset_atoms mol all"););
TEST_FAILURE(".*ERROR: Reset_atoms image command before simulation box is.*",
command("reset_atoms image all"););
} }
TEST_F(ResetMolIDsTest, FailMissingId) TEST_F(ResetAtomsMolTest, FailMissingId)
{ {
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("atom_modify id no"); command("atom_modify id no");
command("region box block 0 1 0 1 0 1"); command("region box block 0 1 0 1 0 1");
command("create_box 1 box"); command("create_box 1 box");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Cannot use reset_mol_ids unless.*", command("reset_mol_ids all");); TEST_FAILURE(".*ERROR: Cannot use reset_atoms mol unless.*", command("reset_atoms mol all"););
TEST_FAILURE(".*ERROR: Cannot use reset_atoms image unless.*",
command("reset_atoms image all"););
} }
TEST_F(ResetMolIDsTest, FailOnlyMolecular) TEST_F(ResetAtomsMolTest, FailOnlyMolecular)
{ {
BEGIN_HIDE_OUTPUT(); BEGIN_HIDE_OUTPUT();
command("clear"); command("clear");
command("region box block 0 1 0 1 0 1"); command("region box block 0 1 0 1 0 1");
command("create_box 1 box"); command("create_box 1 box");
END_HIDE_OUTPUT(); END_HIDE_OUTPUT();
TEST_FAILURE(".*ERROR: Can only use reset_mol_ids.*", command("reset_mol_ids all");); TEST_FAILURE(".*ERROR: Can only use reset_atoms mol.*", command("reset_atoms mol all"););
} }
class ResetAtomsImageTest : public LAMMPSTest {
protected:
void SetUp() override
{
testbinary = "ResetAtomsImageTest";
LAMMPSTest::SetUp();
if (info->has_style("atom", "full")) {
BEGIN_HIDE_OUTPUT();
command("variable input_dir index \"" STRINGIFY(TEST_INPUT_FOLDER) "\"");
command("include \"${input_dir}/in.fourmol\"");
command("create_atoms 1 single 1.0 1.0 1.0");
command("create_atoms 1 single 2.0 1.0 1.0");
command("create_atoms 1 single 1.0 2.0 1.0");
command("set atom 1*7 image 1 1 -1");
command("set atom 8*9 image 2 -1 0");
command("set atom 8*9 image 2 -1 0");
command("set atom 10 image 2 0 0");
command("set atom 11*12 image 2 0 -1");
command("set atom 13*15 image 1 0 0");
command("set atom 16*17 image 0 1 1");
command("set atom 18*19 image 0 1 0");
command("set atom 20 image 0 2 0");
command("set atom 21*23 image 20 -1 0");
command("set atom 27*28 image 1 0 0");
command("set atom 29 image 1 2 0");
command("set atom 31 image -2 0 1");
command("set atom 32 image 0 20 0");
END_HIDE_OUTPUT();
}
}
};
TEST_F(ResetAtomsImageTest, ResetAtomsImage)
{
if (lmp->atom->natoms == 0) GTEST_SKIP();
EXPECT_EQ(lmp->atom->image[GETIDX(1)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(2)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(3)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(4)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(5)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(6)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(7)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(8)], lammps_encode_image_flags(2, -1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(9)], lammps_encode_image_flags(2, -1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(10)], lammps_encode_image_flags(2, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(11)], lammps_encode_image_flags(2, 0, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(12)], lammps_encode_image_flags(2, 0, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(13)], lammps_encode_image_flags(1, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(14)], lammps_encode_image_flags(1, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(15)], lammps_encode_image_flags(1, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(16)], lammps_encode_image_flags(0, 1, 1));
EXPECT_EQ(lmp->atom->image[GETIDX(17)], lammps_encode_image_flags(0, 1, 1));
EXPECT_EQ(lmp->atom->image[GETIDX(18)], lammps_encode_image_flags(0, 1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(19)], lammps_encode_image_flags(0, 1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(20)], lammps_encode_image_flags(0, 2, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(21)], lammps_encode_image_flags(20, -1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(22)], lammps_encode_image_flags(20, -1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(23)], lammps_encode_image_flags(20, -1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(24)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(25)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(26)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(27)], lammps_encode_image_flags(1, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(28)], lammps_encode_image_flags(1, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(29)], lammps_encode_image_flags(1, 2, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(30)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(31)], lammps_encode_image_flags(-2, 0, 1));
EXPECT_EQ(lmp->atom->image[GETIDX(32)], lammps_encode_image_flags(0, 20, 0));
BEGIN_HIDE_OUTPUT();
command("group subset id 5:32");
command("reset_atoms image subset");
END_HIDE_OUTPUT();
EXPECT_EQ(lmp->atom->image[GETIDX(1)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(2)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(3)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(4)], lammps_encode_image_flags(1, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(5)], lammps_encode_image_flags(0, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(6)], lammps_encode_image_flags(0, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(7)], lammps_encode_image_flags(0, 1, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(8)], lammps_encode_image_flags(1, -1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(9)], lammps_encode_image_flags(1, -1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(10)], lammps_encode_image_flags(1, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(11)], lammps_encode_image_flags(1, 0, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(12)], lammps_encode_image_flags(1, 0, -1));
EXPECT_EQ(lmp->atom->image[GETIDX(13)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(14)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(15)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(16)], lammps_encode_image_flags(-1, 1, 1));
EXPECT_EQ(lmp->atom->image[GETIDX(17)], lammps_encode_image_flags(-1, 1, 1));
EXPECT_EQ(lmp->atom->image[GETIDX(18)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(19)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(20)], lammps_encode_image_flags(0, 1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(21)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(22)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(23)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(24)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(25)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(26)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(27)], lammps_encode_image_flags(0, -1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(28)], lammps_encode_image_flags(0, -1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(29)], lammps_encode_image_flags(0, 1, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(30)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(30)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(31)], lammps_encode_image_flags(0, 0, 0));
EXPECT_EQ(lmp->atom->image[GETIDX(32)], lammps_encode_image_flags(0, 0, 0));
}
} // namespace LAMMPS_NS } // namespace LAMMPS_NS
int main(int argc, char **argv) int main(int argc, char **argv)