merge in current develop
This commit is contained in:
2
.github/CODEOWNERS
vendored
2
.github/CODEOWNERS
vendored
@ -83,7 +83,7 @@ src/bond.* @sjplimp
|
|||||||
src/comm*.* @sjplimp
|
src/comm*.* @sjplimp
|
||||||
src/compute.* @sjplimp
|
src/compute.* @sjplimp
|
||||||
src/dihedral.* @sjplimp
|
src/dihedral.* @sjplimp
|
||||||
src/domain.* @sjplimp
|
src/domain.* @sjplimp @stanmoore1
|
||||||
src/dump*.* @sjplimp
|
src/dump*.* @sjplimp
|
||||||
src/error.* @sjplimp
|
src/error.* @sjplimp
|
||||||
src/finish.* @sjplimp
|
src/finish.* @sjplimp
|
||||||
|
|||||||
@ -635,10 +635,10 @@ Tohoku University (under MIT license)
|
|||||||
|
|
||||||
----------
|
----------
|
||||||
|
|
||||||
.. doxygenfunction:: MathEigen::jacobi3(double const *const *mat, double *eval, double **evec)
|
.. doxygenfunction:: MathEigen::jacobi3(double const *const *mat, double *eval, double **evec, int sort)
|
||||||
:project: progguide
|
:project: progguide
|
||||||
|
|
||||||
.. doxygenfunction:: MathEigen::jacobi3(double const mat[3][3], double *eval, double evec[3][3])
|
.. doxygenfunction:: MathEigen::jacobi3(double const mat[3][3], double *eval, double evec[3][3], int sort)
|
||||||
:project: progguide
|
:project: progguide
|
||||||
|
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|||||||
@ -13,15 +13,44 @@ discussions of such cases.
|
|||||||
Unknown identifier in data file
|
Unknown identifier in data file
|
||||||
-------------------------------
|
-------------------------------
|
||||||
|
|
||||||
This error happens when LAMMPS encounters a line of text in an unexpected format
|
This error happens when LAMMPS encounters a line of text with an
|
||||||
while reading a data file. This is most commonly cause by inconsistent header and
|
unexpected keyword while :doc:`reading a data file <read_data>`. This
|
||||||
section data. The header section informs LAMMPS how many entries or lines are expected in the
|
would be either header keywords or section header keywords. This is
|
||||||
various sections (like Atoms, Masses, Pair Coeffs, *etc.*\ ) of the data file.
|
most commonly due to a mistyped keyword or due to a keyword that is
|
||||||
If there is a mismatch, LAMMPS will either keep reading beyond the end of a section
|
inconsistent with the :doc:`atom style <atom_style>` used.
|
||||||
or stop reading before the section has ended.
|
|
||||||
|
|
||||||
Such a mismatch can happen unexpectedly when the first line of the data
|
The header section informs LAMMPS how many entries or lines are expected
|
||||||
is *not* a comment as required by the format. That would result in
|
in the various sections (like Atoms, Masses, Pair Coeffs, *etc.*\ ) of
|
||||||
LAMMPS expecting, for instance, 0 atoms because the "atoms" header line
|
the data file. If there is a mismatch, LAMMPS will either keep reading
|
||||||
is treated as a comment.
|
beyond the end of a section or stop reading before the section has
|
||||||
|
ended. In that case the next line will not contain a recognized keyword.
|
||||||
|
|
||||||
|
Such a mismatch can also happen when the first line of the data
|
||||||
|
is *not* a comment as required by the format, but a line with a valid
|
||||||
|
header keyword. That would result in LAMMPS expecting, for instance,
|
||||||
|
0 atoms because the "atoms" header line is the first line and thus
|
||||||
|
treated as a comment.
|
||||||
|
|
||||||
|
Another possibility to trigger this error is to have a keyword in the
|
||||||
|
data file that corresponds to a fix (e.g. :doc:`fix cmap <fix_cmap>`)
|
||||||
|
but the :doc:`read_data <read_data>` command is missing the (optional)
|
||||||
|
arguments that identify the fix and the header keyword and section
|
||||||
|
keyword or those arguments are inconsistent with the keywords in the
|
||||||
|
data file.
|
||||||
|
|
||||||
|
.. _err0002:
|
||||||
|
|
||||||
|
Incorrect format in ... section of data file
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
This error happens when LAMMPS reads the contents of a section of a
|
||||||
|
:doc:`data file <read_data>` and the number of parameters in the line
|
||||||
|
differs from what is expected. This most commonly happens, when the
|
||||||
|
atom style is different from what is expected for a specific data file
|
||||||
|
since changing the atom style usually changes the format of the line.
|
||||||
|
|
||||||
|
This error can also happen when the number of entries indicated in the
|
||||||
|
header of a data file (e.g. the number of atoms) is larger than the
|
||||||
|
number of lines provided (e.g. in the corresponding Atoms section)
|
||||||
|
and then LAMMPS will continue reading into the next section and that
|
||||||
|
would have a completely different format.
|
||||||
|
|||||||
@ -65,7 +65,6 @@ Examples
|
|||||||
fix 1 all ave/correlate 1 50 10000 &
|
fix 1 all ave/correlate 1 50 10000 &
|
||||||
c_thermo_press[1] c_thermo_press[2] c_thermo_press[3] &
|
c_thermo_press[1] c_thermo_press[2] c_thermo_press[3] &
|
||||||
type upper ave running title1 "My correlation data"
|
type upper ave running title1 "My correlation data"
|
||||||
|
|
||||||
fix 1 all ave/correlate 1 50 10000 c_thermo_press[*]
|
fix 1 all ave/correlate 1 50 10000 c_thermo_press[*]
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|||||||
@ -20,11 +20,11 @@ Syntax
|
|||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
c_ID = global scalar calculated by a compute with ID
|
c_ID = global scalar calculated by a compute with ID
|
||||||
c_ID[I] = Ith component of global vector calculated by a compute with ID
|
c_ID[I] = Ith component of global vector calculated by a compute with ID, I can include wildcard (see below)
|
||||||
f_ID = global scalar calculated by a fix with ID
|
f_ID = global scalar calculated by a fix with ID
|
||||||
f_ID[I] = Ith component of global vector calculated by a fix with ID
|
f_ID[I] = Ith component of global vector calculated by a fix with ID, I can include wildcard (see below)
|
||||||
v_name = global value calculated by an equal-style variable with name
|
v_name = global value calculated by an equal-style variable with name
|
||||||
v_name[I] = Ith component of global vector calculated by a vector-style variable with name
|
v_name[I] = Ith component of a vector-style variable with name, I can include wildcard (see below)
|
||||||
|
|
||||||
* zero or more keyword/arg pairs may be appended
|
* zero or more keyword/arg pairs may be appended
|
||||||
* keyword = *type* or *start* or *file* or *overwrite* or *title1* or *title2* or *ncorr* or *nlen* or *ncount*
|
* keyword = *type* or *start* or *file* or *overwrite* or *title1* or *title2* or *ncorr* or *nlen* or *ncount*
|
||||||
@ -63,6 +63,7 @@ Examples
|
|||||||
fix 1 all ave/correlate/long 1 10000 &
|
fix 1 all ave/correlate/long 1 10000 &
|
||||||
c_thermo_press[1] c_thermo_press[2] c_thermo_press[3] &
|
c_thermo_press[1] c_thermo_press[2] c_thermo_press[3] &
|
||||||
type upper title1 "My correlation data" nlen 15 ncount 3
|
type upper title1 "My correlation data" nlen 15 ncount 3
|
||||||
|
fix 1 all ave/correlate/long 1 10000 c_thermo_press[*]
|
||||||
|
|
||||||
Description
|
Description
|
||||||
"""""""""""
|
"""""""""""
|
||||||
@ -80,8 +81,10 @@ specified values may represent calculations performed by computes and
|
|||||||
fixes which store their own "group" definitions.
|
fixes which store their own "group" definitions.
|
||||||
|
|
||||||
Each listed value can be the result of a compute or fix or the
|
Each listed value can be the result of a compute or fix or the
|
||||||
evaluation of an equal-style variable. See the
|
evaluation of an equal-style or vector-style variable. For
|
||||||
:doc:`fix ave/correlate <fix_ave_correlate>` page for details.
|
vector-style variables, the specified indices can include a wildcard
|
||||||
|
character. See the :doc:`fix ave/correlate <fix_ave_correlate>` page
|
||||||
|
for details.
|
||||||
|
|
||||||
The *Nevery* and *Nfreq* arguments specify on what time steps the input
|
The *Nevery* and *Nfreq* arguments specify on what time steps the input
|
||||||
values will be used to calculate correlation data and the frequency
|
values will be used to calculate correlation data and the frequency
|
||||||
|
|||||||
@ -136,23 +136,23 @@ transfer between the subsystems:
|
|||||||
\bigtriangledown (\kappa_e \bigtriangledown T_e) -
|
\bigtriangledown (\kappa_e \bigtriangledown T_e) -
|
||||||
g_p (T_e - T_a) + g_s T_a'
|
g_p (T_e - T_a) + g_s T_a'
|
||||||
|
|
||||||
where C_e is the specific heat, rho_e is the density, kappa_e is the
|
where :math:`C_e` is the specific heat, :math:`\rho_e` is the density,
|
||||||
thermal conductivity, T is temperature, the "e" and "a" subscripts
|
:math:`\kappa_e` is the thermal conductivity, *T* is temperature, the
|
||||||
represent electronic and atomic subsystems respectively, g_p is the
|
"e" and "a" subscripts represent electronic and atomic subsystems
|
||||||
coupling constant for the electron-ion interaction, and g_s is the
|
respectively, :math:`g_p` is the coupling constant for the electron-ion
|
||||||
electron stopping coupling parameter. C_e, rho_e, and kappa_e are
|
interaction, and :math:`g_s` is the electron stopping coupling
|
||||||
specified as parameters to the fix. The other quantities are derived.
|
parameter. :math:`C_e`, :math:`\rho_e`, and :math:`\kappa_e` are
|
||||||
The form of the heat diffusion equation used here is almost the same
|
specified as parameters to the fix *ttm* or *ttm/grid*. The other
|
||||||
as that in equation 6 of :ref:`(Duffy) <Duffy>`, with the exception that the
|
quantities are derived. The form of the heat diffusion equation used
|
||||||
electronic density is explicitly represented, rather than being part
|
here is almost the same as that in equation 6 of :ref:`(Duffy) <Duffy>`,
|
||||||
of the specific heat parameter.
|
with the exception that the electronic density is explicitly
|
||||||
|
represented, rather than being part of the specific heat parameter.
|
||||||
|
|
||||||
Currently, the TTM fixes assume that none of the user-supplied
|
Currently, the TTM fixes assume that none of the user-supplied
|
||||||
parameters will vary with temperature. Note that :ref:`(Duffy)
|
parameters will vary with temperature. Note that :ref:`(Duffy) <Duffy>`
|
||||||
<Duffy>` used a tanh() functional form for the temperature dependence
|
used a tanh() functional form for the temperature dependence of the
|
||||||
of the electronic specific heat, but ignored temperature dependencies
|
electronic specific heat, but ignored temperature dependencies of any of
|
||||||
of any of the other parameters. See more discussion below for fix
|
the other parameters. See more discussion below for fix *ttm/mod*.
|
||||||
ttm/mod.
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
@ -265,27 +265,27 @@ heat sources (e.g. laser heating in ablation simulations):
|
|||||||
\bigtriangledown (\kappa_e \bigtriangledown T_e) -
|
\bigtriangledown (\kappa_e \bigtriangledown T_e) -
|
||||||
g_p (T_e - T_a) + g_s T_a' + \theta (x-x_{surface})I_0 \exp(-x/l_{skin})
|
g_p (T_e - T_a) + g_s T_a' + \theta (x-x_{surface})I_0 \exp(-x/l_{skin})
|
||||||
|
|
||||||
where theta is the Heaviside step function, I_0 is the (absorbed)
|
where :math:`\theta` is the Heaviside step function, :math:`I_0` is the
|
||||||
laser pulse intensity for ablation simulations, l_skin is the depth
|
(absorbed) laser pulse intensity for ablation simulations,
|
||||||
of skin-layer, and all other designations have the same meaning as in
|
:math:`l_{skin}` is the depth of the skin-layer, and all other
|
||||||
the former equation. The duration of the pulse is set by the parameter
|
designations have the same meaning as in the former equation. The
|
||||||
*tau* in the *init_file*.
|
duration of the pulse is set by the parameter *tau* in the *init_file*.
|
||||||
|
|
||||||
Fix ttm/mod also allows users to specify the dependencies of C_e and
|
Fix *ttm/mod* also allows users to specify the dependencies of
|
||||||
kappa_e on the electronic temperature. The specific heat is expressed
|
:math:`C_e` and :math:`\kappa_e` on the electronic temperature. The
|
||||||
as
|
specific heat is expressed as
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
|
|
||||||
C_e = C_0 + (a_0 + a_1 X + a_2 X^2 + a_3 X^3 + a_4 X^4) \exp (-(AX)^2)
|
C_e = C_0 + (a_0 + a_1 X + a_2 X^2 + a_3 X^3 + a_4 X^4) \exp (-(AX)^2)
|
||||||
|
|
||||||
where *X* = T_e/1000, and the thermal conductivity is defined as
|
where :math:`X = \frac{T_e}{1000}`, and the thermal conductivity is
|
||||||
kappa_e = D_e\*rho_e\*C_e, where D_e is the thermal diffusion
|
defined as :math:`\kappa_e = D_e \cdot rho_e \cdot C_e`, where
|
||||||
coefficient.
|
:math:`D_e` is the thermal diffusion coefficient.
|
||||||
|
|
||||||
Electronic pressure effects are included in the TTM model to account
|
Electronic pressure effects are included in the TTM model to account for
|
||||||
for the blast force acting on ions because of electronic pressure
|
the blast force acting on ions because of electronic pressure gradient
|
||||||
gradient (see :ref:`(Chen) <Chen>`, :ref:`(Norman) <Norman>`). The total force
|
(see :ref:`(Chen) <Chen>`, :ref:`(Norman) <Norman>`). The total force
|
||||||
acting on an ion is:
|
acting on an ion is:
|
||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
@ -293,13 +293,14 @@ acting on an ion is:
|
|||||||
{\vec F}_i = - \partial U / \partial {\vec r}_i + {\vec
|
{\vec F}_i = - \partial U / \partial {\vec r}_i + {\vec
|
||||||
F}_{langevin} - \nabla P_e/n_{ion}
|
F}_{langevin} - \nabla P_e/n_{ion}
|
||||||
|
|
||||||
where F_langevin is a force from Langevin thermostat simulating
|
where :math:`F_{langevin}` is a force from Langevin thermostat
|
||||||
electron-phonon coupling, and nabla P_e/n_ion is the electron blast
|
simulating electron-phonon coupling, and :math:`\nabla P_e/n_{ion}` is
|
||||||
force.
|
the electron blast force.
|
||||||
|
|
||||||
The electronic pressure is taken to be P_e = B\*rho_e\*C_e\*T_e
|
The electronic pressure is taken to be :math:`P_e = B \cdot rho_e \cdot
|
||||||
|
C_e \cdot T_e`
|
||||||
|
|
||||||
The current fix ttm/mod implementation allows TTM simulations with a
|
The current fix *ttm/mod* implementation allows TTM simulations with a
|
||||||
vacuum. The vacuum region is defined as the grid cells with zero
|
vacuum. The vacuum region is defined as the grid cells with zero
|
||||||
electronic temperature. The numerical scheme does not allow energy
|
electronic temperature. The numerical scheme does not allow energy
|
||||||
exchange with such cells. Since the material can expand to previously
|
exchange with such cells. Since the material can expand to previously
|
||||||
@ -319,10 +320,10 @@ electronic pressure gradient is calculated as
|
|||||||
\frac{x}{x+\lambda}\frac{(C_e{}T_e)_{x+\Delta
|
\frac{x}{x+\lambda}\frac{(C_e{}T_e)_{x+\Delta
|
||||||
x}-(C_e{}T_e)_{x}}{\Delta x} \right]
|
x}-(C_e{}T_e)_{x}}{\Delta x} \right]
|
||||||
|
|
||||||
where lambda is the electron mean free path (see :ref:`(Norman) <Norman>`,
|
where :math:`\lambda` is the electron mean free path (see :ref:`(Norman)
|
||||||
:ref:`(Pisarev) <Pisarev>`)
|
<Norman>`, :ref:`(Pisarev) <Pisarev>`)
|
||||||
|
|
||||||
The fix ttm/mod parameter file *init_file* has the following syntax.
|
The fix *ttm/mod* parameter file *init_file* has the following syntax.
|
||||||
Every line with an odd number is considered as a comment and
|
Every line with an odd number is considered as a comment and
|
||||||
ignored. The lines with the even numbers are treated as follows:
|
ignored. The lines with the even numbers are treated as follows:
|
||||||
|
|
||||||
|
|||||||
@ -1174,12 +1174,17 @@ custom atom properties are the same; just replace the leading "i" with
|
|||||||
|
|
||||||
+--------+---------------+------------------------------------------+
|
+--------+---------------+------------------------------------------+
|
||||||
| equal | i_name[I] | element of per-atom vector (I = atom ID) |
|
| equal | i_name[I] | element of per-atom vector (I = atom ID) |
|
||||||
|
+--------+---------------+------------------------------------------+
|
||||||
| equal | i2_name[I][J] | element of per-atom array (I = atom ID) |
|
| equal | i2_name[I][J] | element of per-atom array (I = atom ID) |
|
||||||
+--------+---------------+------------------------------------------+
|
+--------+---------------+------------------------------------------+
|
||||||
|
+--------+---------------+------------------------------------------+
|
||||||
| vector | i_name[I] | element of per-atom vector (I = atom ID) |
|
| vector | i_name[I] | element of per-atom vector (I = atom ID) |
|
||||||
|
+--------+---------------+------------------------------------------+
|
||||||
| vector | i2_name[I][J] | element of per-atom array (I = atom ID) |
|
| vector | i2_name[I][J] | element of per-atom array (I = atom ID) |
|
||||||
+--------+---------------+------------------------------------------+
|
+--------+---------------+------------------------------------------+
|
||||||
|
+--------+---------------+------------------------------------------+
|
||||||
| atom | i_name | per-atom vector |
|
| atom | i_name | per-atom vector |
|
||||||
|
+--------+---------------+------------------------------------------+
|
||||||
| atom | i2_name[I] | column of per-atom array |
|
| atom | i2_name[I] | column of per-atom array |
|
||||||
+--------+---------------+------------------------------------------+
|
+--------+---------------+------------------------------------------+
|
||||||
|
|
||||||
@ -1222,15 +1227,23 @@ table:
|
|||||||
|
|
||||||
+--------+------------+------------------------------------------+
|
+--------+------------+------------------------------------------+
|
||||||
| equal | c_ID | global scalar |
|
| equal | c_ID | global scalar |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| equal | c_ID[I] | element of global vector |
|
| equal | c_ID[I] | element of global vector |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| equal | c_ID[I][J] | element of global array |
|
| equal | c_ID[I][J] | element of global array |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| equal | C_ID[I] | element of per-atom vector (I = atom ID) |
|
| equal | C_ID[I] | element of per-atom vector (I = atom ID) |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| equal | C_ID[I][J] | element of per-atom array (I = atom ID) |
|
| equal | C_ID[I][J] | element of per-atom array (I = atom ID) |
|
||||||
+--------+------------+------------------------------------------+
|
+--------+------------+------------------------------------------+
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| vector | c_ID | global vector |
|
| vector | c_ID | global vector |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| vector | c_ID[I] | column of global array |
|
| vector | c_ID[I] | column of global array |
|
||||||
+--------+------------+------------------------------------------+
|
+--------+------------+------------------------------------------+
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| atom | c_ID | per-atom vector |
|
| atom | c_ID | per-atom vector |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| atom | c_ID[I] | column of per-atom array |
|
| atom | c_ID[I] | column of per-atom array |
|
||||||
+--------+------------+------------------------------------------+
|
+--------+------------+------------------------------------------+
|
||||||
|
|
||||||
@ -1286,15 +1299,23 @@ and atom-style variables are listed in the following table:
|
|||||||
|
|
||||||
+--------+------------+------------------------------------------+
|
+--------+------------+------------------------------------------+
|
||||||
| equal | f_ID | global scalar |
|
| equal | f_ID | global scalar |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| equal | f_ID[I] | element of global vector |
|
| equal | f_ID[I] | element of global vector |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| equal | f_ID[I][J] | element of global array |
|
| equal | f_ID[I][J] | element of global array |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| equal | F_ID[I] | element of per-atom vector (I = atom ID) |
|
| equal | F_ID[I] | element of per-atom vector (I = atom ID) |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| equal | F_ID[I][J] | element of per-atom array (I = atom ID) |
|
| equal | F_ID[I][J] | element of per-atom array (I = atom ID) |
|
||||||
+--------+------------+------------------------------------------+
|
+--------+------------+------------------------------------------+
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| vector | f_ID | global vector |
|
| vector | f_ID | global vector |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| vector | f_ID[I] | column of global array |
|
| vector | f_ID[I] | column of global array |
|
||||||
+--------+------------+------------------------------------------+
|
+--------+------------+------------------------------------------+
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| atom | f_ID | per-atom vector |
|
| atom | f_ID | per-atom vector |
|
||||||
|
+--------+------------+------------------------------------------+
|
||||||
| atom | f_ID[I] | column of per-atom array |
|
| atom | f_ID[I] | column of per-atom array |
|
||||||
+--------+------------+------------------------------------------+
|
+--------+------------+------------------------------------------+
|
||||||
|
|
||||||
@ -1365,17 +1386,27 @@ per-atom vector.
|
|||||||
|
|
||||||
+--------+-----------+-----------------------------------------------------------------------------------+
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| equal | v_name | global scalar from an equal-style variable |
|
| equal | v_name | global scalar from an equal-style variable |
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| equal | v_name[I] | element of global vector from a vector-style variable |
|
| equal | v_name[I] | element of global vector from a vector-style variable |
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| equal | v_name[I] | element of per-atom vector (I = atom ID) from an atom- or atomfile-style variable |
|
| equal | v_name[I] | element of per-atom vector (I = atom ID) from an atom- or atomfile-style variable |
|
||||||
+--------+-----------+-----------------------------------------------------------------------------------+
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| vector | v_name | global scalar from an equal-style variable |
|
| vector | v_name | global scalar from an equal-style variable |
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| vector | v_name | global vector from a vector-style variable |
|
| vector | v_name | global vector from a vector-style variable |
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| vector | v_name[I] | element of global vector from a vector-style variable |
|
| vector | v_name[I] | element of global vector from a vector-style variable |
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| vector | v_name[I] | element of per-atom vector (I = atom ID) from an atom- or atomfile-style variable |
|
| vector | v_name[I] | element of per-atom vector (I = atom ID) from an atom- or atomfile-style variable |
|
||||||
+--------+-----------+-----------------------------------------------------------------------------------+
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| atom | v_name | global scalar from an equal-style variable |
|
| atom | v_name | global scalar from an equal-style variable |
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| atom | v_name | per-atom vector from an atom-style or atomfile-style variable |
|
| atom | v_name | per-atom vector from an atom-style or atomfile-style variable |
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| atom | v_name[I] | element of global vector from a vector-style variable |
|
| atom | v_name[I] | element of global vector from a vector-style variable |
|
||||||
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
| atom | v_name[I] | element of per-atom vector (I = atom ID) from an atom- or atomfile-style variable |
|
| atom | v_name[I] | element of per-atom vector (I = atom ID) from an atom- or atomfile-style variable |
|
||||||
+--------+-----------+-----------------------------------------------------------------------------------+
|
+--------+-----------+-----------------------------------------------------------------------------------+
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
//#define ASYNC_DEVICE_COPY
|
//#define ASYNC_DEVICE_COPY
|
||||||
|
|
||||||
|
#if 0
|
||||||
#if !defined(USE_OPENCL) && !defined(USE_HIP)
|
#if !defined(USE_OPENCL) && !defined(USE_HIP)
|
||||||
// temporary workaround for int2 also defined in cufft
|
// temporary workaround for int2 also defined in cufft
|
||||||
#ifdef int2
|
#ifdef int2
|
||||||
@ -40,6 +41,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "cufft.h"
|
#include "cufft.h"
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace LAMMPS_AL {
|
namespace LAMMPS_AL {
|
||||||
|
|
||||||
@ -313,10 +315,11 @@ class BaseAmoeba {
|
|||||||
virtual int fphi_mpole();
|
virtual int fphi_mpole();
|
||||||
virtual int polar_real(const int eflag, const int vflag) = 0;
|
virtual int polar_real(const int eflag, const int vflag) = 0;
|
||||||
|
|
||||||
|
#if 0
|
||||||
#if !defined(USE_OPENCL) && !defined(USE_HIP)
|
#if !defined(USE_OPENCL) && !defined(USE_HIP)
|
||||||
cufftHandle plan;
|
cufftHandle plan;
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
bool fft_plan_created;
|
bool fft_plan_created;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -99,10 +99,9 @@ int BodyRoundedPolyhedron::nedges(AtomVecBody::Bonus *bonus)
|
|||||||
{
|
{
|
||||||
int nvertices = bonus->ivalue[0];
|
int nvertices = bonus->ivalue[0];
|
||||||
int nedges = bonus->ivalue[1];
|
int nedges = bonus->ivalue[1];
|
||||||
//int nfaces = bonus->ivalue[2];
|
|
||||||
if (nvertices == 1) return 0;
|
if (nvertices == 1) return 0;
|
||||||
else if (nvertices == 2) return 1;
|
else if (nvertices == 2) return 1;
|
||||||
return nedges; //(nvertices+nfaces-2); // Euler formula: V-E+F=2
|
return nedges;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -116,6 +115,9 @@ double *BodyRoundedPolyhedron::edges(AtomVecBody::Bonus *bonus)
|
|||||||
|
|
||||||
int BodyRoundedPolyhedron::nfaces(AtomVecBody::Bonus *bonus)
|
int BodyRoundedPolyhedron::nfaces(AtomVecBody::Bonus *bonus)
|
||||||
{
|
{
|
||||||
|
int nvertices = bonus->ivalue[0];
|
||||||
|
if (nvertices < 3) return 0;
|
||||||
|
|
||||||
return bonus->ivalue[2];
|
return bonus->ivalue[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -415,17 +415,14 @@ void PairBodyRoundedPolygon::init_style()
|
|||||||
if (!avec)
|
if (!avec)
|
||||||
error->all(FLERR,"Pair body/rounded/polygon requires atom style body");
|
error->all(FLERR,"Pair body/rounded/polygon requires atom style body");
|
||||||
if (strcmp(avec->bptr->style,"rounded/polygon") != 0)
|
if (strcmp(avec->bptr->style,"rounded/polygon") != 0)
|
||||||
error->all(FLERR,"Pair body/rounded/polygon requires "
|
error->all(FLERR,"Pair body/rounded/polygon requires body style rounded/polygon");
|
||||||
"body style rounded/polygon");
|
|
||||||
bptr = dynamic_cast<BodyRoundedPolygon *>(avec->bptr);
|
bptr = dynamic_cast<BodyRoundedPolygon *>(avec->bptr);
|
||||||
|
|
||||||
if (force->newton_pair == 0)
|
if (force->newton_pair == 0)
|
||||||
error->all(FLERR,"Pair style body/rounded/polygon requires "
|
error->all(FLERR,"Pair style body/rounded/polygon requires newton pair on");
|
||||||
"newton pair on");
|
|
||||||
|
|
||||||
if (comm->ghost_velocity == 0)
|
if (comm->ghost_velocity == 0)
|
||||||
error->all(FLERR,"Pair body/rounded/polygon requires "
|
error->all(FLERR,"Pair body/rounded/polygon requires ghost atoms store velocity");
|
||||||
"ghost atoms store velocity");
|
|
||||||
|
|
||||||
neighbor->add_request(this);
|
neighbor->add_request(this);
|
||||||
|
|
||||||
@ -463,27 +460,24 @@ void PairBodyRoundedPolygon::init_style()
|
|||||||
for (i = 1; i <= ntypes; i++)
|
for (i = 1; i <= ntypes; i++)
|
||||||
maxerad[i] = merad[i] = 0;
|
maxerad[i] = merad[i] = 0;
|
||||||
|
|
||||||
int ipour;
|
Fix *fixpour = nullptr;
|
||||||
for (ipour = 0; ipour < modify->nfix; ipour++)
|
auto pours = modify->get_fix_by_style("^pour");
|
||||||
if (strcmp(modify->fix[ipour]->style,"pour") == 0) break;
|
if (pours.size() > 0) fixpour = pours[0];
|
||||||
if (ipour == modify->nfix) ipour = -1;
|
|
||||||
|
Fix *fixdep = nullptr;
|
||||||
|
auto deps = modify->get_fix_by_style("^deposit");
|
||||||
|
if (deps.size() > 0) fixdep = deps[0];
|
||||||
|
|
||||||
int idep;
|
|
||||||
for (idep = 0; idep < modify->nfix; idep++)
|
|
||||||
if (strcmp(modify->fix[idep]->style,"deposit") == 0) break;
|
|
||||||
if (idep == modify->nfix) idep = -1;
|
|
||||||
|
|
||||||
for (i = 1; i <= ntypes; i++) {
|
for (i = 1; i <= ntypes; i++) {
|
||||||
merad[i] = 0.0;
|
merad[i] = 0.0;
|
||||||
if (ipour >= 0) {
|
if (fixpour) {
|
||||||
itype = i;
|
itype = i;
|
||||||
merad[i] =
|
merad[i] = *((double *) fixpour->extract("radius",itype));
|
||||||
*((double *) modify->fix[ipour]->extract("radius",itype));
|
|
||||||
}
|
}
|
||||||
if (idep >= 0) {
|
if (fixdep) {
|
||||||
itype = i;
|
itype = i;
|
||||||
merad[i] =
|
merad[i] = *((double *) fixdep->extract("radius",itype));
|
||||||
*((double *) modify->fix[idep]->extract("radius",itype));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -570,8 +564,7 @@ void PairBodyRoundedPolygon::body2space(int i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((body_num_edges > 0) && (edge_ends == nullptr))
|
if ((body_num_edges > 0) && (edge_ends == nullptr))
|
||||||
error->one(FLERR,"Inconsistent edge data for body of atom {}",
|
error->one(FLERR,"Inconsistent edge data for body of atom {}", atom->tag[i]);
|
||||||
atom->tag[i]);
|
|
||||||
|
|
||||||
for (int m = 0; m < body_num_edges; m++) {
|
for (int m = 0; m < body_num_edges; m++) {
|
||||||
edge[nedge][0] = static_cast<int>(edge_ends[2*m+0]);
|
edge[nedge][0] = static_cast<int>(edge_ends[2*m+0]);
|
||||||
|
|||||||
@ -222,8 +222,7 @@ void PairBodyRoundedPolyhedron::compute(int eflag, int vflag)
|
|||||||
// sphere-sphere interaction
|
// sphere-sphere interaction
|
||||||
|
|
||||||
if (npi == 1 && npj == 1) {
|
if (npi == 1 && npj == 1) {
|
||||||
sphere_against_sphere(i, j, itype, jtype, delx, dely, delz,
|
sphere_against_sphere(i, j, itype, jtype, delx, dely, delz, rsq, v, f, evflag);
|
||||||
rsq, v, f, evflag);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,20 +390,16 @@ void PairBodyRoundedPolyhedron::coeff(int narg, char **arg)
|
|||||||
void PairBodyRoundedPolyhedron::init_style()
|
void PairBodyRoundedPolyhedron::init_style()
|
||||||
{
|
{
|
||||||
avec = dynamic_cast<AtomVecBody *>(atom->style_match("body"));
|
avec = dynamic_cast<AtomVecBody *>(atom->style_match("body"));
|
||||||
if (!avec) error->all(FLERR,"Pair body/rounded/polyhedron requires "
|
if (!avec) error->all(FLERR,"Pair body/rounded/polyhedron requires atom style body");
|
||||||
"atom style body");
|
|
||||||
if (strcmp(avec->bptr->style,"rounded/polyhedron") != 0)
|
if (strcmp(avec->bptr->style,"rounded/polyhedron") != 0)
|
||||||
error->all(FLERR,"Pair body/rounded/polyhedron requires "
|
error->all(FLERR,"Pair body/rounded/polyhedron requires body style rounded/polyhedron");
|
||||||
"body style rounded/polyhedron");
|
|
||||||
bptr = dynamic_cast<BodyRoundedPolyhedron *>(avec->bptr);
|
bptr = dynamic_cast<BodyRoundedPolyhedron *>(avec->bptr);
|
||||||
|
|
||||||
if (force->newton_pair == 0)
|
if (force->newton_pair == 0)
|
||||||
error->all(FLERR,"Pair style body/rounded/polyhedron requires "
|
error->all(FLERR,"Pair style body/rounded/polyhedron requires newton pair on");
|
||||||
"newton pair on");
|
|
||||||
|
|
||||||
if (comm->ghost_velocity == 0)
|
if (comm->ghost_velocity == 0)
|
||||||
error->all(FLERR,"Pair body/rounded/polyhedron requires "
|
error->all(FLERR,"Pair body/rounded/polyhedron requires ghost atoms store velocity");
|
||||||
"ghost atoms store velocity");
|
|
||||||
|
|
||||||
neighbor->add_request(this);
|
neighbor->add_request(this);
|
||||||
|
|
||||||
@ -446,27 +441,23 @@ void PairBodyRoundedPolyhedron::init_style()
|
|||||||
for (i = 1; i <= ntypes; i++)
|
for (i = 1; i <= ntypes; i++)
|
||||||
maxerad[i] = merad[i] = 0;
|
maxerad[i] = merad[i] = 0;
|
||||||
|
|
||||||
int ipour;
|
Fix *fixpour = nullptr;
|
||||||
for (ipour = 0; ipour < modify->nfix; ipour++)
|
auto pours = modify->get_fix_by_style("^pour");
|
||||||
if (strcmp(modify->fix[ipour]->style,"pour") == 0) break;
|
if (pours.size() > 0) fixpour = pours[0];
|
||||||
if (ipour == modify->nfix) ipour = -1;
|
|
||||||
|
|
||||||
int idep;
|
Fix *fixdep = nullptr;
|
||||||
for (idep = 0; idep < modify->nfix; idep++)
|
auto deps = modify->get_fix_by_style("^deposit");
|
||||||
if (strcmp(modify->fix[idep]->style,"deposit") == 0) break;
|
if (deps.size() > 0) fixdep = deps[0];
|
||||||
if (idep == modify->nfix) idep = -1;
|
|
||||||
|
|
||||||
for (i = 1; i <= ntypes; i++) {
|
for (i = 1; i <= ntypes; i++) {
|
||||||
merad[i] = 0.0;
|
merad[i] = 0.0;
|
||||||
if (ipour >= 0) {
|
if (fixpour) {
|
||||||
itype = i;
|
itype = i;
|
||||||
merad[i] =
|
merad[i] = *((double *) fixpour->extract("radius",itype));
|
||||||
*((double *) modify->fix[ipour]->extract("radius",itype));
|
|
||||||
}
|
}
|
||||||
if (idep >= 0) {
|
if (fixdep) {
|
||||||
itype = i;
|
itype = i;
|
||||||
merad[i] =
|
merad[i] = *((double *) fixdep->extract("radius",itype));
|
||||||
*((double *) modify->fix[idep]->extract("radius",itype));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -558,8 +549,7 @@ void PairBodyRoundedPolyhedron::body2space(int i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((body_num_edges > 0) && (edge_ends == nullptr))
|
if ((body_num_edges > 0) && (edge_ends == nullptr))
|
||||||
error->one(FLERR,"Inconsistent edge data for body of atom {}",
|
error->one(FLERR,"Inconsistent edge data for body of atom {}", atom->tag[i]);
|
||||||
atom->tag[i]);
|
|
||||||
|
|
||||||
for (int m = 0; m < body_num_edges; m++) {
|
for (int m = 0; m < body_num_edges; m++) {
|
||||||
edge[nedge][0] = static_cast<int>(edge_ends[2*m+0]);
|
edge[nedge][0] = static_cast<int>(edge_ends[2*m+0]);
|
||||||
@ -585,8 +575,7 @@ void PairBodyRoundedPolyhedron::body2space(int i)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((body_num_faces > 0) && (face_pts == nullptr))
|
if ((body_num_faces > 0) && (face_pts == nullptr))
|
||||||
error->one(FLERR,"Inconsistent face data for body of atom {}",
|
error->one(FLERR,"Inconsistent face data for body of atom {}", atom->tag[i]);
|
||||||
atom->tag[i]);
|
|
||||||
|
|
||||||
for (int m = 0; m < body_num_faces; m++) {
|
for (int m = 0; m < body_num_faces; m++) {
|
||||||
for (int k = 0; k < MAX_FACE_SIZE; k++)
|
for (int k = 0; k < MAX_FACE_SIZE; k++)
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
Contributing authors: Naveen Michaud-Agrawal (Johns Hopkins U)
|
Contributing authors: Naveen Michaud-Agrawal (Johns Hopkins U)
|
||||||
open-source XDR routines from
|
Open Source XDR based I/O routines from
|
||||||
Frans van Hoesel (https://www.rug.nl/staff/f.h.j.van.hoesel/)
|
Frans van Hoesel (https://www.rug.nl/staff/f.h.j.van.hoesel/)
|
||||||
are included in this file
|
are included in this file
|
||||||
Axel Kohlmeyer (Temple U)
|
Axel Kohlmeyer (Temple U)
|
||||||
@ -35,27 +35,29 @@
|
|||||||
#include "output.h"
|
#include "output.h"
|
||||||
#include "update.h"
|
#include "update.h"
|
||||||
|
|
||||||
|
#include "xdr_compat.h"
|
||||||
|
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
#define EPS 1e-5
|
static constexpr double EPS = 1.0e-5;
|
||||||
#define XTC_MAGIC 1995
|
static constexpr int XTC_MAGIC = 1995;
|
||||||
|
|
||||||
#define MYMIN(a,b) ((a) < (b) ? (a) : (b))
|
#define MYMIN(a,b) ((a) < (b) ? (a) : (b))
|
||||||
#define MYMAX(a,b) ((a) > (b) ? (a) : (b))
|
#define MYMAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
|
|
||||||
int xdropen(XDR *, const char *, const char *);
|
static int xdropen(XDR *, const char *, const char *);
|
||||||
int xdrclose(XDR *);
|
static int xdrclose(XDR *);
|
||||||
void xdrfreebuf();
|
static void xdrfreebuf();
|
||||||
int xdr3dfcoord(XDR *, float *, int *, float *);
|
static int xdr3dfcoord(XDR *, float *, int *, float *);
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
DumpXTC::DumpXTC(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg),
|
DumpXTC::DumpXTC(LAMMPS *lmp, int narg, char **arg)
|
||||||
coords(nullptr)
|
: Dump(lmp, narg, arg), coords(nullptr), xd(nullptr)
|
||||||
{
|
{
|
||||||
if (narg != 5) error->all(FLERR,"Illegal dump xtc command");
|
if (narg != 5) error->all(FLERR,"Illegal dump xtc command");
|
||||||
if (binary || compressed || multifile || multiproc)
|
if (binary || compressed || multifile || multiproc)
|
||||||
@ -68,6 +70,7 @@ DumpXTC::DumpXTC(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg),
|
|||||||
flush_flag = 0;
|
flush_flag = 0;
|
||||||
unwrap_flag = 0;
|
unwrap_flag = 0;
|
||||||
precision = 1000.0;
|
precision = 1000.0;
|
||||||
|
xd = new XDR;
|
||||||
|
|
||||||
// allocate global array for atom coords
|
// allocate global array for atom coords
|
||||||
|
|
||||||
@ -105,9 +108,10 @@ DumpXTC::~DumpXTC()
|
|||||||
memory->destroy(coords);
|
memory->destroy(coords);
|
||||||
|
|
||||||
if (me == 0) {
|
if (me == 0) {
|
||||||
xdrclose(&xd);
|
xdrclose(xd);
|
||||||
xdrfreebuf();
|
xdrfreebuf();
|
||||||
}
|
}
|
||||||
|
delete xd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -150,7 +154,8 @@ void DumpXTC::openfile()
|
|||||||
|
|
||||||
fp = nullptr;
|
fp = nullptr;
|
||||||
if (me == 0)
|
if (me == 0)
|
||||||
if (xdropen(&xd,filename,"w") == 0) error->one(FLERR,"Cannot open dump file");
|
if (xdropen(xd,filename,"w") == 0)
|
||||||
|
error->one(FLERR,"Cannot open XTC format dump file {}: {}", filename, utils::getsyserror());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
@ -176,11 +181,11 @@ void DumpXTC::write_header(bigint nbig)
|
|||||||
if (me != 0) return;
|
if (me != 0) return;
|
||||||
|
|
||||||
int tmp = XTC_MAGIC;
|
int tmp = XTC_MAGIC;
|
||||||
xdr_int(&xd,&tmp);
|
xdr_int(xd,&tmp);
|
||||||
xdr_int(&xd,&n);
|
xdr_int(xd,&n);
|
||||||
xdr_int(&xd,&ntimestep);
|
xdr_int(xd,&ntimestep);
|
||||||
float time_value = ntimestep * tfactor * update->dt;
|
float time_value = ntimestep * tfactor * update->dt;
|
||||||
xdr_float(&xd,&time_value);
|
xdr_float(xd,&time_value);
|
||||||
|
|
||||||
// cell basis vectors
|
// cell basis vectors
|
||||||
if (domain->triclinic) {
|
if (domain->triclinic) {
|
||||||
@ -192,18 +197,18 @@ void DumpXTC::write_header(bigint nbig)
|
|||||||
float xz = sfactor * domain->xz;
|
float xz = sfactor * domain->xz;
|
||||||
float yz = sfactor * domain->yz;
|
float yz = sfactor * domain->yz;
|
||||||
|
|
||||||
xdr_float(&xd,&xdim); xdr_float(&xd,&zero); xdr_float(&xd,&zero);
|
xdr_float(xd,&xdim); xdr_float(xd,&zero); xdr_float(xd,&zero);
|
||||||
xdr_float(&xd,&xy ); xdr_float(&xd,&ydim); xdr_float(&xd,&zero);
|
xdr_float(xd,&xy ); xdr_float(xd,&ydim); xdr_float(xd,&zero);
|
||||||
xdr_float(&xd,&xz ); xdr_float(&xd,&yz ); xdr_float(&xd,&zdim);
|
xdr_float(xd,&xz ); xdr_float(xd,&yz ); xdr_float(xd,&zdim);
|
||||||
} else {
|
} else {
|
||||||
float zero = 0.0;
|
float zero = 0.0;
|
||||||
float xdim = sfactor * (domain->boxhi[0] - domain->boxlo[0]);
|
float xdim = sfactor * (domain->boxhi[0] - domain->boxlo[0]);
|
||||||
float ydim = sfactor * (domain->boxhi[1] - domain->boxlo[1]);
|
float ydim = sfactor * (domain->boxhi[1] - domain->boxlo[1]);
|
||||||
float zdim = sfactor * (domain->boxhi[2] - domain->boxlo[2]);
|
float zdim = sfactor * (domain->boxhi[2] - domain->boxlo[2]);
|
||||||
|
|
||||||
xdr_float(&xd,&xdim); xdr_float(&xd,&zero); xdr_float(&xd,&zero);
|
xdr_float(xd,&xdim); xdr_float(xd,&zero); xdr_float(xd,&zero);
|
||||||
xdr_float(&xd,&zero); xdr_float(&xd,&ydim); xdr_float(&xd,&zero);
|
xdr_float(xd,&zero); xdr_float(xd,&ydim); xdr_float(xd,&zero);
|
||||||
xdr_float(&xd,&zero); xdr_float(&xd,&zero); xdr_float(&xd,&zdim);
|
xdr_float(xd,&zero); xdr_float(xd,&zero); xdr_float(xd,&zdim);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,7 +333,7 @@ double DumpXTC::memory_usage()
|
|||||||
|
|
||||||
void DumpXTC::write_frame()
|
void DumpXTC::write_frame()
|
||||||
{
|
{
|
||||||
xdr3dfcoord(&xd,coords,&natoms,&precision);
|
xdr3dfcoord(xd,coords,&natoms,&precision);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
@ -406,7 +411,7 @@ static int magicints[] = {
|
|||||||
|
|
|
|
||||||
| xdropen - open xdr file
|
| xdropen - open xdr file
|
||||||
|
|
|
|
||||||
| This versions differs from xdrstdio_create, because I need to know
|
| This version differs from xdrstdio_create, because I need to know
|
||||||
| the state of the file (read or write) so I can use xdr3dfcoord
|
| the state of the file (read or write) so I can use xdr3dfcoord
|
||||||
| in eigther read or write mode, and the file descriptor
|
| in eigther read or write mode, and the file descriptor
|
||||||
| so I can close the file (something xdr_destroy doesn't do).
|
| so I can close the file (something xdr_destroy doesn't do).
|
||||||
@ -1048,7 +1053,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision)
|
|||||||
}
|
}
|
||||||
if (buf[1] != 0) buf[0]++;
|
if (buf[1] != 0) buf[0]++;
|
||||||
xdr_int(xdrs, &(buf[0])); /* buf[0] holds the length in bytes */
|
xdr_int(xdrs, &(buf[0])); /* buf[0] holds the length in bytes */
|
||||||
return errval * (xdr_opaque(xdrs, (caddr_t)&(buf[3]), (u_int)buf[0]));
|
return errval * (xdr_opaque(xdrs, (char *)&(buf[3]), (unsigned int)buf[0]));
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* xdrs is open for reading */
|
/* xdrs is open for reading */
|
||||||
@ -1129,7 +1134,7 @@ int xdr3dfcoord(XDR *xdrs, float *fp, int *size, float *precision)
|
|||||||
|
|
||||||
if (xdr_int(xdrs, &(buf[0])) == 0)
|
if (xdr_int(xdrs, &(buf[0])) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
if (xdr_opaque(xdrs, (caddr_t)&(buf[3]), (u_int)buf[0]) == 0)
|
if (xdr_opaque(xdrs, (char *)&(buf[3]), (unsigned int)buf[0]) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
buf[0] = buf[1] = buf[2] = 0;
|
buf[0] = buf[1] = buf[2] = 0;
|
||||||
|
|
||||||
|
|||||||
@ -21,8 +21,8 @@ DumpStyle(xtc,DumpXTC);
|
|||||||
#define LMP_DUMP_XTC_H
|
#define LMP_DUMP_XTC_H
|
||||||
|
|
||||||
#include "dump.h"
|
#include "dump.h"
|
||||||
#include "xdr_compat.h"
|
|
||||||
|
|
||||||
|
struct XDR;
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
|
||||||
class DumpXTC : public Dump {
|
class DumpXTC : public Dump {
|
||||||
@ -37,7 +37,7 @@ class DumpXTC : public Dump {
|
|||||||
float precision; // user-adjustable precision setting
|
float precision; // user-adjustable precision setting
|
||||||
float *coords;
|
float *coords;
|
||||||
double sfactor, tfactor; // scaling factors for positions and time unit
|
double sfactor, tfactor; // scaling factors for positions and time unit
|
||||||
XDR xd;
|
XDR *xd;
|
||||||
|
|
||||||
void init_style() override;
|
void init_style() override;
|
||||||
int modify_param(int, char **) override;
|
int modify_param(int, char **) override;
|
||||||
|
|||||||
@ -1,54 +1,63 @@
|
|||||||
// clang-format off
|
|
||||||
#include "xdr_compat.h"
|
#include "xdr_compat.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
/* This file is needed for systems, that do not provide XDR support
|
/*
|
||||||
* in their system libraries. It was written for windows, but will
|
* This file contains an implementation of the Sun External Data Representation (XDR)
|
||||||
* most probably work on other platforms too. better make sure you
|
* routines. They have been adapted specifically for the use with the LAMMPS xtc dump
|
||||||
* test that the xtc files produced are ok before using it.
|
* style to produce compressed trajectory files in the Gromacs XTC format.
|
||||||
*
|
*
|
||||||
* It is also needed on BG/L and Cray XT3/XT4 as we don't have
|
* The XDR sources are avaiable under the BSD 3-clause license for example in
|
||||||
* XDR support in the lightweight kernel runtimes either.
|
* the MIT Kerberos 5 distribution with the following copyright notice and license.
|
||||||
*
|
*
|
||||||
* This file contains the definitions for Sun External Data
|
* @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC
|
||||||
* Representation (XDR) headers and routines.
|
|
||||||
*
|
*
|
||||||
* Although the rest of LAMPPS is GPL, you can copy and use the XDR
|
* Copyright (c) 2010, Oracle America, Inc.
|
||||||
* routines in any way you want as long as you obey Sun's license:
|
|
||||||
*
|
*
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
* All rights reserved.
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
*
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
*
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
* * Redistributions of source code must retain the above copyright
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* modification or enhancement.
|
|
||||||
*
|
*
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
* notice, this list of conditions and the following disclaimer in
|
||||||
* OR ANY PART THEREOF.
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
*
|
*
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
* * Neither the name of the "Oracle America, Inc." nor the names of
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
* its contributors may be used to endorse or promote products
|
||||||
* Sun has been advised of the possibility of such damages.
|
* derived from this software without specific prior written permission.
|
||||||
*
|
*
|
||||||
* Sun Microsystems, Inc.
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
* 2550 Garcia Avenue
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
* Mountain View, California 94043
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef FALSE
|
||||||
|
#define FALSE (0)
|
||||||
|
#endif
|
||||||
|
#ifndef TRUE
|
||||||
|
#define TRUE (1)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define BYTES_PER_XDR_UNIT (4)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* for unit alignment
|
* for unit alignment
|
||||||
*/
|
*/
|
||||||
@ -58,19 +67,18 @@ static xdr_uint32_t xdr_swapbytes(xdr_uint32_t x)
|
|||||||
{
|
{
|
||||||
xdr_uint32_t y;
|
xdr_uint32_t y;
|
||||||
int i;
|
int i;
|
||||||
char *px=(char *)&x;
|
char *px = (char *) &x;
|
||||||
char *py=(char *)&y;
|
char *py = (char *) &y;
|
||||||
|
|
||||||
for (i=0;i<4;i++)
|
for (i = 0; i < 4; i++) py[i] = px[3 - i];
|
||||||
py[i]=px[3-i];
|
|
||||||
|
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static xdr_uint32_t xdr_htonl(xdr_uint32_t x)
|
static xdr_uint32_t xdr_htonl(xdr_uint32_t x)
|
||||||
{
|
{
|
||||||
short s=0x0F00;
|
short s = 0x0F00;
|
||||||
if (*((char *)&s)==(char)0x0F) {
|
if (*((char *) &s) == (char) 0x0F) {
|
||||||
/* bigendian, do nothing */
|
/* bigendian, do nothing */
|
||||||
return x;
|
return x;
|
||||||
} else {
|
} else {
|
||||||
@ -81,8 +89,8 @@ static xdr_uint32_t xdr_htonl(xdr_uint32_t x)
|
|||||||
|
|
||||||
static xdr_uint32_t xdr_ntohl(xdr_uint32_t x)
|
static xdr_uint32_t xdr_ntohl(xdr_uint32_t x)
|
||||||
{
|
{
|
||||||
short s=0x0F00;
|
short s = 0x0F00;
|
||||||
if (*((char *)&s)==(char)0x0F) {
|
if (*((char *) &s) == (char) 0x0F) {
|
||||||
/* bigendian, do nothing */
|
/* bigendian, do nothing */
|
||||||
return x;
|
return x;
|
||||||
} else {
|
} else {
|
||||||
@ -91,221 +99,39 @@ static xdr_uint32_t xdr_ntohl(xdr_uint32_t x)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free a data structure using XDR
|
|
||||||
* Not a filter, but a convenient utility nonetheless
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
xdr_free (xdrproc_t proc, char *objp)
|
|
||||||
{
|
|
||||||
XDR x;
|
|
||||||
|
|
||||||
x.x_op = XDR_FREE;
|
|
||||||
(*proc) (&x, objp);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XDR nothing
|
|
||||||
*/
|
|
||||||
bool_t
|
|
||||||
xdr_void (void)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XDR integers
|
* XDR integers
|
||||||
*/
|
*/
|
||||||
bool_t
|
bool_t xdr_int(XDR *xdrs, int *ip)
|
||||||
xdr_int (XDR *xdrs, int *ip)
|
|
||||||
{
|
{
|
||||||
xdr_int32_t l;
|
xdr_int32_t l;
|
||||||
|
|
||||||
switch (xdrs->x_op)
|
switch (xdrs->x_op) {
|
||||||
{
|
|
||||||
case XDR_ENCODE:
|
case XDR_ENCODE:
|
||||||
l = (xdr_int32_t) (*ip);
|
l = (xdr_int32_t) (*ip);
|
||||||
return xdr_putint32 (xdrs, &l);
|
return xdr_putint32(xdrs, &l);
|
||||||
|
break;
|
||||||
|
|
||||||
case XDR_DECODE:
|
case XDR_DECODE:
|
||||||
if (!xdr_getint32 (xdrs, &l))
|
if (!xdr_getint32(xdrs, &l)) return FALSE;
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*ip = (int) l;
|
*ip = (int) l;
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
|
||||||
case XDR_FREE:
|
case XDR_FREE:
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XDR unsigned integers
|
|
||||||
*/
|
|
||||||
bool_t
|
|
||||||
xdr_u_int (XDR *xdrs, unsigned int *up)
|
|
||||||
{
|
|
||||||
xdr_uint32_t l;
|
|
||||||
|
|
||||||
switch (xdrs->x_op)
|
|
||||||
{
|
|
||||||
case XDR_ENCODE:
|
|
||||||
l = (xdr_uint32_t) (*up);
|
|
||||||
return xdr_putuint32 (xdrs, &l);
|
|
||||||
|
|
||||||
case XDR_DECODE:
|
|
||||||
if (!xdr_getuint32 (xdrs, &l))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*up = (unsigned int) l;
|
|
||||||
|
|
||||||
case XDR_FREE:
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XDR short integers
|
|
||||||
*/
|
|
||||||
bool_t
|
|
||||||
xdr_short (XDR *xdrs, short *sp)
|
|
||||||
{
|
|
||||||
xdr_int32_t l;
|
|
||||||
|
|
||||||
switch (xdrs->x_op)
|
|
||||||
{
|
|
||||||
case XDR_ENCODE:
|
|
||||||
l = (xdr_int32_t) *sp;
|
|
||||||
return xdr_putint32 (xdrs, &l);
|
|
||||||
|
|
||||||
case XDR_DECODE:
|
|
||||||
if (!xdr_getint32 (xdrs, &l))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*sp = (short) l;
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case XDR_FREE:
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XDR unsigned short integers
|
|
||||||
*/
|
|
||||||
bool_t
|
|
||||||
xdr_u_short (XDR *xdrs, unsigned short *usp)
|
|
||||||
{
|
|
||||||
xdr_uint32_t l;
|
|
||||||
|
|
||||||
switch (xdrs->x_op)
|
|
||||||
{
|
|
||||||
case XDR_ENCODE:
|
|
||||||
l = (xdr_uint32_t) *usp;
|
|
||||||
return xdr_putuint32 (xdrs, &l);
|
|
||||||
|
|
||||||
case XDR_DECODE:
|
|
||||||
if (!xdr_getuint32 (xdrs, &l))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*usp = (unsigned short) l;
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case XDR_FREE:
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XDR a char
|
|
||||||
*/
|
|
||||||
bool_t
|
|
||||||
xdr_char (XDR *xdrs, char *cp)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
i = (*cp);
|
|
||||||
if (!xdr_int (xdrs, &i))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*cp = i;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XDR an unsigned char
|
|
||||||
*/
|
|
||||||
bool_t
|
|
||||||
xdr_u_char (XDR *xdrs, unsigned char *cp)
|
|
||||||
{
|
|
||||||
unsigned int u;
|
|
||||||
|
|
||||||
u = (*cp);
|
|
||||||
if (!xdr_u_int (xdrs, &u))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*cp = u;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XDR booleans
|
|
||||||
*/
|
|
||||||
bool_t
|
|
||||||
xdr_bool (XDR *xdrs, int *bp)
|
|
||||||
{
|
|
||||||
#define XDR_FALSE ((xdr_int32_t) 0)
|
|
||||||
#define XDR_TRUE ((xdr_int32_t) 1)
|
|
||||||
|
|
||||||
xdr_int32_t lb;
|
|
||||||
|
|
||||||
switch (xdrs->x_op)
|
|
||||||
{
|
|
||||||
case XDR_ENCODE:
|
|
||||||
lb = *bp ? XDR_TRUE : XDR_FALSE;
|
|
||||||
return xdr_putint32 (xdrs, &lb);
|
|
||||||
|
|
||||||
case XDR_DECODE:
|
|
||||||
if (!xdr_getint32 (xdrs, &lb))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*bp = (lb == XDR_FALSE) ? FALSE : TRUE;
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case XDR_FREE:
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
#undef XDR_FALSE
|
|
||||||
#undef XDR_TRUE
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XDR opaque data
|
* XDR opaque data
|
||||||
* Allows the specification of a fixed size sequence of opaque bytes.
|
* Allows the specification of a fixed size sequence of opaque bytes.
|
||||||
* cp points to the opaque object and cnt gives the byte length.
|
* cp points to the opaque object and cnt gives the byte length.
|
||||||
*/
|
*/
|
||||||
bool_t
|
bool_t xdr_opaque(XDR *xdrs, char *cp, unsigned int cnt)
|
||||||
xdr_opaque (XDR *xdrs, char *cp, unsigned int cnt)
|
|
||||||
{
|
{
|
||||||
unsigned int rndup;
|
unsigned int rndup;
|
||||||
static char crud[BYTES_PER_XDR_UNIT];
|
static char crud[BYTES_PER_XDR_UNIT];
|
||||||
@ -313,219 +139,61 @@ xdr_opaque (XDR *xdrs, char *cp, unsigned int cnt)
|
|||||||
/*
|
/*
|
||||||
* if no data we are done
|
* if no data we are done
|
||||||
*/
|
*/
|
||||||
if (cnt == 0)
|
if (cnt == 0) return TRUE;
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* round byte count to full xdr units
|
* round byte count to full xdr units
|
||||||
*/
|
*/
|
||||||
rndup = cnt % BYTES_PER_XDR_UNIT;
|
rndup = cnt % BYTES_PER_XDR_UNIT;
|
||||||
if (rndup > 0)
|
if (rndup > 0) rndup = BYTES_PER_XDR_UNIT - rndup;
|
||||||
rndup = BYTES_PER_XDR_UNIT - rndup;
|
|
||||||
|
|
||||||
switch (xdrs->x_op)
|
|
||||||
{
|
|
||||||
case XDR_DECODE:
|
|
||||||
if (!xdr_getbytes (xdrs, cp, cnt))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (rndup == 0)
|
|
||||||
return TRUE;
|
|
||||||
return xdr_getbytes (xdrs, (char *)crud, rndup);
|
|
||||||
|
|
||||||
case XDR_ENCODE:
|
|
||||||
if (!xdr_putbytes (xdrs, cp, cnt))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (rndup == 0)
|
|
||||||
return TRUE;
|
|
||||||
return xdr_putbytes (xdrs, xdr_zero, rndup);
|
|
||||||
|
|
||||||
case XDR_FREE:
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* XDR null terminated ASCII strings
|
|
||||||
* xdr_string deals with "C strings" - arrays of bytes that are
|
|
||||||
* terminated by a nullptr character. The parameter cpp references a
|
|
||||||
* pointer to storage; If the pointer is null, then the necessary
|
|
||||||
* storage is allocated. The last parameter is the max allowed length
|
|
||||||
* of the string as specified by a protocol.
|
|
||||||
*/
|
|
||||||
bool_t
|
|
||||||
xdr_string (XDR *xdrs, char **cpp, unsigned int maxsize)
|
|
||||||
{
|
|
||||||
char *sp = *cpp; /* sp is the actual string pointer */
|
|
||||||
unsigned int size = 0;
|
|
||||||
unsigned int nodesize = 0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* first deal with the length since xdr strings are counted-strings
|
|
||||||
*/
|
|
||||||
switch (xdrs->x_op)
|
|
||||||
{
|
|
||||||
case XDR_FREE:
|
|
||||||
if (sp == nullptr)
|
|
||||||
{
|
|
||||||
return TRUE; /* already free */
|
|
||||||
}
|
|
||||||
/* fall through... */
|
|
||||||
case XDR_ENCODE:
|
|
||||||
if (sp == nullptr)
|
|
||||||
return FALSE;
|
|
||||||
size = strlen (sp);
|
|
||||||
break;
|
|
||||||
case XDR_DECODE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!xdr_u_int (xdrs, &size))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (size > maxsize)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
nodesize = size + 1;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* now deal with the actual bytes
|
|
||||||
*/
|
|
||||||
switch (xdrs->x_op)
|
|
||||||
{
|
|
||||||
case XDR_DECODE:
|
|
||||||
if (nodesize == 0)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
if (sp == nullptr)
|
|
||||||
*cpp = sp = (char *) malloc (nodesize);
|
|
||||||
if (sp == nullptr)
|
|
||||||
{
|
|
||||||
(void) fputs ("xdr_string: out of memory\n", stderr);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
sp[size] = 0;
|
|
||||||
/* fall into ... */
|
|
||||||
|
|
||||||
case XDR_ENCODE:
|
|
||||||
return xdr_opaque (xdrs, sp, size);
|
|
||||||
|
|
||||||
case XDR_FREE:
|
|
||||||
free (sp);
|
|
||||||
*cpp = nullptr;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Floating-point stuff */
|
|
||||||
|
|
||||||
bool_t
|
|
||||||
xdr_float(XDR *xdrs, float *fp)
|
|
||||||
{
|
|
||||||
xdr_int32_t tmp;
|
|
||||||
|
|
||||||
switch (xdrs->x_op) {
|
|
||||||
|
|
||||||
case XDR_ENCODE:
|
|
||||||
tmp = *(xdr_int32_t *)fp;
|
|
||||||
return (xdr_putint32(xdrs, &tmp));
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case XDR_DECODE:
|
|
||||||
if (xdr_getint32(xdrs, &tmp)) {
|
|
||||||
*(xdr_int32_t *)fp = tmp;
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case XDR_FREE:
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
return (FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool_t
|
|
||||||
xdr_double(XDR *xdrs, double *dp)
|
|
||||||
{
|
|
||||||
|
|
||||||
/* Windows and some other systems dont define double-precision
|
|
||||||
* word order in the header files, so unfortunately we have
|
|
||||||
* to calculate it!
|
|
||||||
*/
|
|
||||||
static int LSW=-1; /* Least significant fp word */
|
|
||||||
int *ip;
|
|
||||||
xdr_int32_t tmp[2];
|
|
||||||
|
|
||||||
if (LSW<0) {
|
|
||||||
double x=0.987654321; /* Just a number */
|
|
||||||
|
|
||||||
/* Possible representations in IEEE double precision:
|
|
||||||
* (S=small endian, B=big endian)
|
|
||||||
*
|
|
||||||
* Byte order, Word order, Hex
|
|
||||||
* S S b8 56 0e 3c dd 9a ef 3f
|
|
||||||
* B S 3c 0e 56 b8 3f ef 9a dd
|
|
||||||
* S B dd 9a ef 3f b8 56 0e 3c
|
|
||||||
* B B 3f ef 9a dd 3c 0e 56 b8
|
|
||||||
*/
|
|
||||||
|
|
||||||
unsigned char ix = *((char *)&x);
|
|
||||||
|
|
||||||
if (ix==0xdd || ix==0x3f)
|
|
||||||
LSW=1; /* Big endian word order */
|
|
||||||
else if (ix==0xb8 || ix==0x3c)
|
|
||||||
LSW=0; /* Small endian word order */
|
|
||||||
else { /* Catch strange errors */
|
|
||||||
printf("Error when detecting floating-point word order.\n"
|
|
||||||
"Do you have a non-IEEE system?\n"
|
|
||||||
"If possible, use the XDR libraries provided with your system,\n"
|
|
||||||
"instead of the Gromacs fallback XDR source.\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (xdrs->x_op) {
|
switch (xdrs->x_op) {
|
||||||
|
|
||||||
case XDR_ENCODE:
|
case XDR_DECODE:
|
||||||
ip = (int *)dp;
|
if (!xdr_getbytes(xdrs, cp, cnt)) { return FALSE; }
|
||||||
tmp[0] = ip[!LSW];
|
if (rndup == 0) return TRUE;
|
||||||
tmp[1] = ip[LSW];
|
return xdr_getbytes(xdrs, (char *) crud, rndup);
|
||||||
return (xdr_putint32(xdrs, tmp) &&
|
break;
|
||||||
xdr_putint32(xdrs, tmp+1));
|
|
||||||
|
|
||||||
break;
|
case XDR_ENCODE:
|
||||||
|
if (!xdr_putbytes(xdrs, cp, cnt)) { return FALSE; }
|
||||||
|
if (rndup == 0) return TRUE;
|
||||||
|
return xdr_putbytes(xdrs, xdr_zero, rndup);
|
||||||
|
break;
|
||||||
|
|
||||||
case XDR_DECODE:
|
case XDR_FREE:
|
||||||
ip = (int *)dp;
|
return TRUE;
|
||||||
if (xdr_getint32(xdrs, tmp+!LSW) &&
|
break;
|
||||||
xdr_getint32(xdrs, tmp+LSW)) {
|
|
||||||
ip[0] = tmp[0];
|
|
||||||
ip[1] = tmp[1];
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case XDR_FREE:
|
|
||||||
return (TRUE);
|
|
||||||
}
|
}
|
||||||
return (FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Floating-point stuff */
|
||||||
|
|
||||||
|
bool_t xdr_float(XDR *xdrs, float *fp)
|
||||||
|
{
|
||||||
|
xdr_int32_t tmp;
|
||||||
|
|
||||||
|
switch (xdrs->x_op) {
|
||||||
|
|
||||||
|
case XDR_ENCODE:
|
||||||
|
tmp = *(xdr_int32_t *) fp;
|
||||||
|
return (xdr_putint32(xdrs, &tmp));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XDR_DECODE:
|
||||||
|
if (xdr_getint32(xdrs, &tmp)) {
|
||||||
|
*(xdr_int32_t *) fp = tmp;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case XDR_FREE:
|
||||||
|
return TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Array routines */
|
/* Array routines */
|
||||||
|
|
||||||
@ -539,55 +207,37 @@ xdr_double(XDR *xdrs, double *dp)
|
|||||||
* > elemsize: size of each element
|
* > elemsize: size of each element
|
||||||
* > xdr_elem: routine to XDR each element
|
* > xdr_elem: routine to XDR each element
|
||||||
*/
|
*/
|
||||||
bool_t
|
bool_t xdr_vector(XDR *xdrs, char *basep, unsigned int nelem, unsigned int elemsize,
|
||||||
xdr_vector (XDR *xdrs, char *basep, unsigned int nelem,
|
xdrproc_t xdr_elem)
|
||||||
unsigned int elemsize, xdrproc_t xdr_elem)
|
|
||||||
{
|
{
|
||||||
#define LASTUNSIGNED ((unsigned int)0-1)
|
#define LASTUNSIGNED ((unsigned int) 0 - 1)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
char *elptr;
|
char *elptr;
|
||||||
|
|
||||||
elptr = basep;
|
elptr = basep;
|
||||||
for (i = 0; i < nelem; i++)
|
for (i = 0; i < nelem; i++) {
|
||||||
{
|
if (!(*xdr_elem)(xdrs, elptr, LASTUNSIGNED)) { return FALSE; }
|
||||||
if (!(*xdr_elem) (xdrs, elptr, LASTUNSIGNED))
|
elptr += elemsize;
|
||||||
{
|
}
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
elptr += elemsize;
|
|
||||||
}
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#undef LASTUNSIGNED
|
#undef LASTUNSIGNED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool_t xdrstdio_getbytes(XDR *, char *, unsigned int);
|
||||||
|
static bool_t xdrstdio_putbytes(XDR *, char *, unsigned int);
|
||||||
static bool_t xdrstdio_getbytes (XDR *, char *, unsigned int);
|
static void xdrstdio_destroy(XDR *);
|
||||||
static bool_t xdrstdio_putbytes (XDR *, char *, unsigned int);
|
static bool_t xdrstdio_getint32(XDR *, xdr_int32_t *);
|
||||||
static unsigned int xdrstdio_getpos (XDR *);
|
static bool_t xdrstdio_putint32(XDR *, xdr_int32_t *);
|
||||||
static bool_t xdrstdio_setpos (XDR *, unsigned int);
|
|
||||||
static xdr_int32_t *xdrstdio_inline (XDR *, int);
|
|
||||||
static void xdrstdio_destroy (XDR *);
|
|
||||||
static bool_t xdrstdio_getint32 (XDR *, xdr_int32_t *);
|
|
||||||
static bool_t xdrstdio_putint32 (XDR *, xdr_int32_t *);
|
|
||||||
static bool_t xdrstdio_getuint32 (XDR *, xdr_uint32_t *);
|
|
||||||
static bool_t xdrstdio_putuint32 (XDR *, xdr_uint32_t *);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ops vector for stdio type XDR
|
* Ops vector for stdio type XDR
|
||||||
*/
|
*/
|
||||||
static const struct xdr_ops xdrstdio_ops =
|
static const struct xdr_ops xdrstdio_ops = {
|
||||||
{
|
xdrstdio_getbytes, /* deserialize counted bytes */
|
||||||
xdrstdio_getbytes, /* deserialize counted bytes */
|
xdrstdio_putbytes, /* serialize counted bytes */
|
||||||
xdrstdio_putbytes, /* serialize counted bytes */
|
xdrstdio_destroy, /* destroy stream */
|
||||||
xdrstdio_getpos, /* get offset in the stream */
|
xdrstdio_getint32, /* deserialize a int */
|
||||||
xdrstdio_setpos, /* set offset in the stream */
|
xdrstdio_putint32, /* serialize a int */
|
||||||
xdrstdio_inline, /* prime stream for inline macros */
|
|
||||||
xdrstdio_destroy, /* destroy stream */
|
|
||||||
xdrstdio_getint32, /* deserialize a int */
|
|
||||||
xdrstdio_putint32, /* serialize a int */
|
|
||||||
xdrstdio_getuint32, /* deserialize a int */
|
|
||||||
xdrstdio_putuint32 /* serialize a int */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -595,8 +245,7 @@ static const struct xdr_ops xdrstdio_ops =
|
|||||||
* Sets the xdr stream handle xdrs for use on the stream file.
|
* Sets the xdr stream handle xdrs for use on the stream file.
|
||||||
* Operation flag is set to op.
|
* Operation flag is set to op.
|
||||||
*/
|
*/
|
||||||
void
|
void xdrstdio_create(XDR *xdrs, FILE *file, enum xdr_op op)
|
||||||
xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op)
|
|
||||||
{
|
{
|
||||||
xdrs->x_op = op;
|
xdrs->x_op = op;
|
||||||
/* We have to add the const since the `struct xdr_ops' in `struct XDR'
|
/* We have to add the const since the `struct xdr_ops' in `struct XDR'
|
||||||
@ -611,104 +260,42 @@ xdrstdio_create (XDR *xdrs, FILE *file, enum xdr_op op)
|
|||||||
* Destroy a stdio xdr stream.
|
* Destroy a stdio xdr stream.
|
||||||
* Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create.
|
* Cleans up the xdr stream handle xdrs previously set up by xdrstdio_create.
|
||||||
*/
|
*/
|
||||||
static void
|
static void xdrstdio_destroy(XDR *xdrs)
|
||||||
xdrstdio_destroy (XDR *xdrs)
|
|
||||||
{
|
{
|
||||||
(void) fflush ((FILE *) xdrs->x_private);
|
(void) fflush((FILE *) xdrs->x_private);
|
||||||
/* xx should we close the file ?? */
|
/* xx should we close the file ?? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool_t xdrstdio_getbytes(XDR *xdrs, char *addr, unsigned int len)
|
||||||
static bool_t
|
|
||||||
xdrstdio_getbytes (XDR *xdrs, char *addr, unsigned int len)
|
|
||||||
{
|
{
|
||||||
if ((len != 0) && (fread (addr, (int) len, 1,
|
if ((len != 0) && (fread(addr, (int) len, 1, (FILE *) xdrs->x_private) != 1)) return FALSE;
|
||||||
(FILE *) xdrs->x_private) != 1))
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
static bool_t xdrstdio_putbytes(XDR *xdrs, char *addr, unsigned int len)
|
||||||
xdrstdio_putbytes (XDR *xdrs, char *addr, unsigned int len)
|
|
||||||
{
|
{
|
||||||
if ((len != 0) && (fwrite (addr, (int) len, 1,
|
if ((len != 0) && (fwrite(addr, (int) len, 1, (FILE *) xdrs->x_private) != 1)) return FALSE;
|
||||||
(FILE *) xdrs->x_private) != 1))
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int
|
static bool_t xdrstdio_getint32(XDR *xdrs, xdr_int32_t *ip)
|
||||||
xdrstdio_getpos (XDR *xdrs)
|
|
||||||
{
|
|
||||||
return (unsigned int) ftell ((FILE *) xdrs->x_private);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
xdrstdio_setpos (XDR *xdrs, unsigned int pos)
|
|
||||||
{
|
|
||||||
return fseek ((FILE *) xdrs->x_private, (xdr_int32_t) pos, 0) < 0 ? FALSE : TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static xdr_int32_t *
|
|
||||||
xdrstdio_inline (XDR * /*xdrs*/, int /*len*/)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Must do some work to implement this: must ensure
|
|
||||||
* enough data in the underlying stdio buffer,
|
|
||||||
* that the buffer is aligned so that we can indirect through a
|
|
||||||
* long *, and stuff this pointer in xdrs->x_buf. Doing
|
|
||||||
* a fread or fwrite to a scratch buffer would defeat
|
|
||||||
* most of the gains to be had here and require storage
|
|
||||||
* management on this buffer, so we don't do this.
|
|
||||||
*/
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
xdrstdio_getint32 (XDR *xdrs, xdr_int32_t *ip)
|
|
||||||
{
|
{
|
||||||
xdr_int32_t mycopy;
|
xdr_int32_t mycopy;
|
||||||
|
|
||||||
if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
|
if (fread((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) return FALSE;
|
||||||
return FALSE;
|
*ip = xdr_ntohl(mycopy);
|
||||||
*ip = xdr_ntohl (mycopy);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
static bool_t xdrstdio_putint32(XDR *xdrs, xdr_int32_t *ip)
|
||||||
xdrstdio_putint32 (XDR *xdrs, xdr_int32_t *ip)
|
|
||||||
{
|
{
|
||||||
xdr_int32_t mycopy = xdr_htonl (*ip);
|
xdr_int32_t mycopy = xdr_htonl(*ip);
|
||||||
|
|
||||||
ip = &mycopy;
|
ip = &mycopy;
|
||||||
if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1)
|
if (fwrite((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1) return FALSE;
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool_t
|
|
||||||
xdrstdio_getuint32 (XDR *xdrs, xdr_uint32_t *ip)
|
|
||||||
{
|
|
||||||
xdr_uint32_t mycopy;
|
|
||||||
|
|
||||||
if (fread ((char *) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1)
|
|
||||||
return FALSE;
|
|
||||||
*ip = xdr_ntohl (mycopy);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool_t
|
|
||||||
xdrstdio_putuint32 (XDR *xdrs, xdr_uint32_t *ip)
|
|
||||||
{
|
|
||||||
xdr_uint32_t mycopy = xdr_htonl (*ip);
|
|
||||||
|
|
||||||
ip = &mycopy;
|
|
||||||
if (fwrite ((char *) ip, 4, 1, (FILE *) xdrs->x_private) != 1)
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
#ifndef LMP_XDR_COMPAT_H
|
#ifndef LMP_XDR_COMPAT_H
|
||||||
#define LMP_XDR_COMPAT_H
|
#define LMP_XDR_COMPAT_H
|
||||||
|
|
||||||
#include <climits>
|
#include <cstdint>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -9,47 +9,53 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is needed for systems, that do not provide XDR support
|
* This file contains the definitions for Sun External Data Representation (XDR).
|
||||||
* in their system libraries. It was written for windows, but will
|
* They have been adapted specifically for the use with the LAMMPS xtc dump style
|
||||||
* most probably work on other platforms too. better make sure you
|
* to produce compressed trajectory files in the Gromacs XTC format.
|
||||||
* test that the xtc files produced are ok before using it.
|
|
||||||
*
|
*
|
||||||
* It is also needed on BG/L, BG/P and Cray XT3/XT4/XT5 as we don't
|
* The XDR sources are avaiable under the BSD 3-clause license for example in
|
||||||
* have XDR support in the lightweight kernel runtimes either.
|
* the MIT Kerberos 5 distribution with the following copyright notice and license.
|
||||||
*
|
*
|
||||||
* This file contains the definitions for Sun External Data
|
* @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC
|
||||||
* Representation (XDR) headers and routines.
|
|
||||||
*
|
*
|
||||||
* Although the rest of LAMPPS is GPL, you can copy and use the XDR
|
* Copyright (c) 2010, Oracle America, Inc.
|
||||||
* routines in any way you want as long as you obey Sun's license:
|
|
||||||
* Sun RPC is a product of Sun Microsystems, Inc. and is provided for
|
|
||||||
* unrestricted use provided that this legend is included on all tape
|
|
||||||
* media and as a part of the software program in whole or part. Users
|
|
||||||
* may copy or modify Sun RPC without charge, but are not authorized
|
|
||||||
* to license or distribute it to anyone else except as part of a product or
|
|
||||||
* program developed by the user.
|
|
||||||
*
|
*
|
||||||
* SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
|
* All rights reserved.
|
||||||
* WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
|
|
||||||
*
|
*
|
||||||
* Sun RPC is provided with no support and without any obligation on the
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* part of Sun Microsystems, Inc. to assist in its use, correction,
|
* modification, are permitted provided that the following conditions are met:
|
||||||
* modification or enhancement.
|
|
||||||
*
|
*
|
||||||
* SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
|
* * Redistributions of source code must retain the above copyright
|
||||||
* INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
|
* notice, this list of conditions and the following disclaimer.
|
||||||
* OR ANY PART THEREOF.
|
|
||||||
*
|
*
|
||||||
* In no event will Sun Microsystems, Inc. be liable for any lost revenue
|
* * Redistributions in binary form must reproduce the above copyright
|
||||||
* or profits or other special, indirect and consequential damages, even if
|
* notice, this list of conditions and the following disclaimer in
|
||||||
* Sun has been advised of the possibility of such damages.
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
*
|
*
|
||||||
* Sun Microsystems, Inc.
|
* * Neither the name of the "Oracle America, Inc." nor the names of
|
||||||
* 2550 Garcia Avenue
|
* its contributors may be used to endorse or promote products
|
||||||
* Mountain View, California 94043
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||||
|
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||||
|
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||||
|
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* compatibility typedefs */
|
||||||
|
typedef int bool_t;
|
||||||
|
|
||||||
|
typedef int32_t xdr_int32_t;
|
||||||
|
typedef uint32_t xdr_uint32_t;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Xdr operations. XDR_ENCODE causes the type to be encoded into the
|
* Xdr operations. XDR_ENCODE causes the type to be encoded into the
|
||||||
* stream. XDR_DECODE causes the type to be extracted from the stream.
|
* stream. XDR_DECODE causes the type to be extracted from the stream.
|
||||||
@ -57,44 +63,8 @@ extern "C" {
|
|||||||
* XDR_DECODE request.
|
* XDR_DECODE request.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef int bool_t;
|
|
||||||
|
|
||||||
#if defined(_WIN32) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__) || \
|
|
||||||
defined(__OpenBSD__) || defined(__NetBSD__) || (defined(__linux__) && !defined(__GLIBC_MINOR__))
|
|
||||||
typedef char *caddr_t;
|
|
||||||
typedef unsigned int u_int;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Aninteger type that is 32 bits wide. Check if int,
|
|
||||||
* long or short is 32 bits and die if none of them is :-)
|
|
||||||
*/
|
|
||||||
#if (INT_MAX == 2147483647)
|
|
||||||
typedef int xdr_int32_t;
|
|
||||||
typedef unsigned int xdr_uint32_t;
|
|
||||||
#elif (LONG_MAX == 2147483647L)
|
|
||||||
typedef long xdr_int32_t;
|
|
||||||
typedef unsigned long xdr_uint32_t;
|
|
||||||
#elif (SHRT_MAX == 2147483647)
|
|
||||||
typedef short xdr_int32_t;
|
|
||||||
typedef unsigned short xdr_uint32_t;
|
|
||||||
#else
|
|
||||||
#error ERROR: No 32 bit wide integer type found!
|
|
||||||
#endif
|
|
||||||
|
|
||||||
enum xdr_op { XDR_ENCODE = 0, XDR_DECODE = 1, XDR_FREE = 2 };
|
enum xdr_op { XDR_ENCODE = 0, XDR_DECODE = 1, XDR_FREE = 2 };
|
||||||
|
|
||||||
#ifndef FALSE
|
|
||||||
#define FALSE (0)
|
|
||||||
#endif
|
|
||||||
#ifndef TRUE
|
|
||||||
#define TRUE (1)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BYTES_PER_XDR_UNIT (4)
|
|
||||||
/* Macro to round up to units of 4. */
|
|
||||||
#define XDR_RNDUP(x) (((x) + BYTES_PER_XDR_UNIT - 1) & ~(BYTES_PER_XDR_UNIT - 1))
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The XDR handle.
|
* The XDR handle.
|
||||||
* Contains operation which is being applied to the stream,
|
* Contains operation which is being applied to the stream,
|
||||||
@ -113,26 +83,16 @@ struct XDR {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct xdr_ops {
|
struct xdr_ops {
|
||||||
|
/* get some bytes from XDR stream */
|
||||||
bool_t (*x_getbytes)(XDR *__xdrs, char *__addr, unsigned int __len);
|
bool_t (*x_getbytes)(XDR *__xdrs, char *__addr, unsigned int __len);
|
||||||
/* get some bytes from " */
|
/* put some bytes to XDR stream */
|
||||||
bool_t (*x_putbytes)(XDR *__xdrs, char *__addr, unsigned int __len);
|
bool_t (*x_putbytes)(XDR *__xdrs, char *__addr, unsigned int __len);
|
||||||
/* put some bytes to " */
|
|
||||||
unsigned int (*x_getpostn)(XDR *__xdrs);
|
|
||||||
/* returns bytes off from beginning */
|
|
||||||
bool_t (*x_setpostn)(XDR *__xdrs, unsigned int __pos);
|
|
||||||
/* lets you reposition the stream */
|
|
||||||
xdr_int32_t *(*x_inline)(XDR *__xdrs, int __len);
|
|
||||||
/* buf quick ptr to buffered data */
|
|
||||||
void (*x_destroy)(XDR *__xdrs);
|
|
||||||
/* free privates of this xdr_stream */
|
/* free privates of this xdr_stream */
|
||||||
|
void (*x_destroy)(XDR *__xdrs);
|
||||||
|
/* get a int from XDR stream */
|
||||||
bool_t (*x_getint32)(XDR *__xdrs, xdr_int32_t *__ip);
|
bool_t (*x_getint32)(XDR *__xdrs, xdr_int32_t *__ip);
|
||||||
/* get a int from underlying stream */
|
/* put a int to XDR stream */
|
||||||
bool_t (*x_putint32)(XDR *__xdrs, xdr_int32_t *__ip);
|
bool_t (*x_putint32)(XDR *__xdrs, xdr_int32_t *__ip);
|
||||||
/* put a int to " */
|
|
||||||
bool_t (*x_getuint32)(XDR *__xdrs, xdr_uint32_t *__ip);
|
|
||||||
/* get a unsigned int from underlying stream */
|
|
||||||
bool_t (*x_putuint32)(XDR *__xdrs, xdr_uint32_t *__ip);
|
|
||||||
/* put a int to " */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -151,53 +111,25 @@ typedef bool_t (*xdrproc_t)(XDR *, void *, ...);
|
|||||||
*
|
*
|
||||||
* XDR *xdrs;
|
* XDR *xdrs;
|
||||||
* xdr_int32_t *int32p;
|
* xdr_int32_t *int32p;
|
||||||
* long *longp;
|
|
||||||
* char *addr;
|
|
||||||
* unsigned int len;
|
* unsigned int len;
|
||||||
* unsigned int pos;
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define xdr_getint32(xdrs, int32p) (*(xdrs)->x_ops->x_getint32)(xdrs, int32p)
|
#define xdr_getint32(xdrs, int32p) (*(xdrs)->x_ops->x_getint32)(xdrs, int32p)
|
||||||
|
|
||||||
#define xdr_putint32(xdrs, int32p) (*(xdrs)->x_ops->x_putint32)(xdrs, int32p)
|
#define xdr_putint32(xdrs, int32p) (*(xdrs)->x_ops->x_putint32)(xdrs, int32p)
|
||||||
|
|
||||||
#define xdr_getuint32(xdrs, uint32p) (*(xdrs)->x_ops->x_getuint32)(xdrs, uint32p)
|
|
||||||
|
|
||||||
#define xdr_putuint32(xdrs, uint32p) (*(xdrs)->x_ops->x_putuint32)(xdrs, uint32p)
|
|
||||||
|
|
||||||
#define xdr_getbytes(xdrs, addr, len) (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
|
#define xdr_getbytes(xdrs, addr, len) (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len)
|
||||||
|
|
||||||
#define xdr_putbytes(xdrs, addr, len) (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
|
#define xdr_putbytes(xdrs, addr, len) (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len)
|
||||||
|
|
||||||
#define xdr_getpos(xdrs) (*(xdrs)->x_ops->x_getpostn)(xdrs)
|
|
||||||
|
|
||||||
#define xdr_setpos(xdrs, pos) (*(xdrs)->x_ops->x_setpostn)(xdrs, pos)
|
|
||||||
|
|
||||||
#define xdr_inline(xdrs, len) (*(xdrs)->x_ops->x_inline)(xdrs, len)
|
|
||||||
|
|
||||||
#define xdr_destroy(xdrs) \
|
#define xdr_destroy(xdrs) \
|
||||||
do { \
|
do { \
|
||||||
if ((xdrs)->x_ops->x_destroy) (*(xdrs)->x_ops->x_destroy)(xdrs); \
|
if ((xdrs)->x_ops->x_destroy) (*(xdrs)->x_ops->x_destroy)(xdrs); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
extern bool_t xdr_int(XDR *__xdrs, int *__ip);
|
extern bool_t xdr_int(XDR *__xdrs, int *__ip);
|
||||||
extern bool_t xdr_u_int(XDR *__xdrs, unsigned int *__ip);
|
|
||||||
extern bool_t xdr_short(XDR *__xdrs, short *__ip);
|
|
||||||
extern bool_t xdr_u_short(XDR *__xdrs, unsigned short *__ip);
|
|
||||||
extern bool_t xdr_bool(XDR *__xdrs, int *__bp);
|
|
||||||
extern bool_t xdr_opaque(XDR *__xdrs, char *__cp, unsigned int __cnt);
|
extern bool_t xdr_opaque(XDR *__xdrs, char *__cp, unsigned int __cnt);
|
||||||
extern bool_t xdr_string(XDR *__xdrs, char **__cpp, unsigned int __maxsize);
|
|
||||||
extern bool_t xdr_char(XDR *__xdrs, char *__cp);
|
|
||||||
extern bool_t xdr_u_char(XDR *__xdrs, unsigned char *__cp);
|
|
||||||
extern bool_t xdr_vector(XDR *__xdrs, char *__basep, unsigned int __nelem, unsigned int __elemsize,
|
extern bool_t xdr_vector(XDR *__xdrs, char *__basep, unsigned int __nelem, unsigned int __elemsize,
|
||||||
xdrproc_t __xdr_elem);
|
xdrproc_t __xdr_elem);
|
||||||
extern bool_t xdr_float(XDR *__xdrs, float *__fp);
|
extern bool_t xdr_float(XDR *__xdrs, float *__fp);
|
||||||
extern bool_t xdr_double(XDR *__xdrs, double *__dp);
|
|
||||||
extern void xdrstdio_create(XDR *__xdrs, FILE *__file, enum xdr_op __xop);
|
extern void xdrstdio_create(XDR *__xdrs, FILE *__file, enum xdr_op __xop);
|
||||||
|
|
||||||
/* free memory buffers for xdr */
|
|
||||||
extern void xdr_free(xdrproc_t __proc, char *__objp);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
static constexpr double BIG = 1.0e20;
|
static constexpr double BIG = 1.0e20;
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
@ -80,6 +80,11 @@ public:
|
|||||||
void DomainKokkos::reset_box()
|
void DomainKokkos::reset_box()
|
||||||
{
|
{
|
||||||
// perform shrink-wrapping
|
// perform shrink-wrapping
|
||||||
|
|
||||||
|
// nothing to do for empty systems
|
||||||
|
|
||||||
|
if (atom->natoms == 0) return;
|
||||||
|
|
||||||
// compute extent of atoms on this proc
|
// compute extent of atoms on this proc
|
||||||
// for triclinic, this is done in lamda space
|
// for triclinic, this is done in lamda space
|
||||||
|
|
||||||
|
|||||||
@ -39,8 +39,11 @@ FFT3dKokkos<DeviceType>::FFT3dKokkos(LAMMPS *lmp, MPI_Comm comm, int nfast, int
|
|||||||
Pointers(lmp)
|
Pointers(lmp)
|
||||||
{
|
{
|
||||||
int nthreads = lmp->kokkos->nthreads;
|
int nthreads = lmp->kokkos->nthreads;
|
||||||
|
|
||||||
|
#if defined(LMP_KOKKOS_GPU)
|
||||||
int ngpus = lmp->kokkos->ngpus;
|
int ngpus = lmp->kokkos->ngpus;
|
||||||
ExecutionSpace execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
|
ExecutionSpace execution_space = ExecutionSpaceFromDevice<DeviceType>::space;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(FFT_KOKKOS_MKL)
|
#if defined(FFT_KOKKOS_MKL)
|
||||||
if (ngpus > 0 && execution_space == Device)
|
if (ngpus > 0 && execution_space == Device)
|
||||||
|
|||||||
@ -950,10 +950,10 @@ EV_FLOAT pair_compute_neighlist (PairStyle* fpair, std::enable_if_t<(NEIGHFLAG&P
|
|||||||
|
|
||||||
static int vectorsize = 0;
|
static int vectorsize = 0;
|
||||||
static int atoms_per_team = 0;
|
static int atoms_per_team = 0;
|
||||||
static int teamsize_max_for = 0;
|
|
||||||
static int teamsize_max_reduce = 0;
|
|
||||||
|
|
||||||
#if defined(LMP_KOKKOS_GPU)
|
#if defined(LMP_KOKKOS_GPU)
|
||||||
|
static int teamsize_max_for = 0;
|
||||||
|
static int teamsize_max_reduce = 0;
|
||||||
static int lastcall = -1;
|
static int lastcall = -1;
|
||||||
if (!vectorsize || lastcall < fpair->lmp->neighbor->lastcall) {
|
if (!vectorsize || lastcall < fpair->lmp->neighbor->lastcall) {
|
||||||
lastcall = fpair->lmp->update->ntimestep;
|
lastcall = fpair->lmp->update->ntimestep;
|
||||||
|
|||||||
@ -970,7 +970,8 @@ void FixCMAP::read_data_section(char * /*keyword*/, int /*n*/, char *buf,
|
|||||||
atom5 = values.next_tagint();
|
atom5 = values.next_tagint();
|
||||||
if (values.has_next()) throw TokenizerException("too many items",line);
|
if (values.has_next()) throw TokenizerException("too many items",line);
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
error->all(FLERR,"Incorrect format of CMAP section: {}", e.what());
|
error->all(FLERR,"Incorrect format of CMAP section in data file: {}{}",
|
||||||
|
e.what(), utils::errorurl(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
atom1 += id_offset;
|
atom1 += id_offset;
|
||||||
|
|||||||
@ -16,14 +16,16 @@
|
|||||||
Contributing author: Axel Kohlmeyer (Temple U)
|
Contributing author: Axel Kohlmeyer (Temple U)
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#include "omp_compat.h"
|
|
||||||
#include "angle_cosine_squared_omp.h"
|
#include "angle_cosine_squared_omp.h"
|
||||||
#include <cmath>
|
|
||||||
#include "atom.h"
|
#include "atom.h"
|
||||||
#include "comm.h"
|
#include "comm.h"
|
||||||
#include "force.h"
|
#include "force.h"
|
||||||
#include "neighbor.h"
|
#include "neighbor.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include "omp_compat.h"
|
||||||
#include "suffix.h"
|
#include "suffix.h"
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
|||||||
@ -215,9 +215,8 @@ void ComputeSpin::compute_vector()
|
|||||||
tempnum += tx*tx+ty*ty+tz*tz;
|
tempnum += tx*tx+ty*ty+tz*tz;
|
||||||
tempdenom += sp[i][0]*fm[i][0]+fm[i][1]*sp[i][1]+sp[i][2]*fm[i][2];
|
tempdenom += sp[i][0]*fm[i][0]+fm[i][1]*sp[i][1]+sp[i][2]*fm[i][2];
|
||||||
countsp++;
|
countsp++;
|
||||||
}
|
} else error->all(FLERR,"Compute compute/spin requires atom/spin style");
|
||||||
}
|
}
|
||||||
else error->all(FLERR,"Compute compute/spin requires atom/spin style");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MPI_Allreduce(mag,magtot,4,MPI_DOUBLE,MPI_SUM,world);
|
MPI_Allreduce(mag,magtot,4,MPI_DOUBLE,MPI_SUM,world);
|
||||||
|
|||||||
28
src/atom.cpp
28
src/atom.cpp
@ -1068,7 +1068,8 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((nwords != avec->size_data_atom) && (nwords != avec->size_data_atom + 3))
|
if ((nwords != avec->size_data_atom) && (nwords != avec->size_data_atom + 3))
|
||||||
error->all(FLERR,"Incorrect format in {}: {}", location, utils::trim(buf));
|
error->all(FLERR,"Incorrect format in {}: {}{}", location,
|
||||||
|
utils::trim(buf), utils::errorurl(2));
|
||||||
|
|
||||||
*next = '\n';
|
*next = '\n';
|
||||||
// set bounds for my proc
|
// set bounds for my proc
|
||||||
@ -1149,7 +1150,8 @@ void Atom::data_atoms(int n, char *buf, tagint id_offset, tagint mol_offset,
|
|||||||
// skip over empty or comment lines
|
// skip over empty or comment lines
|
||||||
} else if ((nvalues < nwords) ||
|
} else if ((nvalues < nwords) ||
|
||||||
((nvalues > nwords) && (!utils::strmatch(values[nwords],"^#")))) {
|
((nvalues > nwords) && (!utils::strmatch(values[nwords],"^#")))) {
|
||||||
error->all(FLERR, "Incorrect format in {}: {}", location, utils::trim(buf));
|
error->all(FLERR, "Incorrect format in {}: {}{}", location,
|
||||||
|
utils::trim(buf), utils::errorurl(2));
|
||||||
} else {
|
} else {
|
||||||
int imx = 0, imy = 0, imz = 0;
|
int imx = 0, imy = 0, imz = 0;
|
||||||
if (imageflag) {
|
if (imageflag) {
|
||||||
@ -1243,7 +1245,8 @@ void Atom::data_vels(int n, char *buf, tagint id_offset)
|
|||||||
if (values.size() == 0) {
|
if (values.size() == 0) {
|
||||||
// skip over empty or comment lines
|
// skip over empty or comment lines
|
||||||
} else if ((int)values.size() != avec->size_data_vel) {
|
} else if ((int)values.size() != avec->size_data_vel) {
|
||||||
error->all(FLERR, "Incorrect velocity format in data file: {}", utils::trim(buf));
|
error->all(FLERR, "Incorrect format in Velocities section of data file: {}{}",
|
||||||
|
utils::trim(buf), utils::errorurl(2));
|
||||||
} else {
|
} else {
|
||||||
tagint tagdata = utils::tnumeric(FLERR,values[0],false,lmp) + id_offset;
|
tagint tagdata = utils::tnumeric(FLERR,values[0],false,lmp) + id_offset;
|
||||||
if (tagdata <= 0 || tagdata > map_tag_max)
|
if (tagdata <= 0 || tagdata > map_tag_max)
|
||||||
@ -1287,7 +1290,9 @@ void Atom::data_bonds(int n, char *buf, int *count, tagint id_offset,
|
|||||||
// skip over empty or comment lines
|
// skip over empty or comment lines
|
||||||
// Bonds line is: number(ignored), bond type, atomID 1, atomID 2
|
// Bonds line is: number(ignored), bond type, atomID 1, atomID 2
|
||||||
if (nwords > 0) {
|
if (nwords > 0) {
|
||||||
if (nwords != 4) error->all(FLERR, "Incorrect format in {}: {}", location, utils::trim(buf));
|
if (nwords != 4)
|
||||||
|
error->all(FLERR, "Incorrect format in {}: {}{}", location,
|
||||||
|
utils::trim(buf), utils::errorurl(2));
|
||||||
typestr = utils::utf8_subst(values[1]);
|
typestr = utils::utf8_subst(values[1]);
|
||||||
atom1 = utils::tnumeric(FLERR, values[2], false, lmp);
|
atom1 = utils::tnumeric(FLERR, values[2], false, lmp);
|
||||||
atom2 = utils::tnumeric(FLERR, values[3], false, lmp);
|
atom2 = utils::tnumeric(FLERR, values[3], false, lmp);
|
||||||
@ -1378,7 +1383,9 @@ void Atom::data_angles(int n, char *buf, int *count, tagint id_offset,
|
|||||||
// skip over empty or comment lines
|
// skip over empty or comment lines
|
||||||
// Angles line is: number(ignored), angle type, atomID 1, atomID 2, atomID 3
|
// Angles line is: number(ignored), angle type, atomID 1, atomID 2, atomID 3
|
||||||
if (nwords > 0) {
|
if (nwords > 0) {
|
||||||
if (nwords != 5) error->all(FLERR, "Incorrect format in {}: {}", location, utils::trim(buf));
|
if (nwords != 5)
|
||||||
|
error->all(FLERR, "Incorrect format in {}: {}{}", location,
|
||||||
|
utils::trim(buf), utils::errorurl(2));
|
||||||
typestr = utils::utf8_subst(values[1]);
|
typestr = utils::utf8_subst(values[1]);
|
||||||
atom1 = utils::tnumeric(FLERR, values[2], false, lmp);
|
atom1 = utils::tnumeric(FLERR, values[2], false, lmp);
|
||||||
atom2 = utils::tnumeric(FLERR, values[3], false, lmp);
|
atom2 = utils::tnumeric(FLERR, values[3], false, lmp);
|
||||||
@ -1485,7 +1492,9 @@ void Atom::data_dihedrals(int n, char *buf, int *count, tagint id_offset,
|
|||||||
// skip over empty or comment lines
|
// skip over empty or comment lines
|
||||||
// Dihedrals line is: number(ignored), bond type, atomID 1, atomID 2, atomID 3, atomID 4
|
// Dihedrals line is: number(ignored), bond type, atomID 1, atomID 2, atomID 3, atomID 4
|
||||||
if (nwords > 0) {
|
if (nwords > 0) {
|
||||||
if (nwords != 6) error->all(FLERR, "Incorrect format in {}: {}", location, utils::trim(buf));
|
if (nwords != 6)
|
||||||
|
error->all(FLERR, "Incorrect format in {}: {}{}", location,
|
||||||
|
utils::trim(buf), utils::errorurl(2));
|
||||||
typestr = utils::utf8_subst(values[1]);
|
typestr = utils::utf8_subst(values[1]);
|
||||||
atom1 = utils::tnumeric(FLERR, values[2], false, lmp);
|
atom1 = utils::tnumeric(FLERR, values[2], false, lmp);
|
||||||
atom2 = utils::tnumeric(FLERR, values[3], false, lmp);
|
atom2 = utils::tnumeric(FLERR, values[3], false, lmp);
|
||||||
@ -1611,7 +1620,9 @@ void Atom::data_impropers(int n, char *buf, int *count, tagint id_offset,
|
|||||||
// skip over empty or comment lines
|
// skip over empty or comment lines
|
||||||
// Impropers line is: number(ignored), bond type, atomID 1, atomID 2, atomID 3, atomID 4
|
// Impropers line is: number(ignored), bond type, atomID 1, atomID 2, atomID 3, atomID 4
|
||||||
if (nwords > 0) {
|
if (nwords > 0) {
|
||||||
if (nwords != 6) error->all(FLERR, "Incorrect format in {}: {}", location, utils::trim(buf));
|
if (nwords != 6)
|
||||||
|
error->all(FLERR, "Incorrect format in {}: {}{}", location,
|
||||||
|
utils::trim(buf), utils::errorurl(2));
|
||||||
typestr = utils::utf8_subst(values[1]);
|
typestr = utils::utf8_subst(values[1]);
|
||||||
atom1 = utils::tnumeric(FLERR, values[2], false, lmp);
|
atom1 = utils::tnumeric(FLERR, values[2], false, lmp);
|
||||||
atom2 = utils::tnumeric(FLERR, values[3], false, lmp);
|
atom2 = utils::tnumeric(FLERR, values[3], false, lmp);
|
||||||
@ -1727,7 +1738,8 @@ void Atom::data_bonus(int n, char *buf, AtomVec *avec_bonus, tagint id_offset)
|
|||||||
if (values.size() == 0) {
|
if (values.size() == 0) {
|
||||||
// skip over empty or comment lines
|
// skip over empty or comment lines
|
||||||
} else if ((int)values.size() != avec_bonus->size_data_bonus) {
|
} else if ((int)values.size() != avec_bonus->size_data_bonus) {
|
||||||
error->all(FLERR, "Incorrect bonus data format in data file: {}", utils::trim(buf));
|
error->all(FLERR, "Incorrect format in Bonus section of data file: {}{}",
|
||||||
|
utils::trim(buf), utils::errorurl(2));
|
||||||
} else {
|
} else {
|
||||||
tagint tagdata = utils::tnumeric(FLERR,values[0],false,lmp) + id_offset;
|
tagint tagdata = utils::tnumeric(FLERR,values[0],false,lmp) + id_offset;
|
||||||
if (tagdata <= 0 || tagdata > map_tag_max)
|
if (tagdata <= 0 || tagdata > map_tag_max)
|
||||||
|
|||||||
@ -97,7 +97,7 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
|
|
||||||
while (iarg < nargnew) {
|
while (iarg < nargnew) {
|
||||||
if (strcmp(arg[iarg],"type") == 0) {
|
if (strcmp(arg[iarg],"type") == 0) {
|
||||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix ave/correlate type", error);
|
if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate type", error);
|
||||||
if (strcmp(arg[iarg+1],"auto") == 0) type = AUTO;
|
if (strcmp(arg[iarg+1],"auto") == 0) type = AUTO;
|
||||||
else if (strcmp(arg[iarg+1],"upper") == 0) type = UPPER;
|
else if (strcmp(arg[iarg+1],"upper") == 0) type = UPPER;
|
||||||
else if (strcmp(arg[iarg+1],"lower") == 0) type = LOWER;
|
else if (strcmp(arg[iarg+1],"lower") == 0) type = LOWER;
|
||||||
@ -107,17 +107,17 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
else error->all(FLERR,"Unknown fix ave/correlate type: {}");
|
else error->all(FLERR,"Unknown fix ave/correlate type: {}");
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"ave") == 0) {
|
} else if (strcmp(arg[iarg],"ave") == 0) {
|
||||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix ave/correlate ave", error);
|
if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate ave", error);
|
||||||
if (strcmp(arg[iarg+1],"one") == 0) ave = ONE;
|
if (strcmp(arg[iarg+1],"one") == 0) ave = ONE;
|
||||||
else if (strcmp(arg[iarg+1],"running") == 0) ave = RUNNING;
|
else if (strcmp(arg[iarg+1],"running") == 0) ave = RUNNING;
|
||||||
else error->all(FLERR,"Unknown fix ave/correlate ave mode: {}", arg[iarg+1]);
|
else error->all(FLERR,"Unknown fix ave/correlate ave mode: {}", arg[iarg+1]);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"start") == 0) {
|
} else if (strcmp(arg[iarg],"start") == 0) {
|
||||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix ave/correlate start", error);
|
if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate start", error);
|
||||||
startstep = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
startstep = utils::inumeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"prefactor") == 0) {
|
} else if (strcmp(arg[iarg],"prefactor") == 0) {
|
||||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix ave/correlate prefactor", error);
|
if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate prefactor", error);
|
||||||
prefactor = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
prefactor = utils::numeric(FLERR,arg[iarg+1],false,lmp);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"file") == 0) {
|
} else if (strcmp(arg[iarg],"file") == 0) {
|
||||||
@ -133,17 +133,17 @@ FixAveCorrelate::FixAveCorrelate(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
overwrite = 1;
|
overwrite = 1;
|
||||||
iarg += 1;
|
iarg += 1;
|
||||||
} else if (strcmp(arg[iarg],"title1") == 0) {
|
} else if (strcmp(arg[iarg],"title1") == 0) {
|
||||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix ave/correlate title1", error);
|
if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate title1", error);
|
||||||
delete[] title1;
|
delete[] title1;
|
||||||
title1 = utils::strdup(arg[iarg+1]);
|
title1 = utils::strdup(arg[iarg+1]);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"title2") == 0) {
|
} else if (strcmp(arg[iarg],"title2") == 0) {
|
||||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix ave/correlate title2", error);
|
if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate title2", error);
|
||||||
delete[] title2;
|
delete[] title2;
|
||||||
title2 = utils::strdup(arg[iarg+1]);
|
title2 = utils::strdup(arg[iarg+1]);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
} else if (strcmp(arg[iarg],"title3") == 0) {
|
} else if (strcmp(arg[iarg],"title3") == 0) {
|
||||||
if (iarg+2 > narg) utils::missing_cmd_args(FLERR, "fix ave/correlate title3", error);
|
if (iarg+2 > nargnew) utils::missing_cmd_args(FLERR, "fix ave/correlate title3", error);
|
||||||
delete[] title3;
|
delete[] title3;
|
||||||
title3 = utils::strdup(arg[iarg+1]);
|
title3 = utils::strdup(arg[iarg+1]);
|
||||||
iarg += 2;
|
iarg += 2;
|
||||||
|
|||||||
@ -113,256 +113,256 @@ void FixAveHistoWeight::end_of_step()
|
|||||||
double weight = 0.0;
|
double weight = 0.0;
|
||||||
double *weights = nullptr;
|
double *weights = nullptr;
|
||||||
int stride = 0;
|
int stride = 0;
|
||||||
auto &val = values[1];
|
auto &val1 = values[1];
|
||||||
int j = val.argindex;
|
int j = val1.argindex;
|
||||||
|
|
||||||
// atom attributes
|
// atom attributes
|
||||||
|
|
||||||
if (val.which == ArgInfo::X) {
|
if (val1.which == ArgInfo::X) {
|
||||||
weights = &atom->x[0][j];
|
weights = &atom->x[0][j];
|
||||||
stride = 3;
|
stride = 3;
|
||||||
} else if (val.which == ArgInfo::V) {
|
} else if (val1.which == ArgInfo::V) {
|
||||||
weights = &atom->v[0][j];
|
weights = &atom->v[0][j];
|
||||||
stride = 3;
|
stride = 3;
|
||||||
bin_atoms(&atom->v[0][j],3);
|
bin_atoms(&atom->v[0][j],3);
|
||||||
} else if (val.which == ArgInfo::F) {
|
} else if (val1.which == ArgInfo::F) {
|
||||||
weights = &atom->f[0][j];
|
weights = &atom->f[0][j];
|
||||||
stride = 3;
|
stride = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// invoke compute if not previously invoked
|
// invoke compute if not previously invoked
|
||||||
|
|
||||||
if (val.which == ArgInfo::COMPUTE) {
|
if (val1.which == ArgInfo::COMPUTE) {
|
||||||
|
|
||||||
if (kind == GLOBAL && mode == SCALAR) {
|
if (kind == GLOBAL && mode == SCALAR) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_SCALAR)) {
|
if (!(val1.val.c->invoked_flag & Compute::INVOKED_SCALAR)) {
|
||||||
val.val.c->compute_scalar();
|
val1.val.c->compute_scalar();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_SCALAR;
|
val1.val.c->invoked_flag |= Compute::INVOKED_SCALAR;
|
||||||
}
|
}
|
||||||
weight = val.val.c->scalar;
|
weight = val1.val.c->scalar;
|
||||||
} else {
|
} else {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_VECTOR)) {
|
if (!(val1.val.c->invoked_flag & Compute::INVOKED_VECTOR)) {
|
||||||
val.val.c->compute_vector();
|
val1.val.c->compute_vector();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_VECTOR;
|
val1.val.c->invoked_flag |= Compute::INVOKED_VECTOR;
|
||||||
}
|
}
|
||||||
weight = val.val.c->vector[j-1];
|
weight = val1.val.c->vector[j-1];
|
||||||
}
|
}
|
||||||
} else if (kind == GLOBAL && mode == VECTOR) {
|
} else if (kind == GLOBAL && mode == VECTOR) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_VECTOR)) {
|
if (!(val1.val.c->invoked_flag & Compute::INVOKED_VECTOR)) {
|
||||||
val.val.c->compute_vector();
|
val1.val.c->compute_vector();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_VECTOR;
|
val1.val.c->invoked_flag |= Compute::INVOKED_VECTOR;
|
||||||
}
|
}
|
||||||
weights = val.val.c->vector;
|
weights = val1.val.c->vector;
|
||||||
stride = 1;
|
stride = 1;
|
||||||
} else {
|
} else {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_ARRAY)) {
|
if (!(val1.val.c->invoked_flag & Compute::INVOKED_ARRAY)) {
|
||||||
val.val.c->compute_array();
|
val1.val.c->compute_array();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_ARRAY;
|
val1.val.c->invoked_flag |= Compute::INVOKED_ARRAY;
|
||||||
}
|
}
|
||||||
if (val.val.c->array) weights = &val.val.c->array[0][j-1];
|
if (val1.val.c->array) weights = &val1.val.c->array[0][j-1];
|
||||||
stride = val.val.c->size_array_cols;
|
stride = val1.val.c->size_array_cols;
|
||||||
}
|
}
|
||||||
} else if (kind == PERATOM) {
|
} else if (kind == PERATOM) {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_PERATOM)) {
|
if (!(val1.val.c->invoked_flag & Compute::INVOKED_PERATOM)) {
|
||||||
val.val.c->compute_peratom();
|
val1.val.c->compute_peratom();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_PERATOM;
|
val1.val.c->invoked_flag |= Compute::INVOKED_PERATOM;
|
||||||
}
|
}
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
weights = val.val.c->vector_atom;
|
weights = val1.val.c->vector_atom;
|
||||||
stride = 1;
|
stride = 1;
|
||||||
} else if (val.val.c->array_atom) {
|
} else if (val1.val.c->array_atom) {
|
||||||
weights = &val.val.c->array_atom[0][j-1];
|
weights = &val1.val.c->array_atom[0][j-1];
|
||||||
stride = val.val.c->size_peratom_cols;
|
stride = val1.val.c->size_peratom_cols;
|
||||||
}
|
}
|
||||||
} else if (kind == LOCAL) {
|
} else if (kind == LOCAL) {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_LOCAL)) {
|
if (!(val1.val.c->invoked_flag & Compute::INVOKED_LOCAL)) {
|
||||||
val.val.c->compute_local();
|
val1.val.c->compute_local();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_LOCAL;
|
val1.val.c->invoked_flag |= Compute::INVOKED_LOCAL;
|
||||||
}
|
}
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
weights = val.val.c->vector_local;
|
weights = val1.val.c->vector_local;
|
||||||
stride = 1;
|
stride = 1;
|
||||||
} else if (val.val.c->array_local) {
|
} else if (val1.val.c->array_local) {
|
||||||
weights = &val.val.c->array_local[0][j-1];
|
weights = &val1.val.c->array_local[0][j-1];
|
||||||
stride = val.val.c->size_local_cols;
|
stride = val1.val.c->size_local_cols;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// access fix fields, guaranteed to be ready
|
// access fix fields, guaranteed to be ready
|
||||||
|
|
||||||
} else if (val.which == ArgInfo::FIX) {
|
} else if (val1.which == ArgInfo::FIX) {
|
||||||
|
|
||||||
if (kind == GLOBAL && mode == SCALAR) {
|
if (kind == GLOBAL && mode == SCALAR) {
|
||||||
if (j == 0) weight = val.val.f->compute_scalar();
|
if (j == 0) weight = val1.val.f->compute_scalar();
|
||||||
else weight = val.val.f->compute_vector(j-1);
|
else weight = val1.val.f->compute_vector(j-1);
|
||||||
} else if (kind == GLOBAL && mode == VECTOR) {
|
} else if (kind == GLOBAL && mode == VECTOR) {
|
||||||
error->all(FLERR,"Fix ave/histo/weight option not yet supported");
|
error->all(FLERR,"Fix ave/histo/weight option not yet supported");
|
||||||
// NOTE: need to allocate local storage
|
// NOTE: need to allocate local storage
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
int n = val.val.f->size_vector;
|
int n = val1.val.f->size_vector;
|
||||||
for (int i = 0; i < n; i++) weights[n] = val.val.f->compute_vector(i);
|
for (int i = 0; i < n; i++) weights[n] = val1.val.f->compute_vector(i);
|
||||||
} else {
|
} else {
|
||||||
int n = val.val.f->size_vector;
|
int n = val1.val.f->size_vector;
|
||||||
for (int i = 0; i < n; i++) weights[n] = val.val.f->compute_array(i,j-1);
|
for (int i = 0; i < n; i++) weights[n] = val1.val.f->compute_array(i,j-1);
|
||||||
}
|
}
|
||||||
} else if (kind == PERATOM) {
|
} else if (kind == PERATOM) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
weights = val.val.f->vector_atom;
|
weights = val1.val.f->vector_atom;
|
||||||
stride = 1;
|
stride = 1;
|
||||||
} else if (val.val.f->array_atom) {
|
} else if (val1.val.f->array_atom) {
|
||||||
weights = &val.val.f->array_atom[0][j-1];
|
weights = &val1.val.f->array_atom[0][j-1];
|
||||||
stride = val.val.f->size_peratom_cols;
|
stride = val1.val.f->size_peratom_cols;
|
||||||
}
|
}
|
||||||
} else if (kind == LOCAL) {
|
} else if (kind == LOCAL) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
weights = val.val.f->vector_local;
|
weights = val1.val.f->vector_local;
|
||||||
stride = 1;
|
stride = 1;
|
||||||
} else if (val.val.f->array_local) {
|
} else if (val1.val.f->array_local) {
|
||||||
weights = &val.val.f->array_local[0][j-1];
|
weights = &val1.val.f->array_local[0][j-1];
|
||||||
stride = val.val.f->size_local_cols;
|
stride = val1.val.f->size_local_cols;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// evaluate equal-style variable
|
// evaluate equal-style variable
|
||||||
|
|
||||||
} else if (val.which == ArgInfo::VARIABLE && kind == GLOBAL) {
|
} else if (val1.which == ArgInfo::VARIABLE && kind == GLOBAL) {
|
||||||
weight = input->variable->compute_equal(val.val.v);
|
weight = input->variable->compute_equal(val1.val.v);
|
||||||
|
|
||||||
} else if (val.which == ArgInfo::VARIABLE && kind == PERATOM) {
|
} else if (val1.which == ArgInfo::VARIABLE && kind == PERATOM) {
|
||||||
if (atom->nmax > maxatom) {
|
if (atom->nmax > maxatom) {
|
||||||
memory->destroy(vector);
|
memory->destroy(vector);
|
||||||
maxatom = atom->nmax;
|
maxatom = atom->nmax;
|
||||||
memory->create(vector,maxatom,"ave/histo/weight:vector");
|
memory->create(vector,maxatom,"ave/histo/weight:vector");
|
||||||
}
|
}
|
||||||
input->variable->compute_atom(val.val.v,igroup,vector,1,0);
|
input->variable->compute_atom(val1.val.v,igroup,vector,1,0);
|
||||||
weights = vector;
|
weights = vector;
|
||||||
stride = 1;
|
stride = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bin values using weights, values are 1st value (i = 0)
|
// bin values using weights, values are 1st value (i = 0)
|
||||||
|
|
||||||
val = values[0];
|
auto &val0 = values[0];
|
||||||
j = val.argindex;
|
j = val0.argindex;
|
||||||
|
|
||||||
// atom attributes
|
// atom attributes
|
||||||
|
|
||||||
if (val.which == ArgInfo::X && weights != nullptr)
|
if (val0.which == ArgInfo::X && weights != nullptr)
|
||||||
bin_atoms_weights(&atom->x[0][j],3,weights,stride);
|
bin_atoms_weights(&atom->x[0][j],3,weights,stride);
|
||||||
else if (val.which == ArgInfo::V && weights != nullptr)
|
else if (val0.which == ArgInfo::V && weights != nullptr)
|
||||||
bin_atoms_weights(&atom->v[0][j],3,weights,stride);
|
bin_atoms_weights(&atom->v[0][j],3,weights,stride);
|
||||||
else if (val.which == ArgInfo::F && weights != nullptr)
|
else if (val0.which == ArgInfo::F && weights != nullptr)
|
||||||
bin_atoms_weights(&atom->f[0][j],3,weights,stride);
|
bin_atoms_weights(&atom->f[0][j],3,weights,stride);
|
||||||
|
|
||||||
// invoke compute if not previously invoked
|
// invoke compute if not previously invoked
|
||||||
|
|
||||||
if (val.which == ArgInfo::COMPUTE) {
|
if (val0.which == ArgInfo::COMPUTE) {
|
||||||
|
|
||||||
if (kind == GLOBAL && mode == SCALAR) {
|
if (kind == GLOBAL && mode == SCALAR) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_SCALAR)) {
|
if (!(val0.val.c->invoked_flag & Compute::INVOKED_SCALAR)) {
|
||||||
val.val.c->compute_scalar();
|
val0.val.c->compute_scalar();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_SCALAR;
|
val0.val.c->invoked_flag |= Compute::INVOKED_SCALAR;
|
||||||
}
|
}
|
||||||
bin_one_weights(val.val.c->scalar,weight);
|
bin_one_weights(val0.val.c->scalar,weight);
|
||||||
} else {
|
} else {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_VECTOR)) {
|
if (!(val0.val.c->invoked_flag & Compute::INVOKED_VECTOR)) {
|
||||||
val.val.c->compute_vector();
|
val0.val.c->compute_vector();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_VECTOR;
|
val0.val.c->invoked_flag |= Compute::INVOKED_VECTOR;
|
||||||
}
|
}
|
||||||
bin_one_weights(val.val.c->vector[j-1],weight);
|
bin_one_weights(val0.val.c->vector[j-1],weight);
|
||||||
}
|
}
|
||||||
} else if (kind == GLOBAL && mode == VECTOR) {
|
} else if (kind == GLOBAL && mode == VECTOR) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_VECTOR)) {
|
if (!(val0.val.c->invoked_flag & Compute::INVOKED_VECTOR)) {
|
||||||
val.val.c->compute_vector();
|
val0.val.c->compute_vector();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_VECTOR;
|
val0.val.c->invoked_flag |= Compute::INVOKED_VECTOR;
|
||||||
}
|
}
|
||||||
bin_vector_weights(val.val.c->size_vector,val.val.c->vector,1,
|
bin_vector_weights(val0.val.c->size_vector,val0.val.c->vector,1,
|
||||||
weights,stride);
|
weights,stride);
|
||||||
} else {
|
} else {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_ARRAY)) {
|
if (!(val0.val.c->invoked_flag & Compute::INVOKED_ARRAY)) {
|
||||||
val.val.c->compute_array();
|
val0.val.c->compute_array();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_ARRAY;
|
val0.val.c->invoked_flag |= Compute::INVOKED_ARRAY;
|
||||||
}
|
}
|
||||||
if (val.val.c->array)
|
if (val0.val.c->array)
|
||||||
bin_vector_weights(val.val.c->size_array_rows,&val.val.c->array[0][j-1],
|
bin_vector_weights(val0.val.c->size_array_rows,&val0.val.c->array[0][j-1],
|
||||||
val.val.c->size_array_cols,weights,stride);
|
val0.val.c->size_array_cols,weights,stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (kind == PERATOM) {
|
} else if (kind == PERATOM) {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_PERATOM)) {
|
if (!(val0.val.c->invoked_flag & Compute::INVOKED_PERATOM)) {
|
||||||
val.val.c->compute_peratom();
|
val0.val.c->compute_peratom();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_PERATOM;
|
val0.val.c->invoked_flag |= Compute::INVOKED_PERATOM;
|
||||||
}
|
}
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
bin_atoms_weights(val.val.c->vector_atom,1,weights, stride);
|
bin_atoms_weights(val0.val.c->vector_atom,1,weights, stride);
|
||||||
else if (val.val.c->array_atom)
|
else if (val0.val.c->array_atom)
|
||||||
bin_atoms_weights(&val.val.c->array_atom[0][j-1],
|
bin_atoms_weights(&val0.val.c->array_atom[0][j-1],
|
||||||
val.val.c->size_peratom_cols,weights,stride);
|
val0.val.c->size_peratom_cols,weights,stride);
|
||||||
|
|
||||||
} else if (kind == LOCAL) {
|
} else if (kind == LOCAL) {
|
||||||
if (!(val.val.c->invoked_flag & Compute::INVOKED_LOCAL)) {
|
if (!(val0.val.c->invoked_flag & Compute::INVOKED_LOCAL)) {
|
||||||
val.val.c->compute_local();
|
val0.val.c->compute_local();
|
||||||
val.val.c->invoked_flag |= Compute::INVOKED_LOCAL;
|
val0.val.c->invoked_flag |= Compute::INVOKED_LOCAL;
|
||||||
}
|
}
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
bin_vector_weights(val.val.c->size_local_rows,
|
bin_vector_weights(val0.val.c->size_local_rows,
|
||||||
val.val.c->vector_local,1,weights,stride);
|
val0.val.c->vector_local,1,weights,stride);
|
||||||
else if (val.val.c->array_local)
|
else if (val0.val.c->array_local)
|
||||||
bin_vector_weights(val.val.c->size_local_rows,
|
bin_vector_weights(val0.val.c->size_local_rows,
|
||||||
&val.val.c->array_local[0][j-1],
|
&val0.val.c->array_local[0][j-1],
|
||||||
val.val.c->size_local_cols,weights,stride);
|
val0.val.c->size_local_cols,weights,stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
// access fix fields, guaranteed to be ready
|
// access fix fields, guaranteed to be ready
|
||||||
|
|
||||||
} else if (val.which == ArgInfo::FIX) {
|
} else if (val0.which == ArgInfo::FIX) {
|
||||||
|
|
||||||
if (kind == GLOBAL && mode == SCALAR) {
|
if (kind == GLOBAL && mode == SCALAR) {
|
||||||
if (j == 0) bin_one_weights(val.val.f->compute_scalar(),weight);
|
if (j == 0) bin_one_weights(val0.val.f->compute_scalar(),weight);
|
||||||
else bin_one_weights(val.val.f->compute_vector(j-1),weight);
|
else bin_one_weights(val0.val.f->compute_vector(j-1),weight);
|
||||||
|
|
||||||
} else if (kind == GLOBAL && mode == VECTOR) {
|
} else if (kind == GLOBAL && mode == VECTOR) {
|
||||||
if (j == 0) {
|
if (j == 0) {
|
||||||
int n = val.val.f->size_vector;
|
int n = val0.val.f->size_vector;
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
bin_one_weights(val.val.f->compute_vector(i),weights[i*stride]);
|
bin_one_weights(val0.val.f->compute_vector(i),weights[i*stride]);
|
||||||
} else {
|
} else {
|
||||||
int n = val.val.f->size_vector;
|
int n = val0.val.f->size_vector;
|
||||||
for (int i = 0; i < n; i++)
|
for (int i = 0; i < n; i++)
|
||||||
bin_one_weights(val.val.f->compute_array(i,j-1),weights[i*stride]);
|
bin_one_weights(val0.val.f->compute_array(i,j-1),weights[i*stride]);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (kind == PERATOM) {
|
} else if (kind == PERATOM) {
|
||||||
if (j == 0)
|
if (j == 0)
|
||||||
bin_atoms_weights(val.val.f->vector_atom,1,weights,stride);
|
bin_atoms_weights(val0.val.f->vector_atom,1,weights,stride);
|
||||||
else if (val.val.f->array_atom)
|
else if (val0.val.f->array_atom)
|
||||||
bin_atoms_weights(&val.val.f->array_atom[0][j-1],val.val.f->size_peratom_cols,
|
bin_atoms_weights(&val0.val.f->array_atom[0][j-1],val0.val.f->size_peratom_cols,
|
||||||
weights,stride);
|
weights,stride);
|
||||||
|
|
||||||
|
|
||||||
} else if (kind == LOCAL) {
|
} else if (kind == LOCAL) {
|
||||||
if (j == 0) bin_vector_weights(val.val.f->size_local_rows,val.val.f->vector_local,1,
|
if (j == 0) bin_vector_weights(val0.val.f->size_local_rows,val0.val.f->vector_local,1,
|
||||||
weights,stride);
|
weights,stride);
|
||||||
else if (val.val.f->array_local)
|
else if (val0.val.f->array_local)
|
||||||
bin_vector_weights(val.val.f->size_local_rows,&val.val.f->array_local[0][j-1],
|
bin_vector_weights(val0.val.f->size_local_rows,&val0.val.f->array_local[0][j-1],
|
||||||
val.val.f->size_local_cols,weights,stride);
|
val0.val.f->size_local_cols,weights,stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
// evaluate equal-style variable
|
// evaluate equal-style variable
|
||||||
|
|
||||||
} else if (val.which == ArgInfo::VARIABLE && kind == GLOBAL) {
|
} else if (val0.which == ArgInfo::VARIABLE && kind == GLOBAL) {
|
||||||
bin_one_weights(input->variable->compute_equal(val.val.v),weight);
|
bin_one_weights(input->variable->compute_equal(val0.val.v),weight);
|
||||||
|
|
||||||
} else if (val.which == ArgInfo::VARIABLE && kind == PERATOM) {
|
} else if (val0.which == ArgInfo::VARIABLE && kind == PERATOM) {
|
||||||
if (atom->nmax > maxatom) {
|
if (atom->nmax > maxatom) {
|
||||||
memory->destroy(vector);
|
memory->destroy(vector);
|
||||||
maxatom = atom->nmax;
|
maxatom = atom->nmax;
|
||||||
memory->create(vector,maxatom,"ave/histo/weight:vector");
|
memory->create(vector,maxatom,"ave/histo/weight:vector");
|
||||||
}
|
}
|
||||||
input->variable->compute_atom(val.val.v,igroup,vector,1,0);
|
input->variable->compute_atom(val0.val.v,igroup,vector,1,0);
|
||||||
bin_atoms_weights(vector,1,weights,stride);
|
bin_atoms_weights(vector,1,weights,stride);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -328,8 +328,9 @@ void FixPropertyAtom::read_data_section(char *keyword, int n, char *buf, tagint
|
|||||||
try {
|
try {
|
||||||
ValueTokenizer values(buf);
|
ValueTokenizer values(buf);
|
||||||
if ((int) values.count() != values_peratom + 1)
|
if ((int) values.count() != values_peratom + 1)
|
||||||
error->all(FLERR, "Incorrect format in {} section of data file: {} expected {} and got {}",
|
error->all(FLERR, "Incorrect format in {} section of data file: {}\n"
|
||||||
keyword, buf, values_peratom + 1, values.count());
|
"expected {} parameters and got {}{}", keyword, utils::trim(buf),
|
||||||
|
values_peratom + 1, values.count(), utils::errorurl(2));
|
||||||
|
|
||||||
itag = values.next_tagint() + id_offset;
|
itag = values.next_tagint() + id_offset;
|
||||||
if (itag <= 0 || itag > map_tag_max)
|
if (itag <= 0 || itag > map_tag_max)
|
||||||
|
|||||||
@ -31,7 +31,7 @@ using namespace MathEigen;
|
|||||||
typedef Jacobi<double, double *, double (*)[3], double const (*)[3]> Jacobi_v1;
|
typedef Jacobi<double, double *, double (*)[3], double const (*)[3]> Jacobi_v1;
|
||||||
typedef Jacobi<double, double *, double **, double const *const *> Jacobi_v2;
|
typedef Jacobi<double, double *, double **, double const *const *> Jacobi_v2;
|
||||||
|
|
||||||
int MathEigen::jacobi3(double const mat[3][3], double *eval, double evec[3][3])
|
int MathEigen::jacobi3(double const mat[3][3], double *eval, double evec[3][3], int sort)
|
||||||
{
|
{
|
||||||
// make copy of const matrix
|
// make copy of const matrix
|
||||||
|
|
||||||
@ -44,7 +44,15 @@ int MathEigen::jacobi3(double const mat[3][3], double *eval, double evec[3][3])
|
|||||||
// create instance of generic Jacobi class and get eigenvalues and -vectors
|
// create instance of generic Jacobi class and get eigenvalues and -vectors
|
||||||
|
|
||||||
Jacobi_v1 ecalc3(3, M, midx);
|
Jacobi_v1 ecalc3(3, M, midx);
|
||||||
int ierror = ecalc3.Diagonalize(mat, eval, evec, Jacobi_v1::SORT_DECREASING_EVALS);
|
int ierror = 1;
|
||||||
|
if (sort == -1)
|
||||||
|
ierror = ecalc3.Diagonalize(mat, eval, evec, Jacobi_v1::SORT_DECREASING_EVALS);
|
||||||
|
else if (sort == 0)
|
||||||
|
ierror = ecalc3.Diagonalize(mat, eval, evec, Jacobi_v1::DO_NOT_SORT);
|
||||||
|
else if (sort == 1)
|
||||||
|
ierror = ecalc3.Diagonalize(mat, eval, evec, Jacobi_v1::SORT_INCREASING_EVALS);
|
||||||
|
|
||||||
|
if (ierror) return ierror;
|
||||||
|
|
||||||
// transpose the evec matrix
|
// transpose the evec matrix
|
||||||
|
|
||||||
@ -54,7 +62,7 @@ int MathEigen::jacobi3(double const mat[3][3], double *eval, double evec[3][3])
|
|||||||
return ierror;
|
return ierror;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MathEigen::jacobi3(double const *const *mat, double *eval, double **evec)
|
int MathEigen::jacobi3(double const *const *mat, double *eval, double **evec, int sort)
|
||||||
{
|
{
|
||||||
// make copy of const matrix
|
// make copy of const matrix
|
||||||
|
|
||||||
@ -67,7 +75,15 @@ int MathEigen::jacobi3(double const *const *mat, double *eval, double **evec)
|
|||||||
// create instance of generic Jacobi class and get eigenvalues and -vectors
|
// create instance of generic Jacobi class and get eigenvalues and -vectors
|
||||||
|
|
||||||
Jacobi_v2 ecalc3(3, M, midx);
|
Jacobi_v2 ecalc3(3, M, midx);
|
||||||
int ierror = ecalc3.Diagonalize(mat, eval, evec, Jacobi_v2::SORT_DECREASING_EVALS);
|
int ierror = 1;
|
||||||
|
if (sort == -1)
|
||||||
|
ierror = ecalc3.Diagonalize(mat, eval, evec, Jacobi_v2::SORT_DECREASING_EVALS);
|
||||||
|
else if (sort == 0)
|
||||||
|
ierror = ecalc3.Diagonalize(mat, eval, evec, Jacobi_v2::DO_NOT_SORT);
|
||||||
|
else if (sort == 1)
|
||||||
|
ierror = ecalc3.Diagonalize(mat, eval, evec, Jacobi_v2::SORT_INCREASING_EVALS);
|
||||||
|
|
||||||
|
if (ierror) return ierror;
|
||||||
|
|
||||||
// transpose the evec matrix
|
// transpose the evec matrix
|
||||||
|
|
||||||
|
|||||||
@ -22,13 +22,14 @@ namespace MathEigen {
|
|||||||
* \param mat the 3x3 matrix you wish to diagonalize
|
* \param mat the 3x3 matrix you wish to diagonalize
|
||||||
* \param eval store the eigenvalues here
|
* \param eval store the eigenvalues here
|
||||||
* \param evec store the eigenvectors here...
|
* \param evec store the eigenvectors here...
|
||||||
|
* \param sort order eigenvalues and -vectors (-1 decreasing (default), 1 increasing, 0 unsorted)
|
||||||
* \return 0 if eigenvalue calculation converged, 1 if it failed */
|
* \return 0 if eigenvalue calculation converged, 1 if it failed */
|
||||||
|
|
||||||
int jacobi3(double const *const *mat, double *eval, double **evec);
|
int jacobi3(double const *const *mat, double *eval, double **evec, int sort = -1);
|
||||||
|
|
||||||
/** \overload */
|
/** \overload */
|
||||||
|
|
||||||
int jacobi3(double const mat[3][3], double *eval, double evec[3][3]);
|
int jacobi3(double const mat[3][3], double *eval, double evec[3][3], int sort = -1);
|
||||||
|
|
||||||
} // namespace MathEigen
|
} // namespace MathEigen
|
||||||
|
|
||||||
|
|||||||
@ -249,12 +249,7 @@ std::string platform::os_info()
|
|||||||
} else if (build == "22631") {
|
} else if (build == "22631") {
|
||||||
buf = "Windows 11 23H2";
|
buf = "Windows 11 23H2";
|
||||||
} else {
|
} else {
|
||||||
const char *entry = "ProductName";
|
buf = "Windows Build " + build;
|
||||||
RegGetValue(HKEY_LOCAL_MACHINE, subkey, entry, RRF_RT_REG_SZ, nullptr, &value,
|
|
||||||
(LPDWORD) &value_length);
|
|
||||||
// enforce zero termination
|
|
||||||
value[1023] = '\0';
|
|
||||||
buf = value;
|
|
||||||
}
|
}
|
||||||
DWORD fullversion, majorv, minorv, buildv = 0;
|
DWORD fullversion, majorv, minorv, buildv = 0;
|
||||||
fullversion = GetVersion();
|
fullversion = GetVersion();
|
||||||
|
|||||||
@ -1360,7 +1360,8 @@ void ReadData::header(int firstpass)
|
|||||||
// check that exiting string is a valid section keyword
|
// check that exiting string is a valid section keyword
|
||||||
|
|
||||||
parse_keyword(1);
|
parse_keyword(1);
|
||||||
if (!is_data_section(keyword)) error->all(FLERR, "Unknown identifier in data file: {}", keyword);
|
if (!is_data_section(keyword))
|
||||||
|
error->all(FLERR, "Unknown identifier in data file: {}{}", keyword, utils::errorurl(1));
|
||||||
|
|
||||||
// error checks on header values
|
// error checks on header values
|
||||||
// must be consistent with atom style and other header values
|
// must be consistent with atom style and other header values
|
||||||
|
|||||||
@ -1662,15 +1662,19 @@ double Variable::evaluate(char *str, Tree **tree, int ivar)
|
|||||||
|
|
||||||
if (!compute->array_flag)
|
if (!compute->array_flag)
|
||||||
print_var_error(FLERR,"Mismatched compute in variable formula",ivar);
|
print_var_error(FLERR,"Mismatched compute in variable formula",ivar);
|
||||||
if (index1 > compute->size_array_cols)
|
|
||||||
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
|
|
||||||
if (!compute->is_initialized())
|
if (!compute->is_initialized())
|
||||||
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
|
print_var_error(FLERR,"Variable formula compute cannot be invoked before "
|
||||||
"initialization by a run",ivar);
|
"initialization by a run",ivar);
|
||||||
|
if (index1 > compute->size_array_cols)
|
||||||
|
print_var_error(FLERR,"Variable formula compute array is accessed out-of-range",ivar,0);
|
||||||
if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
|
if (!(compute->invoked_flag & Compute::INVOKED_ARRAY)) {
|
||||||
compute->compute_array();
|
compute->compute_array();
|
||||||
compute->invoked_flag |= Compute::INVOKED_ARRAY;
|
compute->invoked_flag |= Compute::INVOKED_ARRAY;
|
||||||
}
|
}
|
||||||
|
// wait until after compute invocation to check size_array_rows
|
||||||
|
// b/c may be zero until after initial invocation
|
||||||
|
if (compute->size_array_rows == 0)
|
||||||
|
print_var_error(FLERR,"Variable formula compute array is zero length",ivar);
|
||||||
|
|
||||||
// wait to check row count until after compute invocation
|
// wait to check row count until after compute invocation
|
||||||
// to allow for computes with size_array_rows_variable == 1
|
// to allow for computes with size_array_rows_variable == 1
|
||||||
|
|||||||
@ -54,7 +54,7 @@ improper = {}
|
|||||||
kspace = {}
|
kspace = {}
|
||||||
pair = {}
|
pair = {}
|
||||||
|
|
||||||
style_pattern = re.compile("(.+)Style\((.+),(.+)\)")
|
style_pattern = re.compile("(.+)Style\\((.+),(.+)\\)")
|
||||||
upper = re.compile("[A-Z]+")
|
upper = re.compile("[A-Z]+")
|
||||||
gpu = re.compile("(.+)/gpu$")
|
gpu = re.compile("(.+)/gpu$")
|
||||||
intel = re.compile("(.+)/intel$")
|
intel = re.compile("(.+)/intel$")
|
||||||
@ -176,19 +176,19 @@ def check_tests(name,styles,yaml,search,skip=()):
|
|||||||
|
|
||||||
counter = 0
|
counter = 0
|
||||||
counter += check_tests('pair',pair,'*-pair-*.yaml',
|
counter += check_tests('pair',pair,'*-pair-*.yaml',
|
||||||
'.*pair_style:\s*((\S+).*)?',skip=('meam','lj/sf'))
|
'.*pair_style:\\s*((\\S+).*)?',skip=('meam','lj/sf'))
|
||||||
counter += check_tests('bond',bond,'bond-*.yaml',
|
counter += check_tests('bond',bond,'bond-*.yaml',
|
||||||
'.*bond_style:\s*((\S+).*)?')
|
'.*bond_style:\\s*((\\S+).*)?')
|
||||||
counter += check_tests('angle',angle,'angle-*.yaml',
|
counter += check_tests('angle',angle,'angle-*.yaml',
|
||||||
'.*angle_style:\s*((\S+).*)?')
|
'.*angle_style:\\s*((\\S+).*)?')
|
||||||
counter += check_tests('dihedral',dihedral,'dihedral-*.yaml',
|
counter += check_tests('dihedral',dihedral,'dihedral-*.yaml',
|
||||||
'.*dihedral_style:\s*((\S+).*)?')
|
'.*dihedral_style:\\s*((\\S+).*)?')
|
||||||
counter += check_tests('improper',improper,'improper-*.yaml',
|
counter += check_tests('improper',improper,'improper-*.yaml',
|
||||||
'.*improper_style:\s*((\S+).*)?')
|
'.*improper_style:\\s*((\\S+).*)?')
|
||||||
counter += check_tests('kspace',kspace,'kspace-*.yaml',
|
counter += check_tests('kspace',kspace,'kspace-*.yaml',
|
||||||
'.*kspace_style\s*((\S+).*)?')
|
'.*kspace_style\\s*((\\S+).*)?')
|
||||||
counter += check_tests('fix',fix,'fix-*.yaml',
|
counter += check_tests('fix',fix,'fix-*.yaml',
|
||||||
' fix\s+((\S+)\s*)?')
|
' fix\\s+((\\S+)\\s*)?')
|
||||||
|
|
||||||
total = len(pair)+len(bond)+len(angle)+len(dihedral)+len(improper)+len(kspace)+len(fix)
|
total = len(pair)+len(bond)+len(angle)+len(dihedral)+len(improper)+len(kspace)+len(fix)
|
||||||
print(f"\nTotal tests missing: {counter} of {total}")
|
print(f"\nTotal tests missing: {counter} of {total}")
|
||||||
|
|||||||
Reference in New Issue
Block a user