Merge pull request #2487 from akohlmey/collected-small-changes
Collected small changes and fixes
This commit is contained in:
6
README
6
README
@ -37,14 +37,14 @@ tools pre- and post-processing tools
|
||||
|
||||
Point your browser at any of these files to get started:
|
||||
|
||||
https://lammps.sandia.gov/doc/Manual.html LAMMPS user manual
|
||||
https://lammps.sandia.gov/doc/Manual.html LAMMPS manual
|
||||
https://lammps.sandia.gov/doc/Intro.html hi-level introduction
|
||||
https://lammps.sandia.gov/doc/Build.html how to build LAMMPS
|
||||
https://lammps.sandia.gov/doc/Run_head.html how to run LAMMPS
|
||||
https://lammps.sandia.gov/doc/Commands_all.html Table of available commands
|
||||
https://lammps.sandia.gov/doc/pg_library.html LAMMPS programmer guide
|
||||
https://lammps.sandia.gov/doc/Library.html LAMMPS library interfaces
|
||||
https://lammps.sandia.gov/doc/Modify.html how to modify and extend LAMMPS
|
||||
https://lammps.sandia.gov/doc/pg_developer.html LAMMPS developer guide
|
||||
https://lammps.sandia.gov/doc/Developer.html LAMMPS developer info
|
||||
|
||||
You can also create these doc pages locally:
|
||||
|
||||
|
||||
@ -108,13 +108,18 @@ results over a given number of steps and operations within a given
|
||||
error margin). The status of this automated testing can be viewed on
|
||||
`https://ci.lammps.org <https://ci.lammps.org>`_.
|
||||
|
||||
The scripts and inputs for integration, run, and regression testing
|
||||
are maintained in a
|
||||
`separate repository <https://github.com/lammps/lammps-testing>`_
|
||||
of the LAMMPS project on GitHub.
|
||||
|
||||
The unit testing facility is integrated into the CMake build process
|
||||
of the LAMMPS source code distribution itself. It can be enabled by
|
||||
setting ``-D ENABLE_TESTING=on`` during the CMake configuration step.
|
||||
It requires the `YAML <http://pyyaml.org/>`_ library and development
|
||||
headers (if not found locally a recent version will be downloaded
|
||||
and compiled transparently) to compile and will download and compile
|
||||
a specific recent version of the
|
||||
headers (if those are not found locally a recent version will be
|
||||
downloaded and compiled along with LAMMPS and the test program) to
|
||||
compile and will download and compile a specific recent version of the
|
||||
`Googletest <https://github.com/google/googletest/>`_ C++ test framework
|
||||
for implementing the tests.
|
||||
|
||||
@ -164,22 +169,21 @@ The ``ctest`` command has many options, the most important ones are:
|
||||
In its full implementation, the unit test framework will consist of multiple
|
||||
kinds of tests implemented in different programming languages (C++, C, Python,
|
||||
Fortran) and testing different aspects of the LAMMPS software and its features.
|
||||
At the moment only tests for "force styles" are implemented. More on those
|
||||
in the next section.
|
||||
The tests will adapt to the compilation settings of LAMMPS, so that tests
|
||||
will be skipped if prerequisite features are not available in LAMMPS.
|
||||
|
||||
.. note::
|
||||
|
||||
The unit test framework is new and still under development.
|
||||
The coverage is only minimal and will be expanded over time.
|
||||
Tests styles of the same kind of style (e.g. pair styles or
|
||||
bond styles) are performed with the same executable using
|
||||
different input files in YAML format. So to add a test for
|
||||
another pair style can be done by copying the YAML file and
|
||||
editing the style settings and then running the individual test
|
||||
program with a flag to update the computed reference data.
|
||||
Detailed documentation about how to add new test program and
|
||||
the contents of the YAML files for existing test programs
|
||||
will be provided in time as well.
|
||||
The unit test framework was added in spring 2020 and is under active
|
||||
development. The coverage is not complete and will be expanded over
|
||||
time.
|
||||
|
||||
Tests for styles of the same kind of style (e.g. pair styles or bond
|
||||
styles) are performed with the same test executable using different
|
||||
input files in YAML format. So to add a test for another style of the
|
||||
same kind it may be sufficient to add a suitable YAML file.
|
||||
:doc:`Detailed instructions for adding tests <Developer_unittest>` are
|
||||
provided in the Programmer Guide part of the manual.
|
||||
|
||||
Unit tests for force styles
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
@ -13,5 +13,6 @@ of time and requests from the LAMMPS user community.
|
||||
Developer_org
|
||||
Developer_flow
|
||||
Developer_write
|
||||
Developer_unittest
|
||||
Classes
|
||||
Developer_utils
|
||||
|
||||
523
doc/src/Developer_unittest.rst
Normal file
523
doc/src/Developer_unittest.rst
Normal file
@ -0,0 +1,523 @@
|
||||
Adding tests for unit testing
|
||||
-----------------------------
|
||||
|
||||
This section discusses adding or expanding tests for the unit test
|
||||
infrastructure included into the LAMMPS source code distribution.
|
||||
Unlike example inputs, unit tests focus on testing the "local" behavior
|
||||
of individual features, tend to run very fast, and should be set up to
|
||||
cover as much of the added code as possible. When contributing code to
|
||||
the distribution, the LAMMPS developers will appreciate if additions
|
||||
to the integrated unit test facility are included.
|
||||
|
||||
Given the complex nature of MD simulations where many operations can
|
||||
only be performed when suitable "real" simulation environment has been
|
||||
set up, not all tests will be unit tests in the strict definition of
|
||||
the term. They are rather executed on a more abstract level by issuing
|
||||
LAMMPS script commands and then inspecting the changes to the internal
|
||||
data. For some classes of tests, generic test programs have been
|
||||
written that can be applied to parts of LAMMPS that use the same
|
||||
interface (via polymorphism) and those are driven by input files, so
|
||||
tests can be added by simply adding more of those input files. Those
|
||||
tests should be seen more as a hybrid between unit and regression tests.
|
||||
|
||||
When adding tests it is recommended to also :ref:`enable support for
|
||||
code coverage reporting <testing>`, and study the coverage reports
|
||||
so that it is possible to monitor which parts of the code of a given
|
||||
file are executed during the tests and which tests would need to be
|
||||
added to increase the coverage.
|
||||
|
||||
The tests are grouped into categories and corresponding folders.
|
||||
The following sections describe how the tests are implemented and
|
||||
executed in those categories with increasing complexity of tests
|
||||
and implementation.
|
||||
|
||||
|
||||
Tests for utility functions
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
These tests are driven by programs in the ``unittest/utils`` folder
|
||||
and most closely resemble conventional unit tests. There is one test
|
||||
program for each namespace or group of classes or file. The naming
|
||||
convention for the sources and executables is that they start with
|
||||
with ``test_``. The following sources and groups of tests are currently
|
||||
available:
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
:widths: auto
|
||||
:align: left
|
||||
|
||||
* - File name:
|
||||
- Test name:
|
||||
- Description:
|
||||
* - ``test_fmtlib.cpp``
|
||||
- FmtLib
|
||||
- Tests for ``fmtlib::`` functions used by LAMMPS
|
||||
* - ``test_math_eigen_impl.cpp``
|
||||
- MathEigen
|
||||
- Tests for ``MathEigen::`` classes and functions
|
||||
* - ``test_mempool.cpp``
|
||||
- MemPool
|
||||
- Tests for :cpp:class:`MyPage <LAMMPS_NS::MyPage>` and :cpp:class:`MyPoolChunk <LAMMPS_NS::MyPoolChunk>`
|
||||
* - ``test_tokenizer.cpp``
|
||||
- Tokenizer
|
||||
- Tests for :cpp:class:`Tokenizer <LAMMPS_NS::Tokenizer>` and :cpp:class:`ValueTokenizer <LAMMPS_NS::ValueTokenizer>`
|
||||
* - ``test_utils.cpp``
|
||||
- Utils
|
||||
- Tests for ``utils::`` :doc:`functions <Developer_utils>`
|
||||
|
||||
To add tests either an existing source file needs to be modified or a
|
||||
new source file needs to be added to the distribution and enabled for
|
||||
testing. To add a new file suitable CMake script code needs to be added
|
||||
to the ``CMakeLists.txt`` file in the ``unittest/utils`` folder. Example:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
add_executable(test_tokenizer test_tokenizer.cpp)
|
||||
target_link_libraries(test_tokenizer PRIVATE lammps GTest::GMockMain GTest::GMock GTest::GTest)
|
||||
add_test(Tokenizer test_tokenizer)
|
||||
|
||||
This adds instructions to build the ``test_tokenizer`` executable from
|
||||
``test_tokenizer.cpp`` and links it with the GoogleTest libraries and the
|
||||
LAMMPS library as well as it uses the ``main()`` function from the
|
||||
GoogleMock library of GoogleTest. The third line registers the executable
|
||||
as a test program to be run from ``ctest`` under the name ``Tokenizer``.
|
||||
|
||||
The test executable itself will execute multiple individual tests
|
||||
through the GoogleTest framework. In this case each test consists of
|
||||
creating a tokenizer class instance with a given string and explicit or
|
||||
default separator choice, and then executing member functions of the
|
||||
class and comparing their results with expected values. A few examples:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
TEST(Tokenizer, empty_string)
|
||||
{
|
||||
Tokenizer t("", " ");
|
||||
ASSERT_EQ(t.count(), 0);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, two_words)
|
||||
{
|
||||
Tokenizer t("test word", " ");
|
||||
ASSERT_EQ(t.count(), 2);
|
||||
}
|
||||
|
||||
TEST(Tokenizer, default_separators)
|
||||
{
|
||||
Tokenizer t(" \r\n test \t word \f");
|
||||
ASSERT_THAT(t.next(), Eq("test"));
|
||||
ASSERT_THAT(t.next(), Eq("word"));
|
||||
ASSERT_EQ(t.count(), 2);
|
||||
}
|
||||
|
||||
Each of these TEST functions will become an individual
|
||||
test run by the test program. When using the ``ctest``
|
||||
command as a front end to run the tests, their output
|
||||
will be suppressed and only a summary printed, but adding
|
||||
the '-V' option will then produce output from the tests
|
||||
above like the following:
|
||||
|
||||
.. code-block::
|
||||
|
||||
[...]
|
||||
1: [ RUN ] Tokenizer.empty_string
|
||||
1: [ OK ] Tokenizer.empty_string (0 ms)
|
||||
1: [ RUN ] Tokenizer.two_words
|
||||
1: [ OK ] Tokenizer.two_words (0 ms)
|
||||
1: [ RUN ] Tokenizer.default_separators
|
||||
1: [ OK ] Tokenizer.default_separators (0 ms)
|
||||
[...]
|
||||
|
||||
The MathEigen test collection has been adapted from a standalone test
|
||||
and does not use the GoogleTest framework and thus not representative.
|
||||
The other test sources, however, can serve as guiding examples for
|
||||
additional tests.
|
||||
|
||||
Tests for individual LAMMPS commands
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The tests ``unittest/commands`` are a bit more complex as they require
|
||||
to first create a :cpp:class:`LAMMPS <LAMMPS_NS::LAMMPS>` class instance
|
||||
and then use the :doc:`C++ API <Cplusplus>` to pass individual commands
|
||||
to that LAMMPS instance. For that reason these tests use a GoogleTest
|
||||
"test fixture", i.e. a class derived from ``testing::Test`` that will
|
||||
create (and delete) the required LAMMPS class instance for each set of
|
||||
tests in a ``TEST_F()`` function. Please see the individual source files
|
||||
for different examples of setting up suitable test fixtures. Here is an
|
||||
example for implementing a test using a fixture by first checking the
|
||||
default value and then issuing LAMMPS commands and checking whether they
|
||||
have the desired effect:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
TEST_F(SimpleCommandsTest, ResetTimestep)
|
||||
{
|
||||
ASSERT_EQ(lmp->update->ntimestep, 0);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_timestep 10");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->update->ntimestep, 10);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_timestep 0");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->update->ntimestep, 0);
|
||||
}
|
||||
|
||||
Please note the use of the (global) verbose variable to control whether
|
||||
the LAMMPS command will be silent by capturing the output or not. In
|
||||
the default case, verbose == false, the test output will be compact and
|
||||
not mixed with LAMMPS output. However setting the verbose flag (via
|
||||
setting the ``TEST_ARGS`` environment variable, ``TEST_ARGS=-v``) can be
|
||||
helpful to understand why tests fail unexpectedly.
|
||||
|
||||
Another complexity of these tests stems from the need to capture
|
||||
situations where LAMMPS will stop with an error, i.e. handle so-called
|
||||
"death tests". Here the LAMMPS code will operate differently depending
|
||||
on whether it was configured to throw C++ exceptions on errors or call
|
||||
either ``exit()`` or ``MPI_Abort()``. In the latter case, the test code
|
||||
also needs to detect whether LAMMPS was compiled with the OpenMPI
|
||||
library, as OpenMPI is **only** compatible the death test options of the
|
||||
GoogleTest library when C++ exceptions are enabled; otherwise those
|
||||
"death tests" must be skipped to avoid reporting bogus failures. The
|
||||
specifics of this step are implemented in the ``TEST_FAILURE()``
|
||||
macro. These tests operate by capturing the screen output when executing
|
||||
the failing command and then comparing that with a provided regular
|
||||
expression string pattern. Example:
|
||||
|
||||
.. code-block:: C++
|
||||
|
||||
TEST_F(SimpleCommandsTest, UnknownCommand)
|
||||
{
|
||||
TEST_FAILURE(".*ERROR: Unknown command.*", lmp->input->one("XXX one two"););
|
||||
}
|
||||
|
||||
The following test programs are currently available:
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
:widths: auto
|
||||
:align: left
|
||||
|
||||
* - File name:
|
||||
- Test name:
|
||||
- Description:
|
||||
* - ``test_simple_commands.cpp``
|
||||
- SimpleCommands
|
||||
- Tests for LAMMPS commands that do not require a box
|
||||
* - ``test_lattice_region.cpp``
|
||||
- LatticeRegion
|
||||
- Tests to validate the :doc:`lattice <lattice>` and :doc:`region <region>` commands
|
||||
* - ``test_kim_commands.cpp``
|
||||
- KimCommands
|
||||
- Tests for several commands from the :ref:`KIM package <PKG-KIM>`
|
||||
* - ``test_reset_ids.cpp``
|
||||
- ResetIDs
|
||||
- Tests to validate the :doc:`reset_atom_ids <reset_atom_ids>` and :doc:`reset_mol_ids <reset_mol_ids>` commands
|
||||
|
||||
|
||||
Tests for the C-style library interface
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Tests for validating the LAMMPS C-style library interface are in the
|
||||
``unittest/c-library`` folder. They are implemented in either way used
|
||||
for utility functions and for LAMMPS commands, but use the functions
|
||||
implemented in the ``src/library.cpp`` file as much as possible. There
|
||||
may be some overlap with other tests, but only in as much as is required
|
||||
to test the C-style library API. The tests are distributed over
|
||||
multiple test programs which tries to match the grouping of the
|
||||
functions in the source code and :ref:`in the manual <lammps_c_api>`.
|
||||
|
||||
This group of tests also includes tests invoking LAMMPS in parallel
|
||||
through the library interface, provided that LAMMPS was compiled with
|
||||
MPI support. These include tests where LAMMPS is run in multi-partition
|
||||
mode or only on a subset of the MPI world communicator. The CMake
|
||||
script code for adding this kind of test looks like this:
|
||||
|
||||
.. code-block:: CMake
|
||||
|
||||
if (BUILD_MPI)
|
||||
add_executable(test_library_mpi test_library_mpi.cpp)
|
||||
target_link_libraries(test_library_mpi PRIVATE lammps GTest::GTest GTest::GMock)
|
||||
target_compile_definitions(test_library_mpi PRIVATE ${TEST_CONFIG_DEFS})
|
||||
add_mpi_test(NAME LibraryMPI NUM_PROCS 4 COMMAND $<TARGET_FILE:test_library_mpi>)
|
||||
endif()
|
||||
|
||||
Note the custom function ``add_mpi_test()`` which adapts how ``ctest``
|
||||
will execute the test so it is launched in parallel (with 4 MPI ranks).
|
||||
|
||||
Tests for the Python module and package
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The ``unittest/python`` folder contains primarily tests for classes and
|
||||
functions in the LAMMPS python module but also for commands in the
|
||||
PYTHON package. These tests are only enabled, if the necessary
|
||||
prerequisites are detected or enabled during configuration and
|
||||
compilation of LAMMPS (shared library build enabled, Python interpreter
|
||||
found, Python development files found).
|
||||
|
||||
The Python tests are implemented using the ``unittest`` standard Python
|
||||
module and split into multiple files with similar categories as the
|
||||
tests for the C-style library interface.
|
||||
|
||||
Tests for the Fortran interface
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Tests for using the Fortran module are in the ``unittest/fortran``
|
||||
folder. Since they are also using the GoogleTest library, they require
|
||||
to also implement test wrappers in C++ that will call fortran functions
|
||||
which provide a C function interface through ISO_C_BINDINGS that will in
|
||||
turn call the functions in the LAMMPS Fortran module. This part of the
|
||||
unit tests is incomplete since the Fortran module it is based on is
|
||||
incomplete as well.
|
||||
|
||||
Tests for the C++-style library interface
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The tests in the ``unittest/cplusplus`` folder are somewhat similar to
|
||||
the tests for the C-style library interface, but do not need to test the
|
||||
several convenience and utility functions that are only available through
|
||||
the C-style interface. Instead it can focus on the more generic features
|
||||
that are used internally. This part of the unit tests is currently still
|
||||
mostly in the planning stage.
|
||||
|
||||
Tests for reading and writing file formats
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The ``unittest/formats`` folder contains test programs for reading and
|
||||
writing files like data files, restart files, potential files or dump files.
|
||||
This covers simple things like the file i/o convenience functions in the
|
||||
``utils::`` namespace to complex tests of atom styles where creating and
|
||||
deleting of atoms with different properties is tested in different ways
|
||||
and through script commands or reading and writing of data or restart files.
|
||||
|
||||
Tests for styles computing or modifying forces
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
These are tests common configurations for pair styles, bond styles,
|
||||
angle styles, kspace styles and certain fix styles. Those are tests
|
||||
driven by some test executables build from sources in the
|
||||
``unittest/force-styles`` folder and use LAMMPS input template and data
|
||||
files as well as input files in YAML format from the
|
||||
``unittest/force-styles/tests`` folder. The YAML file names have to
|
||||
follow some naming conventions so they get associated with the test
|
||||
programs and categorized and listed with canonical names in the list
|
||||
of tests as displayed by ``ctest -N``. If you add a new YAML file,
|
||||
you need to re-run CMake to update the corresponding list of tests.
|
||||
|
||||
A minimal YAML file for a (molecular) pair style test will looks
|
||||
something like the following (see ``mol-pair-zero.yaml``):
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
---
|
||||
lammps_version: 24 Aug 2020
|
||||
date_generated: Tue Sep 15 09:44:21 202
|
||||
epsilon: 1e-14
|
||||
prerequisites: ! |
|
||||
atom full
|
||||
pair zero
|
||||
pre_commands: ! ""
|
||||
post_commands: ! ""
|
||||
input_file: in.fourmol
|
||||
pair_style: zero 8.0
|
||||
pair_coeff: ! |
|
||||
* *
|
||||
extract: ! ""
|
||||
natoms: 29
|
||||
init_vdwl: 0
|
||||
init_coul: 0
|
||||
|
||||
[...]
|
||||
|
||||
The following table describes the available keys and their purpose for
|
||||
testing pair styles:
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Key:
|
||||
- Description:
|
||||
* - lammps_version
|
||||
- LAMMPS version used to last update the reference data
|
||||
* - date_generated
|
||||
- date when the file was last updated
|
||||
* - epsilon
|
||||
- base value for the relative precision required for tests to pass
|
||||
* - prerequisites
|
||||
- list of style kind / style name pairs required to run the test
|
||||
* - pre_commands
|
||||
- LAMMPS commands to be executed before the input template file is read
|
||||
* - post_commands
|
||||
- LAMMPS commands to be executed right before the actual tests
|
||||
* - input_file
|
||||
- LAMMPS input file template based on pair style zero
|
||||
* - pair_style
|
||||
- arguments to the pair_style command to be tested
|
||||
* - pair_coeff
|
||||
- list of pair_coeff arguments to set parameters for the input template
|
||||
* - extract
|
||||
- list of keywords supported by ``Pair::extract()`` and their dimension
|
||||
* - natoms
|
||||
- number of atoms in the input file template
|
||||
* - init_vdwl
|
||||
- non-Coulomb pair energy after "run 0"
|
||||
* - init_coul
|
||||
- Coulomb pair energy after "run 0"
|
||||
* - init_stress
|
||||
- stress tensor after "run 0"
|
||||
* - init_forces
|
||||
- forces on atoms after "run 0"
|
||||
* - run_vdwl
|
||||
- non-Coulomb pair energy after "run 4"
|
||||
* - run_coul
|
||||
- Coulomb pair energy after "run 4"
|
||||
* - run_stress
|
||||
- stress tensor after "run 4"
|
||||
* - run_forces
|
||||
- forces on atoms after "run 4"
|
||||
|
||||
The test program will read all this data from the YAML file and then
|
||||
create a LAMMPS instance, apply the settings/commands from the YAML file
|
||||
as needed and then issue a "run 0" command, write out a restart file, a
|
||||
data file and a coeff file. The actual test will then compare computed
|
||||
energies, stresses, and forces with the reference data, issue a "run 4"
|
||||
command and compare to the second set of reference data. This will be
|
||||
run with both the newton_pair setting enabled and disabled and is
|
||||
expected to generate the same results (allowing for some numerical
|
||||
noise). Then it will restart from the previously generated restart and
|
||||
compare with the reference and also start from the data file. A final
|
||||
check will use multi-cutoff r-RESPA (if supported by the pair style) at
|
||||
a 1:1 split and compare to the Verlet results. These sets of tests are
|
||||
run with multiple test fixtures for accelerated styles (OPT, USER-OMP,
|
||||
USER-INTEL) and for the latter two with 4 OpenMP threads enabled. For
|
||||
these tests the relative error (epsilon) is lowered by a common factor
|
||||
due to the additional numerical noise, but the tests are still comparing
|
||||
to the same reference data.
|
||||
|
||||
Additional tests will check whether all listed extract keywords are
|
||||
supported and have the correct dimensionality and the final set of tests
|
||||
will set up a few pairs of atoms explicitly and in such a fashion that
|
||||
the forces on the atoms computed from ``Pair::compute()`` will match
|
||||
individually with the results from ``Pair::single()``, if the pair style
|
||||
does support that functionality.
|
||||
|
||||
With this scheme a large fraction of the code of any tested pair style
|
||||
will be executed and consistent results are required for different
|
||||
settings and between different accelerated pair style variants and the
|
||||
base class, as well as for computing individual pairs through the
|
||||
``Pair::single()`` where supported.
|
||||
|
||||
The ``test_pair_style`` tester is used with 4 categories of test inputs:
|
||||
|
||||
- pair styles compatible with molecular systems using bonded
|
||||
interactions and exclusions. For pair styles requiring a KSpace style
|
||||
the KSpace computations are disabled. The YAML files match the
|
||||
pattern "mol-pair-\*.yaml" and the tests are correspondingly labeled
|
||||
with "MolPairStyle:\*"
|
||||
- pair styles not compatible with the previous input template.
|
||||
The YAML files match the pattern "atomic-pair-\*.yaml" and the tests are
|
||||
correspondingly labeled with "AtomicPairStyle:\*"
|
||||
- manybody pair styles.
|
||||
The YAML files match the pattern "atomic-pair-\*.yaml" and the tests are
|
||||
correspondingly labeled with "AtomicPairStyle:\*"
|
||||
- kspace styles.
|
||||
The YAML files match the pattern "kspace-\*.yaml" and the tests are
|
||||
correspondingly labeled with "KSpaceStyle:\*". In these cases a compatible
|
||||
pair style is defined, but the computation of the pair style contributions
|
||||
is disabled.
|
||||
|
||||
The ``test_bond_style`` and ``test_angle_style`` are set up in a similar
|
||||
fashion and share support functions with the pair style tester. The final
|
||||
group of tests in this section is for fix styles that add/manipulate forces
|
||||
and velocities, e.g. for time integration, thermostats and more.
|
||||
|
||||
Adding a new test is easiest done by copying and modifying an existing test
|
||||
for a style that is similar to one to be tested. The file name should follow
|
||||
the naming conventions described above and after copying the file, the first
|
||||
step is to replace the style names where needed. The coefficient values
|
||||
do not have to be meaningful, just in a reasonable range for the given system.
|
||||
It does not matter if some forces are large, for as long as they do not diverge.
|
||||
|
||||
The template input files define a large number of index variables at the top
|
||||
that can be modified inside the YAML file to control the behavior. For example,
|
||||
if a pair style requires a "newton on" setting, the following can be used in
|
||||
as the "pre_commands" section:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
pre_commands: ! |
|
||||
variable newton_pair delete
|
||||
variable newton_pair index on
|
||||
|
||||
And for a pair style requiring a kspace solver the following would be used as
|
||||
the "post_commands" section:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
post_commands: ! |
|
||||
pair_modify table 0
|
||||
kspace_style pppm/tip4p 1.0e-6
|
||||
kspace_modify gewald 0.3
|
||||
kspace_modify compute no
|
||||
|
||||
Note that this disables computing the kspace contribution, but still will run
|
||||
the setup. The "gewald" parameter should be set explicitly to speed up the run.
|
||||
For styles with long-range electrostatics, typically two tests are added one using
|
||||
the (slower) analytic approximation of the erfc() function and the other using
|
||||
the tabulated coulomb, to test both code paths. The reference results in the YAML
|
||||
files then should be compared manually, if they agree well enough within the limits
|
||||
of those two approximations.
|
||||
|
||||
The ``test_pair_style`` and equivalent programs have special command line options
|
||||
to update the YAML files. Running a command like
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ test_pair_style mol-pair-lennard_mdf.yaml -g new.yaml
|
||||
|
||||
will read the settings from the ``mol-pair-lennard_mdf.yaml`` file and then compute
|
||||
the reference data and write a new file with to ``new.yaml``. If this step fails,
|
||||
there are likely some (LAMMPS or YAML) syntax issues in the YAML file that need to
|
||||
be resolved and then one can compare the two files to see if the output is as expected.
|
||||
|
||||
It is also possible to do an update in place with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ test_pair_style mol-pair-lennard_mdf.yaml -u
|
||||
|
||||
And one can finally run the full set of tests with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ test_pair_style mol-pair-lennard_mdf.yaml
|
||||
|
||||
This will just print a summary of the groups of tests. When using the "-v" flag
|
||||
the test will also keep any LAMMPS output and when using the "-s" flag, there
|
||||
will be some statistics reported on the relative errors for the individual checks
|
||||
which can help to figure out what would be a good choice of the epsilon parameter.
|
||||
It should be as small as possible to catch any unintended side effects from changes
|
||||
elsewhere, but large enough to accommodate the numerical noise due to the implementation
|
||||
of the potentials and differences in compilers.
|
||||
|
||||
.. note::
|
||||
|
||||
These kinds of tests can be very sensitive to compiler optimization and
|
||||
thus the expectation is that they pass with compiler optimization turned
|
||||
off. When compiler optimization is enabled, there may be some failures, but
|
||||
one has to carefully check whether those are acceptable due to the enhanced
|
||||
numerical noise from reordering floating-point math operations or due to
|
||||
the compiler mis-compiling the code. That is not always obvious.
|
||||
|
||||
|
||||
Tests for programs in the tools folder
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The ``unittest/tools`` folder contains tests for programs in the
|
||||
``tools`` folder. This currently only contains tests for the LAMMPS
|
||||
shell, which are implemented as a python scripts using the ``unittest``
|
||||
Python module and launching the tool commands through the ``subprocess``
|
||||
Python module.
|
||||
@ -36,7 +36,7 @@ polarizability :math:`\alpha` by
|
||||
|
||||
Ideally, the mass of the Drude particle should be small, and the
|
||||
stiffness of the harmonic bond should be large, so that the Drude
|
||||
particle remains close ot the core. The values of Drude mass, Drude
|
||||
particle remains close to the core. The values of Drude mass, Drude
|
||||
charge, and force constant can be chosen following different
|
||||
strategies, as in the following examples of polarizable force
|
||||
fields:
|
||||
|
||||
@ -38,7 +38,7 @@ Description
|
||||
Define a calculation that reduces one or more per-atom vectors into
|
||||
per-chunk values. This can be useful for diagnostic output. Or when
|
||||
used in conjunction with the :doc:`compute chunk/spread/atom <compute_chunk_spread_atom>` command it can be
|
||||
used ot create per-atom values that induce a new set of chunks with a
|
||||
used to create per-atom values that induce a new set of chunks with a
|
||||
second :doc:`compute chunk/atom <compute_chunk_atom>` command. An
|
||||
example is given below.
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ A detailed description of this method can be found in
|
||||
|
||||
The *sysdim* keyword is optional. If specified with a value smaller
|
||||
than the dimensionality of the LAMMPS simulation, its value is used
|
||||
for the dynamical matrix calculation. For example, using LAMMPS ot
|
||||
for the dynamical matrix calculation. For example, using LAMMPS to
|
||||
model a 2D or 3D system, the phonon dispersion of a 1D atomic chain
|
||||
can be computed using *sysdim* = 1.
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ Examples
|
||||
message server md file tmp.couple
|
||||
|
||||
message client md zmq localhost:5555
|
||||
message server md zmq \*:5555
|
||||
message server md zmq *:5555
|
||||
|
||||
message client md mpi/one
|
||||
message server md mpi/one
|
||||
|
||||
@ -13,7 +13,16 @@ Syntax
|
||||
* style = *atom* or *type* or *mol* or *group* or *region*
|
||||
* ID = atom ID range or type range or mol ID range or group ID or region ID
|
||||
* one or more keyword/value pairs may be appended
|
||||
* keyword = *type* or *type/fraction* or *type/ratio* or *type/subset* or *mol* or *x* or *y* or *z* or *charge* or *dipole* or *dipole/random* or *quat* or *spin* or *spin/random* or *quat* or *quat/random* or *diameter* or *shape* or *length* or *tri* or *theta* or *theta/random* or *angmom* or *omega* or *mass* or *density* or *density/disc* or *volume* or *image* or *bond* or *angle* or *dihedral* or *improper* or *sph/e* or *sph/cv* or *sph/rho* or *smd/contact/radius* or *smd/mass/density* or *dpd/theta* or *edpd/temp* or *edpd/cv* or *cc* or *i_name* or *d_name*
|
||||
* keyword = *type* or *type/fraction* or *type/ratio* or *type/subset* or *mol*
|
||||
or *x* or *y* or *z* or *vx* or *vy* or *vz*
|
||||
or *charge* or *dipole* or *dipole/random* or *spin* or *spin/random*
|
||||
or *quat* *quat/random* or *diameter* or *shape* or *length* or *tri*
|
||||
or *theta* or *theta/random* or *angmom* or *omega* or *mass*
|
||||
or *density* or *density/disc* or *volume* or *image*
|
||||
or *bond* or *angle* or *dihedral* or *improper*
|
||||
or *sph/e* or *sph/cv* or *sph/rho* or *smd/contact/radius* or *smd/mass/density*
|
||||
or *dpd/theta* or *edpd/temp* or *edpd/cv* or *cc*
|
||||
or *i_name* or *d_name*
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
|
||||
@ -66,11 +66,15 @@ generality, LAMMPS sets the fundamental quantities mass, :math:`\sigma`,
|
||||
masses, distances, energies you specify are multiples of these
|
||||
fundamental values. The formulas relating the reduced or unitless
|
||||
quantity (with an asterisk) to the same quantity with units is also
|
||||
given. Thus you can use the mass & :math:`\sigma` & :math:`\epsilon`
|
||||
given. Thus you can use the mass, :math:`\sigma`, and :math:`\epsilon`
|
||||
values for a specific material and convert the results from a unitless
|
||||
LJ simulation into physical quantities.
|
||||
LJ simulation into physical quantities. Please note that using
|
||||
these three properties as base, your unit of time has to conform
|
||||
to the relation :math:`\epsilon = \frac{m \sigma^2}{\tau^2}` since
|
||||
energy is a derived unit (in SI units you equivalently have the relation
|
||||
:math:`1\mathsf{J} = 1\frac{\mathsf{kg}\cdot\mathsf{m}^2}{\mathsf{s}^2}`).
|
||||
|
||||
* mass = mass or *m*
|
||||
* mass = mass or :math:`m`, where :math:`M^* = \frac{M}{m}`
|
||||
* distance = :math:`\sigma`, where :math:`x^* = \frac{x}{\sigma}`
|
||||
* time = :math:`\tau`, where :math:`\tau^* = \tau \sqrt{\frac{\epsilon}{m \sigma^2}}`
|
||||
* energy = :math:`\epsilon`, where :math:`E^* = \frac{E}{\epsilon}`
|
||||
|
||||
@ -148,6 +148,7 @@ athomps
|
||||
atm
|
||||
atomeye
|
||||
atomfile
|
||||
AtomicPairStyle
|
||||
atomID
|
||||
atomistic
|
||||
attogram
|
||||
@ -1119,11 +1120,13 @@ gmail
|
||||
gmake
|
||||
gmask
|
||||
Gmask
|
||||
GMock
|
||||
gneb
|
||||
GNEB
|
||||
Goldfarb
|
||||
Gonzalez-Melchor
|
||||
googlemail
|
||||
googletest
|
||||
Gordan
|
||||
Goudeau
|
||||
GPa
|
||||
@ -1544,6 +1547,7 @@ ksh
|
||||
kspace
|
||||
Kspace
|
||||
KSpace
|
||||
KSpaceStyle
|
||||
Kspring
|
||||
kT
|
||||
kTequil
|
||||
@ -1930,6 +1934,7 @@ mol
|
||||
Mol
|
||||
molfile
|
||||
Molfile
|
||||
MolPairStyle
|
||||
moltemplate
|
||||
momb
|
||||
Monaghan
|
||||
@ -2306,7 +2311,6 @@ ortho
|
||||
orthonormal
|
||||
orthorhombic
|
||||
oso
|
||||
ot
|
||||
Otype
|
||||
Ouldridge
|
||||
outfile
|
||||
@ -3295,6 +3299,7 @@ vdfmax
|
||||
vdim
|
||||
vdisplace
|
||||
vdW
|
||||
vdwl
|
||||
vec
|
||||
vectorial
|
||||
vectorization
|
||||
@ -3462,6 +3467,7 @@ xyz
|
||||
xz
|
||||
xzhou
|
||||
yaff
|
||||
yaml
|
||||
YAFF
|
||||
Yamada
|
||||
Yaser
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -255,11 +255,11 @@ void PPPMGPU::compute(int eflag, int vflag)
|
||||
|
||||
if (triclinic == 0) {
|
||||
gc->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO_GPU,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
brick2fft_gpu();
|
||||
} else {
|
||||
gc->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
PPPM::brick2fft();
|
||||
}
|
||||
|
||||
@ -274,20 +274,20 @@ void PPPMGPU::compute(int eflag, int vflag)
|
||||
|
||||
if (differentiation_flag == 1)
|
||||
gc->forward_comm_kspace(this,1,sizeof(FFT_SCALAR),FORWARD_AD,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
else
|
||||
gc->forward_comm_kspace(this,3,sizeof(FFT_SCALAR),FORWARD_IK,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
|
||||
// extra per-atom energy/virial communication
|
||||
|
||||
if (evflag_atom) {
|
||||
if (differentiation_flag == 1 && vflag_atom)
|
||||
gc->forward_comm_kspace(this,6,sizeof(FFT_SCALAR),FORWARD_AD_PERATOM,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
else if (differentiation_flag == 0)
|
||||
gc->forward_comm_kspace(this,7,sizeof(FFT_SCALAR),FORWARD_IK_PERATOM,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
}
|
||||
|
||||
poisson_time += MPI_Wtime()-t3;
|
||||
@ -831,7 +831,7 @@ void PPPMGPU::compute_group_group(int groupbit_A, int groupbit_B, int AA_flag)
|
||||
density_fft = density_A_fft;
|
||||
|
||||
gc->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
brick2fft();
|
||||
|
||||
// group B
|
||||
@ -840,7 +840,7 @@ void PPPMGPU::compute_group_group(int groupbit_A, int groupbit_B, int AA_flag)
|
||||
density_fft = density_B_fft;
|
||||
|
||||
gc->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
brick2fft();
|
||||
|
||||
// switch back pointers
|
||||
|
||||
@ -626,7 +626,7 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf)
|
||||
if (KIM_SupportStatus_NotEqual(kim_model_support_for_forces,
|
||||
KIM_SUPPORT_STATUS_notSupported) &&
|
||||
(KIM_SupportStatus_Equal(kim_model_support_for_particleVirial,
|
||||
KIM_SUPPORT_STATUS_notSupported) ||
|
||||
KIM_SUPPORT_STATUS_notSupported) ||
|
||||
(vflag_atom == 0))) {
|
||||
const double *const fp = &(atom->f[0][0]);
|
||||
for (int i = first; i < last; i++) {
|
||||
@ -635,9 +635,9 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf)
|
||||
buf[m++] = fp[3*i+2];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
// ----------------------------------------------------------------------
|
||||
// see Pair::ev_setup & Integrate::ev_set()
|
||||
// see Pair::ev_setup & Integrate::ev_set()
|
||||
// for values of eflag (0-3) and vflag (0-14)
|
||||
// -------------------------------------------------------------------------
|
||||
if ((vflag_atom != 0) &&
|
||||
@ -660,7 +660,7 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf)
|
||||
buf[m++] = va[6*i+5];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
if ((vflag_atom != 0) &&
|
||||
KIM_SupportStatus_Equal(kim_model_support_for_forces,
|
||||
KIM_SUPPORT_STATUS_notSupported) &&
|
||||
@ -676,7 +676,7 @@ int PairKIM::pack_reverse_comm(int n, int first, double *buf)
|
||||
buf[m++] = va[6*i+5];
|
||||
}
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -720,7 +720,7 @@ void PairKIM::unpack_reverse_comm(int n, int *list, double *buf)
|
||||
va[j*6+5]+=buf[m++];
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((vflag_atom != 0) &&
|
||||
KIM_SupportStatus_Equal(kim_model_support_for_forces,
|
||||
KIM_SUPPORT_STATUS_notSupported) &&
|
||||
|
||||
@ -245,7 +245,7 @@ void FixShakeKokkos<DeviceType>::pre_neighbor()
|
||||
Kokkos::parallel_for(nlocal, LAMMPS_LAMBDA(const int& i) {
|
||||
if (d_shake_flag[i]) {
|
||||
if (d_shake_flag[i] == 2) {
|
||||
const int atom1 = map_array(d_shake_atom(i,0));
|
||||
const int atom1 = map_array(d_shake_atom(i,0));
|
||||
const int atom2 = map_array(d_shake_atom(i,1));
|
||||
if (atom1 == -1 || atom2 == -1) {
|
||||
d_error_flag() = 1;
|
||||
@ -548,7 +548,7 @@ void FixShakeKokkos<DeviceType>::unconstrained_update()
|
||||
|
||||
auto mass = this->d_mass;
|
||||
auto type = this->d_type;
|
||||
|
||||
|
||||
Kokkos::parallel_for(nlocal, LAMMPS_LAMBDA(const int& i) {
|
||||
if (d_shake_flag[i]) {
|
||||
const double dtfmsq = dtfsq / mass[type[i]];
|
||||
@ -568,7 +568,7 @@ void FixShakeKokkos<DeviceType>::unconstrained_update()
|
||||
template<class DeviceType>
|
||||
template<int NEIGHFLAG, int EVFLAG>
|
||||
KOKKOS_INLINE_FUNCTION
|
||||
void FixShakeKokkos<DeviceType>::shake(int m, EV_FLOAT& ev) const
|
||||
void FixShakeKokkos<DeviceType>::shake(int m, EV_FLOAT& ev) const
|
||||
{
|
||||
|
||||
// The f array is duplicated for OpenMP, atomic for CUDA, and neither for Serial
|
||||
@ -1644,7 +1644,7 @@ void FixShakeKokkos<DeviceType>::correct_coordinates(int vflag) {
|
||||
|
||||
dtfsq = 0.5 * update->dt * update->dt * force->ftm2v;
|
||||
FixShakeKokkos<DeviceType>::post_force(vflag);
|
||||
|
||||
|
||||
atomKK->sync(Host,X_MASK|F_MASK);
|
||||
|
||||
// integrate coordinates: x' = xnp1 + dt^2/2m_i * f, where f is the constraining force
|
||||
|
||||
@ -161,7 +161,7 @@ void MSMCG::compute(int eflag, int vflag)
|
||||
|
||||
current_level = 0;
|
||||
gcall->reverse_comm_kspace(this,1,sizeof(double),REVERSE_RHO,
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
|
||||
// forward communicate charge density values to fill ghost grid points
|
||||
// compute direct sum interaction and then restrict to coarser grid
|
||||
@ -170,7 +170,7 @@ void MSMCG::compute(int eflag, int vflag)
|
||||
if (!active_flag[n]) continue;
|
||||
current_level = n;
|
||||
gc[n]->forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO,
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
direct(n);
|
||||
restriction(n);
|
||||
}
|
||||
@ -182,16 +182,16 @@ void MSMCG::compute(int eflag, int vflag)
|
||||
if (domain->nonperiodic) {
|
||||
current_level = levels-1;
|
||||
gc[levels-1]->
|
||||
forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
direct_top(levels-1);
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,1,sizeof(double),REVERSE_AD,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
reverse_comm_kspace(this,1,sizeof(double),REVERSE_AD,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
if (vflag_atom)
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
|
||||
} else {
|
||||
// Here using MPI_Allreduce is cheaper than using commgrid
|
||||
@ -200,9 +200,9 @@ void MSMCG::compute(int eflag, int vflag)
|
||||
grid_swap_reverse(levels-1,egrid[levels-1]);
|
||||
current_level = levels-1;
|
||||
if (vflag_atom)
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -215,13 +215,13 @@ void MSMCG::compute(int eflag, int vflag)
|
||||
|
||||
current_level = n;
|
||||
gc[n]->reverse_comm_kspace(this,1,sizeof(double),REVERSE_AD,
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
|
||||
// extra per-atom virial communication
|
||||
|
||||
if (vflag_atom)
|
||||
gc[n]->reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
}
|
||||
|
||||
// all procs communicate E-field values
|
||||
@ -229,13 +229,13 @@ void MSMCG::compute(int eflag, int vflag)
|
||||
|
||||
current_level = 0;
|
||||
gcall->forward_comm_kspace(this,1,sizeof(double),FORWARD_AD,
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
|
||||
// extra per-atom energy/virial communication
|
||||
|
||||
if (vflag_atom)
|
||||
gcall->forward_comm_kspace(this,6,sizeof(double),FORWARD_AD_PERATOM,
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
|
||||
// calculate the force on my particles (interpolation)
|
||||
|
||||
|
||||
@ -292,9 +292,9 @@ Variables needed for calculating the 1/r and 1/r^6 potential
|
||||
double *, double *, double *,
|
||||
double *, double *, double *,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, double *, double **, double **,
|
||||
FFT_SCALAR ***, double *, double **, double **,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***);
|
||||
|
||||
virtual void poisson_ad(FFT_SCALAR*, FFT_SCALAR*,
|
||||
@ -316,17 +316,17 @@ Variables needed for calculating the 1/r and 1/r^6 potential
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***,
|
||||
FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***,
|
||||
FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***);
|
||||
virtual void poisson_2s_ad(FFT_SCALAR *, FFT_SCALAR *,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***,
|
||||
FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***,
|
||||
FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***);
|
||||
|
||||
virtual void poisson_2s_peratom(FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***,
|
||||
@ -342,10 +342,10 @@ Variables needed for calculating the 1/r and 1/r^6 potential
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ***, FFT_SCALAR ***, FFT_SCALAR ***,
|
||||
FFT_SCALAR ****, FFT_SCALAR ****, FFT_SCALAR ****,
|
||||
FFT_SCALAR ****,
|
||||
FFT_SCALAR ****,
|
||||
FFT_SCALAR ****, FFT_SCALAR ****, FFT_SCALAR ****);
|
||||
virtual void poisson_none_peratom(int, int,
|
||||
FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***,
|
||||
FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***,
|
||||
FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***,
|
||||
FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***,
|
||||
FFT_SCALAR***, FFT_SCALAR***, FFT_SCALAR***);
|
||||
|
||||
@ -46,7 +46,7 @@ PairNb3bHarmonic::PairNb3bHarmonic(LAMMPS *lmp) : Pair(lmp)
|
||||
single_enable = 0;
|
||||
restartinfo = 0;
|
||||
one_coeff = 1;
|
||||
manybody_flag = 1;
|
||||
manybody_flag = 1;
|
||||
centroidstressflag = CENTROID_NOTAVAIL;
|
||||
unit_convert_flag = utils::get_supported_conversions(utils::ENERGY);
|
||||
|
||||
|
||||
@ -230,7 +230,7 @@ void PPPMIntel::compute_first(int eflag, int vflag)
|
||||
// remap from 3d decomposition to FFT decomposition
|
||||
|
||||
gc->reverse_comm_kspace(this,1,sizeof(FFT_SCALAR),REVERSE_RHO,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
brick2fft();
|
||||
|
||||
// compute potential gradient on my FFT grid and
|
||||
@ -246,20 +246,20 @@ void PPPMIntel::compute_first(int eflag, int vflag)
|
||||
|
||||
if (differentiation_flag == 1)
|
||||
gc->forward_comm_kspace(this,1,sizeof(FFT_SCALAR),FORWARD_AD,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
else
|
||||
gc->forward_comm_kspace(this,3,sizeof(FFT_SCALAR),FORWARD_IK,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
|
||||
// extra per-atom energy/virial communication
|
||||
|
||||
if (evflag_atom) {
|
||||
if (differentiation_flag == 1 && vflag_atom)
|
||||
gc->forward_comm_kspace(this,6,sizeof(FFT_SCALAR),FORWARD_AD_PERATOM,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
else if (differentiation_flag == 0)
|
||||
gc->forward_comm_kspace(this,7,sizeof(FFT_SCALAR),FORWARD_IK_PERATOM,
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
gc_buf1,gc_buf2,MPI_FFT_SCALAR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -166,7 +166,7 @@ void MSMCGOMP::compute(int eflag, int vflag)
|
||||
|
||||
current_level = 0;
|
||||
gcall->reverse_comm_kspace(this,1,sizeof(double),REVERSE_RHO,
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
|
||||
// forward communicate charge density values to fill ghost grid points
|
||||
// compute direct sum interaction and then restrict to coarser grid
|
||||
@ -175,7 +175,7 @@ void MSMCGOMP::compute(int eflag, int vflag)
|
||||
if (!active_flag[n]) continue;
|
||||
current_level = n;
|
||||
gc[n]->forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO,
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
direct(n);
|
||||
restriction(n);
|
||||
}
|
||||
@ -187,16 +187,16 @@ void MSMCGOMP::compute(int eflag, int vflag)
|
||||
if (domain->nonperiodic) {
|
||||
current_level = levels-1;
|
||||
gc[levels-1]->
|
||||
forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
forward_comm_kspace(this,1,sizeof(double),FORWARD_RHO,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
direct_top(levels-1);
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,1,sizeof(double),REVERSE_AD,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
reverse_comm_kspace(this,1,sizeof(double),REVERSE_AD,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
if (vflag_atom)
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
|
||||
} else {
|
||||
// Here using MPI_Allreduce is cheaper than using commgrid
|
||||
@ -205,9 +205,9 @@ void MSMCGOMP::compute(int eflag, int vflag)
|
||||
grid_swap_reverse(levels-1,egrid[levels-1]);
|
||||
current_level = levels-1;
|
||||
if (vflag_atom)
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
gc[levels-1]->
|
||||
reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[levels-1],gc_buf2[levels-1],MPI_DOUBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,13 +220,13 @@ void MSMCGOMP::compute(int eflag, int vflag)
|
||||
|
||||
current_level = n;
|
||||
gc[n]->reverse_comm_kspace(this,1,sizeof(double),REVERSE_AD,
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
|
||||
// extra per-atom virial communication
|
||||
|
||||
if (vflag_atom)
|
||||
gc[n]->reverse_comm_kspace(this,6,sizeof(double),REVERSE_AD_PERATOM,
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
gc_buf1[n],gc_buf2[n],MPI_DOUBLE);
|
||||
}
|
||||
|
||||
// all procs communicate E-field values
|
||||
@ -234,13 +234,13 @@ void MSMCGOMP::compute(int eflag, int vflag)
|
||||
|
||||
current_level = 0;
|
||||
gcall->forward_comm_kspace(this,1,sizeof(double),FORWARD_AD,
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
|
||||
// extra per-atom energy/virial communication
|
||||
|
||||
if (vflag_atom)
|
||||
gcall->forward_comm_kspace(this,6,sizeof(double),FORWARD_AD_PERATOM,
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
gcall_buf1,gcall_buf2,MPI_DOUBLE);
|
||||
|
||||
// calculate the force on my particles (interpolation)
|
||||
|
||||
|
||||
@ -126,11 +126,11 @@ void ComputeCentroidStressAtom::init()
|
||||
|
||||
// check if force components and fixes support centroid atom stress
|
||||
// all bond styles support it as CENTROID_SAME
|
||||
|
||||
|
||||
if (pairflag && force->pair)
|
||||
if (force->pair->centroidstressflag == CENTROID_NOTAVAIL)
|
||||
error->all(FLERR, "Pair style does not support compute centroid/stress/atom");
|
||||
|
||||
|
||||
if (angleflag && force->angle)
|
||||
if (force->angle->centroidstressflag == CENTROID_NOTAVAIL)
|
||||
error->all(FLERR, "Angle style does not support compute centroid/stress/atom");
|
||||
@ -150,8 +150,8 @@ void ComputeCentroidStressAtom::init()
|
||||
if (fixflag) {
|
||||
for (int ifix = 0; ifix < modify->nfix; ifix++)
|
||||
if (modify->fix[ifix]->virial_flag &&
|
||||
modify->fix[ifix]->centroidstressflag == CENTROID_NOTAVAIL)
|
||||
error->all(FLERR, "Fix style does not support compute centroid/stress/atom");
|
||||
modify->fix[ifix]->centroidstressflag == CENTROID_NOTAVAIL)
|
||||
error->all(FLERR, "Fix style does not support compute centroid/stress/atom");
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,9 +199,9 @@ void ComputeCentroidStressAtom::compute_peratom()
|
||||
stress[i][j] = 0.0;
|
||||
|
||||
// add in per-atom contributions from all force components and fixes
|
||||
|
||||
|
||||
// pair styles are either CENTROID_SAME or CENTROID_AVAIL or CENTROID_NOTAVAIL
|
||||
|
||||
|
||||
if (pairflag && force->pair && force->pair->compute_flag) {
|
||||
if (force->pair->centroidstressflag == CENTROID_AVAIL) {
|
||||
double **cvatom = force->pair->cvatom;
|
||||
@ -223,7 +223,7 @@ void ComputeCentroidStressAtom::compute_peratom()
|
||||
// bond styles are all CENTROID_SAME
|
||||
// angle, dihedral, improper styles are CENTROID_AVAIL or CENTROID_NOTAVAIL
|
||||
// KSpace styles are all CENTROID_NOTAVAIL, placeholder CENTROID_SAME below
|
||||
|
||||
|
||||
if (bondflag && force->bond) {
|
||||
double **vatom = force->bond->vatom;
|
||||
for (i = 0; i < nbond; i++) {
|
||||
@ -271,7 +271,7 @@ void ComputeCentroidStressAtom::compute_peratom()
|
||||
// e.g. fix ave/spatial defined before fix shake,
|
||||
// and fix ave/spatial uses a per-atom stress from this compute as input
|
||||
// fix styles are CENTROID_SAME or CENTROID_NOTAVAIL
|
||||
|
||||
|
||||
if (fixflag) {
|
||||
for (int ifix = 0; ifix < modify->nfix; ifix++)
|
||||
if (modify->fix[ifix]->virial_flag) {
|
||||
|
||||
@ -105,7 +105,7 @@ Fix::Fix(LAMMPS *lmp, int /*narg*/, char **arg) :
|
||||
maxeatom = maxvatom = 0;
|
||||
vflag_atom = 0;
|
||||
centroidstressflag = CENTROID_SAME;
|
||||
|
||||
|
||||
// KOKKOS per-fix data masks
|
||||
|
||||
execution_space = Host;
|
||||
|
||||
@ -41,7 +41,7 @@ FixNeighHistory::FixNeighHistory(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
restart_peratom = 1;
|
||||
restart_global = 1;
|
||||
|
||||
|
||||
create_attribute = 1;
|
||||
maxexchange_dynamic = 1;
|
||||
|
||||
@ -855,7 +855,7 @@ void FixNeighHistory::write_restart(FILE *fp)
|
||||
if (comm->me == 0) {
|
||||
int size = 0;
|
||||
fwrite(&size,sizeof(int),1,fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ class FixNeighHistory : public Fix {
|
||||
void unpack_reverse_comm(int, int *, double *);
|
||||
int pack_exchange(int, double *);
|
||||
int unpack_exchange(int, double *);
|
||||
void write_restart(FILE *);
|
||||
void write_restart(FILE *);
|
||||
int pack_restart(int, double *);
|
||||
void unpack_restart(int, int);
|
||||
int size_restart(int);
|
||||
|
||||
@ -18,7 +18,7 @@
|
||||
#include <vector>
|
||||
|
||||
// The fmt library version in the form major * 10000 + minor * 100 + patch.
|
||||
#define FMT_VERSION 70102
|
||||
#define FMT_VERSION 70103
|
||||
|
||||
#ifdef __clang__
|
||||
# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
|
||||
@ -769,7 +769,7 @@ class fixed_buffer_traits {
|
||||
explicit fixed_buffer_traits(size_t limit) : limit_(limit) {}
|
||||
size_t count() const { return count_; }
|
||||
size_t limit(size_t size) {
|
||||
size_t n = limit_ - count_;
|
||||
size_t n = limit_ > count_ ? limit_ - count_ : 0;
|
||||
count_ += size;
|
||||
return size < n ? size : n;
|
||||
}
|
||||
@ -792,7 +792,7 @@ class iterator_buffer final : public Traits, public buffer<T> {
|
||||
public:
|
||||
explicit iterator_buffer(OutputIt out, size_t n = buffer_size)
|
||||
: Traits(n),
|
||||
buffer<T>(data_, 0, n < size_t(buffer_size) ? n : size_t(buffer_size)),
|
||||
buffer<T>(data_, 0, buffer_size),
|
||||
out_(out) {}
|
||||
~iterator_buffer() { flush(); }
|
||||
|
||||
|
||||
@ -1145,8 +1145,8 @@ template <typename T = void> struct null {};
|
||||
template <typename Char> struct fill_t {
|
||||
private:
|
||||
enum { max_size = 4 };
|
||||
Char data_[max_size];
|
||||
unsigned char size_;
|
||||
Char data_[max_size] = {Char(' '), Char(0), Char(0), Char(0)};
|
||||
unsigned char size_ = 1;
|
||||
|
||||
public:
|
||||
FMT_CONSTEXPR void operator=(basic_string_view<Char> s) {
|
||||
@ -1166,13 +1166,6 @@ template <typename Char> struct fill_t {
|
||||
FMT_CONSTEXPR const Char& operator[](size_t index) const {
|
||||
return data_[index];
|
||||
}
|
||||
|
||||
static FMT_CONSTEXPR fill_t<Char> make() {
|
||||
auto fill = fill_t<Char>();
|
||||
fill[0] = Char(' ');
|
||||
fill.size_ = 1;
|
||||
return fill;
|
||||
}
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
@ -1204,8 +1197,7 @@ template <typename Char> struct basic_format_specs {
|
||||
type(0),
|
||||
align(align::none),
|
||||
sign(sign::none),
|
||||
alt(false),
|
||||
fill(detail::fill_t<Char>::make()) {}
|
||||
alt(false) {}
|
||||
};
|
||||
|
||||
using format_specs = basic_format_specs<char>;
|
||||
@ -1274,7 +1266,7 @@ template <typename T> struct decimal_fp {
|
||||
int exponent;
|
||||
};
|
||||
|
||||
template <typename T> decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT;
|
||||
template <typename T> FMT_API decimal_fp<T> to_decimal(T x) FMT_NOEXCEPT;
|
||||
} // namespace dragonbox
|
||||
|
||||
template <typename T>
|
||||
|
||||
@ -388,7 +388,7 @@ class ostream final : private detail::buffer<char> {
|
||||
clear();
|
||||
}
|
||||
|
||||
void grow(size_t) final;
|
||||
FMT_API void grow(size_t) override final;
|
||||
|
||||
ostream(cstring_view path, const detail::ostream_params& params)
|
||||
: file_(path, params.oflag) {
|
||||
|
||||
@ -254,7 +254,10 @@ struct formatter<
|
||||
enable_if_t<fmt::is_range<T, Char>::value
|
||||
// Workaround a bug in MSVC 2017 and earlier.
|
||||
#if !FMT_MSC_VER || FMT_MSC_VER >= 1927
|
||||
&& has_formatter<detail::value_type<T>, format_context>::value
|
||||
&&
|
||||
(has_formatter<detail::value_type<T>, format_context>::value ||
|
||||
detail::has_fallback_formatter<detail::value_type<T>,
|
||||
format_context>::value)
|
||||
#endif
|
||||
>> {
|
||||
formatting_range<Char> formatting;
|
||||
|
||||
@ -24,9 +24,9 @@ int format_float(char* buf, std::size_t size, const char* format, int precision,
|
||||
: snprintf_ptr(buf, size, format, precision, value);
|
||||
}
|
||||
|
||||
template dragonbox::decimal_fp<float> dragonbox::to_decimal(float x)
|
||||
template FMT_API dragonbox::decimal_fp<float> dragonbox::to_decimal(float x)
|
||||
FMT_NOEXCEPT;
|
||||
template dragonbox::decimal_fp<double> dragonbox::to_decimal(double x)
|
||||
template FMT_API dragonbox::decimal_fp<double> dragonbox::to_decimal(double x)
|
||||
FMT_NOEXCEPT;
|
||||
|
||||
// DEPRECATED! This function exists for ABI compatibility.
|
||||
|
||||
@ -315,7 +315,7 @@ long getpagesize() {
|
||||
# endif
|
||||
}
|
||||
|
||||
void ostream::grow(size_t) {
|
||||
FMT_API void ostream::grow(size_t) {
|
||||
if (this->size() == this->capacity()) flush();
|
||||
}
|
||||
#endif // FMT_USE_FCNTL
|
||||
|
||||
@ -89,7 +89,7 @@ KSpace::KSpace(LAMMPS *lmp) : Pointers(lmp)
|
||||
eatom = nullptr;
|
||||
vatom = nullptr;
|
||||
centroidstressflag = CENTROID_NOTAVAIL;
|
||||
|
||||
|
||||
execution_space = Host;
|
||||
datamask_read = ALL_MASK;
|
||||
datamask_modify = ALL_MASK;
|
||||
|
||||
@ -841,6 +841,10 @@ not recognized, the function returns -1.
|
||||
See :doc:`create_box`.
|
||||
* - nthreads
|
||||
- Number of requested OpenMP threads for LAMMPS' execution
|
||||
* - newton_bond
|
||||
- 1 if Newton's 3rd law is applied to bonded interactions, 0 if not.
|
||||
* - newton_pair
|
||||
- 1 if Newton's 3rd law is applied to non-bonded interactions, 0 if not.
|
||||
* - triclinic
|
||||
- 1 if the the simulation box is triclinic, 0 if orthogonal.
|
||||
See :doc:`change_box`.
|
||||
@ -933,6 +937,8 @@ int lammps_extract_setting(void *handle, const char *keyword)
|
||||
|
||||
if (strcmp(keyword,"dimension") == 0) return lmp->domain->dimension;
|
||||
if (strcmp(keyword,"box_exist") == 0) return lmp->domain->box_exist;
|
||||
if (strcmp(keyword,"newton_bond") == 0) return lmp->force->newton_bond;
|
||||
if (strcmp(keyword,"newton_pair") == 0) return lmp->force->newton_pair;
|
||||
if (strcmp(keyword,"triclinic") == 0) return lmp->domain->triclinic;
|
||||
|
||||
if (strcmp(keyword,"universe_rank") == 0) return lmp->universe->me;
|
||||
|
||||
@ -805,7 +805,7 @@ void Pair::ev_setup(int eflag, int vflag, int alloc)
|
||||
eflag_either = eflag;
|
||||
eflag_global = eflag & ENERGY_GLOBAL;
|
||||
eflag_atom = eflag & ENERGY_ATOM;
|
||||
|
||||
|
||||
vflag_global = vflag & VIRIAL_PAIR;
|
||||
if (vflag & VIRIAL_FDOTR && no_virial_fdotr_compute == 1) vflag_global = 1;
|
||||
vflag_fdotr = 0;
|
||||
@ -817,7 +817,7 @@ void Pair::ev_setup(int eflag, int vflag, int alloc)
|
||||
vflag_either = vflag_global || vflag_atom || cvflag_atom;
|
||||
|
||||
evflag = eflag_either || vflag_either;
|
||||
|
||||
|
||||
// reallocate per-atom arrays if necessary
|
||||
|
||||
if (eflag_atom && atom->nmax > maxeatom) {
|
||||
|
||||
@ -163,7 +163,7 @@ void PairHybrid::compute(int eflag, int vflag)
|
||||
}
|
||||
|
||||
// substyles may be CENTROID_SAME or CENTROID_AVAIL
|
||||
|
||||
|
||||
if (cvflag_atom) {
|
||||
n = atom->nlocal;
|
||||
if (force->newton_pair) n += atom->nghost;
|
||||
@ -385,7 +385,7 @@ void PairHybrid::flags()
|
||||
compute_flag = 0;
|
||||
respa_enable = 0;
|
||||
restartinfo = 0;
|
||||
|
||||
|
||||
for (m = 0; m < nstyles; m++) {
|
||||
if (styles[m]->single_enable) ++single_enable;
|
||||
if (styles[m]->respa_enable) ++respa_enable;
|
||||
@ -418,7 +418,7 @@ void PairHybrid::flags()
|
||||
if (styles[m]->centroidstressflag == CENTROID_NOTAVAIL)
|
||||
centroidstressflag = CENTROID_NOTAVAIL;
|
||||
if (centroidstressflag == CENTROID_SAME &&
|
||||
styles[m]->centroidstressflag == CENTROID_AVAIL)
|
||||
styles[m]->centroidstressflag == CENTROID_AVAIL)
|
||||
centroidstressflag = CENTROID_AVAIL;
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,10 +91,11 @@ TEST_F(LibraryProperties, thermo)
|
||||
{
|
||||
if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP();
|
||||
std::string input = INPUT_DIR + PATH_SEP + "in.fourmol";
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
::testing::internal::CaptureStdout();
|
||||
lammps_file(lmp, input.c_str());
|
||||
lammps_command(lmp, "run 2 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
EXPECT_EQ(lammps_get_thermo(lmp, "step"), 2);
|
||||
EXPECT_EQ(lammps_get_thermo(lmp, "atoms"), 29);
|
||||
EXPECT_DOUBLE_EQ(lammps_get_thermo(lmp, "vol"), 3375.0);
|
||||
@ -106,10 +107,11 @@ TEST_F(LibraryProperties, box)
|
||||
{
|
||||
if (!lammps_has_style(lmp, "atom", "full")) GTEST_SKIP();
|
||||
std::string input = INPUT_DIR + PATH_SEP + "in.fourmol";
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
::testing::internal::CaptureStdout();
|
||||
lammps_file(lmp, input.c_str());
|
||||
lammps_command(lmp, "run 2 post no");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
if (verbose) std::cout << output;
|
||||
double boxlo[3], boxhi[3], xy, yz, xz;
|
||||
int pflags[3], boxflag;
|
||||
lammps_extract_box(lmp, boxlo, boxhi, &xy, &yz, &xz, pflags, &boxflag);
|
||||
@ -204,6 +206,28 @@ TEST_F(LibraryProperties, setting)
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "universe_size"), 1);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "universe_rank"), 0);
|
||||
EXPECT_GT(lammps_extract_setting(lmp, "nthreads"), 0);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 1);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 1);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lammps_command(lmp, "newton off");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 0);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 0);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lammps_command(lmp, "newton on off");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 1);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 0);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lammps_command(lmp, "newton off on");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 0);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 1);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lammps_command(lmp, "newton on");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_pair"), 1);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "newton_bond"), 1);
|
||||
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "ntypes"), 0);
|
||||
EXPECT_EQ(lammps_extract_setting(lmp, "nbondtypes"), 0);
|
||||
|
||||
@ -480,182 +480,182 @@ TEST_F(ResetIDsTest, TopologyData)
|
||||
ASSERT_EQ(lmp->atom->natoms, 23);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 26);
|
||||
|
||||
auto num_bond = lmp->atom->num_bond;
|
||||
auto num_angle = lmp->atom->num_angle;
|
||||
auto num_dihedral = lmp->atom->num_dihedral;
|
||||
auto num_improper = lmp->atom->num_improper;
|
||||
auto bond_atom = lmp->atom->bond_atom;
|
||||
auto angle_atom1 = lmp->atom->angle_atom1;
|
||||
auto angle_atom2 = lmp->atom->angle_atom2;
|
||||
auto angle_atom3 = lmp->atom->angle_atom3;
|
||||
ASSERT_EQ(num_bond[GETIDX(1)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][0],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][1],3);
|
||||
ASSERT_EQ(num_bond[GETIDX(2)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(3)],3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][0],4);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][1],5);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][2],6);
|
||||
ASSERT_EQ(num_bond[GETIDX(4)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(5)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(6)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(6)][0],8);
|
||||
ASSERT_EQ(bond_atom[GETIDX(6)][1],7);
|
||||
ASSERT_EQ(num_bond[GETIDX(7)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(8)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][0],9);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][1],10);
|
||||
ASSERT_EQ(num_bond[GETIDX(9)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(10)],3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(10)][0],11);
|
||||
ASSERT_EQ(bond_atom[GETIDX(10)][1],12);
|
||||
ASSERT_EQ(bond_atom[GETIDX(10)][2],16);
|
||||
ASSERT_EQ(num_bond[GETIDX(11)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(12)],3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(12)][0],13);
|
||||
ASSERT_EQ(bond_atom[GETIDX(12)][1],14);
|
||||
ASSERT_EQ(bond_atom[GETIDX(12)][2],15);
|
||||
ASSERT_EQ(num_bond[GETIDX(13)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(14)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(15)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(16)],1);
|
||||
ASSERT_EQ(bond_atom[GETIDX(16)][0],17);
|
||||
ASSERT_EQ(num_bond[GETIDX(17)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(18)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(18)][0],19);
|
||||
ASSERT_EQ(bond_atom[GETIDX(18)][1],20);
|
||||
ASSERT_EQ(num_bond[GETIDX(19)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(20)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(24)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(24)][0],25);
|
||||
ASSERT_EQ(bond_atom[GETIDX(24)][1],26);
|
||||
ASSERT_EQ(num_bond[GETIDX(25)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(26)],0);
|
||||
auto num_bond = lmp->atom->num_bond;
|
||||
auto num_angle = lmp->atom->num_angle;
|
||||
auto num_dihedral = lmp->atom->num_dihedral;
|
||||
auto num_improper = lmp->atom->num_improper;
|
||||
auto bond_atom = lmp->atom->bond_atom;
|
||||
auto angle_atom1 = lmp->atom->angle_atom1;
|
||||
auto angle_atom2 = lmp->atom->angle_atom2;
|
||||
auto angle_atom3 = lmp->atom->angle_atom3;
|
||||
ASSERT_EQ(num_bond[GETIDX(1)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][0], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][1], 3);
|
||||
ASSERT_EQ(num_bond[GETIDX(2)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(3)], 3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][0], 4);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][1], 5);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][2], 6);
|
||||
ASSERT_EQ(num_bond[GETIDX(4)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(5)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(6)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(6)][0], 8);
|
||||
ASSERT_EQ(bond_atom[GETIDX(6)][1], 7);
|
||||
ASSERT_EQ(num_bond[GETIDX(7)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(8)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][0], 9);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][1], 10);
|
||||
ASSERT_EQ(num_bond[GETIDX(9)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(10)], 3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(10)][0], 11);
|
||||
ASSERT_EQ(bond_atom[GETIDX(10)][1], 12);
|
||||
ASSERT_EQ(bond_atom[GETIDX(10)][2], 16);
|
||||
ASSERT_EQ(num_bond[GETIDX(11)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(12)], 3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(12)][0], 13);
|
||||
ASSERT_EQ(bond_atom[GETIDX(12)][1], 14);
|
||||
ASSERT_EQ(bond_atom[GETIDX(12)][2], 15);
|
||||
ASSERT_EQ(num_bond[GETIDX(13)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(14)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(15)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(16)], 1);
|
||||
ASSERT_EQ(bond_atom[GETIDX(16)][0], 17);
|
||||
ASSERT_EQ(num_bond[GETIDX(17)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(18)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(18)][0], 19);
|
||||
ASSERT_EQ(bond_atom[GETIDX(18)][1], 20);
|
||||
ASSERT_EQ(num_bond[GETIDX(19)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(20)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(24)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(24)][0], 25);
|
||||
ASSERT_EQ(bond_atom[GETIDX(24)][1], 26);
|
||||
ASSERT_EQ(num_bond[GETIDX(25)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(26)], 0);
|
||||
|
||||
ASSERT_EQ(num_angle[GETIDX(1)],1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(1)][0],2);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(1)][0],1);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(1)][0],3);
|
||||
ASSERT_EQ(num_angle[GETIDX(2)],0);
|
||||
ASSERT_EQ(num_angle[GETIDX(3)],6);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][0],1);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][0],3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][0],5);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][1],1);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][1],3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][1],4);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][2],1);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][2],3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][2],6);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][3],4);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][3],3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][3],5);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][4],5);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][4],3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][4],6);
|
||||
ASSERT_EQ(num_angle[GETIDX(18)],1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(18)][0],19);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(18)][0],18);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(18)][0],20);
|
||||
ASSERT_EQ(num_angle[GETIDX(24)],1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(24)][0],25);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(24)][0],24);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(24)][0],26);
|
||||
ASSERT_EQ(num_angle[GETIDX(1)], 1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(1)][0], 2);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(1)][0], 1);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(1)][0], 3);
|
||||
ASSERT_EQ(num_angle[GETIDX(2)], 0);
|
||||
ASSERT_EQ(num_angle[GETIDX(3)], 6);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][0], 1);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][0], 3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][0], 5);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][1], 1);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][1], 3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][1], 4);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][2], 1);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][2], 3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][2], 6);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][3], 4);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][3], 3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][3], 5);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(3)][4], 5);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(3)][4], 3);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(3)][4], 6);
|
||||
ASSERT_EQ(num_angle[GETIDX(18)], 1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(18)][0], 19);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(18)][0], 18);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(18)][0], 20);
|
||||
ASSERT_EQ(num_angle[GETIDX(24)], 1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(24)][0], 25);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(24)][0], 24);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(24)][0], 26);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("reset_atom_ids sort yes");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
num_bond = lmp->atom->num_bond;
|
||||
num_angle = lmp->atom->num_angle;
|
||||
num_dihedral = lmp->atom->num_dihedral;
|
||||
num_improper = lmp->atom->num_improper;
|
||||
bond_atom = lmp->atom->bond_atom;
|
||||
angle_atom1 = lmp->atom->angle_atom1;
|
||||
angle_atom2 = lmp->atom->angle_atom2;
|
||||
angle_atom3 = lmp->atom->angle_atom3;
|
||||
ASSERT_EQ(num_bond[GETIDX(1)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][0],3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][1],2);
|
||||
ASSERT_EQ(num_bond[GETIDX(2)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(3)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][0],16);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][1],5);
|
||||
ASSERT_EQ(num_bond[GETIDX(4)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(5)],3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(5)][0],4);
|
||||
ASSERT_EQ(bond_atom[GETIDX(5)][1],8);
|
||||
ASSERT_EQ(bond_atom[GETIDX(5)][2],18);
|
||||
ASSERT_EQ(num_bond[GETIDX(6)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(7)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(8)],3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][0],9);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][1],6);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][2],7);
|
||||
ASSERT_EQ(num_bond[GETIDX(9)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(10)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(11)],3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(11)][0],10);
|
||||
ASSERT_EQ(bond_atom[GETIDX(11)][1],19);
|
||||
ASSERT_EQ(bond_atom[GETIDX(11)][2],1);
|
||||
ASSERT_EQ(num_bond[GETIDX(12)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(13)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(14)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(14)][0],13);
|
||||
ASSERT_EQ(bond_atom[GETIDX(14)][1],15);
|
||||
ASSERT_EQ(num_bond[GETIDX(15)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(16)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(17)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(18)],1);
|
||||
ASSERT_EQ(bond_atom[GETIDX(18)][0],17);
|
||||
ASSERT_EQ(num_bond[GETIDX(19)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(20)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(20)][0],12);
|
||||
ASSERT_EQ(bond_atom[GETIDX(20)][1],11);
|
||||
ASSERT_EQ(num_bond[GETIDX(21)],0);
|
||||
ASSERT_EQ(num_bond[GETIDX(22)],2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(22)][0],21);
|
||||
ASSERT_EQ(bond_atom[GETIDX(22)][1],23);
|
||||
ASSERT_EQ(num_bond[GETIDX(23)],0);
|
||||
num_bond = lmp->atom->num_bond;
|
||||
num_angle = lmp->atom->num_angle;
|
||||
num_dihedral = lmp->atom->num_dihedral;
|
||||
num_improper = lmp->atom->num_improper;
|
||||
bond_atom = lmp->atom->bond_atom;
|
||||
angle_atom1 = lmp->atom->angle_atom1;
|
||||
angle_atom2 = lmp->atom->angle_atom2;
|
||||
angle_atom3 = lmp->atom->angle_atom3;
|
||||
ASSERT_EQ(num_bond[GETIDX(1)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][0], 3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(1)][1], 2);
|
||||
ASSERT_EQ(num_bond[GETIDX(2)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(3)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][0], 16);
|
||||
ASSERT_EQ(bond_atom[GETIDX(3)][1], 5);
|
||||
ASSERT_EQ(num_bond[GETIDX(4)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(5)], 3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(5)][0], 4);
|
||||
ASSERT_EQ(bond_atom[GETIDX(5)][1], 8);
|
||||
ASSERT_EQ(bond_atom[GETIDX(5)][2], 18);
|
||||
ASSERT_EQ(num_bond[GETIDX(6)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(7)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(8)], 3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][0], 9);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][1], 6);
|
||||
ASSERT_EQ(bond_atom[GETIDX(8)][2], 7);
|
||||
ASSERT_EQ(num_bond[GETIDX(9)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(10)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(11)], 3);
|
||||
ASSERT_EQ(bond_atom[GETIDX(11)][0], 10);
|
||||
ASSERT_EQ(bond_atom[GETIDX(11)][1], 19);
|
||||
ASSERT_EQ(bond_atom[GETIDX(11)][2], 1);
|
||||
ASSERT_EQ(num_bond[GETIDX(12)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(13)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(14)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(14)][0], 13);
|
||||
ASSERT_EQ(bond_atom[GETIDX(14)][1], 15);
|
||||
ASSERT_EQ(num_bond[GETIDX(15)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(16)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(17)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(18)], 1);
|
||||
ASSERT_EQ(bond_atom[GETIDX(18)][0], 17);
|
||||
ASSERT_EQ(num_bond[GETIDX(19)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(20)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(20)][0], 12);
|
||||
ASSERT_EQ(bond_atom[GETIDX(20)][1], 11);
|
||||
ASSERT_EQ(num_bond[GETIDX(21)], 0);
|
||||
ASSERT_EQ(num_bond[GETIDX(22)], 2);
|
||||
ASSERT_EQ(bond_atom[GETIDX(22)][0], 21);
|
||||
ASSERT_EQ(bond_atom[GETIDX(22)][1], 23);
|
||||
ASSERT_EQ(num_bond[GETIDX(23)], 0);
|
||||
|
||||
ASSERT_EQ(num_angle[GETIDX(1)],3);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(1)][0],11);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(1)][0],1);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(1)][0],2);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(1)][1],11);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(1)][1],1);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(1)][1],3);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(1)][2],2);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(1)][2],1);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(1)][2],3);
|
||||
ASSERT_EQ(num_angle[GETIDX(2)],0);
|
||||
ASSERT_EQ(num_angle[GETIDX(5)],6);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][0],3);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][0],5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][0],4);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][1],3);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][1],5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][1],18);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][2],4);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][2],5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][2],8);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][3],8);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][3],5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][3],18);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][4],3);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][4],5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][4],8);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][5],4);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][5],5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][5],18);
|
||||
ASSERT_EQ(num_angle[GETIDX(20)],1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(20)][0],12);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(20)][0],20);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(20)][0],11);
|
||||
ASSERT_EQ(num_angle[GETIDX(22)],1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(22)][0],21);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(22)][0],22);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(22)][0],23);
|
||||
ASSERT_EQ(num_angle[GETIDX(1)], 3);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(1)][0], 11);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(1)][0], 1);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(1)][0], 2);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(1)][1], 11);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(1)][1], 1);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(1)][1], 3);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(1)][2], 2);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(1)][2], 1);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(1)][2], 3);
|
||||
ASSERT_EQ(num_angle[GETIDX(2)], 0);
|
||||
ASSERT_EQ(num_angle[GETIDX(5)], 6);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][0], 3);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][0], 5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][0], 4);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][1], 3);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][1], 5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][1], 18);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][2], 4);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][2], 5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][2], 8);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][3], 8);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][3], 5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][3], 18);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][4], 3);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][4], 5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][4], 8);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(5)][5], 4);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(5)][5], 5);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(5)][5], 18);
|
||||
ASSERT_EQ(num_angle[GETIDX(20)], 1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(20)][0], 12);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(20)][0], 20);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(20)][0], 11);
|
||||
ASSERT_EQ(num_angle[GETIDX(22)], 1);
|
||||
ASSERT_EQ(angle_atom1[GETIDX(22)][0], 21);
|
||||
ASSERT_EQ(angle_atom2[GETIDX(22)][0], 22);
|
||||
ASSERT_EQ(angle_atom3[GETIDX(22)][0], 23);
|
||||
}
|
||||
|
||||
TEST_F(ResetIDsTest, DeathTests)
|
||||
|
||||
@ -11,13 +11,16 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "lammps.h"
|
||||
|
||||
#include "force.h"
|
||||
#include "info.h"
|
||||
#include "input.h"
|
||||
#include "lammps.h"
|
||||
#include "output.h"
|
||||
#include "update.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include "fmt/format.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@ -161,6 +164,33 @@ TEST_F(SimpleCommandsTest, Log)
|
||||
TEST_FAILURE(".*ERROR: Illegal log command.*", lmp->input->one("log"););
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Newton)
|
||||
{
|
||||
// default setting is "on" for both
|
||||
ASSERT_EQ(lmp->force->newton_pair, 1);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 1);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("newton off");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->force->newton_pair, 0);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 0);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("newton on off");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->force->newton_pair, 1);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 0);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("newton off on");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->force->newton_pair, 0);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 1);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("newton on");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
ASSERT_EQ(lmp->force->newton_pair, 1);
|
||||
ASSERT_EQ(lmp->force->newton_bond, 1);
|
||||
}
|
||||
|
||||
TEST_F(SimpleCommandsTest, Quit)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
@ -319,7 +349,7 @@ TEST_F(SimpleCommandsTest, Shell)
|
||||
lmp->input->one("shell putenv TEST_VARIABLE=simpletest");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
char * test_var = getenv("TEST_VARIABLE");
|
||||
char *test_var = getenv("TEST_VARIABLE");
|
||||
ASSERT_NE(test_var, nullptr);
|
||||
ASSERT_THAT(test_var, StrEq("simpletest"));
|
||||
|
||||
@ -328,8 +358,8 @@ TEST_F(SimpleCommandsTest, Shell)
|
||||
lmp->input->one("shell putenv TEST_VARIABLE2=simpletest2 OTHER_VARIABLE=2");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
char * test_var2 = getenv("TEST_VARIABLE2");
|
||||
char * other_var = getenv("OTHER_VARIABLE");
|
||||
char *test_var2 = getenv("TEST_VARIABLE2");
|
||||
char *other_var = getenv("OTHER_VARIABLE");
|
||||
|
||||
ASSERT_NE(test_var2, nullptr);
|
||||
ASSERT_THAT(test_var2, StrEq("simpletest2"));
|
||||
|
||||
@ -1,114 +1,110 @@
|
||||
// unit tests for issuing command to a LAMMPS instance through the Input class
|
||||
|
||||
#include "lammps.h"
|
||||
#include "input.h"
|
||||
#include "atom.h"
|
||||
#include "input.h"
|
||||
#include "lammps.h"
|
||||
#include "memory.h"
|
||||
#include <cstring>
|
||||
#include <mpi.h>
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
const char *demo_input[] = {
|
||||
"region box block 0 $x 0 2 0 2",
|
||||
"create_box 1 box",
|
||||
"create_atoms 1 single 1.0 1.0 ${zpos}" };
|
||||
const char *cont_input[] = {
|
||||
"create_atoms 1 single &",
|
||||
"0.2 0.1 0.1" };
|
||||
const char *demo_input[] = {"region box block 0 $x 0 2 0 2", "create_box 1 box",
|
||||
"create_atoms 1 single 1.0 1.0 ${zpos}"};
|
||||
const char *cont_input[] = {"create_atoms 1 single &", "0.2 0.1 0.1"};
|
||||
|
||||
namespace LAMMPS_NS
|
||||
{
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class Input_commands : public ::testing::Test
|
||||
class Input_commands : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
Input_commands()
|
||||
{
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
Input_commands() {
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
if (!flag) MPI_Init(&argc,&argv);
|
||||
}
|
||||
~Input_commands() override {}
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
if (!flag) MPI_Init(&argc, &argv);
|
||||
}
|
||||
~Input_commands() override {}
|
||||
|
||||
void SetUp() override {
|
||||
const char *args[] = {"LAMMPS_test",
|
||||
"-log", "none",
|
||||
"-echo", "screen",
|
||||
"-nocite",
|
||||
"-var", "zpos", "1.5",
|
||||
"-var","x","2"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "screen", "-nocite",
|
||||
"-var", "zpos", "1.5", "-var", "x", "2"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,8).c_str(), "LAMMPS (");
|
||||
}
|
||||
void TearDown() override {
|
||||
::testing::internal::CaptureStdout();
|
||||
delete lmp;
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
|
||||
lmp = nullptr;
|
||||
}
|
||||
};
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0, 8).c_str(), "LAMMPS (");
|
||||
}
|
||||
void TearDown() override
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
delete lmp;
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
|
||||
lmp = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(Input_commands, from_file) {
|
||||
FILE *fp;
|
||||
const char demo_file[] = "in.test";
|
||||
const char cont_file[] = "in.cont";
|
||||
TEST_F(Input_commands, from_file)
|
||||
{
|
||||
FILE *fp;
|
||||
const char demo_file[] = "in.test";
|
||||
const char cont_file[] = "in.cont";
|
||||
|
||||
fp = fopen(demo_file,"w");
|
||||
for (unsigned int i=0; i < sizeof(demo_input)/sizeof(char *); ++i) {
|
||||
fputs(demo_input[i],fp);
|
||||
fputc('\n',fp);
|
||||
}
|
||||
fclose(fp);
|
||||
fp = fopen(cont_file,"w");
|
||||
for (unsigned int i=0; i < sizeof(cont_input)/sizeof(char *); ++i) {
|
||||
fputs(cont_input[i],fp);
|
||||
fputc('\n',fp);
|
||||
}
|
||||
fclose(fp);
|
||||
fp = fopen(demo_file, "w");
|
||||
for (unsigned int i = 0; i < sizeof(demo_input) / sizeof(char *); ++i) {
|
||||
fputs(demo_input[i], fp);
|
||||
fputc('\n', fp);
|
||||
}
|
||||
fclose(fp);
|
||||
fp = fopen(cont_file, "w");
|
||||
for (unsigned int i = 0; i < sizeof(cont_input) / sizeof(char *); ++i) {
|
||||
fputs(cont_input[i], fp);
|
||||
fputc('\n', fp);
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
EXPECT_EQ(lmp->atom->natoms,0);
|
||||
lmp->input->file(demo_file);
|
||||
lmp->input->file(cont_file);
|
||||
EXPECT_EQ(lmp->atom->natoms,2);
|
||||
EXPECT_EQ(lmp->atom->natoms, 0);
|
||||
lmp->input->file(demo_file);
|
||||
lmp->input->file(cont_file);
|
||||
EXPECT_EQ(lmp->atom->natoms, 2);
|
||||
|
||||
unlink(demo_file);
|
||||
unlink(cont_file);
|
||||
};
|
||||
unlink(demo_file);
|
||||
unlink(cont_file);
|
||||
};
|
||||
|
||||
TEST_F(Input_commands, from_line) {
|
||||
EXPECT_EQ(lmp->atom->natoms,0);
|
||||
for (unsigned int i=0; i < sizeof(demo_input)/sizeof(char *); ++i) {
|
||||
lmp->input->one(demo_input[i]);
|
||||
}
|
||||
EXPECT_EQ(lmp->atom->natoms,1);
|
||||
};
|
||||
TEST_F(Input_commands, from_line)
|
||||
{
|
||||
EXPECT_EQ(lmp->atom->natoms, 0);
|
||||
for (unsigned int i = 0; i < sizeof(demo_input) / sizeof(char *); ++i) {
|
||||
lmp->input->one(demo_input[i]);
|
||||
}
|
||||
EXPECT_EQ(lmp->atom->natoms, 1);
|
||||
};
|
||||
|
||||
TEST_F(Input_commands, substitute) {
|
||||
char *string,*scratch;
|
||||
int nstring=100,nscratch=100;
|
||||
TEST_F(Input_commands, substitute)
|
||||
{
|
||||
char *string, *scratch;
|
||||
int nstring = 100, nscratch = 100;
|
||||
|
||||
lmp->memory->create(string,nstring,"test:string");
|
||||
lmp->memory->create(scratch,nscratch,"test:scratch");
|
||||
strcpy(string,demo_input[0]);
|
||||
lmp->input->substitute(string,scratch,nstring,nscratch,0);
|
||||
EXPECT_STREQ(string,"region box block 0 2 0 2 0 2");
|
||||
lmp->memory->create(string, nstring, "test:string");
|
||||
lmp->memory->create(scratch, nscratch, "test:scratch");
|
||||
strcpy(string, demo_input[0]);
|
||||
lmp->input->substitute(string, scratch, nstring, nscratch, 0);
|
||||
EXPECT_STREQ(string, "region box block 0 2 0 2 0 2");
|
||||
|
||||
strcpy(string,demo_input[2]);
|
||||
lmp->input->substitute(string,scratch,nstring,nscratch,0);
|
||||
EXPECT_STREQ(string,"create_atoms 1 single 1.0 1.0 1.5");
|
||||
lmp->memory->destroy(string);
|
||||
lmp->memory->destroy(scratch);
|
||||
};
|
||||
}
|
||||
strcpy(string, demo_input[2]);
|
||||
lmp->input->substitute(string, scratch, nstring, nscratch, 0);
|
||||
EXPECT_STREQ(string, "create_atoms 1 single 1.0 1.0 1.5");
|
||||
lmp->memory->destroy(string);
|
||||
lmp->memory->destroy(scratch);
|
||||
};
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// unit tests for the LAMMPS base class
|
||||
|
||||
#include "lammps.h"
|
||||
#include <cstdio> // for stdin, stdout
|
||||
#include <mpi.h>
|
||||
#include <cstdio> // for stdin, stdout
|
||||
#include <string>
|
||||
|
||||
#include "gmock/gmock.h"
|
||||
@ -10,342 +10,326 @@
|
||||
|
||||
using ::testing::StartsWith;
|
||||
|
||||
namespace LAMMPS_NS
|
||||
{
|
||||
// test fixture for regular tests
|
||||
class LAMMPS_plain : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
LAMMPS_plain() : lmp(nullptr) {
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
if (!flag) MPI_Init(&argc,&argv);
|
||||
}
|
||||
|
||||
~LAMMPS_plain() override {
|
||||
lmp = nullptr;
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
const char *args[] = {"LAMMPS_test",
|
||||
"-log", "none",
|
||||
"-echo", "both",
|
||||
"-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
::testing::internal::CaptureStdout();
|
||||
delete lmp;
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, StartsWith("Total wall time:"));
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_plain, InitMembers)
|
||||
namespace LAMMPS_NS {
|
||||
// test fixture for regular tests
|
||||
class LAMMPS_plain : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
LAMMPS_plain() : lmp(nullptr)
|
||||
{
|
||||
EXPECT_NE(lmp->memory, nullptr);
|
||||
EXPECT_NE(lmp->error, nullptr);
|
||||
EXPECT_NE(lmp->universe, nullptr);
|
||||
EXPECT_NE(lmp->input, nullptr);
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
EXPECT_NE(lmp->atom, nullptr);
|
||||
EXPECT_NE(lmp->update, nullptr);
|
||||
EXPECT_NE(lmp->neighbor, nullptr);
|
||||
EXPECT_NE(lmp->comm, nullptr);
|
||||
EXPECT_NE(lmp->domain, nullptr);
|
||||
EXPECT_NE(lmp->force, nullptr);
|
||||
EXPECT_NE(lmp->modify, nullptr);
|
||||
EXPECT_NE(lmp->group, nullptr);
|
||||
EXPECT_NE(lmp->output, nullptr);
|
||||
EXPECT_NE(lmp->timer, nullptr);
|
||||
|
||||
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
EXPECT_EQ(lmp->screen, stdout);
|
||||
EXPECT_EQ(lmp->logfile, nullptr);
|
||||
EXPECT_GE(lmp->initclock, 0.0);
|
||||
|
||||
EXPECT_EQ(lmp->suffix_enable, 0);
|
||||
EXPECT_EQ(lmp->suffix, nullptr);
|
||||
EXPECT_EQ(lmp->suffix2, nullptr);
|
||||
|
||||
EXPECT_STREQ(lmp->exename, "LAMMPS_test");
|
||||
EXPECT_EQ(lmp->num_package, 0);
|
||||
EXPECT_EQ(lmp->clientserver, 0);
|
||||
|
||||
EXPECT_EQ(lmp->kokkos, nullptr);
|
||||
EXPECT_EQ(lmp->atomKK, nullptr);
|
||||
EXPECT_EQ(lmp->memoryKK, nullptr);
|
||||
EXPECT_NE(lmp->python, nullptr);
|
||||
EXPECT_EQ(lmp->citeme, nullptr);
|
||||
if (LAMMPS::has_git_info) {
|
||||
EXPECT_STRNE(LAMMPS::git_commit,"");
|
||||
EXPECT_STRNE(LAMMPS::git_branch,"");
|
||||
EXPECT_STRNE(LAMMPS::git_descriptor,"");
|
||||
} else {
|
||||
EXPECT_STREQ(LAMMPS::git_commit,"(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_branch,"(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_descriptor,"(unknown)");
|
||||
}
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
if (!flag) MPI_Init(&argc, &argv);
|
||||
}
|
||||
|
||||
TEST_F(LAMMPS_plain, TestStyles)
|
||||
~LAMMPS_plain() override { lmp = nullptr; }
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
// skip tests if base class is not available
|
||||
if (lmp == nullptr) return;
|
||||
const char *found;
|
||||
|
||||
const char *atom_styles[] = {
|
||||
"atomic", "body", "charge", "ellipsoid", "hybrid",
|
||||
"line", "sphere", "tri", NULL };
|
||||
for (int i = 0; atom_styles[i] != NULL; ++i) {
|
||||
found = lmp->match_style("atom",atom_styles[i]);
|
||||
EXPECT_STREQ(found, NULL);
|
||||
}
|
||||
|
||||
const char *molecule_atom_styles[] = {
|
||||
"angle", "bond", "full", "molecular", "template", NULL };
|
||||
for (int i = 0; molecule_atom_styles[i] != NULL; ++i) {
|
||||
found = lmp->match_style("atom",molecule_atom_styles[i]);
|
||||
EXPECT_STREQ(found, "MOLECULE");
|
||||
}
|
||||
|
||||
const char *kokkos_atom_styles[] = {
|
||||
"angle/kk", "bond/kk", "full/kk", "molecular/kk", "hybrid/kk", NULL };
|
||||
for (int i = 0; kokkos_atom_styles[i] != NULL; ++i) {
|
||||
found = lmp->match_style("atom",kokkos_atom_styles[i]);
|
||||
EXPECT_STREQ(found, "KOKKOS");
|
||||
}
|
||||
found = lmp->match_style("atom","dipole");
|
||||
EXPECT_STREQ(found,"DIPOLE");
|
||||
found = lmp->match_style("atom","peri");
|
||||
EXPECT_STREQ(found,"PERI");
|
||||
found = lmp->match_style("atom","spin");
|
||||
EXPECT_STREQ(found,"SPIN");
|
||||
found = lmp->match_style("atom","wavepacket");
|
||||
EXPECT_STREQ(found,"USER-AWPMD");
|
||||
found = lmp->match_style("atom","dpd");
|
||||
EXPECT_STREQ(found,"USER-DPD");
|
||||
found = lmp->match_style("atom","edpd");
|
||||
EXPECT_STREQ(found,"USER-MESODPD");
|
||||
found = lmp->match_style("atom","mdpd");
|
||||
EXPECT_STREQ(found,"USER-MESODPD");
|
||||
found = lmp->match_style("atom","tdpd");
|
||||
EXPECT_STREQ(found,"USER-MESODPD");
|
||||
found = lmp->match_style("atom","spin");
|
||||
EXPECT_STREQ(found,"SPIN");
|
||||
found = lmp->match_style("atom","smd");
|
||||
EXPECT_STREQ(found,"USER-SMD");
|
||||
found = lmp->match_style("atom","sph");
|
||||
EXPECT_STREQ(found,"USER-SPH");
|
||||
found = lmp->match_style("atom","i_don't_exist");
|
||||
EXPECT_STREQ(found,NULL);
|
||||
}
|
||||
|
||||
// test fixture for OpenMP with 2 threads
|
||||
class LAMMPS_omp : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
LAMMPS_omp() : lmp(nullptr) {
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
if (!flag) MPI_Init(&argc,&argv);
|
||||
}
|
||||
|
||||
~LAMMPS_omp() override {
|
||||
lmp = nullptr;
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
const char *args[] = {"LAMMPS_test",
|
||||
"-log", "none",
|
||||
"-screen", "none",
|
||||
"-echo", "screen",
|
||||
"-pk", "omp","2", "neigh", "yes",
|
||||
"-sf", "omp"
|
||||
};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
|
||||
// only run this test fixture with omp suffix if USER-OMP package is installed
|
||||
|
||||
if (LAMMPS::is_installed_pkg("USER-OMP"))
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
else GTEST_SKIP();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete lmp;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_omp, InitMembers)
|
||||
{
|
||||
EXPECT_NE(lmp->memory, nullptr);
|
||||
EXPECT_NE(lmp->error, nullptr);
|
||||
EXPECT_NE(lmp->universe, nullptr);
|
||||
EXPECT_NE(lmp->input, nullptr);
|
||||
|
||||
EXPECT_NE(lmp->atom, nullptr);
|
||||
EXPECT_NE(lmp->update, nullptr);
|
||||
EXPECT_NE(lmp->neighbor, nullptr);
|
||||
EXPECT_NE(lmp->comm, nullptr);
|
||||
EXPECT_NE(lmp->domain, nullptr);
|
||||
EXPECT_NE(lmp->force, nullptr);
|
||||
EXPECT_NE(lmp->modify, nullptr);
|
||||
EXPECT_NE(lmp->group, nullptr);
|
||||
EXPECT_NE(lmp->output, nullptr);
|
||||
EXPECT_NE(lmp->timer, nullptr);
|
||||
|
||||
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
EXPECT_EQ(lmp->screen, nullptr);
|
||||
EXPECT_EQ(lmp->logfile, nullptr);
|
||||
EXPECT_GE(lmp->initclock, 0.0);
|
||||
|
||||
EXPECT_EQ(lmp->suffix_enable, 1);
|
||||
EXPECT_STREQ(lmp->suffix, "omp");
|
||||
EXPECT_EQ(lmp->suffix2, nullptr);
|
||||
|
||||
EXPECT_STREQ(lmp->exename, "LAMMPS_test");
|
||||
EXPECT_EQ(lmp->num_package, 1);
|
||||
EXPECT_EQ(lmp->clientserver, 0);
|
||||
|
||||
EXPECT_EQ(lmp->kokkos, nullptr);
|
||||
EXPECT_EQ(lmp->atomKK, nullptr);
|
||||
EXPECT_EQ(lmp->memoryKK, nullptr);
|
||||
EXPECT_NE(lmp->python, nullptr);
|
||||
EXPECT_NE(lmp->citeme, nullptr);
|
||||
if (LAMMPS::has_git_info) {
|
||||
EXPECT_STRNE(LAMMPS::git_commit,"");
|
||||
EXPECT_STRNE(LAMMPS::git_branch,"");
|
||||
EXPECT_STRNE(LAMMPS::git_descriptor,"");
|
||||
} else {
|
||||
EXPECT_STREQ(LAMMPS::git_commit,"(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_branch,"(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_descriptor,"(unknown)");
|
||||
}
|
||||
}
|
||||
|
||||
// test fixture for Kokkos tests
|
||||
class LAMMPS_kokkos : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
LAMMPS_kokkos() : lmp(nullptr) {
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
if (!flag) MPI_Init(&argc,&argv);
|
||||
}
|
||||
|
||||
~LAMMPS_kokkos() override {
|
||||
lmp = nullptr;
|
||||
}
|
||||
|
||||
void SetUp() override {
|
||||
const char *args[] = {"LAMMPS_test",
|
||||
"-log", "none",
|
||||
"-echo", "none",
|
||||
"-screen", "none",
|
||||
"-k", "on","t", "2",
|
||||
"-sf", "kk"
|
||||
};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
|
||||
// only run this test fixture with kk suffix if KOKKOS package is installed
|
||||
// also need to figure out a way to find which parallelizations are enabled
|
||||
|
||||
if (LAMMPS::is_installed_pkg("KOKKOS")) {
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, StartsWith("Kokkos::OpenMP::"));
|
||||
} else GTEST_SKIP();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete lmp;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_kokkos, InitMembers)
|
||||
{
|
||||
EXPECT_NE(lmp->memory, nullptr);
|
||||
EXPECT_NE(lmp->error, nullptr);
|
||||
EXPECT_NE(lmp->universe, nullptr);
|
||||
EXPECT_NE(lmp->input, nullptr);
|
||||
|
||||
EXPECT_NE(lmp->atom, nullptr);
|
||||
EXPECT_NE(lmp->update, nullptr);
|
||||
EXPECT_NE(lmp->neighbor, nullptr);
|
||||
EXPECT_NE(lmp->comm, nullptr);
|
||||
EXPECT_NE(lmp->domain, nullptr);
|
||||
EXPECT_NE(lmp->force, nullptr);
|
||||
EXPECT_NE(lmp->modify, nullptr);
|
||||
EXPECT_NE(lmp->group, nullptr);
|
||||
EXPECT_NE(lmp->output, nullptr);
|
||||
EXPECT_NE(lmp->timer, nullptr);
|
||||
|
||||
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
EXPECT_EQ(lmp->screen, nullptr);
|
||||
EXPECT_EQ(lmp->logfile, nullptr);
|
||||
EXPECT_GE(lmp->initclock, 0.0);
|
||||
|
||||
EXPECT_EQ(lmp->suffix_enable, 1);
|
||||
EXPECT_STREQ(lmp->suffix, "kk");
|
||||
EXPECT_EQ(lmp->suffix2, nullptr);
|
||||
|
||||
EXPECT_STREQ(lmp->exename, "LAMMPS_test");
|
||||
EXPECT_EQ(lmp->num_package, 0);
|
||||
EXPECT_EQ(lmp->clientserver, 0);
|
||||
|
||||
EXPECT_NE(lmp->kokkos, nullptr);
|
||||
EXPECT_NE(lmp->atomKK, nullptr);
|
||||
EXPECT_NE(lmp->memoryKK, nullptr);
|
||||
EXPECT_NE(lmp->python, nullptr);
|
||||
EXPECT_NE(lmp->citeme, nullptr);
|
||||
if (LAMMPS::has_git_info) {
|
||||
EXPECT_STRNE(LAMMPS::git_commit,"");
|
||||
EXPECT_STRNE(LAMMPS::git_branch,"");
|
||||
EXPECT_STRNE(LAMMPS::git_descriptor,"");
|
||||
} else {
|
||||
EXPECT_STREQ(LAMMPS::git_commit,"(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_branch,"(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_descriptor,"(unknown)");
|
||||
}
|
||||
}
|
||||
|
||||
// check help message printing
|
||||
TEST(LAMMPS_help, HelpMessage) {
|
||||
const char *args[] = {"LAMMPS_test", "-h"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args)/sizeof(char *);
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "both", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output,
|
||||
StartsWith("\nLarge-scale Atomic/Molecular Massively Parallel Simulator -"));
|
||||
EXPECT_THAT(output, StartsWith("LAMMPS ("));
|
||||
}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
delete lmp;
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, StartsWith("Total wall time:"));
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_plain, InitMembers)
|
||||
{
|
||||
EXPECT_NE(lmp->memory, nullptr);
|
||||
EXPECT_NE(lmp->error, nullptr);
|
||||
EXPECT_NE(lmp->universe, nullptr);
|
||||
EXPECT_NE(lmp->input, nullptr);
|
||||
|
||||
EXPECT_NE(lmp->atom, nullptr);
|
||||
EXPECT_NE(lmp->update, nullptr);
|
||||
EXPECT_NE(lmp->neighbor, nullptr);
|
||||
EXPECT_NE(lmp->comm, nullptr);
|
||||
EXPECT_NE(lmp->domain, nullptr);
|
||||
EXPECT_NE(lmp->force, nullptr);
|
||||
EXPECT_NE(lmp->modify, nullptr);
|
||||
EXPECT_NE(lmp->group, nullptr);
|
||||
EXPECT_NE(lmp->output, nullptr);
|
||||
EXPECT_NE(lmp->timer, nullptr);
|
||||
|
||||
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
EXPECT_EQ(lmp->screen, stdout);
|
||||
EXPECT_EQ(lmp->logfile, nullptr);
|
||||
EXPECT_GE(lmp->initclock, 0.0);
|
||||
|
||||
EXPECT_EQ(lmp->suffix_enable, 0);
|
||||
EXPECT_EQ(lmp->suffix, nullptr);
|
||||
EXPECT_EQ(lmp->suffix2, nullptr);
|
||||
|
||||
EXPECT_STREQ(lmp->exename, "LAMMPS_test");
|
||||
EXPECT_EQ(lmp->num_package, 0);
|
||||
EXPECT_EQ(lmp->clientserver, 0);
|
||||
|
||||
EXPECT_EQ(lmp->kokkos, nullptr);
|
||||
EXPECT_EQ(lmp->atomKK, nullptr);
|
||||
EXPECT_EQ(lmp->memoryKK, nullptr);
|
||||
EXPECT_NE(lmp->python, nullptr);
|
||||
EXPECT_EQ(lmp->citeme, nullptr);
|
||||
if (LAMMPS::has_git_info) {
|
||||
EXPECT_STRNE(LAMMPS::git_commit, "");
|
||||
EXPECT_STRNE(LAMMPS::git_branch, "");
|
||||
EXPECT_STRNE(LAMMPS::git_descriptor, "");
|
||||
} else {
|
||||
EXPECT_STREQ(LAMMPS::git_commit, "(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_branch, "(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_descriptor, "(unknown)");
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(LAMMPS_plain, TestStyles)
|
||||
{
|
||||
// skip tests if base class is not available
|
||||
if (lmp == nullptr) return;
|
||||
const char *found;
|
||||
|
||||
const char *atom_styles[] = {"atomic", "body", "charge", "ellipsoid", "hybrid",
|
||||
"line", "sphere", "tri", NULL};
|
||||
for (int i = 0; atom_styles[i] != NULL; ++i) {
|
||||
found = lmp->match_style("atom", atom_styles[i]);
|
||||
EXPECT_STREQ(found, NULL);
|
||||
}
|
||||
|
||||
const char *molecule_atom_styles[] = {"angle", "bond", "full", "molecular", "template", NULL};
|
||||
for (int i = 0; molecule_atom_styles[i] != NULL; ++i) {
|
||||
found = lmp->match_style("atom", molecule_atom_styles[i]);
|
||||
EXPECT_STREQ(found, "MOLECULE");
|
||||
}
|
||||
|
||||
const char *kokkos_atom_styles[] = {"angle/kk", "bond/kk", "full/kk",
|
||||
"molecular/kk", "hybrid/kk", NULL};
|
||||
for (int i = 0; kokkos_atom_styles[i] != NULL; ++i) {
|
||||
found = lmp->match_style("atom", kokkos_atom_styles[i]);
|
||||
EXPECT_STREQ(found, "KOKKOS");
|
||||
}
|
||||
found = lmp->match_style("atom", "dipole");
|
||||
EXPECT_STREQ(found, "DIPOLE");
|
||||
found = lmp->match_style("atom", "peri");
|
||||
EXPECT_STREQ(found, "PERI");
|
||||
found = lmp->match_style("atom", "spin");
|
||||
EXPECT_STREQ(found, "SPIN");
|
||||
found = lmp->match_style("atom", "wavepacket");
|
||||
EXPECT_STREQ(found, "USER-AWPMD");
|
||||
found = lmp->match_style("atom", "dpd");
|
||||
EXPECT_STREQ(found, "USER-DPD");
|
||||
found = lmp->match_style("atom", "edpd");
|
||||
EXPECT_STREQ(found, "USER-MESODPD");
|
||||
found = lmp->match_style("atom", "mdpd");
|
||||
EXPECT_STREQ(found, "USER-MESODPD");
|
||||
found = lmp->match_style("atom", "tdpd");
|
||||
EXPECT_STREQ(found, "USER-MESODPD");
|
||||
found = lmp->match_style("atom", "spin");
|
||||
EXPECT_STREQ(found, "SPIN");
|
||||
found = lmp->match_style("atom", "smd");
|
||||
EXPECT_STREQ(found, "USER-SMD");
|
||||
found = lmp->match_style("atom", "sph");
|
||||
EXPECT_STREQ(found, "USER-SPH");
|
||||
found = lmp->match_style("atom", "i_don't_exist");
|
||||
EXPECT_STREQ(found, NULL);
|
||||
}
|
||||
|
||||
// test fixture for OpenMP with 2 threads
|
||||
class LAMMPS_omp : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
LAMMPS_omp() : lmp(nullptr)
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
if (!flag) MPI_Init(&argc, &argv);
|
||||
}
|
||||
|
||||
~LAMMPS_omp() override { lmp = nullptr; }
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-screen", "none", "-echo", "screen",
|
||||
"-pk", "omp", "2", "neigh", "yes", "-sf", "omp"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
// only run this test fixture with omp suffix if USER-OMP package is installed
|
||||
|
||||
if (LAMMPS::is_installed_pkg("USER-OMP"))
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
else
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
void TearDown() override { delete lmp; }
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_omp, InitMembers)
|
||||
{
|
||||
EXPECT_NE(lmp->memory, nullptr);
|
||||
EXPECT_NE(lmp->error, nullptr);
|
||||
EXPECT_NE(lmp->universe, nullptr);
|
||||
EXPECT_NE(lmp->input, nullptr);
|
||||
|
||||
EXPECT_NE(lmp->atom, nullptr);
|
||||
EXPECT_NE(lmp->update, nullptr);
|
||||
EXPECT_NE(lmp->neighbor, nullptr);
|
||||
EXPECT_NE(lmp->comm, nullptr);
|
||||
EXPECT_NE(lmp->domain, nullptr);
|
||||
EXPECT_NE(lmp->force, nullptr);
|
||||
EXPECT_NE(lmp->modify, nullptr);
|
||||
EXPECT_NE(lmp->group, nullptr);
|
||||
EXPECT_NE(lmp->output, nullptr);
|
||||
EXPECT_NE(lmp->timer, nullptr);
|
||||
|
||||
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
EXPECT_EQ(lmp->screen, nullptr);
|
||||
EXPECT_EQ(lmp->logfile, nullptr);
|
||||
EXPECT_GE(lmp->initclock, 0.0);
|
||||
|
||||
EXPECT_EQ(lmp->suffix_enable, 1);
|
||||
EXPECT_STREQ(lmp->suffix, "omp");
|
||||
EXPECT_EQ(lmp->suffix2, nullptr);
|
||||
|
||||
EXPECT_STREQ(lmp->exename, "LAMMPS_test");
|
||||
EXPECT_EQ(lmp->num_package, 1);
|
||||
EXPECT_EQ(lmp->clientserver, 0);
|
||||
|
||||
EXPECT_EQ(lmp->kokkos, nullptr);
|
||||
EXPECT_EQ(lmp->atomKK, nullptr);
|
||||
EXPECT_EQ(lmp->memoryKK, nullptr);
|
||||
EXPECT_NE(lmp->python, nullptr);
|
||||
EXPECT_NE(lmp->citeme, nullptr);
|
||||
if (LAMMPS::has_git_info) {
|
||||
EXPECT_STRNE(LAMMPS::git_commit, "");
|
||||
EXPECT_STRNE(LAMMPS::git_branch, "");
|
||||
EXPECT_STRNE(LAMMPS::git_descriptor, "");
|
||||
} else {
|
||||
EXPECT_STREQ(LAMMPS::git_commit, "(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_branch, "(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_descriptor, "(unknown)");
|
||||
}
|
||||
}
|
||||
|
||||
// test fixture for Kokkos tests
|
||||
class LAMMPS_kokkos : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
LAMMPS_kokkos() : lmp(nullptr)
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
int flag;
|
||||
MPI_Initialized(&flag);
|
||||
if (!flag) MPI_Init(&argc, &argv);
|
||||
}
|
||||
|
||||
~LAMMPS_kokkos() override { lmp = nullptr; }
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-log", "none", "-echo", "none", "-screen", "none",
|
||||
"-k", "on", "t", "2", "-sf", "kk"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
// only run this test fixture with kk suffix if KOKKOS package is installed
|
||||
// also need to figure out a way to find which parallelizations are enabled
|
||||
|
||||
if (LAMMPS::is_installed_pkg("KOKKOS")) {
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output, StartsWith("Kokkos::OpenMP::"));
|
||||
} else
|
||||
GTEST_SKIP();
|
||||
}
|
||||
|
||||
void TearDown() override { delete lmp; }
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_kokkos, InitMembers)
|
||||
{
|
||||
EXPECT_NE(lmp->memory, nullptr);
|
||||
EXPECT_NE(lmp->error, nullptr);
|
||||
EXPECT_NE(lmp->universe, nullptr);
|
||||
EXPECT_NE(lmp->input, nullptr);
|
||||
|
||||
EXPECT_NE(lmp->atom, nullptr);
|
||||
EXPECT_NE(lmp->update, nullptr);
|
||||
EXPECT_NE(lmp->neighbor, nullptr);
|
||||
EXPECT_NE(lmp->comm, nullptr);
|
||||
EXPECT_NE(lmp->domain, nullptr);
|
||||
EXPECT_NE(lmp->force, nullptr);
|
||||
EXPECT_NE(lmp->modify, nullptr);
|
||||
EXPECT_NE(lmp->group, nullptr);
|
||||
EXPECT_NE(lmp->output, nullptr);
|
||||
EXPECT_NE(lmp->timer, nullptr);
|
||||
|
||||
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
EXPECT_EQ(lmp->screen, nullptr);
|
||||
EXPECT_EQ(lmp->logfile, nullptr);
|
||||
EXPECT_GE(lmp->initclock, 0.0);
|
||||
|
||||
EXPECT_EQ(lmp->suffix_enable, 1);
|
||||
EXPECT_STREQ(lmp->suffix, "kk");
|
||||
EXPECT_EQ(lmp->suffix2, nullptr);
|
||||
|
||||
EXPECT_STREQ(lmp->exename, "LAMMPS_test");
|
||||
EXPECT_EQ(lmp->num_package, 0);
|
||||
EXPECT_EQ(lmp->clientserver, 0);
|
||||
|
||||
EXPECT_NE(lmp->kokkos, nullptr);
|
||||
EXPECT_NE(lmp->atomKK, nullptr);
|
||||
EXPECT_NE(lmp->memoryKK, nullptr);
|
||||
EXPECT_NE(lmp->python, nullptr);
|
||||
EXPECT_NE(lmp->citeme, nullptr);
|
||||
if (LAMMPS::has_git_info) {
|
||||
EXPECT_STRNE(LAMMPS::git_commit, "");
|
||||
EXPECT_STRNE(LAMMPS::git_branch, "");
|
||||
EXPECT_STRNE(LAMMPS::git_descriptor, "");
|
||||
} else {
|
||||
EXPECT_STREQ(LAMMPS::git_commit, "(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_branch, "(unknown)");
|
||||
EXPECT_STREQ(LAMMPS::git_descriptor, "(unknown)");
|
||||
}
|
||||
}
|
||||
|
||||
// check help message printing
|
||||
TEST(LAMMPS_help, HelpMessage)
|
||||
{
|
||||
const char *args[] = {"LAMMPS_test", "-h"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
|
||||
::testing::internal::CaptureStdout();
|
||||
LAMMPS *lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_THAT(output,
|
||||
StartsWith("\nLarge-scale Atomic/Molecular Massively Parallel Simulator -"));
|
||||
delete lmp;
|
||||
}
|
||||
} // namespace LAMMPS_NS
|
||||
|
||||
@ -266,7 +266,7 @@ void generate_yaml_file(const char *outfile, const TestConfig &config)
|
||||
|
||||
// run_pos
|
||||
block.clear();
|
||||
auto x = lmp->atom->x;
|
||||
auto x = lmp->atom->x;
|
||||
for (int i = 1; i <= natoms; ++i) {
|
||||
const int j = lmp->atom->map(i);
|
||||
block += fmt::format("{:3} {:23.16e} {:23.16e} {:23.16e}\n", i, x[j][0], x[j][1], x[j][2]);
|
||||
@ -519,8 +519,8 @@ TEST(FixTimestep, plain)
|
||||
// rigid fixes need work to test properly with r-RESPA.
|
||||
// fix nve/limit cannot work with r-RESPA
|
||||
ifix = lmp->modify->find_fix("test");
|
||||
if (!utils::strmatch(lmp->modify->fix[ifix]->style, "^rigid")
|
||||
&& !utils::strmatch(lmp->modify->fix[ifix]->style, "^nve/limit")) {
|
||||
if (!utils::strmatch(lmp->modify->fix[ifix]->style, "^rigid") &&
|
||||
!utils::strmatch(lmp->modify->fix[ifix]->style, "^nve/limit")) {
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
cleanup_lammps(lmp, test_config);
|
||||
|
||||
@ -12,9 +12,9 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "test_main.h"
|
||||
#include "pointers.h"
|
||||
#include "test_config.h"
|
||||
#include "test_config_reader.h"
|
||||
#include "pointers.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
@ -132,83 +132,82 @@ protected:
|
||||
|
||||
// default class Atom state
|
||||
struct AtomState {
|
||||
std::string atom_style = "atomic";
|
||||
bigint natoms = 0;
|
||||
int nlocal = 0;
|
||||
int nghost = 0;
|
||||
int nmax = 1;
|
||||
int tag_enable = 1;
|
||||
int molecular = Atom::ATOMIC;
|
||||
bigint nellipsoids = 0;
|
||||
bigint nlines = 0;
|
||||
bigint ntris = 0;
|
||||
bigint nbodies = 0;
|
||||
bigint nbonds = 0;
|
||||
bigint nangles = 0;
|
||||
bigint ndihedrals = 0;
|
||||
bigint nimpropers = 0;
|
||||
int ntypes = 0;
|
||||
int nbondtypes = 0;
|
||||
int nangletypes = 0;
|
||||
int ndihedraltypes = 0;
|
||||
int nimpropertypes = 0;
|
||||
int bond_per_atom = 0;
|
||||
int angle_per_atom = 0;
|
||||
int dihedral_per_atom = 0;
|
||||
int improper_per_atom = 0;
|
||||
int extra_bond_per_atom = 0;
|
||||
int extra_angle_per_atom = 0;
|
||||
std::string atom_style = "atomic";
|
||||
bigint natoms = 0;
|
||||
int nlocal = 0;
|
||||
int nghost = 0;
|
||||
int nmax = 1;
|
||||
int tag_enable = 1;
|
||||
int molecular = Atom::ATOMIC;
|
||||
bigint nellipsoids = 0;
|
||||
bigint nlines = 0;
|
||||
bigint ntris = 0;
|
||||
bigint nbodies = 0;
|
||||
bigint nbonds = 0;
|
||||
bigint nangles = 0;
|
||||
bigint ndihedrals = 0;
|
||||
bigint nimpropers = 0;
|
||||
int ntypes = 0;
|
||||
int nbondtypes = 0;
|
||||
int nangletypes = 0;
|
||||
int ndihedraltypes = 0;
|
||||
int nimpropertypes = 0;
|
||||
int bond_per_atom = 0;
|
||||
int angle_per_atom = 0;
|
||||
int dihedral_per_atom = 0;
|
||||
int improper_per_atom = 0;
|
||||
int extra_bond_per_atom = 0;
|
||||
int extra_angle_per_atom = 0;
|
||||
int extra_dihedral_per_atom = 0;
|
||||
int extra_improper_per_atom = 0;
|
||||
|
||||
int sphere_flag = 0;
|
||||
int ellipsoid_flag = 0;
|
||||
int line_flag = 0;
|
||||
int tri_flag = 0;
|
||||
int body_flag = 0;
|
||||
int peri_flag = 0;
|
||||
int electron_flag = 0;
|
||||
int wavepacket_flag = 0;
|
||||
int sph_flag = 0;
|
||||
int molecule_flag = 0;
|
||||
int molindex_flag = 0;
|
||||
int molatom_flag = 0;
|
||||
int q_flag = 0;
|
||||
int mu_flag = 0;
|
||||
int rmass_flag = 0;
|
||||
int radius_flag = 0;
|
||||
int omega_flag = 0;
|
||||
int torque_flag = 0;
|
||||
int angmom_flag = 0;
|
||||
int vfrac_flag = 0;
|
||||
int spin_flag = 0;
|
||||
int eradius_flag = 0;
|
||||
int ervel_flag = 0;
|
||||
int erforce_flag = 0;
|
||||
int cs_flag = 0;
|
||||
int csforce_flag = 0;
|
||||
int vforce_flag = 0;
|
||||
int ervelforce_flag = 0;
|
||||
int etag_flag = 0;
|
||||
int rho_flag = 0;
|
||||
int esph_flag = 0;
|
||||
int cv_flag = 0;
|
||||
int vest_flag = 0;
|
||||
int dpd_flag = 0;
|
||||
int edpd_flag = 0;
|
||||
int tdpd_flag = 0;
|
||||
int mesont_flag = 0;
|
||||
int sp_flag = 0;
|
||||
int x0_flag = 0;
|
||||
int smd_flag = 0;
|
||||
int damage_flag = 0;
|
||||
int contact_radius_flag = 0;
|
||||
int smd_data_9_flag = 0;
|
||||
int smd_stress_flag = 0;
|
||||
int eff_plastic_strain_flag = 0;
|
||||
int sphere_flag = 0;
|
||||
int ellipsoid_flag = 0;
|
||||
int line_flag = 0;
|
||||
int tri_flag = 0;
|
||||
int body_flag = 0;
|
||||
int peri_flag = 0;
|
||||
int electron_flag = 0;
|
||||
int wavepacket_flag = 0;
|
||||
int sph_flag = 0;
|
||||
int molecule_flag = 0;
|
||||
int molindex_flag = 0;
|
||||
int molatom_flag = 0;
|
||||
int q_flag = 0;
|
||||
int mu_flag = 0;
|
||||
int rmass_flag = 0;
|
||||
int radius_flag = 0;
|
||||
int omega_flag = 0;
|
||||
int torque_flag = 0;
|
||||
int angmom_flag = 0;
|
||||
int vfrac_flag = 0;
|
||||
int spin_flag = 0;
|
||||
int eradius_flag = 0;
|
||||
int ervel_flag = 0;
|
||||
int erforce_flag = 0;
|
||||
int cs_flag = 0;
|
||||
int csforce_flag = 0;
|
||||
int vforce_flag = 0;
|
||||
int ervelforce_flag = 0;
|
||||
int etag_flag = 0;
|
||||
int rho_flag = 0;
|
||||
int esph_flag = 0;
|
||||
int cv_flag = 0;
|
||||
int vest_flag = 0;
|
||||
int dpd_flag = 0;
|
||||
int edpd_flag = 0;
|
||||
int tdpd_flag = 0;
|
||||
int mesont_flag = 0;
|
||||
int sp_flag = 0;
|
||||
int x0_flag = 0;
|
||||
int smd_flag = 0;
|
||||
int damage_flag = 0;
|
||||
int contact_radius_flag = 0;
|
||||
int smd_data_9_flag = 0;
|
||||
int smd_stress_flag = 0;
|
||||
int eff_plastic_strain_flag = 0;
|
||||
int eff_plastic_strain_rate_flag = 0;
|
||||
double pdscale = 1.0;
|
||||
|
||||
double pdscale = 1.0;
|
||||
|
||||
int maxspecial = 1;
|
||||
|
||||
@ -217,48 +216,49 @@ struct AtomState {
|
||||
int nivector = 0;
|
||||
int ndvector = 0;
|
||||
|
||||
int nextra_grow = 0;
|
||||
int nextra_restart = 0;
|
||||
int nextra_border = 0;
|
||||
int nextra_grow_max = 0;
|
||||
int nextra_grow = 0;
|
||||
int nextra_restart = 0;
|
||||
int nextra_border = 0;
|
||||
int nextra_grow_max = 0;
|
||||
int nextra_restart_max = 0;
|
||||
int nextra_border_max = 0;
|
||||
int nextra_store = 0;
|
||||
int nextra_border_max = 0;
|
||||
int nextra_store = 0;
|
||||
|
||||
int map_style = Atom::MAP_NONE;
|
||||
int map_user = 0;
|
||||
int map_style = Atom::MAP_NONE;
|
||||
int map_user = 0;
|
||||
tagint map_tag_max = -1;
|
||||
|
||||
// properties X that aren't controlled by an equivalent X_flag
|
||||
bool has_type = true;
|
||||
bool has_mask = true;
|
||||
bool has_type = true;
|
||||
bool has_mask = true;
|
||||
bool has_image = true;
|
||||
bool has_x = true;
|
||||
bool has_v = true;
|
||||
bool has_f = true;
|
||||
bool has_x = true;
|
||||
bool has_v = true;
|
||||
bool has_f = true;
|
||||
|
||||
bool has_bonds = false;
|
||||
bool has_angles = false;
|
||||
bool has_bonds = false;
|
||||
bool has_angles = false;
|
||||
bool has_dihedral = false;
|
||||
bool has_improper = false;
|
||||
|
||||
bool has_iname = false;
|
||||
bool has_dname = false;
|
||||
bool has_mass = false;
|
||||
bool has_iname = false;
|
||||
bool has_dname = false;
|
||||
bool has_mass = false;
|
||||
bool has_mass_setflag = false;
|
||||
|
||||
bool has_nspecial = false;
|
||||
bool has_special = false;
|
||||
bool has_special = false;
|
||||
};
|
||||
|
||||
#define ASSERT_ARRAY_ALLOCATED(ptr, enabled) \
|
||||
if (enabled) { \
|
||||
ASSERT_NE(ptr, nullptr); \
|
||||
} else { \
|
||||
ASSERT_EQ(ptr, nullptr); \
|
||||
if (enabled) { \
|
||||
ASSERT_NE(ptr, nullptr); \
|
||||
} else { \
|
||||
ASSERT_EQ(ptr, nullptr); \
|
||||
}
|
||||
|
||||
void ASSERT_ATOM_STATE_EQ(Atom* atom, const AtomState& expected) {
|
||||
void ASSERT_ATOM_STATE_EQ(Atom *atom, const AtomState &expected)
|
||||
{
|
||||
ASSERT_THAT(std::string(atom->atom_style), Eq(expected.atom_style));
|
||||
|
||||
ASSERT_NE(atom->avec, nullptr);
|
||||
@ -289,7 +289,7 @@ void ASSERT_ATOM_STATE_EQ(Atom* atom, const AtomState& expected) {
|
||||
ASSERT_EQ(atom->extra_angle_per_atom, expected.extra_angle_per_atom);
|
||||
ASSERT_EQ(atom->extra_dihedral_per_atom, expected.extra_dihedral_per_atom);
|
||||
ASSERT_EQ(atom->extra_improper_per_atom, expected.extra_improper_per_atom);
|
||||
|
||||
|
||||
ASSERT_EQ(atom->sphere_flag, expected.sphere_flag);
|
||||
ASSERT_EQ(atom->ellipsoid_flag, expected.ellipsoid_flag);
|
||||
ASSERT_EQ(atom->line_flag, expected.line_flag);
|
||||
@ -470,14 +470,14 @@ TEST_F(AtomStyleTest, atomic_is_default)
|
||||
{
|
||||
AtomState expected;
|
||||
expected.atom_style = "atomic";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
}
|
||||
@ -486,14 +486,14 @@ TEST_F(AtomStyleTest, atomic_after_charge)
|
||||
{
|
||||
AtomState expected;
|
||||
expected.atom_style = "atomic";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("atom_style charge");
|
||||
@ -702,15 +702,15 @@ TEST_F(AtomStyleTest, charge)
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "charge";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_image = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.q_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_image = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.q_flag = 1;
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
@ -878,20 +878,20 @@ TEST_F(AtomStyleTest, sphere)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "sphere";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.atom_style = "sphere";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.sphere_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.radius_flag = 1;
|
||||
expected.omega_flag = 1;
|
||||
expected.omega_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
@ -1049,19 +1049,19 @@ TEST_F(AtomStyleTest, ellipsoid)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "ellipsoid";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.atom_style = "ellipsoid";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.ellipsoid_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.angmom_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.rmass_flag = 1;
|
||||
expected.angmom_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
@ -1387,22 +1387,22 @@ TEST_F(AtomStyleTest, line)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "line";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.sphere_flag = 1;
|
||||
expected.atom_style = "line";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.sphere_flag = 1;
|
||||
expected.molecule_flag = 1;
|
||||
expected.line_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.radius_flag = 1;
|
||||
expected.omega_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.line_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.radius_flag = 1;
|
||||
expected.omega_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
@ -1657,23 +1657,23 @@ TEST_F(AtomStyleTest, tri)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "tri";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.sphere_flag = 1;
|
||||
expected.atom_style = "tri";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.sphere_flag = 1;
|
||||
expected.molecule_flag = 1;
|
||||
expected.tri_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.radius_flag = 1;
|
||||
expected.omega_flag = 1;
|
||||
expected.angmom_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.tri_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.radius_flag = 1;
|
||||
expected.omega_flag = 1;
|
||||
expected.angmom_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
@ -2061,20 +2061,20 @@ TEST_F(AtomStyleTest, body_nparticle)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "body";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.body_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.atom_style = "body";
|
||||
expected.molecular = Atom::ATOMIC;
|
||||
expected.tag_enable = 1;
|
||||
expected.body_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.radius_flag = 1;
|
||||
expected.angmom_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
@ -2631,22 +2631,22 @@ TEST_F(AtomStyleTest, template)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "template";
|
||||
expected.molecular = Atom::TEMPLATE;
|
||||
expected.nbondtypes = 2;
|
||||
expected.nangletypes = 2;
|
||||
expected.tag_enable = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.atom_style = "template";
|
||||
expected.molecular = Atom::TEMPLATE;
|
||||
expected.nbondtypes = 2;
|
||||
expected.nangletypes = 2;
|
||||
expected.tag_enable = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.molecule_flag = 1;
|
||||
expected.molindex_flag = 1;
|
||||
expected.molatom_flag = 1;
|
||||
expected.nmolecule = 2;
|
||||
expected.map_style = 3;
|
||||
expected.molatom_flag = 1;
|
||||
expected.nmolecule = 2;
|
||||
expected.map_style = 3;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
@ -3027,23 +3027,23 @@ TEST_F(AtomStyleTest, template_charge)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "hybrid";
|
||||
expected.molecular = Atom::TEMPLATE;
|
||||
expected.nbondtypes = 2;
|
||||
expected.nangletypes = 2;
|
||||
expected.tag_enable = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.atom_style = "hybrid";
|
||||
expected.molecular = Atom::TEMPLATE;
|
||||
expected.nbondtypes = 2;
|
||||
expected.nangletypes = 2;
|
||||
expected.tag_enable = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.molecule_flag = 1;
|
||||
expected.molindex_flag = 1;
|
||||
expected.molatom_flag = 1;
|
||||
expected.q_flag = 1;
|
||||
expected.nmolecule = 2;
|
||||
expected.map_style = 3;
|
||||
expected.molatom_flag = 1;
|
||||
expected.q_flag = 1;
|
||||
expected.nmolecule = 2;
|
||||
expected.map_style = 3;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
@ -3407,7 +3407,6 @@ TEST_F(AtomStyleTest, template_charge)
|
||||
ASSERT_EQ(lmp->atom->tag_consecutive(), 1);
|
||||
ASSERT_EQ(lmp->atom->map_tag_max, 16);
|
||||
|
||||
|
||||
type = lmp->atom->type;
|
||||
molecule = lmp->atom->molecule;
|
||||
molindex = lmp->atom->molindex;
|
||||
@ -3456,20 +3455,20 @@ TEST_F(AtomStyleTest, bond)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "bond";
|
||||
expected.molecular = Atom::MOLECULAR;
|
||||
expected.tag_enable = 1;
|
||||
expected.atom_style = "bond";
|
||||
expected.molecular = Atom::MOLECULAR;
|
||||
expected.tag_enable = 1;
|
||||
expected.molecule_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_bonds = true;
|
||||
expected.has_nspecial = true;
|
||||
expected.has_special = true;
|
||||
expected.map_style = 3;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_bonds = true;
|
||||
expected.has_nspecial = true;
|
||||
expected.has_special = true;
|
||||
expected.map_style = 3;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
@ -3804,21 +3803,21 @@ TEST_F(AtomStyleTest, angle)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "angle";
|
||||
expected.molecular = Atom::MOLECULAR;
|
||||
expected.tag_enable = 1;
|
||||
expected.atom_style = "angle";
|
||||
expected.molecular = Atom::MOLECULAR;
|
||||
expected.tag_enable = 1;
|
||||
expected.molecule_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_bonds = true;
|
||||
expected.has_angles = true;
|
||||
expected.has_nspecial = true;
|
||||
expected.has_special = true;
|
||||
expected.map_style = 3;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_bonds = true;
|
||||
expected.has_angles = true;
|
||||
expected.has_nspecial = true;
|
||||
expected.has_special = true;
|
||||
expected.map_style = 3;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
@ -4164,28 +4163,28 @@ TEST_F(AtomStyleTest, full_ellipsoid)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
AtomState expected;
|
||||
expected.atom_style = "hybrid";
|
||||
expected.molecular = Atom::MOLECULAR;
|
||||
expected.tag_enable = 1;
|
||||
expected.molecule_flag = 1;
|
||||
expected.atom_style = "hybrid";
|
||||
expected.molecular = Atom::MOLECULAR;
|
||||
expected.tag_enable = 1;
|
||||
expected.molecule_flag = 1;
|
||||
expected.ellipsoid_flag = 1;
|
||||
expected.q_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.angmom_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_bonds = true;
|
||||
expected.has_angles = true;
|
||||
expected.has_dihedral = true;
|
||||
expected.has_improper = true;
|
||||
expected.has_nspecial = true;
|
||||
expected.has_special = true;
|
||||
expected.map_style = 3;
|
||||
expected.q_flag = 1;
|
||||
expected.rmass_flag = 1;
|
||||
expected.torque_flag = 1;
|
||||
expected.angmom_flag = 1;
|
||||
expected.has_type = true;
|
||||
expected.has_mask = true;
|
||||
expected.has_image = true;
|
||||
expected.has_x = true;
|
||||
expected.has_v = true;
|
||||
expected.has_f = true;
|
||||
expected.has_bonds = true;
|
||||
expected.has_angles = true;
|
||||
expected.has_dihedral = true;
|
||||
expected.has_improper = true;
|
||||
expected.has_nspecial = true;
|
||||
expected.has_special = true;
|
||||
expected.map_style = 3;
|
||||
|
||||
ASSERT_ATOM_STATE_EQ(lmp->atom, expected);
|
||||
|
||||
|
||||
@ -11,30 +11,33 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
char * BINARY2TXT_BINARY = nullptr;
|
||||
char *BINARY2TXT_BINARY = nullptr;
|
||||
|
||||
class DumpAtomTest : public MeltTest {
|
||||
std::string dump_style = "atom";
|
||||
|
||||
public:
|
||||
void enable_triclinic() {
|
||||
void enable_triclinic()
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("change_box all triclinic");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id all {} 1 {}", dump_style, dump_file));
|
||||
|
||||
@ -46,7 +49,9 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_text_and_binary_dump(std::string text_file, std::string binary_file, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_binary_dump(std::string text_file, std::string binary_file,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
|
||||
command(fmt::format("dump id1 all {} 1 {}", dump_style, binary_file));
|
||||
@ -60,7 +65,8 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_binary_to_text(std::string binary_file) {
|
||||
std::string convert_binary_to_text(std::string binary_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string cmdline = fmt::format("{} {}", BINARY2TXT_BINARY, binary_file);
|
||||
system(cmdline.c_str());
|
||||
@ -290,9 +296,9 @@ TEST_F(DumpAtomTest, triclinic_with_image_run0)
|
||||
|
||||
TEST_F(DumpAtomTest, binary_run0)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_text_run0.melt";
|
||||
auto text_file = "dump_text_run0.melt";
|
||||
auto binary_file = "dump_binary_run0.melt.bin";
|
||||
|
||||
generate_text_and_binary_dump(text_file, binary_file, "", 0);
|
||||
@ -311,9 +317,9 @@ TEST_F(DumpAtomTest, binary_run0)
|
||||
|
||||
TEST_F(DumpAtomTest, binary_with_units_run0)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_text_with_units_run0.melt";
|
||||
auto text_file = "dump_text_with_units_run0.melt";
|
||||
auto binary_file = "dump_binary_with_units_run0.melt.bin";
|
||||
|
||||
generate_text_and_binary_dump(text_file, binary_file, "scale no units yes", 0);
|
||||
@ -332,9 +338,9 @@ TEST_F(DumpAtomTest, binary_with_units_run0)
|
||||
|
||||
TEST_F(DumpAtomTest, binary_with_time_run0)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_text_with_time_run0.melt";
|
||||
auto text_file = "dump_text_with_time_run0.melt";
|
||||
auto binary_file = "dump_binary_with_time_run0.melt.bin";
|
||||
|
||||
generate_text_and_binary_dump(text_file, binary_file, "scale no time yes", 0);
|
||||
@ -353,9 +359,9 @@ TEST_F(DumpAtomTest, binary_with_time_run0)
|
||||
|
||||
TEST_F(DumpAtomTest, binary_triclinic_run0)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_text_tri_run0.melt";
|
||||
auto text_file = "dump_text_tri_run0.melt";
|
||||
auto binary_file = "dump_binary_tri_run0.melt.bin";
|
||||
|
||||
enable_triclinic();
|
||||
@ -375,9 +381,9 @@ TEST_F(DumpAtomTest, binary_triclinic_run0)
|
||||
|
||||
TEST_F(DumpAtomTest, binary_triclinic_with_units_run0)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_text_tri_with_units_run0.melt";
|
||||
auto text_file = "dump_text_tri_with_units_run0.melt";
|
||||
auto binary_file = "dump_binary_tri_with_units_run0.melt.bin";
|
||||
|
||||
enable_triclinic();
|
||||
@ -397,9 +403,9 @@ TEST_F(DumpAtomTest, binary_triclinic_with_units_run0)
|
||||
|
||||
TEST_F(DumpAtomTest, binary_triclinic_with_time_run0)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_text_tri_with_time_run0.melt";
|
||||
auto text_file = "dump_text_tri_with_time_run0.melt";
|
||||
auto binary_file = "dump_binary_tri_with_time_run0.melt.bin";
|
||||
|
||||
enable_triclinic();
|
||||
@ -419,9 +425,9 @@ TEST_F(DumpAtomTest, binary_triclinic_with_time_run0)
|
||||
|
||||
TEST_F(DumpAtomTest, binary_triclinic_with_image_run0)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_text_tri_with_image_run0.melt";
|
||||
auto text_file = "dump_text_tri_with_image_run0.melt";
|
||||
auto binary_file = "dump_binary_tri_with_image_run0.melt.bin";
|
||||
|
||||
enable_triclinic();
|
||||
@ -501,8 +507,7 @@ TEST_F(DumpAtomTest, dump_modify_scale_invalid)
|
||||
command("dump id all atom 1 dump.txt");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*Illegal dump_modify command.*",
|
||||
command("dump_modify id scale true"););
|
||||
TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id scale true"););
|
||||
}
|
||||
|
||||
TEST_F(DumpAtomTest, dump_modify_image_invalid)
|
||||
@ -511,8 +516,7 @@ TEST_F(DumpAtomTest, dump_modify_image_invalid)
|
||||
command("dump id all atom 1 dump.txt");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*Illegal dump_modify command.*",
|
||||
command("dump_modify id image true"););
|
||||
TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id image true"););
|
||||
}
|
||||
|
||||
TEST_F(DumpAtomTest, dump_modify_invalid)
|
||||
@ -521,8 +525,7 @@ TEST_F(DumpAtomTest, dump_modify_invalid)
|
||||
command("dump id all atom 1 dump.txt");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*Illegal dump_modify command.*",
|
||||
command("dump_modify id true"););
|
||||
TEST_FAILURE(".*Illegal dump_modify command.*", command("dump_modify id true"););
|
||||
}
|
||||
|
||||
TEST_F(DumpAtomTest, write_dump)
|
||||
@ -547,7 +550,7 @@ TEST_F(DumpAtomTest, write_dump)
|
||||
|
||||
TEST_F(DumpAtomTest, binary_write_dump)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto reference = "dump_run0.melt.bin";
|
||||
auto dump_file = "write_dump_atom_run0_p0.melt.bin";
|
||||
|
||||
@ -11,30 +11,33 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
char * GZIP_BINARY = nullptr;
|
||||
char *GZIP_BINARY = nullptr;
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
class DumpAtomGZTest : public MeltTest {
|
||||
std::string dump_style = "atom";
|
||||
|
||||
public:
|
||||
void enable_triclinic() {
|
||||
void enable_triclinic()
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("change_box all triclinic");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id all {} 1 {}", dump_style, dump_file));
|
||||
|
||||
@ -46,7 +49,10 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
|
||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_file));
|
||||
@ -60,26 +66,27 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// GZ compressed files
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
TEST_F(DumpAtomGZTest, compressed_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_gz_text_run0.melt";
|
||||
auto text_file = "dump_gz_text_run0.melt";
|
||||
auto compressed_file = "dump_gz_compressed_run0.melt.gz";
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "", 0);
|
||||
@ -101,12 +108,13 @@ TEST_F(DumpAtomGZTest, compressed_run0)
|
||||
|
||||
TEST_F(DumpAtomGZTest, compressed_with_units_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_gz_text_with_units_run0.melt";
|
||||
auto text_file = "dump_gz_text_with_units_run0.melt";
|
||||
auto compressed_file = "dump_gz_compressed_with_units_run0.melt.gz";
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes", 0);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes",
|
||||
0);
|
||||
|
||||
TearDown();
|
||||
|
||||
@ -124,12 +132,13 @@ TEST_F(DumpAtomGZTest, compressed_with_units_run0)
|
||||
|
||||
TEST_F(DumpAtomGZTest, compressed_with_time_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_gz_text_with_time_run0.melt";
|
||||
auto text_file = "dump_gz_text_with_time_run0.melt";
|
||||
auto compressed_file = "dump_gz_compressed_with_time_run0.melt.gz";
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes", 0);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes",
|
||||
0);
|
||||
|
||||
TearDown();
|
||||
|
||||
@ -147,9 +156,9 @@ TEST_F(DumpAtomGZTest, compressed_with_time_run0)
|
||||
|
||||
TEST_F(DumpAtomGZTest, compressed_triclinic_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_gz_text_tri_run0.melt";
|
||||
auto text_file = "dump_gz_text_tri_run0.melt";
|
||||
auto compressed_file = "dump_gz_compressed_tri_run0.melt.gz";
|
||||
|
||||
enable_triclinic();
|
||||
@ -171,13 +180,14 @@ TEST_F(DumpAtomGZTest, compressed_triclinic_run0)
|
||||
|
||||
TEST_F(DumpAtomGZTest, compressed_triclinic_with_units_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_gz_text_tri_with_units_run0.melt";
|
||||
auto text_file = "dump_gz_text_tri_with_units_run0.melt";
|
||||
auto compressed_file = "dump_gz_compressed_tri_with_units_run0.melt.gz";
|
||||
|
||||
enable_triclinic();
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes", 0);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no units yes",
|
||||
0);
|
||||
|
||||
TearDown();
|
||||
|
||||
@ -195,13 +205,14 @@ TEST_F(DumpAtomGZTest, compressed_triclinic_with_units_run0)
|
||||
|
||||
TEST_F(DumpAtomGZTest, compressed_triclinic_with_time_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_gz_text_tri_with_time_run0.melt";
|
||||
auto text_file = "dump_gz_text_tri_with_time_run0.melt";
|
||||
auto compressed_file = "dump_gz_compressed_tri_with_time_run0.melt.gz";
|
||||
|
||||
enable_triclinic();
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes", 0);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/gz", "scale no time yes",
|
||||
0);
|
||||
|
||||
TearDown();
|
||||
|
||||
@ -219,9 +230,9 @@ TEST_F(DumpAtomGZTest, compressed_triclinic_with_time_run0)
|
||||
|
||||
TEST_F(DumpAtomGZTest, compressed_triclinic_with_image_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_gz_text_tri_with_image_run0.melt";
|
||||
auto text_file = "dump_gz_text_tri_with_image_run0.melt";
|
||||
auto compressed_file = "dump_gz_compressed_tri_with_image_run0.melt.gz";
|
||||
|
||||
enable_triclinic();
|
||||
|
||||
@ -11,30 +11,33 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
char * ZSTD_BINARY = nullptr;
|
||||
char *ZSTD_BINARY = nullptr;
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
class DumpAtomZSTDTest : public MeltTest {
|
||||
std::string dump_style = "atom";
|
||||
|
||||
public:
|
||||
void enable_triclinic() {
|
||||
void enable_triclinic()
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("change_box all triclinic");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_dump(std::string dump_file, std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id all {} 1 {}", dump_style, dump_file));
|
||||
|
||||
@ -46,7 +49,10 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
|
||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_file));
|
||||
@ -60,26 +66,27 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// ZSTD compressed files
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
TEST_F(DumpAtomZSTDTest, compressed_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_zstd_text_run0.melt";
|
||||
auto text_file = "dump_zstd_text_run0.melt";
|
||||
auto compressed_file = "dump_zstd_compressed_run0.melt.zst";
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "", 0);
|
||||
@ -102,12 +109,13 @@ TEST_F(DumpAtomZSTDTest, compressed_run0)
|
||||
|
||||
TEST_F(DumpAtomZSTDTest, compressed_with_units_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_zstd_text_with_units_run0.melt";
|
||||
auto text_file = "dump_zstd_text_with_units_run0.melt";
|
||||
auto compressed_file = "dump_zstd_compressed_with_units_run0.melt.zst";
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no units yes", 0);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no units yes",
|
||||
0);
|
||||
|
||||
// make sure file is closed
|
||||
TearDown();
|
||||
@ -126,12 +134,13 @@ TEST_F(DumpAtomZSTDTest, compressed_with_units_run0)
|
||||
|
||||
TEST_F(DumpAtomZSTDTest, compressed_with_time_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_zstd_text_with_time_run0.melt";
|
||||
auto text_file = "dump_zstd_text_with_time_run0.melt";
|
||||
auto compressed_file = "dump_zstd_compressed_with_time_run0.melt.zst";
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no time yes", 0);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no time yes",
|
||||
0);
|
||||
|
||||
// make sure file is closed
|
||||
TearDown();
|
||||
@ -150,9 +159,9 @@ TEST_F(DumpAtomZSTDTest, compressed_with_time_run0)
|
||||
|
||||
TEST_F(DumpAtomZSTDTest, compressed_triclinic_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_zstd_text_tri_run0.melt";
|
||||
auto text_file = "dump_zstd_text_tri_run0.melt";
|
||||
auto compressed_file = "dump_zstd_compressed_tri_run0.melt.zst";
|
||||
|
||||
enable_triclinic();
|
||||
@ -175,13 +184,14 @@ TEST_F(DumpAtomZSTDTest, compressed_triclinic_run0)
|
||||
|
||||
TEST_F(DumpAtomZSTDTest, compressed_triclinic_with_units_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_zstd_text_tri_with_units_run0.melt";
|
||||
auto text_file = "dump_zstd_text_tri_with_units_run0.melt";
|
||||
auto compressed_file = "dump_zstd_compressed_tri_with_units_run0.melt.zst";
|
||||
|
||||
enable_triclinic();
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no units yes", 0);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no units yes",
|
||||
0);
|
||||
|
||||
// make sure file is closed
|
||||
TearDown();
|
||||
@ -200,13 +210,14 @@ TEST_F(DumpAtomZSTDTest, compressed_triclinic_with_units_run0)
|
||||
|
||||
TEST_F(DumpAtomZSTDTest, compressed_triclinic_with_time_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_zstd_text_tri_with_time_run0.melt";
|
||||
auto text_file = "dump_zstd_text_tri_with_time_run0.melt";
|
||||
auto compressed_file = "dump_zstd_compressed_tri_with_time_run0.melt.zst";
|
||||
|
||||
enable_triclinic();
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no time yes", 0);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "atom/zstd", "scale no time yes",
|
||||
0);
|
||||
|
||||
// make sure file is closed
|
||||
TearDown();
|
||||
@ -225,9 +236,9 @@ TEST_F(DumpAtomZSTDTest, compressed_triclinic_with_time_run0)
|
||||
|
||||
TEST_F(DumpAtomZSTDTest, compressed_triclinic_with_image_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_zstd_text_tri_with_image_run0.melt";
|
||||
auto text_file = "dump_zstd_text_tri_with_image_run0.melt";
|
||||
auto compressed_file = "dump_zstd_compressed_tri_with_image_run0.melt.zst";
|
||||
|
||||
enable_triclinic();
|
||||
|
||||
@ -11,20 +11,23 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
class DumpCfgTest : public MeltTest {
|
||||
std::string dump_style = "cfg";
|
||||
|
||||
public:
|
||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
|
||||
int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, fields));
|
||||
|
||||
@ -40,28 +43,26 @@ public:
|
||||
TEST_F(DumpCfgTest, invalid_options)
|
||||
{
|
||||
TEST_FAILURE(".*Dump cfg arguments must start with 'mass type xs ys zs'.*",
|
||||
command("dump id all cfg 1 dump.cfg id type proc procp1 mass x y z");
|
||||
);
|
||||
command("dump id all cfg 1 dump.cfg id type proc procp1 mass x y z"););
|
||||
}
|
||||
|
||||
TEST_F(DumpCfgTest, require_multifile)
|
||||
{
|
||||
auto dump_file = "dump.melt.cfg_run.cfg";
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
auto fields =
|
||||
"mass type xs ys zs id proc procp1 x y z ix iy iz xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id all cfg 1 {} {}", dump_file, fields));
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
TEST_FAILURE(".*Dump cfg requires one snapshot per file.*",
|
||||
command("run 0");
|
||||
);
|
||||
TEST_FAILURE(".*Dump cfg requires one snapshot per file.*", command("run 0"););
|
||||
}
|
||||
|
||||
TEST_F(DumpCfgTest, run0)
|
||||
{
|
||||
auto dump_file = "dump_cfg_run*.melt.cfg";
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
|
||||
generate_dump(dump_file, fields, "", 0);
|
||||
|
||||
@ -75,7 +76,7 @@ TEST_F(DumpCfgTest, run0)
|
||||
TEST_F(DumpCfgTest, unwrap_run0)
|
||||
{
|
||||
auto dump_file = "dump_cfg_unwrap_run*.melt.cfg";
|
||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
|
||||
generate_dump(dump_file, fields, "", 0);
|
||||
|
||||
@ -89,7 +90,7 @@ TEST_F(DumpCfgTest, unwrap_run0)
|
||||
TEST_F(DumpCfgTest, no_buffer_run0)
|
||||
{
|
||||
auto dump_file = "dump_cfg_no_buffer_run*.melt.cfg";
|
||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
|
||||
generate_dump(dump_file, fields, "buffer no", 0);
|
||||
|
||||
@ -103,7 +104,7 @@ TEST_F(DumpCfgTest, no_buffer_run0)
|
||||
TEST_F(DumpCfgTest, no_unwrap_no_buffer_run0)
|
||||
{
|
||||
auto dump_file = "dump_cfg_no_unwrap_no_buffer_run*.melt.cfg";
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
|
||||
generate_dump(dump_file, fields, "buffer no", 0);
|
||||
|
||||
@ -114,7 +115,6 @@ TEST_F(DumpCfgTest, no_unwrap_no_buffer_run0)
|
||||
delete_file("dump_cfg_no_unwrap_no_buffer_run0.melt.cfg");
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MPI_Init(&argc, &argv);
|
||||
|
||||
@ -11,23 +11,26 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
char * GZIP_BINARY = nullptr;
|
||||
char *GZIP_BINARY = nullptr;
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
class DumpCfgGZTest : public MeltTest {
|
||||
std::string dump_style = "cfg";
|
||||
|
||||
public:
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style,
|
||||
std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style, std::string fields,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
||||
@ -41,10 +44,12 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
@ -53,13 +58,13 @@ public:
|
||||
|
||||
TEST_F(DumpCfgGZTest, compressed_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_files = "dump_cfg_gz_text_run*.melt.cfg";
|
||||
auto text_files = "dump_cfg_gz_text_run*.melt.cfg";
|
||||
auto compressed_files = "dump_cfg_gz_compressed_run*.melt.cfg.gz";
|
||||
auto text_file = "dump_cfg_gz_text_run0.melt.cfg";
|
||||
auto compressed_file = "dump_cfg_gz_compressed_run0.melt.cfg.gz";
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
auto text_file = "dump_cfg_gz_text_run0.melt.cfg";
|
||||
auto compressed_file = "dump_cfg_gz_compressed_run0.melt.cfg.gz";
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "cfg/gz", fields, "", 0);
|
||||
|
||||
@ -77,16 +82,15 @@ TEST_F(DumpCfgGZTest, compressed_run0)
|
||||
delete_file(converted_file);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(DumpCfgGZTest, compressed_unwrap_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_files = "dump_cfg_unwrap_gz_text_run*.melt.cfg";
|
||||
auto text_files = "dump_cfg_unwrap_gz_text_run*.melt.cfg";
|
||||
auto compressed_files = "dump_cfg_unwrap_gz_compressed_run*.melt.cfg.gz";
|
||||
auto text_file = "dump_cfg_unwrap_gz_text_run0.melt.cfg";
|
||||
auto compressed_file = "dump_cfg_unwrap_gz_compressed_run0.melt.cfg.gz";
|
||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
auto text_file = "dump_cfg_unwrap_gz_text_run0.melt.cfg";
|
||||
auto compressed_file = "dump_cfg_unwrap_gz_compressed_run0.melt.cfg.gz";
|
||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "cfg/gz", fields, "", 0);
|
||||
|
||||
|
||||
@ -11,23 +11,26 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
char * ZSTD_BINARY = nullptr;
|
||||
char *ZSTD_BINARY = nullptr;
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
class DumpCfgZstdTest : public MeltTest {
|
||||
std::string dump_style = "cfg";
|
||||
|
||||
public:
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style,
|
||||
std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style, std::string fields,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
||||
@ -41,10 +44,12 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
@ -53,13 +58,13 @@ public:
|
||||
|
||||
TEST_F(DumpCfgZstdTest, compressed_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_files = "dump_cfg_zstd_text_run*.melt.cfg";
|
||||
auto text_files = "dump_cfg_zstd_text_run*.melt.cfg";
|
||||
auto compressed_files = "dump_cfg_zstd_compressed_run*.melt.cfg.zst";
|
||||
auto text_file = "dump_cfg_zstd_text_run0.melt.cfg";
|
||||
auto compressed_file = "dump_cfg_zstd_compressed_run0.melt.cfg.zst";
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
auto text_file = "dump_cfg_zstd_text_run0.melt.cfg";
|
||||
auto compressed_file = "dump_cfg_zstd_compressed_run0.melt.cfg.zst";
|
||||
auto fields = "mass type xs ys zs id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "cfg/zstd", fields, "", 0);
|
||||
|
||||
@ -77,16 +82,15 @@ TEST_F(DumpCfgZstdTest, compressed_run0)
|
||||
delete_file(converted_file);
|
||||
}
|
||||
|
||||
|
||||
TEST_F(DumpCfgZstdTest, compressed_unwrap_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_files = "dump_cfg_unwrap_zstd_text_run*.melt.cfg";
|
||||
auto text_files = "dump_cfg_unwrap_zstd_text_run*.melt.cfg";
|
||||
auto compressed_files = "dump_cfg_unwrap_zstd_compressed_run*.melt.cfg.zst";
|
||||
auto text_file = "dump_cfg_unwrap_zstd_text_run0.melt.cfg";
|
||||
auto compressed_file = "dump_cfg_unwrap_zstd_compressed_run0.melt.cfg.zst";
|
||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
auto text_file = "dump_cfg_unwrap_zstd_text_run0.melt.cfg";
|
||||
auto compressed_file = "dump_cfg_unwrap_zstd_compressed_run0.melt.cfg.zst";
|
||||
auto fields = "mass type xsu ysu zsu id proc procp1 x y z ix iy iz vx vy vz fx fy fz";
|
||||
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "cfg/zstd", fields, "", 0);
|
||||
|
||||
|
||||
@ -11,28 +11,32 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
char * BINARY2TXT_BINARY = nullptr;
|
||||
char *BINARY2TXT_BINARY = nullptr;
|
||||
|
||||
class DumpCustomTest : public MeltTest {
|
||||
std::string dump_style = "custom";
|
||||
|
||||
public:
|
||||
void enable_triclinic() {
|
||||
void enable_triclinic()
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("change_box all triclinic");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
|
||||
int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, fields));
|
||||
|
||||
@ -44,8 +48,10 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_text_and_binary_dump(std::string text_file, std::string binary_file, std::string fields,
|
||||
std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_binary_dump(std::string text_file, std::string binary_file,
|
||||
std::string fields, std::string dump_modify_options,
|
||||
int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", dump_style, binary_file, fields));
|
||||
@ -59,7 +65,8 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_binary_to_text(std::string binary_file) {
|
||||
std::string convert_binary_to_text(std::string binary_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string cmdline = fmt::format("{} {}", BINARY2TXT_BINARY, binary_file);
|
||||
system(cmdline.c_str());
|
||||
@ -71,7 +78,8 @@ public:
|
||||
TEST_F(DumpCustomTest, run1)
|
||||
{
|
||||
auto dump_file = "dump_custom_run1.melt";
|
||||
auto fields = "id type proc procp1 mass x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
auto fields =
|
||||
"id type proc procp1 mass x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
generate_dump(dump_file, fields, "units yes", 1);
|
||||
|
||||
@ -88,7 +96,7 @@ TEST_F(DumpCustomTest, run1)
|
||||
TEST_F(DumpCustomTest, thresh_run0)
|
||||
{
|
||||
auto dump_file = "dump_custom_thresh_run0.melt";
|
||||
auto fields = "id type x y z";
|
||||
auto fields = "id type x y z";
|
||||
|
||||
generate_dump(dump_file, fields, "units yes thresh x < 1 thresh y < 1 thresh z < 1", 0);
|
||||
|
||||
@ -109,7 +117,7 @@ TEST_F(DumpCustomTest, compute_run0)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto dump_file = "dump_custom_compute_run0.melt";
|
||||
auto fields = "id type x y z c_comp[1] c_comp[2] c_comp[3]";
|
||||
auto fields = "id type x y z c_comp[1] c_comp[2] c_comp[3]";
|
||||
|
||||
generate_dump(dump_file, fields, "units yes", 0);
|
||||
|
||||
@ -130,7 +138,7 @@ TEST_F(DumpCustomTest, fix_run0)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto dump_file = "dump_custom_compute_run0.melt";
|
||||
auto fields = "id x y z f_numdiff[1] f_numdiff[2] f_numdiff[3]";
|
||||
auto fields = "id x y z f_numdiff[1] f_numdiff[2] f_numdiff[3]";
|
||||
|
||||
generate_dump(dump_file, fields, "units yes", 0);
|
||||
|
||||
@ -152,7 +160,7 @@ TEST_F(DumpCustomTest, custom_run0)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto dump_file = "dump_custom_custom_run0.melt";
|
||||
auto fields = "id x y z i_flag1 d_flag2";
|
||||
auto fields = "id x y z i_flag1 d_flag2";
|
||||
|
||||
generate_dump(dump_file, fields, "units yes", 0);
|
||||
|
||||
@ -168,9 +176,9 @@ TEST_F(DumpCustomTest, custom_run0)
|
||||
|
||||
TEST_F(DumpCustomTest, binary_run1)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_custom_text_run1.melt";
|
||||
auto text_file = "dump_custom_text_run1.melt";
|
||||
auto binary_file = "dump_custom_binary_run1.melt.bin";
|
||||
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
@ -191,7 +199,7 @@ TEST_F(DumpCustomTest, binary_run1)
|
||||
TEST_F(DumpCustomTest, triclinic_run1)
|
||||
{
|
||||
auto dump_file = "dump_custom_tri_run1.melt";
|
||||
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
enable_triclinic();
|
||||
|
||||
@ -209,12 +217,12 @@ TEST_F(DumpCustomTest, triclinic_run1)
|
||||
|
||||
TEST_F(DumpCustomTest, binary_triclinic_run1)
|
||||
{
|
||||
if(!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
if (!BINARY2TXT_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_custom_tri_text_run1.melt";
|
||||
auto text_file = "dump_custom_tri_text_run1.melt";
|
||||
auto binary_file = "dump_custom_tri_binary_run1.melt.bin";
|
||||
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
enable_triclinic();
|
||||
|
||||
generate_text_and_binary_dump(text_file, binary_file, fields, "units yes", 1);
|
||||
@ -239,8 +247,8 @@ TEST_F(DumpCustomTest, with_variable_run1)
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto dump_file = "dump_custom_with_variable_run1.melt";
|
||||
auto fields = "id type x y z v_p";
|
||||
|
||||
auto fields = "id type x y z v_p";
|
||||
|
||||
generate_dump(dump_file, fields, "units yes", 1);
|
||||
|
||||
ASSERT_FILE_EXISTS(dump_file);
|
||||
@ -253,7 +261,6 @@ TEST_F(DumpCustomTest, with_variable_run1)
|
||||
delete_file(dump_file);
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
MPI_Init(&argc, &argv);
|
||||
|
||||
@ -11,28 +11,32 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
char * GZIP_BINARY = nullptr;
|
||||
char *GZIP_BINARY = nullptr;
|
||||
|
||||
class DumpCustomGZTest : public MeltTest {
|
||||
std::string dump_style = "custom";
|
||||
|
||||
public:
|
||||
void enable_triclinic() {
|
||||
void enable_triclinic()
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("change_box all triclinic");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
|
||||
int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, fields));
|
||||
|
||||
@ -44,8 +48,10 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style,
|
||||
std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style, std::string fields,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
||||
@ -59,10 +65,12 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
@ -71,13 +79,14 @@ public:
|
||||
|
||||
TEST_F(DumpCustomGZTest, compressed_run1)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_custom_gz_text_run1.melt";
|
||||
auto text_file = "dump_custom_gz_text_run1.melt";
|
||||
auto compressed_file = "dump_custom_gz_compressed_run1.melt.gz";
|
||||
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/gz", fields, "units yes", 1);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/gz", fields, "units yes",
|
||||
1);
|
||||
|
||||
TearDown();
|
||||
|
||||
@ -95,15 +104,16 @@ TEST_F(DumpCustomGZTest, compressed_run1)
|
||||
|
||||
TEST_F(DumpCustomGZTest, compressed_triclinic_run1)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_custom_gz_tri_text_run1.melt";
|
||||
auto text_file = "dump_custom_gz_tri_text_run1.melt";
|
||||
auto compressed_file = "dump_custom_gz_tri_compressed_run1.melt.gz";
|
||||
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
enable_triclinic();
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/gz", fields, "units yes", 1);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/gz", fields, "units yes",
|
||||
1);
|
||||
|
||||
TearDown();
|
||||
|
||||
|
||||
@ -11,28 +11,32 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
char * ZSTD_BINARY = nullptr;
|
||||
char *ZSTD_BINARY = nullptr;
|
||||
|
||||
class DumpCustomZstdTest : public MeltTest {
|
||||
std::string dump_style = "custom";
|
||||
|
||||
public:
|
||||
void enable_triclinic() {
|
||||
void enable_triclinic()
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("change_box all triclinic");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_dump(std::string dump_file, std::string fields, std::string dump_modify_options,
|
||||
int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id all {} 1 {} {}", dump_style, dump_file, fields));
|
||||
|
||||
@ -44,8 +48,10 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style,
|
||||
std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style, std::string fields,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
||||
@ -59,10 +65,12 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
@ -71,13 +79,14 @@ public:
|
||||
|
||||
TEST_F(DumpCustomZstdTest, compressed_run1)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_custom_zstd_text_run1.melt";
|
||||
auto text_file = "dump_custom_zstd_text_run1.melt";
|
||||
auto compressed_file = "dump_custom_zstd_compressed_run1.melt.zst";
|
||||
auto fields = "id type proc x y z ix iy iz xs ys zs xu yu zu xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/zstd", fields, "units yes", 1);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/zstd", fields,
|
||||
"units yes", 1);
|
||||
|
||||
TearDown();
|
||||
|
||||
@ -95,15 +104,16 @@ TEST_F(DumpCustomZstdTest, compressed_run1)
|
||||
|
||||
TEST_F(DumpCustomZstdTest, compressed_triclinic_run1)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_file = "dump_custom_zstd_tri_text_run1.melt";
|
||||
auto text_file = "dump_custom_zstd_tri_text_run1.melt";
|
||||
auto compressed_file = "dump_custom_zstd_tri_compressed_run1.melt.zst";
|
||||
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
auto fields = "id type proc x y z xs ys zs xsu ysu zsu vx vy vz fx fy fz";
|
||||
|
||||
enable_triclinic();
|
||||
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/zstd", fields, "units yes", 1);
|
||||
generate_text_and_compressed_dump(text_file, compressed_file, "custom/zstd", fields,
|
||||
"units yes", 1);
|
||||
|
||||
TearDown();
|
||||
|
||||
|
||||
@ -11,23 +11,26 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
char * GZIP_BINARY = nullptr;
|
||||
char *GZIP_BINARY = nullptr;
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
class DumpLocalGZTest : public MeltTest {
|
||||
std::string dump_style = "local";
|
||||
|
||||
public:
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style,
|
||||
std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style, std::string fields,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
||||
@ -41,10 +44,12 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
@ -53,17 +58,17 @@ public:
|
||||
|
||||
TEST_F(DumpLocalGZTest, compressed_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("compute comp all pair/local dist eng");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto text_files = "dump_local_gz_text_run*.melt.local";
|
||||
auto text_files = "dump_local_gz_text_run*.melt.local";
|
||||
auto compressed_files = "dump_local_gz_compressed_run*.melt.local.gz";
|
||||
auto text_file = "dump_local_gz_text_run0.melt.local";
|
||||
auto compressed_file = "dump_local_gz_compressed_run0.melt.local.gz";
|
||||
auto fields = "index c_comp[1]";
|
||||
auto text_file = "dump_local_gz_text_run0.melt.local";
|
||||
auto compressed_file = "dump_local_gz_compressed_run0.melt.local.gz";
|
||||
auto fields = "index c_comp[1]";
|
||||
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "local/gz", fields, "", 0);
|
||||
|
||||
|
||||
@ -11,23 +11,26 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
char * ZSTD_BINARY = nullptr;
|
||||
char *ZSTD_BINARY = nullptr;
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
class DumpLocalGZTest : public MeltTest {
|
||||
std::string dump_style = "local";
|
||||
|
||||
public:
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style,
|
||||
std::string fields, std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style, std::string fields,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {} {}", dump_style, text_file, fields));
|
||||
command(fmt::format("dump id1 all {} 1 {} {}", compression_style, compressed_file, fields));
|
||||
@ -41,10 +44,12 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
@ -53,17 +58,17 @@ public:
|
||||
|
||||
TEST_F(DumpLocalGZTest, compressed_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command("compute comp all pair/local dist eng");
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
|
||||
auto text_files = "dump_local_zstd_text_run*.melt.local";
|
||||
auto text_files = "dump_local_zstd_text_run*.melt.local";
|
||||
auto compressed_files = "dump_local_zstd_compressed_run*.melt.local.zst";
|
||||
auto text_file = "dump_local_zstd_text_run0.melt.local";
|
||||
auto compressed_file = "dump_local_zstd_compressed_run0.melt.local.zst";
|
||||
auto fields = "index c_comp[1]";
|
||||
auto text_file = "dump_local_zstd_text_run0.melt.local";
|
||||
auto compressed_file = "dump_local_zstd_compressed_run0.melt.local.zst";
|
||||
auto fields = "index c_comp[1]";
|
||||
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "local/zstd", fields, "", 0);
|
||||
|
||||
|
||||
@ -11,23 +11,26 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
char * GZIP_BINARY = nullptr;
|
||||
char *GZIP_BINARY = nullptr;
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
class DumpXYZGZTest : public MeltTest {
|
||||
std::string dump_style = "xyz";
|
||||
|
||||
public:
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style,
|
||||
std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
|
||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_file));
|
||||
@ -41,10 +44,12 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", GZIP_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
@ -53,12 +58,12 @@ public:
|
||||
|
||||
TEST_F(DumpXYZGZTest, compressed_run0)
|
||||
{
|
||||
if(!GZIP_BINARY) GTEST_SKIP();
|
||||
if (!GZIP_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_files = "dump_xyz_gz_text_run*.melt.xyz";
|
||||
auto text_files = "dump_xyz_gz_text_run*.melt.xyz";
|
||||
auto compressed_files = "dump_xyz_gz_compressed_run*.melt.xyz.gz";
|
||||
auto text_file = "dump_xyz_gz_text_run0.melt.xyz";
|
||||
auto compressed_file = "dump_xyz_gz_compressed_run0.melt.xyz.gz";
|
||||
auto text_file = "dump_xyz_gz_text_run0.melt.xyz";
|
||||
auto compressed_file = "dump_xyz_gz_compressed_run0.melt.xyz.gz";
|
||||
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "xyz/gz", "", 0);
|
||||
|
||||
|
||||
@ -11,23 +11,26 @@
|
||||
See the README file in the top-level LAMMPS directory.
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "../testing/core.h"
|
||||
#include "../testing/systems/melt.h"
|
||||
#include "../testing/utils.h"
|
||||
#include "fmt/format.h"
|
||||
#include "utils.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
char * ZSTD_BINARY = nullptr;
|
||||
char *ZSTD_BINARY = nullptr;
|
||||
|
||||
using ::testing::Eq;
|
||||
|
||||
class DumpXYZGZTest : public MeltTest {
|
||||
std::string dump_style = "xyz";
|
||||
|
||||
public:
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file, std::string compression_style,
|
||||
std::string dump_modify_options, int ntimesteps) {
|
||||
void generate_text_and_compressed_dump(std::string text_file, std::string compressed_file,
|
||||
std::string compression_style,
|
||||
std::string dump_modify_options, int ntimesteps)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
command(fmt::format("dump id0 all {} 1 {}", dump_style, text_file));
|
||||
command(fmt::format("dump id1 all {} 1 {}", compression_style, compressed_file));
|
||||
@ -41,10 +44,12 @@ public:
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
std::string convert_compressed_to_text(std::string compressed_file) {
|
||||
std::string convert_compressed_to_text(std::string compressed_file)
|
||||
{
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
|
||||
std::string cmdline = fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
std::string cmdline =
|
||||
fmt::format("{} -d -c {} > {}", ZSTD_BINARY, compressed_file, converted_file);
|
||||
system(cmdline.c_str());
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
return converted_file;
|
||||
@ -53,12 +58,12 @@ public:
|
||||
|
||||
TEST_F(DumpXYZGZTest, compressed_run0)
|
||||
{
|
||||
if(!ZSTD_BINARY) GTEST_SKIP();
|
||||
if (!ZSTD_BINARY) GTEST_SKIP();
|
||||
|
||||
auto text_files = "dump_xyz_zstd_text_run*.melt.xyz";
|
||||
auto text_files = "dump_xyz_zstd_text_run*.melt.xyz";
|
||||
auto compressed_files = "dump_xyz_zstd_compressed_run*.melt.xyz.zst";
|
||||
auto text_file = "dump_xyz_zstd_text_run0.melt.xyz";
|
||||
auto compressed_file = "dump_xyz_zstd_compressed_run0.melt.xyz.zst";
|
||||
auto text_file = "dump_xyz_zstd_text_run0.melt.xyz";
|
||||
auto compressed_file = "dump_xyz_zstd_compressed_run0.melt.xyz.zst";
|
||||
|
||||
generate_text_and_compressed_dump(text_files, compressed_files, "xyz/zstd", "", 0);
|
||||
|
||||
|
||||
@ -650,15 +650,14 @@ TEST_F(PairUnitConvertTest, table_real2metal)
|
||||
|
||||
double pnew;
|
||||
lmp->output->thermo->evaluate_keyword("press", &pnew);
|
||||
EXPECT_NEAR(pold, 1.0/p_convert * pnew, fabs(pnew * rel_error));
|
||||
EXPECT_NEAR(pold, 1.0 / p_convert * pnew, fabs(pnew * rel_error));
|
||||
double enew = lmp->force->pair->eng_vdwl + lmp->force->pair->eng_coul;
|
||||
EXPECT_NEAR(1.0/ev_convert * eold, enew, fabs(enew * rel_error));
|
||||
EXPECT_NEAR(1.0 / ev_convert * eold, enew, fabs(enew * rel_error));
|
||||
|
||||
f = lmp->atom->f;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
for (int j = 0; j < 3; ++j)
|
||||
EXPECT_NEAR(1.0/ev_convert * fold[i][j], f[i][j],
|
||||
fabs(f[i][j] * rel_error));
|
||||
EXPECT_NEAR(1.0 / ev_convert * fold[i][j], f[i][j], fabs(f[i][j] * rel_error));
|
||||
}
|
||||
|
||||
TEST_F(PairUnitConvertTest, tersoff)
|
||||
|
||||
@ -31,8 +31,8 @@
|
||||
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <mpi.h>
|
||||
#include <vector>
|
||||
|
||||
#if defined(OMPI_MAJOR_VERSION)
|
||||
const bool have_openmpi = true;
|
||||
|
||||
@ -1,65 +1,70 @@
|
||||
// unit tests for issuing command to a LAMMPS instance through the Fortran wrapper
|
||||
|
||||
#include "lammps.h"
|
||||
#include <cstdio> // for stdin, stdout
|
||||
#include <mpi.h>
|
||||
#include <cstdio> // for stdin, stdout
|
||||
#include <string>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
// prototypes for fortran reverse wrapper functions
|
||||
extern "C" {
|
||||
void *f_lammps_with_args();
|
||||
void f_lammps_close();
|
||||
void f_lammps_file();
|
||||
void f_lammps_command();
|
||||
void f_lammps_commands_list();
|
||||
void f_lammps_commands_string();
|
||||
double f_lammps_get_natoms();
|
||||
void *f_lammps_with_args();
|
||||
void f_lammps_close();
|
||||
void f_lammps_file();
|
||||
void f_lammps_command();
|
||||
void f_lammps_commands_list();
|
||||
void f_lammps_commands_string();
|
||||
double f_lammps_get_natoms();
|
||||
}
|
||||
|
||||
class LAMMPS_commands : public ::testing::Test
|
||||
{
|
||||
class LAMMPS_commands : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS_NS::LAMMPS *lmp;
|
||||
LAMMPS_commands() {};
|
||||
~LAMMPS_commands() override {};
|
||||
LAMMPS_commands(){};
|
||||
~LAMMPS_commands() override{};
|
||||
|
||||
void SetUp() override {
|
||||
void SetUp() override
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
lmp = (LAMMPS_NS::LAMMPS *)f_lammps_with_args();
|
||||
lmp = (LAMMPS_NS::LAMMPS *)f_lammps_with_args();
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,8).c_str(), "LAMMPS (");
|
||||
EXPECT_STREQ(output.substr(0, 8).c_str(), "LAMMPS (");
|
||||
}
|
||||
void TearDown() override {
|
||||
void TearDown() override
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
f_lammps_close();
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
|
||||
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
|
||||
lmp = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_commands, from_file) {
|
||||
EXPECT_EQ(f_lammps_get_natoms(),0);
|
||||
TEST_F(LAMMPS_commands, from_file)
|
||||
{
|
||||
EXPECT_EQ(f_lammps_get_natoms(), 0);
|
||||
f_lammps_file();
|
||||
EXPECT_EQ(f_lammps_get_natoms(),2);
|
||||
EXPECT_EQ(f_lammps_get_natoms(), 2);
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_commands, from_line) {
|
||||
EXPECT_EQ(f_lammps_get_natoms(),0);
|
||||
TEST_F(LAMMPS_commands, from_line)
|
||||
{
|
||||
EXPECT_EQ(f_lammps_get_natoms(), 0);
|
||||
f_lammps_command();
|
||||
EXPECT_EQ(f_lammps_get_natoms(),1);
|
||||
EXPECT_EQ(f_lammps_get_natoms(), 1);
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_commands, from_list) {
|
||||
EXPECT_EQ(f_lammps_get_natoms(),0);
|
||||
TEST_F(LAMMPS_commands, from_list)
|
||||
{
|
||||
EXPECT_EQ(f_lammps_get_natoms(), 0);
|
||||
f_lammps_commands_list();
|
||||
EXPECT_EQ(f_lammps_get_natoms(),2);
|
||||
EXPECT_EQ(f_lammps_get_natoms(), 2);
|
||||
};
|
||||
|
||||
TEST_F(LAMMPS_commands, from_string) {
|
||||
EXPECT_EQ(f_lammps_get_natoms(),0);
|
||||
TEST_F(LAMMPS_commands, from_string)
|
||||
{
|
||||
EXPECT_EQ(f_lammps_get_natoms(), 0);
|
||||
f_lammps_commands_string();
|
||||
EXPECT_EQ(f_lammps_get_natoms(),2);
|
||||
EXPECT_EQ(f_lammps_get_natoms(), 2);
|
||||
};
|
||||
|
||||
@ -1,33 +1,34 @@
|
||||
// unit tests for the LAMMPS base class
|
||||
|
||||
#include "lammps.h"
|
||||
#include <cstdio> // for stdin, stdout
|
||||
#include <mpi.h>
|
||||
#include <cstdio> // for stdin, stdout
|
||||
#include <string>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
// prototypes for fortran reverse wrapper functions
|
||||
extern "C" {
|
||||
void *f_lammps_open_no_args();
|
||||
void *f_lammps_open_with_args();
|
||||
void *f_lammps_no_mpi_no_args();
|
||||
void *f_lammps_no_mpi_with_args();
|
||||
void f_lammps_close();
|
||||
int f_lammps_get_comm();
|
||||
void *f_lammps_open_no_args();
|
||||
void *f_lammps_open_with_args();
|
||||
void *f_lammps_no_mpi_no_args();
|
||||
void *f_lammps_no_mpi_with_args();
|
||||
void f_lammps_close();
|
||||
int f_lammps_get_comm();
|
||||
}
|
||||
|
||||
TEST(open_no_mpi, no_args) {
|
||||
TEST(open_no_mpi, no_args)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
int mpi_init=0;
|
||||
int mpi_init = 0;
|
||||
MPI_Initialized(&mpi_init);
|
||||
EXPECT_EQ(mpi_init,0);
|
||||
void *handle = f_lammps_no_mpi_no_args();
|
||||
EXPECT_EQ(mpi_init, 0);
|
||||
void *handle = f_lammps_no_mpi_no_args();
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
|
||||
EXPECT_STREQ(output.substr(0, 6).c_str(), "LAMMPS");
|
||||
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
|
||||
MPI_Initialized(&mpi_init);
|
||||
EXPECT_NE(mpi_init,0);
|
||||
EXPECT_NE(mpi_init, 0);
|
||||
EXPECT_EQ(lmp->world, MPI_COMM_WORLD);
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
EXPECT_EQ(lmp->screen, stdout);
|
||||
@ -35,14 +36,15 @@ TEST(open_no_mpi, no_args) {
|
||||
::testing::internal::CaptureStdout();
|
||||
f_lammps_close();
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
|
||||
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
|
||||
}
|
||||
|
||||
TEST(open_no_mpi, with_args) {
|
||||
TEST(open_no_mpi, with_args)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
void *handle = f_lammps_no_mpi_with_args();
|
||||
void *handle = f_lammps_no_mpi_with_args();
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
|
||||
EXPECT_STREQ(output.substr(0, 6).c_str(), "LAMMPS");
|
||||
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
EXPECT_EQ(lmp->screen, stdout);
|
||||
@ -53,17 +55,18 @@ TEST(open_no_mpi, with_args) {
|
||||
::testing::internal::CaptureStdout();
|
||||
f_lammps_close();
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
|
||||
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
|
||||
}
|
||||
|
||||
TEST(fortran_open, no_args) {
|
||||
TEST(fortran_open, no_args)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
void *handle = f_lammps_open_no_args();
|
||||
void *handle = f_lammps_open_no_args();
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
|
||||
EXPECT_STREQ(output.substr(0, 6).c_str(), "LAMMPS");
|
||||
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
|
||||
|
||||
int f_comm = f_lammps_get_comm();
|
||||
int f_comm = f_lammps_get_comm();
|
||||
MPI_Comm mycomm = MPI_Comm_f2c(f_comm);
|
||||
EXPECT_EQ(lmp->world, mycomm);
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
@ -72,17 +75,18 @@ TEST(fortran_open, no_args) {
|
||||
::testing::internal::CaptureStdout();
|
||||
f_lammps_close();
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
|
||||
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
|
||||
}
|
||||
|
||||
TEST(fortran_open, with_args) {
|
||||
TEST(fortran_open, with_args)
|
||||
{
|
||||
::testing::internal::CaptureStdout();
|
||||
void *handle = f_lammps_open_with_args();
|
||||
void *handle = f_lammps_open_with_args();
|
||||
std::string output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,6).c_str(),"LAMMPS");
|
||||
EXPECT_STREQ(output.substr(0, 6).c_str(), "LAMMPS");
|
||||
LAMMPS_NS::LAMMPS *lmp = (LAMMPS_NS::LAMMPS *)handle;
|
||||
|
||||
int f_comm = f_lammps_get_comm();
|
||||
int f_comm = f_lammps_get_comm();
|
||||
MPI_Comm mycomm = MPI_Comm_f2c(f_comm);
|
||||
EXPECT_EQ(lmp->world, mycomm);
|
||||
EXPECT_EQ(lmp->infile, stdin);
|
||||
@ -93,5 +97,5 @@ TEST(fortran_open, with_args) {
|
||||
::testing::internal::CaptureStdout();
|
||||
f_lammps_close();
|
||||
output = ::testing::internal::GetCapturedStdout();
|
||||
EXPECT_STREQ(output.substr(0,16).c_str(), "Total wall time:");
|
||||
EXPECT_STREQ(output.substr(0, 16).c_str(), "Total wall time:");
|
||||
}
|
||||
|
||||
@ -32,13 +32,13 @@ bool verbose = false;
|
||||
using LAMMPS_NS::utils::split_words;
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
using ::testing::StrEq;
|
||||
using ::testing::MatchesRegex;
|
||||
using ::testing::StrEq;
|
||||
|
||||
class PythonPackageTest : public ::testing::Test {
|
||||
protected:
|
||||
LAMMPS *lmp;
|
||||
Info *info;
|
||||
Info *info;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
@ -74,7 +74,7 @@ protected:
|
||||
|
||||
TEST_F(PythonPackageTest, python_invoke)
|
||||
{
|
||||
if (!info->has_style("command","python")) GTEST_SKIP();
|
||||
if (!info->has_style("command", "python")) GTEST_SKIP();
|
||||
// execute python function from file
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("python printnum file ${input_dir}/func.py");
|
||||
@ -107,9 +107,9 @@ TEST_F(PythonPackageTest, python_invoke)
|
||||
ASSERT_THAT(output, MatchesRegex("python.*2.25.*"));
|
||||
}
|
||||
|
||||
TEST_F(PythonPackageTest, python_variable)
|
||||
TEST_F(PythonPackageTest, python_variable)
|
||||
{
|
||||
if (!info->has_style("command","python")) GTEST_SKIP();
|
||||
if (!info->has_style("command", "python")) GTEST_SKIP();
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp->input->one("variable sq python square");
|
||||
lmp->input->one("variable val index 1.5");
|
||||
|
||||
@ -41,31 +41,26 @@ using ::testing::MatchesRegex;
|
||||
// whether to print verbose output (i.e. not capturing LAMMPS screen output).
|
||||
bool verbose = false;
|
||||
|
||||
|
||||
class LAMMPSTest : public ::testing::Test {
|
||||
public:
|
||||
void command(const std::string &line) {
|
||||
lmp->input->one(line.c_str());
|
||||
}
|
||||
void command(const std::string &line) { lmp->input->one(line.c_str()); }
|
||||
|
||||
protected:
|
||||
const char * testbinary = "LAMMPSTest";
|
||||
const char *testbinary = "LAMMPSTest";
|
||||
LAMMPS *lmp;
|
||||
|
||||
void SetUp() override
|
||||
{
|
||||
const char *args[] = { testbinary, "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
const char *args[] = {testbinary, "-log", "none", "-echo", "screen", "-nocite"};
|
||||
char **argv = (char **)args;
|
||||
int argc = sizeof(args) / sizeof(char *);
|
||||
if (!verbose) ::testing::internal::CaptureStdout();
|
||||
lmp = new LAMMPS(argc, argv, MPI_COMM_WORLD);
|
||||
InitSystem();
|
||||
if (!verbose) ::testing::internal::GetCapturedStdout();
|
||||
}
|
||||
|
||||
|
||||
virtual void InitSystem() {
|
||||
}
|
||||
virtual void InitSystem() {}
|
||||
|
||||
void TearDown() override
|
||||
{
|
||||
@ -76,5 +71,4 @@ protected:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -17,7 +17,8 @@
|
||||
|
||||
class MeltTest : public LAMMPSTest {
|
||||
protected:
|
||||
virtual void InitSystem() override {
|
||||
virtual void InitSystem() override
|
||||
{
|
||||
command("units lj");
|
||||
command("atom_style atomic");
|
||||
command("atom_modify map yes");
|
||||
@ -34,7 +35,7 @@ protected:
|
||||
command("pair_coeff 1 1 1.0 1.0 2.5");
|
||||
|
||||
command("neighbor 0.3 bin");
|
||||
command("neigh_modify every 20 delay 0 check no");
|
||||
command("neigh_modify every 20 delay 0 check no");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -13,12 +13,12 @@
|
||||
#ifndef TEST_EXTENSIONS__H
|
||||
#define TEST_EXTENSIONS__H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sys/types.h>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <vector>
|
||||
|
||||
static void delete_file(const std::string &filename)
|
||||
{
|
||||
@ -44,14 +44,15 @@ static bool equal_lines(const std::string &fileA, const std::string &fileB)
|
||||
std::string lineA, lineB;
|
||||
|
||||
while (std::getline(afile, lineA)) {
|
||||
if(!std::getline(bfile, lineB)) return false;
|
||||
if(lineA != lineB) return false;
|
||||
if (!std::getline(bfile, lineB)) return false;
|
||||
if (lineA != lineB) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static std::vector<std::string> read_lines(const std::string &filename) {
|
||||
static std::vector<std::string> read_lines(const std::string &filename)
|
||||
{
|
||||
std::vector<std::string> lines;
|
||||
std::ifstream infile(filename);
|
||||
std::string line;
|
||||
@ -62,7 +63,8 @@ static std::vector<std::string> read_lines(const std::string &filename) {
|
||||
return lines;
|
||||
}
|
||||
|
||||
static bool file_exists(const std::string &filename) {
|
||||
static bool file_exists(const std::string &filename)
|
||||
{
|
||||
struct stat result;
|
||||
return stat(filename.c_str(), &result) == 0;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -19,329 +19,333 @@
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
TEST(MyPage, int) {
|
||||
TEST(MyPage, int)
|
||||
{
|
||||
MyPage<int> p;
|
||||
|
||||
// default init. maxchunk=1, pagesize=1024
|
||||
int rv = p.init();
|
||||
ASSERT_EQ(rv,0);
|
||||
ASSERT_EQ(rv, 0);
|
||||
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
int *iptr = p.vget();
|
||||
// second call to vget() should give same pointer without vgot()
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
p.vgot(1);
|
||||
++iptr;
|
||||
ASSERT_EQ(0,p.status());
|
||||
ASSERT_EQ(p.ndatum,1);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(0, p.status());
|
||||
ASSERT_EQ(p.ndatum, 1);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
// use too large chunk size
|
||||
p.vgot(2);
|
||||
ASSERT_EQ(1,p.status());
|
||||
ASSERT_EQ(1, p.status());
|
||||
|
||||
p.reset();
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
iptr = p.vget();
|
||||
p.vgot(1);
|
||||
++iptr;
|
||||
ASSERT_EQ(iptr,p.get());
|
||||
ASSERT_EQ(iptr, p.get());
|
||||
++iptr;
|
||||
ASSERT_EQ(iptr,p.get(1));
|
||||
ASSERT_EQ(p.ndatum,3);
|
||||
ASSERT_EQ(p.nchunk,3);
|
||||
ASSERT_EQ(iptr, p.get(1));
|
||||
ASSERT_EQ(p.ndatum, 3);
|
||||
ASSERT_EQ(p.nchunk, 3);
|
||||
|
||||
// restart with custom init. maxchunk=16, pagesize=256
|
||||
rv = p.init(16,64,2);
|
||||
ASSERT_EQ(rv,0);
|
||||
rv = p.init(16, 64, 2);
|
||||
ASSERT_EQ(rv, 0);
|
||||
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
iptr = p.vget();
|
||||
// second call to vget() should give same pointer without vgot()
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
p.vgot(16);
|
||||
iptr += 16;
|
||||
ASSERT_EQ(0,p.status());
|
||||
ASSERT_EQ(p.ndatum,16);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
ASSERT_EQ(0, p.status());
|
||||
ASSERT_EQ(p.ndatum, 16);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
|
||||
// use too large chunk size
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
p.vgot(32);
|
||||
ASSERT_EQ(1,p.status());
|
||||
ASSERT_EQ(1, p.status());
|
||||
|
||||
p.reset();
|
||||
ASSERT_EQ(0,p.status());
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(0, p.status());
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
iptr = p.vget();
|
||||
p.vgot(16);
|
||||
iptr = p.vget();
|
||||
p.vgot(4);
|
||||
iptr += 4;
|
||||
ASSERT_EQ(iptr,p.get());
|
||||
ASSERT_EQ(iptr, p.get());
|
||||
++iptr;
|
||||
ASSERT_EQ(iptr,p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(),(double)sizeof(int)*128.0);
|
||||
ASSERT_EQ(p.ndatum,37);
|
||||
ASSERT_EQ(p.nchunk,4);
|
||||
ASSERT_EQ(iptr, p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(), (double)sizeof(int) * 128.0);
|
||||
ASSERT_EQ(p.ndatum, 37);
|
||||
ASSERT_EQ(p.nchunk, 4);
|
||||
p.get(16);
|
||||
p.get(16);
|
||||
// allocation on the same page
|
||||
iptr = p.get(16);
|
||||
iptr += 16;
|
||||
ASSERT_EQ(iptr,p.get(16));
|
||||
ASSERT_EQ(iptr, p.get(16));
|
||||
// allocation on different pages
|
||||
p.get(16);
|
||||
iptr += 16;
|
||||
ASSERT_NE(iptr,p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(),(double)sizeof(int)*256.0);
|
||||
ASSERT_EQ(p.ndatum,133);
|
||||
ASSERT_EQ(p.nchunk,10);
|
||||
ASSERT_NE(iptr, p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(), (double)sizeof(int) * 256.0);
|
||||
ASSERT_EQ(p.ndatum, 133);
|
||||
ASSERT_EQ(p.nchunk, 10);
|
||||
}
|
||||
|
||||
TEST(MyPage, double) {
|
||||
TEST(MyPage, double)
|
||||
{
|
||||
MyPage<double> p;
|
||||
|
||||
// default init. maxchunk=1, pagesize=1024
|
||||
int rv = p.init();
|
||||
ASSERT_EQ(rv,0);
|
||||
ASSERT_EQ(rv, 0);
|
||||
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
double *iptr = p.vget();
|
||||
// second call to vget() should give same pointer without vgot()
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
p.vgot(1);
|
||||
++iptr;
|
||||
ASSERT_EQ(0,p.status());
|
||||
ASSERT_EQ(p.ndatum,1);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(0, p.status());
|
||||
ASSERT_EQ(p.ndatum, 1);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
// use too large chunk size
|
||||
p.vgot(2);
|
||||
ASSERT_EQ(1,p.status());
|
||||
ASSERT_EQ(1, p.status());
|
||||
|
||||
p.reset();
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
iptr = p.vget();
|
||||
p.vgot(1);
|
||||
++iptr;
|
||||
ASSERT_EQ(iptr,p.get());
|
||||
ASSERT_EQ(iptr, p.get());
|
||||
++iptr;
|
||||
ASSERT_EQ(iptr,p.get(1));
|
||||
ASSERT_EQ(p.ndatum,3);
|
||||
ASSERT_EQ(p.nchunk,3);
|
||||
ASSERT_EQ(iptr, p.get(1));
|
||||
ASSERT_EQ(p.ndatum, 3);
|
||||
ASSERT_EQ(p.nchunk, 3);
|
||||
|
||||
// restart with custom init. maxchunk=16, pagesize=256
|
||||
rv = p.init(16,64,2);
|
||||
ASSERT_EQ(rv,0);
|
||||
rv = p.init(16, 64, 2);
|
||||
ASSERT_EQ(rv, 0);
|
||||
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
iptr = p.vget();
|
||||
// second call to vget() should give same pointer without vgot()
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
p.vgot(16);
|
||||
iptr += 16;
|
||||
ASSERT_EQ(0,p.status());
|
||||
ASSERT_EQ(p.ndatum,16);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
ASSERT_EQ(0, p.status());
|
||||
ASSERT_EQ(p.ndatum, 16);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
|
||||
// use too large chunk size
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
p.vgot(32);
|
||||
ASSERT_EQ(1,p.status());
|
||||
ASSERT_EQ(1, p.status());
|
||||
|
||||
p.reset();
|
||||
ASSERT_EQ(0,p.status());
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(0, p.status());
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
iptr = p.vget();
|
||||
p.vgot(16);
|
||||
iptr = p.vget();
|
||||
p.vgot(4);
|
||||
iptr += 4;
|
||||
ASSERT_EQ(iptr,p.get());
|
||||
ASSERT_EQ(iptr, p.get());
|
||||
++iptr;
|
||||
ASSERT_EQ(iptr,p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(),(double)sizeof(double)*128.0);
|
||||
ASSERT_EQ(p.ndatum,37);
|
||||
ASSERT_EQ(p.nchunk,4);
|
||||
ASSERT_EQ(iptr, p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(), (double)sizeof(double) * 128.0);
|
||||
ASSERT_EQ(p.ndatum, 37);
|
||||
ASSERT_EQ(p.nchunk, 4);
|
||||
p.get(16);
|
||||
p.get(16);
|
||||
// allocation on the same page
|
||||
iptr = p.get(16);
|
||||
iptr += 16;
|
||||
ASSERT_EQ(iptr,p.get(16));
|
||||
ASSERT_EQ(iptr, p.get(16));
|
||||
// allocation on different pages
|
||||
p.get(16);
|
||||
iptr += 16;
|
||||
ASSERT_NE(iptr,p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(),(double)sizeof(double)*256.0);
|
||||
ASSERT_EQ(p.ndatum,133);
|
||||
ASSERT_EQ(p.nchunk,10);
|
||||
ASSERT_NE(iptr, p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(), (double)sizeof(double) * 256.0);
|
||||
ASSERT_EQ(p.ndatum, 133);
|
||||
ASSERT_EQ(p.nchunk, 10);
|
||||
}
|
||||
|
||||
TEST(MyPage, bigint) {
|
||||
TEST(MyPage, bigint)
|
||||
{
|
||||
MyPage<bigint> p;
|
||||
|
||||
// default init. maxchunk=1, pagesize=1024
|
||||
int rv = p.init();
|
||||
ASSERT_EQ(rv,0);
|
||||
ASSERT_EQ(rv, 0);
|
||||
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
bigint *iptr = p.vget();
|
||||
// second call to vget() should give same pointer without vgot()
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
p.vgot(1);
|
||||
++iptr;
|
||||
ASSERT_EQ(0,p.status());
|
||||
ASSERT_EQ(p.ndatum,1);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(0, p.status());
|
||||
ASSERT_EQ(p.ndatum, 1);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
// use too large chunk size
|
||||
p.vgot(2);
|
||||
ASSERT_EQ(1,p.status());
|
||||
ASSERT_EQ(1, p.status());
|
||||
|
||||
p.reset();
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
iptr = p.vget();
|
||||
p.vgot(1);
|
||||
++iptr;
|
||||
ASSERT_EQ(iptr,p.get());
|
||||
ASSERT_EQ(iptr, p.get());
|
||||
++iptr;
|
||||
ASSERT_EQ(iptr,p.get(1));
|
||||
ASSERT_EQ(p.ndatum,3);
|
||||
ASSERT_EQ(p.nchunk,3);
|
||||
ASSERT_EQ(iptr, p.get(1));
|
||||
ASSERT_EQ(p.ndatum, 3);
|
||||
ASSERT_EQ(p.nchunk, 3);
|
||||
|
||||
// restart with custom init. maxchunk=16, pagesize=256
|
||||
rv = p.init(16,64,2);
|
||||
ASSERT_EQ(rv,0);
|
||||
rv = p.init(16, 64, 2);
|
||||
ASSERT_EQ(rv, 0);
|
||||
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
iptr = p.vget();
|
||||
// second call to vget() should give same pointer without vgot()
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
p.vgot(16);
|
||||
iptr += 16;
|
||||
ASSERT_EQ(0,p.status());
|
||||
ASSERT_EQ(p.ndatum,16);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
ASSERT_EQ(0, p.status());
|
||||
ASSERT_EQ(p.ndatum, 16);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
|
||||
// use too large chunk size
|
||||
ASSERT_EQ(iptr,p.vget());
|
||||
ASSERT_EQ(iptr, p.vget());
|
||||
p.vgot(32);
|
||||
ASSERT_EQ(1,p.status());
|
||||
ASSERT_EQ(1, p.status());
|
||||
|
||||
p.reset();
|
||||
ASSERT_EQ(0,p.status());
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(0, p.status());
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
|
||||
iptr = p.vget();
|
||||
p.vgot(16);
|
||||
iptr = p.vget();
|
||||
p.vgot(4);
|
||||
iptr += 4;
|
||||
ASSERT_EQ(iptr,p.get());
|
||||
ASSERT_EQ(iptr, p.get());
|
||||
++iptr;
|
||||
ASSERT_EQ(iptr,p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(),(double)sizeof(bigint)*128.0);
|
||||
ASSERT_EQ(p.ndatum,37);
|
||||
ASSERT_EQ(p.nchunk,4);
|
||||
ASSERT_EQ(iptr, p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(), (double)sizeof(bigint) * 128.0);
|
||||
ASSERT_EQ(p.ndatum, 37);
|
||||
ASSERT_EQ(p.nchunk, 4);
|
||||
p.get(16);
|
||||
p.get(16);
|
||||
// allocation on the same page
|
||||
iptr = p.get(16);
|
||||
iptr += 16;
|
||||
ASSERT_EQ(iptr,p.get(16));
|
||||
ASSERT_EQ(iptr, p.get(16));
|
||||
// allocation on different pages
|
||||
p.get(16);
|
||||
iptr += 16;
|
||||
ASSERT_NE(iptr,p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(),(double)sizeof(bigint)*256.0);
|
||||
ASSERT_EQ(p.ndatum,133);
|
||||
ASSERT_EQ(p.nchunk,10);
|
||||
ASSERT_NE(iptr, p.get(16));
|
||||
ASSERT_DOUBLE_EQ(p.size(), (double)sizeof(bigint) * 256.0);
|
||||
ASSERT_EQ(p.ndatum, 133);
|
||||
ASSERT_EQ(p.nchunk, 10);
|
||||
}
|
||||
|
||||
TEST(MyPoolChunk, int) {
|
||||
TEST(MyPoolChunk, int)
|
||||
{
|
||||
// defaults to minchunk=1, maxchunk=1, nbin=1, chunksperpage=1024, pagedelta=1
|
||||
MyPoolChunk<int> p;
|
||||
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.size(),0.0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
ASSERT_EQ(p.size(), 0.0);
|
||||
|
||||
int idx=~0x0000;
|
||||
int idx = ~0x0000;
|
||||
int *iptr = p.get(idx);
|
||||
ASSERT_NE(iptr,nullptr);
|
||||
ASSERT_EQ(idx,0);
|
||||
ASSERT_NE(iptr, nullptr);
|
||||
ASSERT_EQ(idx, 0);
|
||||
|
||||
iptr = p.get(1,idx);
|
||||
ASSERT_NE(iptr,nullptr);
|
||||
ASSERT_EQ(idx,1);
|
||||
iptr = p.get(1, idx);
|
||||
ASSERT_NE(iptr, nullptr);
|
||||
ASSERT_EQ(idx, 1);
|
||||
// we have only one page allocated
|
||||
ASSERT_EQ(p.size(),1024*sizeof(int)+1024*sizeof(int)+sizeof(void *)+sizeof(int));
|
||||
ASSERT_EQ(p.ndatum,2);
|
||||
ASSERT_EQ(p.nchunk,2);
|
||||
ASSERT_EQ(p.size(), 1024 * sizeof(int) + 1024 * sizeof(int) + sizeof(void *) + sizeof(int));
|
||||
ASSERT_EQ(p.ndatum, 2);
|
||||
ASSERT_EQ(p.nchunk, 2);
|
||||
|
||||
p.put(0);
|
||||
ASSERT_EQ(p.ndatum,1);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
ASSERT_EQ(p.ndatum, 1);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
|
||||
iptr = p.get(2,idx);
|
||||
ASSERT_EQ(iptr,nullptr);
|
||||
ASSERT_EQ(p.status(),3);
|
||||
ASSERT_EQ(p.ndatum,1);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
iptr = p.get(2, idx);
|
||||
ASSERT_EQ(iptr, nullptr);
|
||||
ASSERT_EQ(p.status(), 3);
|
||||
ASSERT_EQ(p.ndatum, 1);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
}
|
||||
|
||||
TEST(MyPoolChunk, double) {
|
||||
TEST(MyPoolChunk, double)
|
||||
{
|
||||
// defaults to minchunk=1, maxchunk=1, nbin=1, chunksperpage=1024, pagedelta=1
|
||||
MyPoolChunk<double> p;
|
||||
|
||||
ASSERT_EQ(p.ndatum,0);
|
||||
ASSERT_EQ(p.nchunk,0);
|
||||
ASSERT_EQ(p.size(),0.0);
|
||||
ASSERT_EQ(p.ndatum, 0);
|
||||
ASSERT_EQ(p.nchunk, 0);
|
||||
ASSERT_EQ(p.size(), 0.0);
|
||||
|
||||
int idx=~0x0000;
|
||||
int idx = ~0x0000;
|
||||
double *dptr = p.get(idx);
|
||||
ASSERT_NE(dptr,nullptr);
|
||||
ASSERT_EQ(idx,0);
|
||||
ASSERT_NE(dptr, nullptr);
|
||||
ASSERT_EQ(idx, 0);
|
||||
|
||||
dptr = p.get(1,idx);
|
||||
ASSERT_NE(dptr,nullptr);
|
||||
ASSERT_EQ(idx,1);
|
||||
dptr = p.get(1, idx);
|
||||
ASSERT_NE(dptr, nullptr);
|
||||
ASSERT_EQ(idx, 1);
|
||||
// we have only one page allocated
|
||||
ASSERT_EQ(p.size(),1024*sizeof(int)+1024*sizeof(double)+sizeof(void *)+sizeof(int));
|
||||
ASSERT_EQ(p.size(), 1024 * sizeof(int) + 1024 * sizeof(double) + sizeof(void *) + sizeof(int));
|
||||
|
||||
p.put(0);
|
||||
ASSERT_EQ(p.ndatum,1);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
ASSERT_EQ(p.ndatum, 1);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
|
||||
dptr = p.get(2,idx);
|
||||
ASSERT_EQ(dptr,nullptr);
|
||||
ASSERT_EQ(p.status(),3);
|
||||
ASSERT_EQ(p.ndatum,1);
|
||||
ASSERT_EQ(p.nchunk,1);
|
||||
dptr = p.get(2, idx);
|
||||
ASSERT_EQ(dptr, nullptr);
|
||||
ASSERT_EQ(p.status(), 3);
|
||||
ASSERT_EQ(p.ndatum, 1);
|
||||
ASSERT_EQ(p.nchunk, 1);
|
||||
}
|
||||
|
||||
|
||||
@ -158,13 +158,15 @@ TEST(ValueTokenizer, valid_double_with_exponential)
|
||||
ASSERT_DOUBLE_EQ(values.next_double(), 3.14e22);
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, contains) {
|
||||
TEST(ValueTokenizer, contains)
|
||||
{
|
||||
ValueTokenizer values("test word");
|
||||
ASSERT_TRUE(values.contains("test"));
|
||||
ASSERT_TRUE(values.contains("word"));
|
||||
}
|
||||
|
||||
TEST(ValueTokenizer, not_contains) {
|
||||
TEST(ValueTokenizer, not_contains)
|
||||
{
|
||||
ValueTokenizer values("test word");
|
||||
ASSERT_FALSE(values.contains("test2"));
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ using ::testing::Eq;
|
||||
using ::testing::StrEq;
|
||||
|
||||
#if !defined(FLERR)
|
||||
#define FLERR __FILE__,__LINE__
|
||||
#define FLERR __FILE__, __LINE__
|
||||
#endif
|
||||
|
||||
TEST(Utils, trim)
|
||||
@ -373,11 +373,11 @@ TEST(Utils, bounds_case1)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "9", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,9);
|
||||
ASSERT_EQ(nhi,9);
|
||||
ASSERT_EQ(nlo, 9);
|
||||
ASSERT_EQ(nhi, 9);
|
||||
utils::bounds(FLERR, "1", 1, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,1);
|
||||
ASSERT_EQ(nhi,1);
|
||||
ASSERT_EQ(nlo, 1);
|
||||
ASSERT_EQ(nhi, 1);
|
||||
}
|
||||
|
||||
TEST(Utils, bounds_case2)
|
||||
@ -386,11 +386,11 @@ TEST(Utils, bounds_case2)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "*", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,0);
|
||||
ASSERT_EQ(nhi,10);
|
||||
ASSERT_EQ(nlo, 0);
|
||||
ASSERT_EQ(nhi, 10);
|
||||
utils::bounds(FLERR, "*", -10, 5, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,-10);
|
||||
ASSERT_EQ(nhi,5);
|
||||
ASSERT_EQ(nlo, -10);
|
||||
ASSERT_EQ(nhi, 5);
|
||||
}
|
||||
|
||||
TEST(Utils, bounds_case3)
|
||||
@ -399,11 +399,11 @@ TEST(Utils, bounds_case3)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "2*", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,2);
|
||||
ASSERT_EQ(nhi,10);
|
||||
ASSERT_EQ(nlo, 2);
|
||||
ASSERT_EQ(nhi, 10);
|
||||
utils::bounds(FLERR, "3*", -10, 5, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,3);
|
||||
ASSERT_EQ(nhi,5);
|
||||
ASSERT_EQ(nlo, 3);
|
||||
ASSERT_EQ(nhi, 5);
|
||||
}
|
||||
|
||||
TEST(Utils, bounds_case4)
|
||||
@ -412,11 +412,11 @@ TEST(Utils, bounds_case4)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "*2", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,0);
|
||||
ASSERT_EQ(nhi,2);
|
||||
ASSERT_EQ(nlo, 0);
|
||||
ASSERT_EQ(nhi, 2);
|
||||
utils::bounds(FLERR, "*3", -10, 5, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,-10);
|
||||
ASSERT_EQ(nhi,3);
|
||||
ASSERT_EQ(nlo, -10);
|
||||
ASSERT_EQ(nhi, 3);
|
||||
}
|
||||
|
||||
TEST(Utils, bounds_case5)
|
||||
@ -425,11 +425,11 @@ TEST(Utils, bounds_case5)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "2*5", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,2);
|
||||
ASSERT_EQ(nhi,5);
|
||||
ASSERT_EQ(nlo, 2);
|
||||
ASSERT_EQ(nhi, 5);
|
||||
utils::bounds(FLERR, "-2*3", -10, 5, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,-2);
|
||||
ASSERT_EQ(nhi,3);
|
||||
ASSERT_EQ(nlo, -2);
|
||||
ASSERT_EQ(nhi, 3);
|
||||
}
|
||||
|
||||
TEST(Utils, boundsbig_case1)
|
||||
@ -438,11 +438,11 @@ TEST(Utils, boundsbig_case1)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "9", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,9);
|
||||
ASSERT_EQ(nhi,9);
|
||||
ASSERT_EQ(nlo, 9);
|
||||
ASSERT_EQ(nhi, 9);
|
||||
utils::bounds(FLERR, "1", 1, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,1);
|
||||
ASSERT_EQ(nhi,1);
|
||||
ASSERT_EQ(nlo, 1);
|
||||
ASSERT_EQ(nhi, 1);
|
||||
}
|
||||
|
||||
TEST(Utils, boundsbig_case2)
|
||||
@ -451,11 +451,11 @@ TEST(Utils, boundsbig_case2)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "*", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,0);
|
||||
ASSERT_EQ(nhi,10);
|
||||
ASSERT_EQ(nlo, 0);
|
||||
ASSERT_EQ(nhi, 10);
|
||||
utils::bounds(FLERR, "*", -10, 5, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,-10);
|
||||
ASSERT_EQ(nhi,5);
|
||||
ASSERT_EQ(nlo, -10);
|
||||
ASSERT_EQ(nhi, 5);
|
||||
}
|
||||
|
||||
TEST(Utils, boundsbig_case3)
|
||||
@ -464,11 +464,11 @@ TEST(Utils, boundsbig_case3)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "2*", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,2);
|
||||
ASSERT_EQ(nhi,10);
|
||||
ASSERT_EQ(nlo, 2);
|
||||
ASSERT_EQ(nhi, 10);
|
||||
utils::bounds(FLERR, "3*", -10, 5, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,3);
|
||||
ASSERT_EQ(nhi,5);
|
||||
ASSERT_EQ(nlo, 3);
|
||||
ASSERT_EQ(nhi, 5);
|
||||
}
|
||||
|
||||
TEST(Utils, boundsbig_case4)
|
||||
@ -477,11 +477,11 @@ TEST(Utils, boundsbig_case4)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "*2", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,0);
|
||||
ASSERT_EQ(nhi,2);
|
||||
ASSERT_EQ(nlo, 0);
|
||||
ASSERT_EQ(nhi, 2);
|
||||
utils::bounds(FLERR, "*3", -10, 5, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,-10);
|
||||
ASSERT_EQ(nhi,3);
|
||||
ASSERT_EQ(nlo, -10);
|
||||
ASSERT_EQ(nhi, 3);
|
||||
}
|
||||
|
||||
TEST(Utils, boundsbig_case5)
|
||||
@ -490,11 +490,11 @@ TEST(Utils, boundsbig_case5)
|
||||
|
||||
nlo = nhi = -1;
|
||||
utils::bounds(FLERR, "2*5", 0, 10, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,2);
|
||||
ASSERT_EQ(nhi,5);
|
||||
ASSERT_EQ(nlo, 2);
|
||||
ASSERT_EQ(nhi, 5);
|
||||
utils::bounds(FLERR, "-2*3", -10, 5, nlo, nhi, nullptr);
|
||||
ASSERT_EQ(nlo,-2);
|
||||
ASSERT_EQ(nhi,3);
|
||||
ASSERT_EQ(nlo, -2);
|
||||
ASSERT_EQ(nhi, 3);
|
||||
}
|
||||
|
||||
TEST(Utils, guesspath)
|
||||
@ -628,19 +628,18 @@ TEST(Utils, timespec2seconds_hhmmss)
|
||||
ASSERT_DOUBLE_EQ(utils::timespec2seconds("2:10:45"), 7845.0);
|
||||
}
|
||||
|
||||
|
||||
TEST(Utils, date2num)
|
||||
{
|
||||
ASSERT_EQ(utils::date2num("1Jan05"),20050101);
|
||||
ASSERT_EQ(utils::date2num("10Feb2005"),20050210);
|
||||
ASSERT_EQ(utils::date2num("02Mar10"),20100302);
|
||||
ASSERT_EQ(utils::date2num(" 5Apr1900"),19000405);
|
||||
ASSERT_EQ(utils::date2num("10May22 "),20220510);
|
||||
ASSERT_EQ(utils::date2num("1 Jun 05"),20050601);
|
||||
ASSERT_EQ(utils::date2num("10 Jul 2005"),20050710);
|
||||
ASSERT_EQ(utils::date2num("02 Aug 10"),20100802);
|
||||
ASSERT_EQ(utils::date2num(" 5 September 99"),20990905);
|
||||
ASSERT_EQ(utils::date2num("10October22 "),20221010);
|
||||
ASSERT_EQ(utils::date2num("30November 02"),20021130);
|
||||
ASSERT_EQ(utils::date2num("31December100"),1001231);
|
||||
ASSERT_EQ(utils::date2num("1Jan05"), 20050101);
|
||||
ASSERT_EQ(utils::date2num("10Feb2005"), 20050210);
|
||||
ASSERT_EQ(utils::date2num("02Mar10"), 20100302);
|
||||
ASSERT_EQ(utils::date2num(" 5Apr1900"), 19000405);
|
||||
ASSERT_EQ(utils::date2num("10May22 "), 20220510);
|
||||
ASSERT_EQ(utils::date2num("1 Jun 05"), 20050601);
|
||||
ASSERT_EQ(utils::date2num("10 Jul 2005"), 20050710);
|
||||
ASSERT_EQ(utils::date2num("02 Aug 10"), 20100802);
|
||||
ASSERT_EQ(utils::date2num(" 5 September 99"), 20990905);
|
||||
ASSERT_EQ(utils::date2num("10October22 "), 20221010);
|
||||
ASSERT_EQ(utils::date2num("30November 02"), 20021130);
|
||||
ASSERT_EQ(utils::date2num("31December100"), 1001231);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user