diff --git a/cmake/Modules/OpenCLLoader.cmake b/cmake/Modules/OpenCLLoader.cmake index 239fba5ba9..3a8e63b213 100644 --- a/cmake/Modules/OpenCLLoader.cmake +++ b/cmake/Modules/OpenCLLoader.cmake @@ -1,6 +1,6 @@ message(STATUS "Downloading and building OpenCL loader library") -set(OPENCL_LOADER_URL "${LAMMPS_THIRDPARTY_URL}/opencl-loader-2021.06.30.tar.gz" CACHE STRING "URL for OpenCL loader tarball") -set(OPENCL_LOADER_MD5 "f9e55dd550cfbf77f46507adf7cb8fd2" CACHE STRING "MD5 checksum of OpenCL loader tarball") +set(OPENCL_LOADER_URL "${LAMMPS_THIRDPARTY_URL}/opencl-loader-2021.09.18.tar.gz" CACHE STRING "URL for OpenCL loader tarball") +set(OPENCL_LOADER_MD5 "3b3882627964bd02e5c3b02065daac3c" CACHE STRING "MD5 checksum of OpenCL loader tarball") mark_as_advanced(OPENCL_LOADER_URL) mark_as_advanced(OPENCL_LOADER_MD5) diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index 2b6977005d..aaa784ca8b 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -71,44 +71,47 @@ if(GPU_API STREQUAL "CUDA") # build arch/gencode commands for nvcc based on CUDA toolkit version and use choice # --arch translates directly instead of JIT, so this should be for the preferred or most common architecture set(GPU_CUDA_GENCODE "-arch=${GPU_ARCH}") - # Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0 - if((CUDA_VERSION VERSION_GREATER_EQUAL "3.2") AND (CUDA_VERSION VERSION_LESS "9.0")) - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_20,code=[sm_20,compute_20] ") - endif() - # Kepler (GPU Arch 3.0) is supported by CUDA 5 to CUDA 10.2 - if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "11.0")) - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_30,code=[sm_30,compute_30] ") - endif() - # Kepler (GPU Arch 3.5) is supported by CUDA 5 to CUDA 11 - if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "12.0")) - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_35,code=[sm_35,compute_35]") - endif() - # Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "6.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52]") - endif() - # Pascal (GPU Arch 6.x) is supported by CUDA 8 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "8.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61]") - endif() - # Volta (GPU Arch 7.0) is supported by CUDA 9 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "9.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_70,code=[sm_70,compute_70]") - endif() - # Turing (GPU Arch 7.5) is supported by CUDA 10 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "10.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_75,code=[sm_75,compute_75]") - endif() - # Ampere (GPU Arch 8.0) is supported by CUDA 11 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_80,code=[sm_80,compute_80]") - endif() - # Ampere (GPU Arch 8.6) is supported by CUDA 11.1 and later - if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") - string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_86,code=[sm_86,compute_86]") - endif() + + # apply the following to build "fat" CUDA binaries only for known CUDA toolkits if(CUDA_VERSION VERSION_GREATER_EQUAL "12.0") - message(WARNING "Unsupported CUDA version. Use at your own risk.") + message(WARNING "Untested CUDA Toolkit version. Use at your own risk") + else() + # Fermi (GPU Arch 2.x) is supported by CUDA 3.2 to CUDA 8.0 + if((CUDA_VERSION VERSION_GREATER_EQUAL "3.2") AND (CUDA_VERSION VERSION_LESS "9.0")) + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_20,code=[sm_20,compute_20] ") + endif() + # Kepler (GPU Arch 3.0) is supported by CUDA 5 to CUDA 10.2 + if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "11.0")) + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_30,code=[sm_30,compute_30] ") + endif() + # Kepler (GPU Arch 3.5) is supported by CUDA 5 to CUDA 11 + if((CUDA_VERSION VERSION_GREATER_EQUAL "5.0") AND (CUDA_VERSION VERSION_LESS "12.0")) + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_35,code=[sm_35,compute_35]") + endif() + # Maxwell (GPU Arch 5.x) is supported by CUDA 6 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "6.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_50,code=[sm_50,compute_50] -gencode arch=compute_52,code=[sm_52,compute_52]") + endif() + # Pascal (GPU Arch 6.x) is supported by CUDA 8 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "8.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_60,code=[sm_60,compute_60] -gencode arch=compute_61,code=[sm_61,compute_61]") + endif() + # Volta (GPU Arch 7.0) is supported by CUDA 9 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "9.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_70,code=[sm_70,compute_70]") + endif() + # Turing (GPU Arch 7.5) is supported by CUDA 10 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "10.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_75,code=[sm_75,compute_75]") + endif() + # Ampere (GPU Arch 8.0) is supported by CUDA 11 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_80,code=[sm_80,compute_80]") + endif() + # Ampere (GPU Arch 8.6) is supported by CUDA 11.1 and later + if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") + string(APPEND GPU_CUDA_GENCODE " -gencode arch=compute_86,code=[sm_86,compute_86]") + endif() endif() cuda_compile_fatbin(GPU_GEN_OBJS ${GPU_LIB_CU} OPTIONS ${CUDA_REQUEST_PIC} diff --git a/cmake/Modules/Packages/ML-QUIP.cmake b/cmake/Modules/Packages/ML-QUIP.cmake index ff9c7b3a7c..5a80e63d55 100644 --- a/cmake/Modules/Packages/ML-QUIP.cmake +++ b/cmake/Modules/Packages/ML-QUIP.cmake @@ -38,7 +38,7 @@ if(DOWNLOAD_QUIP) set(temp "${temp}HAVE_LOCAL_E_MIX=0\nHAVE_QC=0\nHAVE_GAP=1\nHAVE_DESCRIPTORS_NONCOMMERCIAL=1\n") set(temp "${temp}HAVE_TURBOGAP=0\nHAVE_QR=1\nHAVE_THIRDPARTY=0\nHAVE_FX=0\nHAVE_SCME=0\nHAVE_MTP=0\n") set(temp "${temp}HAVE_MBD=0\nHAVE_TTM_NF=0\nHAVE_CH4=0\nHAVE_NETCDF4=0\nHAVE_MDCORE=0\nHAVE_ASAP=0\n") - set(temp "${temp}HAVE_CGAL=0\nHAVE_METIS=0\nHAVE_LMTO_TBE=0\n") + set(temp "${temp}HAVE_CGAL=0\nHAVE_METIS=0\nHAVE_LMTO_TBE=0\nHAVE_SCALAPACK=0\n") file(WRITE ${CMAKE_BINARY_DIR}/quip.config "${temp}") message(STATUS "QUIP download via git requested - we will build our own") diff --git a/cmake/iwyu/iwyu-extra-map.imp b/cmake/iwyu/iwyu-extra-map.imp index 4fadea73fb..8eae74cbfa 100644 --- a/cmake/iwyu/iwyu-extra-map.imp +++ b/cmake/iwyu/iwyu-extra-map.imp @@ -1,7 +1,28 @@ [ - { include: [ "", private, "", public ] }, - { include: [ "", public, "", public ] }, { include: [ "@", private, "", public ] }, { include: [ "@", private, "\"gtest/gtest.h\"", public ] }, { include: [ "@", private, "\"gmock/gmock.h\"", public ] }, + { include: [ "@", private, "\"gmock/gmock.h\"", public ] }, + { include: [ "@<(cell|c_loops|container).hh>", private, "", public ] }, + { include: [ "@\"atom_vec_.*.h\"", public, "\"style_atom.h\"", public ] }, + { include: [ "@\"body_.*.h\"", public, "\"style_body.h\"", public ] }, + { include: [ "@\"compute_.*.h\"", public, "\"style_compute.h\"", public ] }, + { include: [ "@\"fix_.*.h\"", public, "\"style_fix.h\"", public ] }, + { include: [ "@\"dump_.*.h\"", public, "\"style_dump.h\"", public ] }, + { include: [ "@\"min_.*.h\"", public, "\"style_minimize.h\"", public ] }, + { include: [ "@\"reader_.*.h\"", public, "\"style_reader.h\"", public ] }, + { include: [ "@\"region_.*.h\"", public, "\"style_region.h\"", public ] }, + { include: [ "@\"pair_.*.h\"", public, "\"style_pair.h\"", public ] }, + { include: [ "@\"angle_.*.h\"", public, "\"style_angle.h\"", public ] }, + { include: [ "@\"bond_.*.h\"", public, "\"style_bond.h\"", public ] }, + { include: [ "@\"dihedral_.*.h\"", public, "\"style_dihedral.h\"", public ] }, + { include: [ "@\"improper_.*.h\"", public, "\"style_improper.h\"", public ] }, + { include: [ "@\"kspace_.*.h\"", public, "\"style_kspace.h\"", public ] }, + { include: [ "@\"nbin_.*.h\"", public, "\"style_nbin.h\"", public ] }, + { include: [ "@\"npair_.*.h\"", public, "\"style_npair.h\"", public ] }, + { include: [ "@\"nstenci_.*.h\"", public, "\"style_nstencil.h\"", public ] }, + { include: [ "@\"ntopo_.*.h\"", public, "\"style_ntopo.h\"", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", public, "", public ] }, + { include: [ "", private, "", public ] }, ] diff --git a/cmake/presets/most.cmake b/cmake/presets/most.cmake index 9546f1f9a3..eb26b38928 100644 --- a/cmake/presets/most.cmake +++ b/cmake/presets/most.cmake @@ -24,6 +24,7 @@ set(ALL_PACKAGES DRUDE EFF EXTRA-COMPUTE + EXTRA-DUMP EXTRA-FIX EXTRA-MOLECULE EXTRA-PAIR diff --git a/doc/lammps.1 b/doc/lammps.1 index 40d4295b7e..fb79b8d774 100644 --- a/doc/lammps.1 +++ b/doc/lammps.1 @@ -1,4 +1,4 @@ -.TH LAMMPS "31 August 2021" "2021-08-31" +.TH LAMMPS "20 September 2021" "2021-09-20" .SH NAME .B LAMMPS \- Molecular Dynamics Simulator. diff --git a/doc/src/Build_development.rst b/doc/src/Build_development.rst index 581a8dba99..3c2acbaa7e 100644 --- a/doc/src/Build_development.rst +++ b/doc/src/Build_development.rst @@ -58,13 +58,16 @@ Report missing and unneeded '#include' statements (CMake only) The conventions for how and when to use and order include statements in LAMMPS are documented in :doc:`Modify_style`. To assist with following these conventions one can use the `Include What You Use tool `_. -This is still under development and for large and complex projects like LAMMPS +This tool is still under development and for large and complex projects like LAMMPS there are some false positives, so suggested changes need to be verified manually. -It is recommended to use at least version 0.14, which has much fewer incorrect -reports than earlier versions. +It is recommended to use at least version 0.16, which has much fewer incorrect +reports than earlier versions. To install the IWYU toolkit, you need to have +the clang compiler **and** its development package installed. Download the IWYU +version that matches the version of the clang compiler, configure, build, and +install it. -The necessary steps to generate the report can be enabled via a -CMake variable: +The necessary steps to generate the report can be enabled via a CMake variable +during CMake configuration. .. code-block:: bash diff --git a/doc/src/Developer_utils.rst b/doc/src/Developer_utils.rst index 54a21e5e44..17da8bef22 100644 --- a/doc/src/Developer_utils.rst +++ b/doc/src/Developer_utils.rst @@ -203,6 +203,9 @@ Convenience functions .. doxygenfunction:: date2num :project: progguide +.. doxygenfunction:: current_date + :project: progguide + Customized standard functions ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/src/Errors_debug.rst b/doc/src/Errors_debug.rst index 9b11974cf4..786a21ecae 100644 --- a/doc/src/Errors_debug.rst +++ b/doc/src/Errors_debug.rst @@ -40,11 +40,10 @@ We use it to show how to identify the origin of a segmentation fault. After recompiling LAMMPS and running the input you should get something like this: -.. code-block: +.. code-block:: $ ./lmp -in in.melt LAMMPS (19 Mar 2020) - OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:94) using 1 OpenMP thread(s) per MPI task Lattice spacing in x,y,z = 1.6796 1.6796 1.6796 Created orthogonal box = (0 0 0) to (16.796 16.796 16.796) diff --git a/doc/src/Errors_messages.rst b/doc/src/Errors_messages.rst index 02b9edd466..3a593b5a3f 100644 --- a/doc/src/Errors_messages.rst +++ b/doc/src/Errors_messages.rst @@ -7879,19 +7879,19 @@ keyword to allow for additional bonds to be formed *Unexpected end of -reorder file* Self-explanatory. -*Unexpected empty line in AngleCoeffs section* +*Unexpected empty line in Angle Coeffs section* Read a blank line where there should be coefficient data. -*Unexpected empty line in BondCoeffs section* +*Unexpected empty line in Bond Coeffs section* Read a blank line where there should be coefficient data. -*Unexpected empty line in DihedralCoeffs section* +*Unexpected empty line in Dihedral Coeffs section* Read a blank line where there should be coefficient data. -*Unexpected empty line in ImproperCoeffs section* +*Unexpected empty line in Improper Coeffs section* Read a blank line where there should be coefficient data. -*Unexpected empty line in PairCoeffs section* +*Unexpected empty line in Pair Coeffs section* Read a blank line where there should be coefficient data. *Unexpected end of custom file* diff --git a/doc/src/Intro_website.rst b/doc/src/Intro_website.rst index 2ea1969f2a..db930a1b26 100644 --- a/doc/src/Intro_website.rst +++ b/doc/src/Intro_website.rst @@ -26,7 +26,7 @@ available online are listed below. * `Tutorials `_ * `Pre- and post-processing tools for LAMMPS `_ -* `Other software usable with LAMMPS `_ +* `Other software usable with LAMMPS `_ * `Viz tools usable with LAMMPS `_ * `Benchmark performance `_ diff --git a/doc/src/Modify_contribute.rst b/doc/src/Modify_contribute.rst index 79eb1b5029..a7476d0174 100644 --- a/doc/src/Modify_contribute.rst +++ b/doc/src/Modify_contribute.rst @@ -115,8 +115,8 @@ External contributions If you prefer to do so, you can also develop and support your add-on feature **without** having it included in the LAMMPS distribution, for -example as a download from a website of your own. See the `Offsite -LAMMPS packages and tools `_ page +example as a download from a website of your own. See the `External +LAMMPS packages and tools `_ page of the LAMMPS website for examples of groups that do this. We are happy to advertise your package and website from that page. Simply email the `developers `_ with info about your diff --git a/doc/src/Modify_style.rst b/doc/src/Modify_style.rst index 3c56a9397d..50e7afb370 100644 --- a/doc/src/Modify_style.rst +++ b/doc/src/Modify_style.rst @@ -305,19 +305,22 @@ you are uncertain, please ask. FILE pointers and only be done on MPI rank 0. Use the :cpp:func:`utils::logmesg` convenience function where possible. -- header files should only include the absolute minimum number of - include files and **must not** contain any ``using`` statements; - rather the include statements should be put into the corresponding - implementation files. For implementation files, the - "include-what-you-use" principle should be employed. However, when - including the ``pointers.h`` header (or one of the base classes - derived from it) certain headers will be included and thus need to be - specified. These are: `mpi.h`, `cstddef`, `cstdio`, `cstdlib`, - `string`, `utils.h`, `fmt/format.h`, `climits`, `cinttypes`. This also - means any header can assume that `FILE`, `NULL`, and `INT_MAX` are - defined. +- Header files, especially those defining a "style", should only use + the absolute minimum number of include files and **must not** contain + any ``using`` statements. Typically that would be only the header for + the base class. Instead any include statements should be put into the + corresponding implementation files and forward declarations be used. + For implementation files, the "include what you use" principle should + be employed. However, there is the notable exception that when the + ``pointers.h`` header is included (or one of the base classes derived + from it) certain headers will always be included and thus do not need + to be explicitly specified. + These are: `mpi.h`, `cstddef`, `cstdio`, `cstdlib`, `string`, `utils.h`, + `vector`, `fmt/format.h`, `climits`, `cinttypes`. + This also means any such file can assume that `FILE`, `NULL`, and + `INT_MAX` are defined. -- header files that define a new LAMMPS style (i.e. that have a +- Header files that define a new LAMMPS style (i.e. that have a ``SomeStyle(some/name,SomeName);`` macro in them) should only use the include file for the base class and otherwise use forward declarations and pointers; when interfacing to a library use the PIMPL (pointer @@ -325,7 +328,7 @@ you are uncertain, please ask. that contains all library specific data (and thus requires the library header) but use a forward declaration and define the struct only in the implementation file. This is a **strict** requirement since this - is where type clashes between packages and hard to fine bugs have + is where type clashes between packages and hard to find bugs have regularly manifested in the past. - Please use clang-format only to reformat files that you have diff --git a/doc/src/Tools.rst b/doc/src/Tools.rst index 5822286e5f..0d8ffa3f45 100644 --- a/doc/src/Tools.rst +++ b/doc/src/Tools.rst @@ -7,7 +7,7 @@ steps are often necessary to setup and analyze a simulation. A list of such tools can be found on the `LAMMPS webpage `_ at these links: * `Pre/Post processing `_ -* `Offsite LAMMPS packages & tools `_ +* `External LAMMPS packages & tools `_ * `Pizza.py toolkit `_ The last link for `Pizza.py `_ is a Python-based tool developed at diff --git a/doc/src/fix_brownian.rst b/doc/src/fix_brownian.rst index c274c394f3..5e0a899deb 100644 --- a/doc/src/fix_brownian.rst +++ b/doc/src/fix_brownian.rst @@ -8,9 +8,8 @@ fix brownian command fix brownian/sphere command =========================== -fix brownian/sphere command -=========================== - +fix brownian/asphere command +============================ Syntax """""" diff --git a/doc/src/package.rst b/doc/src/package.rst index cbff28cee3..0fc71b48f9 100644 --- a/doc/src/package.rst +++ b/doc/src/package.rst @@ -27,7 +27,7 @@ Syntax on = set Newton pairwise flag on (currently not allowed) *pair/only* = *off* or *on* off = apply "gpu" suffix to all available styles in the GPU package (default) - on - apply "gpu" suffix only pair styles + on = apply "gpu" suffix only pair styles *binsize* value = size size = bin size for neighbor list construction (distance units) *split* = fraction diff --git a/doc/src/pair_hybrid.rst b/doc/src/pair_hybrid.rst index 972c30c36f..9c3cd6622a 100644 --- a/doc/src/pair_hybrid.rst +++ b/doc/src/pair_hybrid.rst @@ -198,8 +198,8 @@ same: Coefficients must be defined for each pair of atoms types via the :doc:`pair_coeff ` command as described above, or in the -data file read by the :doc:`read_data ` commands, or by -mixing as described below. +"Pair Coeffs" or "PairIJ Coeffs" section of the data file read by the +:doc:`read_data ` command, or by mixing as described below. For all of the *hybrid*, *hybrid/overlay*, and *hybrid/scaled* styles, every atom type pair I,J (where I <= J) must be assigned to at least one @@ -208,14 +208,21 @@ examples above, or in the data file read by the :doc:`read_data `, or by mixing as described below. Also all sub-styles must be used at least once in a :doc:`pair_coeff ` command. +.. note:: + + LAMMPS never performs mixing of parameters from different sub-styles, + **even** if they use the same type of coefficients, e.g. contain + a Lennard-Jones potential variant. Those parameters must be provided + explicitly. + If you want there to be no interactions between a particular pair of -atom types, you have 3 choices. You can assign the type pair to some -sub-style and use the :doc:`neigh_modify exclude type ` +atom types, you have 3 choices. You can assign the pair of atom types +to some sub-style and use the :doc:`neigh_modify exclude type ` command. You can assign it to some sub-style and set the coefficients so that there is effectively no interaction (e.g. epsilon = 0.0 in a LJ potential). Or, for *hybrid*, *hybrid/overlay*, or *hybrid/scaled* simulations, you can use this form of the pair_coeff command in your -input script: +input script or the "PairIJ Coeffs" section of your data file: .. code-block:: LAMMPS @@ -238,19 +245,20 @@ styles with different requirements. ---------- -Different force fields (e.g. CHARMM vs AMBER) may have different rules -for applying weightings that change the strength of pairwise -interactions between pairs of atoms that are also 1-2, 1-3, and 1-4 -neighbors in the molecular bond topology, as normally set by the -:doc:`special_bonds ` command. Different weights can be -assigned to different pair hybrid sub-styles via the :doc:`pair_modify -special ` command. This allows multiple force fields to be -used in a model of a hybrid system, however, there is no consistent -approach to determine parameters automatically for the interactions -between the two force fields, this is only recommended when particles +Different force fields (e.g. CHARMM vs. AMBER) may have different rules +for applying exclusions or weights that change the strength of pairwise +non-bonded interactions between pairs of atoms that are also 1-2, 1-3, +and 1-4 neighbors in the molecular bond topology. This is normally a +global setting defined the :doc:`special_bonds ` command. +However, different weights can be assigned to different hybrid +sub-styles via the :doc:`pair_modify special ` command. +This allows multiple force fields to be used in a model of a hybrid +system, however, there is no consistent approach to determine parameters +automatically for the interactions **between** atoms of the two force +fields, thus this approach this is only recommended when particles described by the different force fields do not mix. -Here is an example for mixing CHARMM and AMBER: The global *amber* +Here is an example for combining CHARMM and AMBER: The global *amber* setting sets the 1-4 interactions to non-zero scaling factors and then overrides them with 0.0 only for CHARMM: @@ -260,7 +268,7 @@ then overrides them with 0.0 only for CHARMM: pair_style hybrid lj/charmm/coul/long 8.0 10.0 lj/cut/coul/long 10.0 pair_modify pair lj/charmm/coul/long special lj/coul 0.0 0.0 0.0 -The this input achieves the same effect: +This input achieves the same effect: .. code-block:: LAMMPS @@ -270,9 +278,9 @@ The this input achieves the same effect: pair_modify pair lj/cut/coul/long special coul 0.0 0.0 0.83333333 pair_modify pair lj/charmm/coul/long special lj/coul 0.0 0.0 0.0 -Here is an example for mixing Tersoff with OPLS/AA based on -a data file that defines bonds for all atoms where for the -Tersoff part of the system the force constants for the bonded +Here is an example for combining Tersoff with OPLS/AA based on +a data file that defines bonds for all atoms where - for the +Tersoff part of the system - the force constants for the bonded interactions have been set to 0. Note the global settings are effectively *lj/coul 0.0 0.0 0.5* as required for OPLS/AA: diff --git a/doc/src/read_data.rst b/doc/src/read_data.rst index 5b5c951688..ff212a579a 100644 --- a/doc/src/read_data.rst +++ b/doc/src/read_data.rst @@ -619,7 +619,7 @@ of analysis. * - bond - atom-ID molecule-ID atom-type x y z * - charge - - atom-type q x y z + - atom-ID atom-type q x y z * - dipole - atom-ID atom-type q x y z mux muy muz * - dpd diff --git a/doc/utils/sphinx-config/conf.py.in b/doc/utils/sphinx-config/conf.py.in index 68a61af009..6b95da5a7e 100644 --- a/doc/utils/sphinx-config/conf.py.in +++ b/doc/utils/sphinx-config/conf.py.in @@ -418,6 +418,7 @@ html_context['current_version'] = os.environ.get('LAMMPS_WEBSITE_BUILD_VERSION', html_context['git_commit'] = git_commit html_context['versions'] = [ ('latest', 'https://docs.lammps.org/latest/'), + ('stable', 'https://docs.lammps.org/stable/'), (version, 'https://docs.lammps.org/') ] html_context['downloads'] = [('PDF', 'Manual.pdf')] diff --git a/doc/utils/sphinx-config/false_positives.txt b/doc/utils/sphinx-config/false_positives.txt index fff23a01b0..5394cf92c1 100644 --- a/doc/utils/sphinx-config/false_positives.txt +++ b/doc/utils/sphinx-config/false_positives.txt @@ -2440,6 +2440,7 @@ packings padua Padua pafi +PairIJ palegoldenrod palegreen paleturquoise diff --git a/examples/COUPLE/lammps_quest/README b/examples/COUPLE/lammps_quest/README index 8f4a365858..9ddf99cc52 100644 --- a/examples/COUPLE/lammps_quest/README +++ b/examples/COUPLE/lammps_quest/README @@ -1,15 +1,21 @@ +IMPORTANT NOTE: This example has not been updated since 2014, +so it is not likely to work anymore out of the box. There have +been changes to LAMMPS and its library interface that would need +to be applied. Please see the manual for the documentation of +the library interface. + This directory has an application that runs classical MD via LAMMPS, but uses quantum forces calculated by the Quest DFT (density functional) code in place of the usual classical MD forces calculated by a pair style in LAMMPS. -lmpqst.cpp main program - it links LAMMPS as a library - it invokes Quest as an executable -in.lammps LAMMPS input script, without the run command -si_111.in Quest input script for an 8-atom Si unit cell -lmppath.h contains path to LAMMPS home directory -qstexe.h contains full pathname to Quest executable +lmpqst.cpp main program + it links LAMMPS as a library + it invokes Quest as an executable +in.lammps LAMMPS input script, without the run command +si_111.in Quest input script for an 8-atom Si unit cell +lmppath.h contains path to LAMMPS home directory +qstexe.h contains full pathname to Quest executable After editing the Makefile, lmppath.h, and qstexe.h to make them suitable for your box, type: diff --git a/examples/COUPLE/lammps_spparks/README b/examples/COUPLE/lammps_spparks/README index c8365ae8e8..f967e20e8e 100644 --- a/examples/COUPLE/lammps_spparks/README +++ b/examples/COUPLE/lammps_spparks/README @@ -1,3 +1,9 @@ +IMPORTANT NOTE: This example has not been updated since 2013, +so it is not likely to work anymore out of the box. There have +been changes to LAMMPS and its library interface that would need +to be applied. Please see the manual for the documentation of +the library interface. + This directory has an application that models grain growth in the presence of strain. diff --git a/examples/COUPLE/multiple/multiple.cpp b/examples/COUPLE/multiple/multiple.cpp index 5e875bf879..1b6bb66485 100644 --- a/examples/COUPLE/multiple/multiple.cpp +++ b/examples/COUPLE/multiple/multiple.cpp @@ -5,7 +5,7 @@ Copyright (2003) Sandia Corporation. Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains - certain rights in this software. This software is distributed under + certain rights in this software. This software is distributed under the GNU General Public License. See the README file in the top-level LAMMPS directory. @@ -28,13 +28,9 @@ #include #include -#include "lammps.h" // these are LAMMPS include files -#include "input.h" -#include "atom.h" +#define LAMMPS_LIB_MPI // to make lammps_open() visible #include "library.h" -using namespace LAMMPS_NS; - int main(int narg, char **arg) { // setup MPI and various communicators @@ -68,13 +64,13 @@ int main(int narg, char **arg) int instance = me*ninstance / nprocs; MPI_Comm comm_lammps; MPI_Comm_split(MPI_COMM_WORLD,instance,0,&comm_lammps); - + // each instance: unique screen file, log file, temperature char str1[32],str2[32],str3[32]; char **lmparg = new char*[8]; - lmparg[0] = NULL; // required placeholder for program name + lmparg[0] = (char *) "LAMMPS"; // required placeholder for program name lmparg[1] = (char *) "-screen"; sprintf(str1,"screen.%d",instance); lmparg[2] = str1; @@ -86,13 +82,9 @@ int main(int narg, char **arg) sprintf(str3,"%g",temperature + instance*tdelta); lmparg[7] = str3; - // open N instances of LAMMPS - // either of these methods will work + // create N instances of LAMMPS - LAMMPS *lmp = new LAMMPS(8,lmparg,comm_lammps); - - //LAMMPS *lmp; - //lammps_open(8,lmparg,comm_lammps,(void **) &lmp); + void *lmp = lammps_open(8,lmparg,comm_lammps,NULL); delete [] lmparg; @@ -102,8 +94,8 @@ int main(int narg, char **arg) // query final temperature and print result for each instance - double *ptr = (double *) - lammps_extract_compute(lmp,(char *) "thermo_temp",0,0); + double *ptr = (double *) + lammps_extract_compute(lmp,"thermo_temp",LMP_STYLE_GLOBAL,LMP_TYPE_SCALAR); double finaltemp = *ptr; double *temps = new double[ninstance]; @@ -112,7 +104,7 @@ int main(int narg, char **arg) int me_lammps; MPI_Comm_rank(comm_lammps,&me_lammps); if (me_lammps == 0) temps[instance] = finaltemp; - + double *alltemps = new double[ninstance]; MPI_Allreduce(temps,alltemps,ninstance,MPI_DOUBLE,MPI_SUM,MPI_COMM_WORLD); @@ -125,7 +117,7 @@ int main(int narg, char **arg) // delete LAMMPS instances - delete lmp; + lammps_close(lmp); // close down MPI diff --git a/examples/COUPLE/plugin/README b/examples/COUPLE/plugin/README index b035ed3c0e..bced08b6d7 100644 --- a/examples/COUPLE/plugin/README +++ b/examples/COUPLE/plugin/README @@ -13,7 +13,7 @@ like below. mpicc -c -O -Wall -g -I$HOME/lammps/src liblammpsplugin.c mpicc -c -O -Wall -g simple.c -mpicc simple.o liblammsplugin.o -ldl -o simpleC +mpicc simple.o liblammpsplugin.o -ldl -o simpleC You also need to build LAMMPS as a shared library (see examples/COUPLE/README), e.g. diff --git a/examples/COUPLE/plugin/liblammpsplugin.c b/examples/COUPLE/plugin/liblammpsplugin.c index 474b0a86c2..ea2e2ab536 100644 --- a/examples/COUPLE/plugin/liblammpsplugin.c +++ b/examples/COUPLE/plugin/liblammpsplugin.c @@ -31,51 +31,105 @@ liblammpsplugin_t *liblammpsplugin_load(const char *lib) if (lib == NULL) return NULL; handle = dlopen(lib,RTLD_NOW|RTLD_GLOBAL); if (handle == NULL) return NULL; - + lmp = (liblammpsplugin_t *) malloc(sizeof(liblammpsplugin_t)); lmp->handle = handle; #define ADDSYM(symbol) lmp->symbol = dlsym(handle,"lammps_" #symbol) ADDSYM(open); ADDSYM(open_no_mpi); + ADDSYM(open_fortran); ADDSYM(close); - ADDSYM(version); + + ADDSYM(mpi_init); + ADDSYM(mpi_finalize); + ADDSYM(kokkos_finalize); + ADDSYM(python_finalize); + ADDSYM(file); ADDSYM(command); ADDSYM(commands_list); ADDSYM(commands_string); - ADDSYM(free); - ADDSYM(extract_setting); - ADDSYM(extract_global); + + ADDSYM(get_natoms); + ADDSYM(get_thermo); + ADDSYM(extract_box); + ADDSYM(reset_box); + + ADDSYM(memory_usage); + ADDSYM(get_mpi_comm); + + ADDSYM(extract_setting); + ADDSYM(extract_global_datatype); + ADDSYM(extract_global); + + ADDSYM(extract_atom_datatype); ADDSYM(extract_atom); + ADDSYM(extract_compute); ADDSYM(extract_fix); ADDSYM(extract_variable); - - ADDSYM(get_thermo); - ADDSYM(get_natoms); - ADDSYM(set_variable); - ADDSYM(reset_box); ADDSYM(gather_atoms); ADDSYM(gather_atoms_concat); ADDSYM(gather_atoms_subset); ADDSYM(scatter_atoms); ADDSYM(scatter_atoms_subset); + ADDSYM(gather_bonds); - ADDSYM(set_fix_external_callback); + ADDSYM(create_atoms); - ADDSYM(config_has_package); - ADDSYM(config_package_count); - ADDSYM(config_package_name); + ADDSYM(find_pair_neighlist); + ADDSYM(find_fix_neighlist); + ADDSYM(find_compute_neighlist); + ADDSYM(neighlist_num_elements); + ADDSYM(neighlist_element_neighbors); + + ADDSYM(version); + ADDSYM(get_os_info); + + ADDSYM(config_has_mpi_support); ADDSYM(config_has_gzip_support); ADDSYM(config_has_png_support); ADDSYM(config_has_jpeg_support); ADDSYM(config_has_ffmpeg_support); ADDSYM(config_has_exceptions); - ADDSYM(create_atoms); + + ADDSYM(config_has_package); + ADDSYM(config_package_count); + ADDSYM(config_package_name); + + ADDSYM(config_accelerator); + ADDSYM(has_gpu_device); + ADDSYM(get_gpu_device_info); + + ADDSYM(has_style); + ADDSYM(style_count); + ADDSYM(style_name); + + ADDSYM(has_id); + ADDSYM(id_count); + ADDSYM(id_name); + + ADDSYM(plugin_count); + ADDSYM(plugin_name); + + ADDSYM(set_fix_external_callback); + ADDSYM(fix_external_get_force); + ADDSYM(fix_external_set_energy_global); + ADDSYM(fix_external_set_energy_peratom); + ADDSYM(fix_external_set_virial_global); + ADDSYM(fix_external_set_virial_peratom); + ADDSYM(fix_external_set_vector_length); + ADDSYM(fix_external_set_vector); + + ADDSYM(free); + + ADDSYM(is_running); + ADDSYM(force_timeout); + #ifdef LAMMPS_EXCEPTIONS lmp->has_exceptions = 1; ADDSYM(has_error); diff --git a/examples/COUPLE/plugin/liblammpsplugin.h b/examples/COUPLE/plugin/liblammpsplugin.h index c70316d8e6..219ddb2574 100644 --- a/examples/COUPLE/plugin/liblammpsplugin.h +++ b/examples/COUPLE/plugin/liblammpsplugin.h @@ -39,75 +39,121 @@ extern "C" { #if defined(LAMMPS_BIGBIG) typedef void (*FixExternalFnPtr)(void *, int64_t, int, int64_t *, double **, double **); -#elif defined(LAMMPS_SMALLBIG) -typedef void (*FixExternalFnPtr)(void *, int64_t, int, int *, double **, double **); -#else +#elif defined(LAMMPS_SMALLSMALL) typedef void (*FixExternalFnPtr)(void *, int, int, int *, double **, double **); +#else +typedef void (*FixExternalFnPtr)(void *, int64_t, int, int *, double **, double **); #endif - struct _liblammpsplugin { int abiversion; int has_exceptions; void *handle; - void (*open)(int, char **, MPI_Comm, void **); - void (*open_no_mpi)(int, char **, void **); + void *(*open)(int, char **, MPI_Comm, void **); + void *(*open_no_mpi)(int, char **, void **); + void *(*open_fortran)(int, char **, void **, int); void (*close)(void *); - int (*version)(void *); + + void (*mpi_init)(); + void (*mpi_finalize)(); + void (*kokkos_finalize)(); + void (*python_finalize)(); + void (*file)(void *, char *); - char *(*command)(void *, char *); - void (*commands_list)(void *, int, char **); - void (*commands_string)(void *, char *); - void (*free)(void *); - int (*extract_setting)(void *, char *); - void *(*extract_global)(void *, char *); - void (*extract_box)(void *, double *, double *, - double *, double *, double *, int *, int *); - void *(*extract_atom)(void *, char *); - void *(*extract_compute)(void *, char *, int, int); - void *(*extract_fix)(void *, char *, int, int, int, int); - void *(*extract_variable)(void *, char *, char *); + char *(*command)(void *, const char *); + void (*commands_list)(void *, int, const char **); + void (*commands_string)(void *, const char *); + double (*get_natoms)(void *); double (*get_thermo)(void *, char *); - int (*get_natoms)(void *); - int (*set_variable)(void *, char *, char *); + void (*extract_box)(void *, double *, double *, + double *, double *, double *, int *, int *); void (*reset_box)(void *, double *, double *, double, double, double); + void (*memory_usage)(void *, double *); + int (*get_mpi_comm)(void *); + + int (*extract_setting)(void *, const char *); + int *(*extract_global_datatype)(void *, const char *); + void *(*extract_global)(void *, const char *); + + void *(*extract_atom_datatype)(void *, const char *); + void *(*extract_atom)(void *, const char *); + + void *(*extract_compute)(void *, const char *, int, int); + void *(*extract_fix)(void *, const char *, int, int, int, int); + void *(*extract_variable)(void *, const char *, char *); + int (*set_variable)(void *, char *, char *); + void (*gather_atoms)(void *, char *, int, int, void *); void (*gather_atoms_concat)(void *, char *, int, int, void *); void (*gather_atoms_subset)(void *, char *, int, int, int, int *, void *); void (*scatter_atoms)(void *, char *, int, int, void *); void (*scatter_atoms_subset)(void *, char *, int, int, int, int *, void *); - void (*set_fix_external_callback)(void *, char *, FixExternalFnPtr, void*); + void (*gather_bonds)(void *, void *); + +// lammps_create_atoms() takes tagint and imageint as args +// ifdef insures they are compatible with rest of LAMMPS +// caller must match to how LAMMPS library is built - int (*config_has_package)(char * package_name); - int (*config_package_count)(); - int (*config_package_name)(int index, char * buffer, int max_size); +#ifndef LAMMPS_BIGBIG + void (*create_atoms)(void *, int, int *, int *, double *, + double *, int *, int); +#else + void (*create_atoms)(void *, int, int64_t *, int *, double *, + double *, int64_t *, int); +#endif + + int (*find_pair_neighlist)(void *, const char *, int, int, int); + int (*find_fix_neighlist)(void *, const char *, int); + int (*find_compute_neighlist)(void *, char *, int); + int (*neighlist_num_elements)(void *, int); + void (*neighlist_element_neighbors)(void *, int, int, int *, int *, int **); + + int (*version)(void *); + void (*get_os_info)(char *, int); + + int (*config_has_mpi_support)(); int (*config_has_gzip_support)(); int (*config_has_png_support)(); int (*config_has_jpeg_support)(); int (*config_has_ffmpeg_support)(); int (*config_has_exceptions)(); - int (*find_pair_neighlist)(void* ptr, char * style, int exact, int nsub, int request); - int (*find_fix_neighlist)(void* ptr, char * id, int request); - int (*find_compute_neighlist)(void* ptr, char * id, int request); - int (*neighlist_num_elements)(void* ptr, int idx); - void (*neighlist_element_neighbors)(void * ptr, int idx, int element, int * iatom, int * numneigh, int ** neighbors); + int (*config_has_package)(const char *); + int (*config_package_count)(); + int (*config_package_name)(int, char *, int); -// lammps_create_atoms() takes tagint and imageint as args -// ifdef insures they are compatible with rest of LAMMPS -// caller must match to how LAMMPS library is built + int (*config_accelerator)(const char *, const char *, const char *); + int (*has_gpu_device)(); + void (*get_gpu_device_info)(char *, int); -#ifdef LAMMPS_BIGBIG - void (*create_atoms)(void *, int, int64_t *, int *, - double *, double *, int64_t *, int); -#else - void (*create_atoms)(void *, int, int *, int *, - double *, double *, int *, int); -#endif + int (*has_style)(void *, const char *, const char *); + int (*style_count)(void *, const char *); + int (*style_name)(void *, const char *, int, char *, int); + + int (*has_id)(void *, const char *, const char *); + int (*id_count)(void *, const char *); + int (*id_name)(void *, const char *, int, char *, int); + + int (*plugin_count)(); + int (*plugin_name)(int, char *, char *, int); + + void (*set_fix_external_callback)(void *, const char *, FixExternalFnPtr, void*); + void (*fix_external_get_force)(void *, const char *); + void (*fix_external_set_energy_global)(void *, const char *, double); + void (*fix_external_set_energy_peratom)(void *, const char *, double *); + void (*fix_external_set_virial_global)(void *, const char *, double *); + void (*fix_external_set_virial_peratom)(void *, const char *, double **); + void (*fix_external_set_vector_length)(void *, const char *, int); + void (*fix_external_set_vector)(void *, const char *, int, double); + + void (*free)(void *); + + void (*is_running)(void *); + void (*force_timeout)(void *); int (*has_error)(void *); int (*get_last_error_message)(void *, char *, int); @@ -117,7 +163,7 @@ typedef struct _liblammpsplugin liblammpsplugin_t; liblammpsplugin_t *liblammpsplugin_load(const char *); int liblammpsplugin_release(liblammpsplugin_t *); - + #undef LAMMPS #ifdef __cplusplus } diff --git a/examples/COUPLE/plugin/log.simple.plugin.1 b/examples/COUPLE/plugin/log.simple.plugin.1 index ba4be378f4..0443e3ec17 100644 --- a/examples/COUPLE/plugin/log.simple.plugin.1 +++ b/examples/COUPLE/plugin/log.simple.plugin.1 @@ -1,9 +1,12 @@ -LAMMPS (18 Feb 2020) -Lattice spacing in x,y,z = 1.6796 1.6796 1.6796 -Created orthogonal box = (0 0 0) to (6.71838 6.71838 6.71838) +LAMMPS (31 Aug 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (6.7183848 6.7183848 6.7183848) 1 by 1 by 1 MPI processor grid Created 256 atoms - create_atoms CPU = 0.000297844 secs + using lattice units in orthogonal box = (0.0000000 0.0000000 0.0000000) to (6.7183848 6.7183848 6.7183848) + create_atoms CPU = 0.001 seconds Neighbor list info ... update every 20 steps, delay 0 steps, check no max neighbors/atom: 2000, page size: 100000 @@ -14,108 +17,108 @@ Neighbor list info ... (1) pair lj/cut, perpetual attributes: half, newton on pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton + stencil: half/bin/3d bin: standard Setting up Verlet run ... Unit style : lj Current step : 0 Time step : 0.005 -Per MPI rank memory allocation (min/avg/max) = 2.63 | 2.63 | 2.63 Mbytes +Per MPI rank memory allocation (min/avg/max) = 2.630 | 2.630 | 2.630 Mbytes Step Temp E_pair E_mol TotEng Press 0 1.44 -6.7733681 0 -4.6218056 -5.0244179 10 1.1298532 -6.3095502 0 -4.6213906 -2.6058175 -Loop time of 0.00164276 on 1 procs for 10 steps with 256 atoms +Loop time of 0.00239712 on 1 procs for 10 steps with 256 atoms -Performance: 2629719.113 tau/day, 6087.313 timesteps/s -93.7% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1802163.347 tau/day, 4171.674 timesteps/s +97.2% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0014956 | 0.0014956 | 0.0014956 | 0.0 | 91.04 +Pair | 0.0020572 | 0.0020572 | 0.0020572 | 0.0 | 85.82 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 8.045e-05 | 8.045e-05 | 8.045e-05 | 0.0 | 4.90 -Output | 1.1399e-05 | 1.1399e-05 | 1.1399e-05 | 0.0 | 0.69 -Modify | 3.7431e-05 | 3.7431e-05 | 3.7431e-05 | 0.0 | 2.28 -Other | | 1.789e-05 | | | 1.09 +Comm | 0.00018731 | 0.00018731 | 0.00018731 | 0.0 | 7.81 +Output | 4.478e-05 | 4.478e-05 | 4.478e-05 | 0.0 | 1.87 +Modify | 6.3637e-05 | 6.3637e-05 | 6.3637e-05 | 0.0 | 2.65 +Other | | 4.419e-05 | | | 1.84 -Nlocal: 256 ave 256 max 256 min +Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1431 ave 1431 max 1431 min +Nghost: 1431.00 ave 1431 max 1431 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 9984 ave 9984 max 9984 min +Neighs: 9984.00 ave 9984 max 9984 min Histogram: 1 0 0 0 0 0 0 0 0 0 Total # of neighbors = 9984 -Ave neighs/atom = 39 +Ave neighs/atom = 39.000000 Neighbor list builds = 0 Dangerous builds not checked Setting up Verlet run ... Unit style : lj Current step : 10 Time step : 0.005 -Per MPI rank memory allocation (min/avg/max) = 2.63 | 2.63 | 2.63 Mbytes +Per MPI rank memory allocation (min/avg/max) = 2.630 | 2.630 | 2.630 Mbytes Step Temp E_pair E_mol TotEng Press 10 1.1298532 -6.3095502 0 -4.6213906 -2.6058175 20 0.6239063 -5.557644 0 -4.6254403 0.97451173 -Loop time of 0.00199768 on 1 procs for 10 steps with 256 atoms +Loop time of 0.00329271 on 1 procs for 10 steps with 256 atoms -Performance: 2162504.180 tau/day, 5005.797 timesteps/s -99.8% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1311987.619 tau/day, 3037.008 timesteps/s +96.4% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0018518 | 0.0018518 | 0.0018518 | 0.0 | 92.70 +Pair | 0.0029015 | 0.0029015 | 0.0029015 | 0.0 | 88.12 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 7.9768e-05 | 7.9768e-05 | 7.9768e-05 | 0.0 | 3.99 -Output | 1.1433e-05 | 1.1433e-05 | 1.1433e-05 | 0.0 | 0.57 -Modify | 3.6904e-05 | 3.6904e-05 | 3.6904e-05 | 0.0 | 1.85 -Other | | 1.773e-05 | | | 0.89 +Comm | 0.00021807 | 0.00021807 | 0.00021807 | 0.0 | 6.62 +Output | 4.9163e-05 | 4.9163e-05 | 4.9163e-05 | 0.0 | 1.49 +Modify | 7.0573e-05 | 7.0573e-05 | 7.0573e-05 | 0.0 | 2.14 +Other | | 5.339e-05 | | | 1.62 -Nlocal: 256 ave 256 max 256 min +Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1431 ave 1431 max 1431 min +Nghost: 1431.00 ave 1431 max 1431 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 9952 ave 9952 max 9952 min +Neighs: 9952.00 ave 9952 max 9952 min Histogram: 1 0 0 0 0 0 0 0 0 0 Total # of neighbors = 9952 -Ave neighs/atom = 38.875 +Ave neighs/atom = 38.875000 Neighbor list builds = 0 Dangerous builds not checked Setting up Verlet run ... Unit style : lj Current step : 20 Time step : 0.005 -Per MPI rank memory allocation (min/avg/max) = 2.63 | 2.63 | 2.63 Mbytes +Per MPI rank memory allocation (min/avg/max) = 2.630 | 2.630 | 2.630 Mbytes Step Temp E_pair E_mol TotEng Press 20 0.6239063 -5.5404291 0 -4.6082254 1.0394285 21 0.63845863 -5.5628733 0 -4.6089263 0.99398278 -Loop time of 0.000304321 on 1 procs for 1 steps with 256 atoms +Loop time of 0.000638039 on 1 procs for 1 steps with 256 atoms -Performance: 1419553.695 tau/day, 3286.004 timesteps/s -98.9% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 677074.599 tau/day, 1567.302 timesteps/s +98.9% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.00027815 | 0.00027815 | 0.00027815 | 0.0 | 91.40 +Pair | 0.00042876 | 0.00042876 | 0.00042876 | 0.0 | 67.20 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 8.321e-06 | 8.321e-06 | 8.321e-06 | 0.0 | 2.73 -Output | 1.0513e-05 | 1.0513e-05 | 1.0513e-05 | 0.0 | 3.45 -Modify | 3.968e-06 | 3.968e-06 | 3.968e-06 | 0.0 | 1.30 -Other | | 3.365e-06 | | | 1.11 +Comm | 5.2872e-05 | 5.2872e-05 | 5.2872e-05 | 0.0 | 8.29 +Output | 0.00012218 | 0.00012218 | 0.00012218 | 0.0 | 19.15 +Modify | 1.3762e-05 | 1.3762e-05 | 1.3762e-05 | 0.0 | 2.16 +Other | | 2.047e-05 | | | 3.21 -Nlocal: 256 ave 256 max 256 min +Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1431 ave 1431 max 1431 min +Nghost: 1431.00 ave 1431 max 1431 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 9705 ave 9705 max 9705 min +Neighs: 9705.00 ave 9705 max 9705 min Histogram: 1 0 0 0 0 0 0 0 0 0 Total # of neighbors = 9705 -Ave neighs/atom = 37.9102 +Ave neighs/atom = 37.910156 Neighbor list builds = 0 Dangerous builds not checked Force on 1 atom via extract_atom: 26.9581 @@ -124,136 +127,136 @@ Setting up Verlet run ... Unit style : lj Current step : 21 Time step : 0.005 -Per MPI rank memory allocation (min/avg/max) = 2.63 | 2.63 | 2.63 Mbytes +Per MPI rank memory allocation (min/avg/max) = 2.630 | 2.630 | 2.630 Mbytes Step Temp E_pair E_mol TotEng Press 21 0.63845863 -5.5628733 0 -4.6089263 0.99398278 31 0.7494946 -5.7306417 0 -4.6107913 0.41043597 -Loop time of 0.00196027 on 1 procs for 10 steps with 256 atoms +Loop time of 0.00281277 on 1 procs for 10 steps with 256 atoms -Performance: 2203779.175 tau/day, 5101.341 timesteps/s -99.7% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1535852.558 tau/day, 3555.214 timesteps/s +92.6% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0018146 | 0.0018146 | 0.0018146 | 0.0 | 92.57 +Pair | 0.0024599 | 0.0024599 | 0.0024599 | 0.0 | 87.45 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 8.0268e-05 | 8.0268e-05 | 8.0268e-05 | 0.0 | 4.09 -Output | 1.0973e-05 | 1.0973e-05 | 1.0973e-05 | 0.0 | 0.56 -Modify | 3.6913e-05 | 3.6913e-05 | 3.6913e-05 | 0.0 | 1.88 -Other | | 1.756e-05 | | | 0.90 +Comm | 0.00020234 | 0.00020234 | 0.00020234 | 0.0 | 7.19 +Output | 3.6436e-05 | 3.6436e-05 | 3.6436e-05 | 0.0 | 1.30 +Modify | 6.7542e-05 | 6.7542e-05 | 6.7542e-05 | 0.0 | 2.40 +Other | | 4.655e-05 | | | 1.65 -Nlocal: 256 ave 256 max 256 min +Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1431 ave 1431 max 1431 min +Nghost: 1431.00 ave 1431 max 1431 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 9688 ave 9688 max 9688 min +Neighs: 9688.00 ave 9688 max 9688 min Histogram: 1 0 0 0 0 0 0 0 0 0 Total # of neighbors = 9688 -Ave neighs/atom = 37.8438 +Ave neighs/atom = 37.843750 Neighbor list builds = 0 Dangerous builds not checked Setting up Verlet run ... Unit style : lj Current step : 31 Time step : 0.005 -Per MPI rank memory allocation (min/avg/max) = 2.63 | 2.63 | 2.63 Mbytes +Per MPI rank memory allocation (min/avg/max) = 2.630 | 2.630 | 2.630 Mbytes Step Temp E_pair E_mol TotEng Press 31 0.7494946 -5.7306417 0 -4.6107913 0.41043597 51 0.71349216 -5.6772387 0 -4.6111811 0.52117681 -Loop time of 0.00433063 on 1 procs for 20 steps with 256 atoms +Loop time of 0.00560916 on 1 procs for 20 steps with 256 atoms -Performance: 1995088.941 tau/day, 4618.261 timesteps/s -99.3% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1540338.414 tau/day, 3565.598 timesteps/s +99.2% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0035121 | 0.0035121 | 0.0035121 | 0.0 | 81.10 -Neigh | 0.00050258 | 0.00050258 | 0.00050258 | 0.0 | 11.61 -Comm | 0.00019444 | 0.00019444 | 0.00019444 | 0.0 | 4.49 -Output | 1.2092e-05 | 1.2092e-05 | 1.2092e-05 | 0.0 | 0.28 -Modify | 7.2917e-05 | 7.2917e-05 | 7.2917e-05 | 0.0 | 1.68 -Other | | 3.647e-05 | | | 0.84 +Pair | 0.0044403 | 0.0044403 | 0.0044403 | 0.0 | 79.16 +Neigh | 0.00056186 | 0.00056186 | 0.00056186 | 0.0 | 10.02 +Comm | 0.00036797 | 0.00036797 | 0.00036797 | 0.0 | 6.56 +Output | 3.676e-05 | 3.676e-05 | 3.676e-05 | 0.0 | 0.66 +Modify | 0.00011282 | 0.00011282 | 0.00011282 | 0.0 | 2.01 +Other | | 8.943e-05 | | | 1.59 -Nlocal: 256 ave 256 max 256 min +Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1421 ave 1421 max 1421 min +Nghost: 1421.00 ave 1421 max 1421 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 9700 ave 9700 max 9700 min +Neighs: 9700.00 ave 9700 max 9700 min Histogram: 1 0 0 0 0 0 0 0 0 0 Total # of neighbors = 9700 -Ave neighs/atom = 37.8906 +Ave neighs/atom = 37.890625 Neighbor list builds = 1 Dangerous builds not checked Setting up Verlet run ... Unit style : lj Current step : 51 Time step : 0.005 -Per MPI rank memory allocation (min/avg/max) = 2.63 | 2.63 | 2.63 Mbytes +Per MPI rank memory allocation (min/avg/max) = 2.630 | 2.630 | 2.630 Mbytes Step Temp E_pair E_mol TotEng Press 51 0.71349216 -5.6772387 0 -4.6111811 0.52117681 61 0.78045421 -5.7781094 0 -4.6120011 0.093808941 -Loop time of 0.00196567 on 1 procs for 10 steps with 256 atoms +Loop time of 0.00373815 on 1 procs for 10 steps with 256 atoms -Performance: 2197727.285 tau/day, 5087.332 timesteps/s -99.7% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1155650.623 tau/day, 2675.117 timesteps/s +98.0% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0018222 | 0.0018222 | 0.0018222 | 0.0 | 92.70 +Pair | 0.0030908 | 0.0030908 | 0.0030908 | 0.0 | 82.68 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 7.8285e-05 | 7.8285e-05 | 7.8285e-05 | 0.0 | 3.98 -Output | 1.0862e-05 | 1.0862e-05 | 1.0862e-05 | 0.0 | 0.55 -Modify | 3.6719e-05 | 3.6719e-05 | 3.6719e-05 | 0.0 | 1.87 -Other | | 1.764e-05 | | | 0.90 +Comm | 0.00038189 | 0.00038189 | 0.00038189 | 0.0 | 10.22 +Output | 4.1615e-05 | 4.1615e-05 | 4.1615e-05 | 0.0 | 1.11 +Modify | 0.00013851 | 0.00013851 | 0.00013851 | 0.0 | 3.71 +Other | | 8.533e-05 | | | 2.28 -Nlocal: 256 ave 256 max 256 min +Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1421 ave 1421 max 1421 min +Nghost: 1421.00 ave 1421 max 1421 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 9700 ave 9700 max 9700 min +Neighs: 9700.00 ave 9700 max 9700 min Histogram: 1 0 0 0 0 0 0 0 0 0 Total # of neighbors = 9700 -Ave neighs/atom = 37.8906 +Ave neighs/atom = 37.890625 Neighbor list builds = 0 Dangerous builds not checked Setting up Verlet run ... Unit style : lj Current step : 61 Time step : 0.005 -Per MPI rank memory allocation (min/avg/max) = 2.63 | 2.63 | 2.63 Mbytes +Per MPI rank memory allocation (min/avg/max) = 2.630 | 2.630 | 2.630 Mbytes Step Temp E_pair E_mol TotEng Press 61 0.78045421 -5.7781094 0 -4.6120011 0.093808941 81 0.77743907 -5.7735004 0 -4.6118971 0.090822641 -Loop time of 0.00430528 on 1 procs for 20 steps with 256 atoms +Loop time of 0.00612177 on 1 procs for 20 steps with 256 atoms -Performance: 2006838.581 tau/day, 4645.460 timesteps/s -99.8% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1411356.519 tau/day, 3267.029 timesteps/s +98.6% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0034931 | 0.0034931 | 0.0034931 | 0.0 | 81.13 -Neigh | 0.00050437 | 0.00050437 | 0.00050437 | 0.0 | 11.72 -Comm | 0.0001868 | 0.0001868 | 0.0001868 | 0.0 | 4.34 -Output | 1.1699e-05 | 1.1699e-05 | 1.1699e-05 | 0.0 | 0.27 -Modify | 7.3308e-05 | 7.3308e-05 | 7.3308e-05 | 0.0 | 1.70 -Other | | 3.604e-05 | | | 0.84 +Pair | 0.0047211 | 0.0047211 | 0.0047211 | 0.0 | 77.12 +Neigh | 0.00083088 | 0.00083088 | 0.00083088 | 0.0 | 13.57 +Comm | 0.00032716 | 0.00032716 | 0.00032716 | 0.0 | 5.34 +Output | 3.9891e-05 | 3.9891e-05 | 3.9891e-05 | 0.0 | 0.65 +Modify | 0.00010926 | 0.00010926 | 0.00010926 | 0.0 | 1.78 +Other | | 9.346e-05 | | | 1.53 -Nlocal: 256 ave 256 max 256 min +Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1405 ave 1405 max 1405 min +Nghost: 1405.00 ave 1405 max 1405 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 9701 ave 9701 max 9701 min +Neighs: 9701.00 ave 9701 max 9701 min Histogram: 1 0 0 0 0 0 0 0 0 0 Total # of neighbors = 9701 -Ave neighs/atom = 37.8945 +Ave neighs/atom = 37.894531 Neighbor list builds = 1 Dangerous builds not checked Deleted 256 atoms, new total = 0 @@ -261,34 +264,34 @@ Setting up Verlet run ... Unit style : lj Current step : 81 Time step : 0.005 -Per MPI rank memory allocation (min/avg/max) = 2.63 | 2.63 | 2.63 Mbytes +Per MPI rank memory allocation (min/avg/max) = 2.630 | 2.630 | 2.630 Mbytes Step Temp E_pair E_mol TotEng Press 81 0.6239063 -5.5404291 0 -4.6082254 1.0394285 91 0.75393007 -5.7375259 0 -4.6110484 0.39357367 -Loop time of 0.00195843 on 1 procs for 10 steps with 256 atoms +Loop time of 0.00319065 on 1 procs for 10 steps with 256 atoms -Performance: 2205851.941 tau/day, 5106.139 timesteps/s -99.7% CPU use with 1 MPI tasks x no OpenMP threads +Performance: 1353954.393 tau/day, 3134.154 timesteps/s +99.2% CPU use with 1 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0018143 | 0.0018143 | 0.0018143 | 0.0 | 92.64 +Pair | 0.0027828 | 0.0027828 | 0.0027828 | 0.0 | 87.22 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 7.8608e-05 | 7.8608e-05 | 7.8608e-05 | 0.0 | 4.01 -Output | 1.0786e-05 | 1.0786e-05 | 1.0786e-05 | 0.0 | 0.55 -Modify | 3.7106e-05 | 3.7106e-05 | 3.7106e-05 | 0.0 | 1.89 -Other | | 1.762e-05 | | | 0.90 +Comm | 0.00023286 | 0.00023286 | 0.00023286 | 0.0 | 7.30 +Output | 4.0459e-05 | 4.0459e-05 | 4.0459e-05 | 0.0 | 1.27 +Modify | 7.3576e-05 | 7.3576e-05 | 7.3576e-05 | 0.0 | 2.31 +Other | | 6.094e-05 | | | 1.91 -Nlocal: 256 ave 256 max 256 min +Nlocal: 256.000 ave 256 max 256 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Nghost: 1431 ave 1431 max 1431 min +Nghost: 1431.00 ave 1431 max 1431 min Histogram: 1 0 0 0 0 0 0 0 0 0 -Neighs: 9705 ave 9705 max 9705 min +Neighs: 9705.00 ave 9705 max 9705 min Histogram: 1 0 0 0 0 0 0 0 0 0 Total # of neighbors = 9705 -Ave neighs/atom = 37.9102 +Ave neighs/atom = 37.910156 Neighbor list builds = 0 Dangerous builds not checked Total wall time: 0:00:00 diff --git a/examples/COUPLE/plugin/log.simple.plugin.4 b/examples/COUPLE/plugin/log.simple.plugin.4 index d76719dd7c..9b578d9919 100644 --- a/examples/COUPLE/plugin/log.simple.plugin.4 +++ b/examples/COUPLE/plugin/log.simple.plugin.4 @@ -1,9 +1,12 @@ -LAMMPS (18 Feb 2020) -Lattice spacing in x,y,z = 1.6796 1.6796 1.6796 -Created orthogonal box = (0 0 0) to (6.71838 6.71838 6.71838) +LAMMPS (31 Aug 2021) +OMP_NUM_THREADS environment is not set. Defaulting to 1 thread. (src/comm.cpp:98) + using 1 OpenMP thread(s) per MPI task +Lattice spacing in x,y,z = 1.6795962 1.6795962 1.6795962 +Created orthogonal box = (0.0000000 0.0000000 0.0000000) to (6.7183848 6.7183848 6.7183848) 1 by 1 by 2 MPI processor grid Created 256 atoms - create_atoms CPU = 0.000265157 secs + using lattice units in orthogonal box = (0.0000000 0.0000000 0.0000000) to (6.7183848 6.7183848 6.7183848) + create_atoms CPU = 0.003 seconds Neighbor list info ... update every 20 steps, delay 0 steps, check no max neighbors/atom: 2000, page size: 100000 @@ -14,7 +17,7 @@ Neighbor list info ... (1) pair lj/cut, perpetual attributes: half, newton on pair build: half/bin/atomonly/newton - stencil: half/bin/3d/newton + stencil: half/bin/3d bin: standard Setting up Verlet run ... Unit style : lj @@ -24,30 +27,30 @@ Per MPI rank memory allocation (min/avg/max) = 2.624 | 2.624 | 2.624 Mbytes Step Temp E_pair E_mol TotEng Press 0 1.44 -6.7733681 0 -4.6218056 -5.0244179 10 1.1298532 -6.3095502 0 -4.6213906 -2.6058175 -Loop time of 0.00115264 on 2 procs for 10 steps with 256 atoms +Loop time of 0.00330899 on 2 procs for 10 steps with 256 atoms -Performance: 3747912.946 tau/day, 8675.724 timesteps/s -94.5% CPU use with 2 MPI tasks x no OpenMP threads +Performance: 1305535.501 tau/day, 3022.073 timesteps/s +75.7% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.00074885 | 0.00075021 | 0.00075156 | 0.0 | 65.09 +Pair | 0.0013522 | 0.0013813 | 0.0014104 | 0.1 | 41.74 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00031829 | 0.00031943 | 0.00032056 | 0.0 | 27.71 -Output | 9.306e-06 | 2.6673e-05 | 4.4041e-05 | 0.0 | 2.31 -Modify | 2.0684e-05 | 2.0891e-05 | 2.1098e-05 | 0.0 | 1.81 -Other | | 3.544e-05 | | | 3.07 +Comm | 0.00049139 | 0.00054241 | 0.00059342 | 0.0 | 16.39 +Output | 3.6986e-05 | 0.00056588 | 0.0010948 | 0.0 | 17.10 +Modify | 4.3909e-05 | 4.3924e-05 | 4.3939e-05 | 0.0 | 1.33 +Other | | 0.0007755 | | | 23.44 -Nlocal: 128 ave 128 max 128 min +Nlocal: 128.000 ave 128 max 128 min Histogram: 2 0 0 0 0 0 0 0 0 0 -Nghost: 1109 ave 1109 max 1109 min +Nghost: 1109.00 ave 1109 max 1109 min Histogram: 2 0 0 0 0 0 0 0 0 0 -Neighs: 4992 ave 4992 max 4992 min +Neighs: 4992.00 ave 4992 max 4992 min Histogram: 2 0 0 0 0 0 0 0 0 0 Total # of neighbors = 9984 -Ave neighs/atom = 39 +Ave neighs/atom = 39.000000 Neighbor list builds = 0 Dangerous builds not checked Setting up Verlet run ... @@ -58,30 +61,30 @@ Per MPI rank memory allocation (min/avg/max) = 2.624 | 2.624 | 2.624 Mbytes Step Temp E_pair E_mol TotEng Press 10 1.1298532 -6.3095502 0 -4.6213906 -2.6058175 20 0.6239063 -5.557644 0 -4.6254403 0.97451173 -Loop time of 0.00120443 on 2 procs for 10 steps with 256 atoms +Loop time of 0.00648485 on 2 procs for 10 steps with 256 atoms -Performance: 3586761.860 tau/day, 8302.689 timesteps/s -95.5% CPU use with 2 MPI tasks x no OpenMP threads +Performance: 666168.017 tau/day, 1542.056 timesteps/s +44.3% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.00087798 | 0.00091359 | 0.0009492 | 0.0 | 75.85 +Pair | 0.0022373 | 0.0024405 | 0.0026437 | 0.4 | 37.63 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00016739 | 0.00020368 | 0.00023997 | 0.0 | 16.91 -Output | 1.0124e-05 | 3.0513e-05 | 5.0901e-05 | 0.0 | 2.53 -Modify | 1.89e-05 | 1.9812e-05 | 2.0725e-05 | 0.0 | 1.64 -Other | | 3.683e-05 | | | 3.06 +Comm | 0.0024446 | 0.0026464 | 0.0028481 | 0.4 | 40.81 +Output | 3.9069e-05 | 0.00059734 | 0.0011556 | 0.0 | 9.21 +Modify | 4.869e-05 | 4.912e-05 | 4.9551e-05 | 0.0 | 0.76 +Other | | 0.0007515 | | | 11.59 -Nlocal: 128 ave 134 max 122 min +Nlocal: 128.000 ave 134 max 122 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Nghost: 1109 ave 1115 max 1103 min +Nghost: 1109.00 ave 1115 max 1103 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Neighs: 4976 ave 5205 max 4747 min +Neighs: 4976.00 ave 5205 max 4747 min Histogram: 1 0 0 0 0 0 0 0 0 1 Total # of neighbors = 9952 -Ave neighs/atom = 38.875 +Ave neighs/atom = 38.875000 Neighbor list builds = 0 Dangerous builds not checked Setting up Verlet run ... @@ -92,34 +95,34 @@ Per MPI rank memory allocation (min/avg/max) = 2.624 | 2.624 | 2.624 Mbytes Step Temp E_pair E_mol TotEng Press 20 0.6239063 -5.5404291 0 -4.6082254 1.0394285 21 0.63845863 -5.5628733 0 -4.6089263 0.99398278 -Loop time of 0.000206062 on 2 procs for 1 steps with 256 atoms +Loop time of 0.00128072 on 2 procs for 1 steps with 256 atoms -Performance: 2096456.406 tau/day, 4852.908 timesteps/s -94.1% CPU use with 2 MPI tasks x no OpenMP threads +Performance: 337310.921 tau/day, 780.812 timesteps/s +60.2% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.00012947 | 0.00013524 | 0.00014101 | 0.0 | 65.63 +Pair | 0.00047351 | 0.00049064 | 0.00050777 | 0.0 | 38.31 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 1.858e-05 | 2.4113e-05 | 2.9647e-05 | 0.0 | 11.70 -Output | 8.699e-06 | 2.4204e-05 | 3.9708e-05 | 0.0 | 11.75 -Modify | 2.34e-06 | 2.3705e-06 | 2.401e-06 | 0.0 | 1.15 -Other | | 2.013e-05 | | | 9.77 +Comm | 7.6767e-05 | 9.3655e-05 | 0.00011054 | 0.0 | 7.31 +Output | 5.4217e-05 | 0.00026297 | 0.00047172 | 0.0 | 20.53 +Modify | 1.1554e-05 | 1.2026e-05 | 1.2498e-05 | 0.0 | 0.94 +Other | | 0.0004214 | | | 32.91 -Nlocal: 128 ave 135 max 121 min +Nlocal: 128.000 ave 135 max 121 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Nghost: 1109 ave 1116 max 1102 min +Nghost: 1109.00 ave 1116 max 1102 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Neighs: 4852.5 ave 5106 max 4599 min +Neighs: 4852.50 ave 5106 max 4599 min Histogram: 1 0 0 0 0 0 0 0 0 1 Total # of neighbors = 9705 -Ave neighs/atom = 37.9102 -Force on 1 atom via extract_atom: -18.109 -Force on 1 atom via extract_variable: -18.109 +Ave neighs/atom = 37.910156 Neighbor list builds = 0 Dangerous builds not checked +Force on 1 atom via extract_atom: -18.109 +Force on 1 atom via extract_variable: -18.109 Force on 1 atom via extract_atom: 26.9581 Force on 1 atom via extract_variable: 26.9581 Setting up Verlet run ... @@ -130,30 +133,30 @@ Per MPI rank memory allocation (min/avg/max) = 2.624 | 2.624 | 2.624 Mbytes Step Temp E_pair E_mol TotEng Press 21 0.63845863 -5.5628733 0 -4.6089263 0.99398278 31 0.7494946 -5.7306417 0 -4.6107913 0.41043597 -Loop time of 0.00119048 on 2 procs for 10 steps with 256 atoms +Loop time of 0.00784933 on 2 procs for 10 steps with 256 atoms -Performance: 3628802.105 tau/day, 8400.005 timesteps/s -98.0% CPU use with 2 MPI tasks x no OpenMP threads +Performance: 550365.761 tau/day, 1273.995 timesteps/s +59.6% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.00085276 | 0.00089699 | 0.00094123 | 0.0 | 75.35 +Pair | 0.0019235 | 0.0033403 | 0.0047572 | 2.5 | 42.56 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00016896 | 0.00021444 | 0.00025992 | 0.0 | 18.01 -Output | 9.413e-06 | 2.5939e-05 | 4.2465e-05 | 0.0 | 2.18 -Modify | 1.8977e-05 | 2.0009e-05 | 2.1042e-05 | 0.0 | 1.68 -Other | | 3.31e-05 | | | 2.78 +Comm | 0.0016948 | 0.003118 | 0.0045411 | 2.5 | 39.72 +Output | 3.6445e-05 | 0.00064636 | 0.0012563 | 0.0 | 8.23 +Modify | 6.2842e-05 | 6.3209e-05 | 6.3577e-05 | 0.0 | 0.81 +Other | | 0.0006814 | | | 8.68 -Nlocal: 128 ave 135 max 121 min +Nlocal: 128.000 ave 135 max 121 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Nghost: 1109 ave 1116 max 1102 min +Nghost: 1109.00 ave 1116 max 1102 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Neighs: 4844 ave 5096 max 4592 min +Neighs: 4844.00 ave 5096 max 4592 min Histogram: 1 0 0 0 0 0 0 0 0 1 Total # of neighbors = 9688 -Ave neighs/atom = 37.8438 +Ave neighs/atom = 37.843750 Neighbor list builds = 0 Dangerous builds not checked Setting up Verlet run ... @@ -164,30 +167,30 @@ Per MPI rank memory allocation (min/avg/max) = 2.624 | 2.624 | 2.624 Mbytes Step Temp E_pair E_mol TotEng Press 31 0.7494946 -5.7306417 0 -4.6107913 0.41043597 51 0.71349216 -5.6772387 0 -4.6111811 0.52117681 -Loop time of 0.00252603 on 2 procs for 20 steps with 256 atoms +Loop time of 0.00696051 on 2 procs for 20 steps with 256 atoms -Performance: 3420382.192 tau/day, 7917.551 timesteps/s -99.2% CPU use with 2 MPI tasks x no OpenMP threads +Performance: 1241287.730 tau/day, 2873.351 timesteps/s +79.2% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0016245 | 0.0017014 | 0.0017784 | 0.2 | 67.36 -Neigh | 0.00025359 | 0.0002563 | 0.00025901 | 0.0 | 10.15 -Comm | 0.00036863 | 0.00045124 | 0.00053385 | 0.0 | 17.86 -Output | 9.839e-06 | 2.8031e-05 | 4.6223e-05 | 0.0 | 1.11 -Modify | 3.7027e-05 | 3.9545e-05 | 4.2063e-05 | 0.0 | 1.57 -Other | | 4.948e-05 | | | 1.96 +Pair | 0.0028267 | 0.0036088 | 0.004391 | 1.3 | 51.85 +Neigh | 0.00040272 | 0.00040989 | 0.00041707 | 0.0 | 5.89 +Comm | 0.00081061 | 0.0015825 | 0.0023544 | 1.9 | 22.74 +Output | 3.6006e-05 | 0.00062106 | 0.0012061 | 0.0 | 8.92 +Modify | 6.8937e-05 | 7.1149e-05 | 7.336e-05 | 0.0 | 1.02 +Other | | 0.0006671 | | | 9.58 -Nlocal: 128 ave 132 max 124 min +Nlocal: 128.000 ave 132 max 124 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Nghost: 1100 ave 1101 max 1099 min +Nghost: 1100.00 ave 1101 max 1099 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Neighs: 4850 ave 4953 max 4747 min +Neighs: 4850.00 ave 4953 max 4747 min Histogram: 1 0 0 0 0 0 0 0 0 1 Total # of neighbors = 9700 -Ave neighs/atom = 37.8906 +Ave neighs/atom = 37.890625 Neighbor list builds = 1 Dangerous builds not checked Setting up Verlet run ... @@ -198,30 +201,30 @@ Per MPI rank memory allocation (min/avg/max) = 2.624 | 2.624 | 2.624 Mbytes Step Temp E_pair E_mol TotEng Press 51 0.71349216 -5.6772387 0 -4.6111811 0.52117681 61 0.78045421 -5.7781094 0 -4.6120011 0.093808941 -Loop time of 0.00115444 on 2 procs for 10 steps with 256 atoms +Loop time of 0.00155862 on 2 procs for 10 steps with 256 atoms -Performance: 3742065.976 tau/day, 8662.190 timesteps/s -96.5% CPU use with 2 MPI tasks x no OpenMP threads +Performance: 2771678.197 tau/day, 6415.922 timesteps/s +95.0% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.00087346 | 0.00089311 | 0.00091275 | 0.0 | 77.36 +Pair | 0.0012369 | 0.001266 | 0.001295 | 0.1 | 81.22 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00016192 | 0.0001823 | 0.00020269 | 0.0 | 15.79 -Output | 9.49e-06 | 2.6234e-05 | 4.2978e-05 | 0.0 | 2.27 -Modify | 1.9095e-05 | 1.9843e-05 | 2.0591e-05 | 0.0 | 1.72 -Other | | 3.296e-05 | | | 2.85 +Comm | 0.00019462 | 0.00022315 | 0.00025169 | 0.0 | 14.32 +Output | 2.0217e-05 | 2.1945e-05 | 2.3673e-05 | 0.0 | 1.41 +Modify | 2.562e-05 | 2.5759e-05 | 2.5898e-05 | 0.0 | 1.65 +Other | | 2.181e-05 | | | 1.40 -Nlocal: 128 ave 132 max 124 min +Nlocal: 128.000 ave 132 max 124 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Nghost: 1100 ave 1101 max 1099 min +Nghost: 1100.00 ave 1101 max 1099 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Neighs: 4850 ave 4953 max 4747 min +Neighs: 4850.00 ave 4953 max 4747 min Histogram: 1 0 0 0 0 0 0 0 0 1 Total # of neighbors = 9700 -Ave neighs/atom = 37.8906 +Ave neighs/atom = 37.890625 Neighbor list builds = 0 Dangerous builds not checked Setting up Verlet run ... @@ -232,30 +235,30 @@ Per MPI rank memory allocation (min/avg/max) = 2.624 | 2.624 | 2.624 Mbytes Step Temp E_pair E_mol TotEng Press 61 0.78045421 -5.7781094 0 -4.6120011 0.093808941 81 0.77743907 -5.7735004 0 -4.6118971 0.090822641 -Loop time of 0.00244325 on 2 procs for 20 steps with 256 atoms +Loop time of 0.00351607 on 2 procs for 20 steps with 256 atoms -Performance: 3536279.919 tau/day, 8185.833 timesteps/s -99.0% CPU use with 2 MPI tasks x no OpenMP threads +Performance: 2457288.612 tau/day, 5688.168 timesteps/s +97.9% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0016916 | 0.0017038 | 0.001716 | 0.0 | 69.73 -Neigh | 0.00025229 | 0.00025512 | 0.00025795 | 0.0 | 10.44 -Comm | 0.00035772 | 0.00036918 | 0.00038064 | 0.0 | 15.11 -Output | 1.0858e-05 | 2.7875e-05 | 4.4891e-05 | 0.0 | 1.14 -Modify | 3.817e-05 | 3.9325e-05 | 4.048e-05 | 0.0 | 1.61 -Other | | 4.796e-05 | | | 1.96 +Pair | 0.0023896 | 0.0024147 | 0.0024397 | 0.1 | 68.67 +Neigh | 0.00037331 | 0.00040456 | 0.0004358 | 0.0 | 11.51 +Comm | 0.00050571 | 0.00051343 | 0.00052116 | 0.0 | 14.60 +Output | 2.6424e-05 | 5.6547e-05 | 8.667e-05 | 0.0 | 1.61 +Modify | 5.0287e-05 | 5.1071e-05 | 5.1856e-05 | 0.0 | 1.45 +Other | | 7.58e-05 | | | 2.16 -Nlocal: 128 ave 128 max 128 min +Nlocal: 128.000 ave 128 max 128 min Histogram: 2 0 0 0 0 0 0 0 0 0 -Nghost: 1088.5 ave 1092 max 1085 min +Nghost: 1088.50 ave 1092 max 1085 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Neighs: 4850.5 ave 4851 max 4850 min +Neighs: 4850.50 ave 4851 max 4850 min Histogram: 1 0 0 0 0 0 0 0 0 1 Total # of neighbors = 9701 -Ave neighs/atom = 37.8945 +Ave neighs/atom = 37.894531 Neighbor list builds = 1 Dangerous builds not checked Deleted 256 atoms, new total = 0 @@ -267,30 +270,30 @@ Per MPI rank memory allocation (min/avg/max) = 2.624 | 2.624 | 2.624 Mbytes Step Temp E_pair E_mol TotEng Press 81 0.6239063 -5.5404291 0 -4.6082254 1.0394285 91 0.75393007 -5.7375259 0 -4.6110484 0.39357367 -Loop time of 0.00118092 on 2 procs for 10 steps with 256 atoms +Loop time of 0.0109747 on 2 procs for 10 steps with 256 atoms -Performance: 3658158.625 tau/day, 8467.960 timesteps/s -98.6% CPU use with 2 MPI tasks x no OpenMP threads +Performance: 393631.731 tau/day, 911.185 timesteps/s +53.5% CPU use with 2 MPI tasks x 1 OpenMP threads MPI task timing breakdown: Section | min time | avg time | max time |%varavg| %total --------------------------------------------------------------- -Pair | 0.0008476 | 0.00089265 | 0.00093771 | 0.0 | 75.59 +Pair | 0.0012057 | 0.0012732 | 0.0013407 | 0.2 | 11.60 Neigh | 0 | 0 | 0 | 0.0 | 0.00 -Comm | 0.00016335 | 0.00020946 | 0.00025557 | 0.0 | 17.74 -Output | 8.87e-06 | 2.5733e-05 | 4.2595e-05 | 0.0 | 2.18 -Modify | 1.8755e-05 | 1.9814e-05 | 2.0872e-05 | 0.0 | 1.68 -Other | | 3.326e-05 | | | 2.82 +Comm | 0.00018882 | 0.00025686 | 0.00032489 | 0.0 | 2.34 +Output | 2.1943e-05 | 0.0047067 | 0.0093915 | 6.8 | 42.89 +Modify | 2.4614e-05 | 2.5439e-05 | 2.6264e-05 | 0.0 | 0.23 +Other | | 0.004712 | | | 42.94 -Nlocal: 128 ave 135 max 121 min +Nlocal: 128.000 ave 135 max 121 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Nghost: 1109 ave 1116 max 1102 min +Nghost: 1109.00 ave 1116 max 1102 min Histogram: 1 0 0 0 0 0 0 0 0 1 -Neighs: 4852.5 ave 5106 max 4599 min +Neighs: 4852.50 ave 5106 max 4599 min Histogram: 1 0 0 0 0 0 0 0 0 1 Total # of neighbors = 9705 -Ave neighs/atom = 37.9102 +Ave neighs/atom = 37.910156 Neighbor list builds = 0 Dangerous builds not checked Total wall time: 0:00:00 diff --git a/examples/COUPLE/plugin/simple.c b/examples/COUPLE/plugin/simple.c index 541e4fd432..dc3934b40c 100644 --- a/examples/COUPLE/plugin/simple.c +++ b/examples/COUPLE/plugin/simple.c @@ -87,7 +87,7 @@ int main(int narg, char **arg) MPI_Abort(MPI_COMM_WORLD,1); } } - if (lammps == 1) plugin->open(0,NULL,comm_lammps,&lmp); + if (lammps == 1) lmp = plugin->open(0,NULL,comm_lammps,NULL); while (1) { if (me == 0) { @@ -139,7 +139,7 @@ int main(int narg, char **arg) cmds[0] = (char *)"run 10"; cmds[1] = (char *)"run 20"; - if (lammps == 1) plugin->commands_list(lmp,2,cmds); + if (lammps == 1) plugin->commands_list(lmp,2,(const char **)cmds); /* delete all atoms create_atoms() to create new ones with old coords, vels @@ -164,12 +164,13 @@ int main(int narg, char **arg) if (lammps == 1) { plugin->close(lmp); + MPI_Barrier(comm_lammps); + MPI_Comm_free(&comm_lammps); liblammpsplugin_release(plugin); } /* close down MPI */ - if (lammps == 1) MPI_Comm_free(&comm_lammps); MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); } diff --git a/lib/gpu/geryon/ocl_device.h b/lib/gpu/geryon/ocl_device.h index 1847b0463b..e5efc239da 100644 --- a/lib/gpu/geryon/ocl_device.h +++ b/lib/gpu/geryon/ocl_device.h @@ -462,7 +462,6 @@ int UCL_Device::set_platform(int pid) { _num_devices = 0; for (int i=0; i 1) { - subdevice_list = new cl_device_id[num_subdevices]; + cl_device_id *subdevice_list = new cl_device_id[num_subdevices]; CL_SAFE_CALL(clCreateSubDevices(device_list[i], props, num_subdevices, subdevice_list, &num_subdevices)); + for (int j=0; j 1) delete[] subdevice_list; } // for i #endif diff --git a/lib/gpu/geryon/ocl_timer.h b/lib/gpu/geryon/ocl_timer.h index 71efe2d2c0..25b20beea5 100644 --- a/lib/gpu/geryon/ocl_timer.h +++ b/lib/gpu/geryon/ocl_timer.h @@ -38,8 +38,10 @@ namespace ucl_opencl { /// Class for timing OpenCL events class UCL_Timer { public: - inline UCL_Timer() : _total_time(0.0f), _initialized(false), has_measured_time(false) { } - inline UCL_Timer(UCL_Device &dev) : _total_time(0.0f), _initialized(false), has_measured_time(false) + inline UCL_Timer() : start_event(nullptr), stop_event(nullptr), _total_time(0.0f), + _initialized(false), has_measured_time(false) { } + inline UCL_Timer(UCL_Device &dev) : start_event(nullptr), stop_event(nullptr), _total_time(0.0f), + _initialized(false), has_measured_time(false) { init(dev); } inline ~UCL_Timer() { clear(); } diff --git a/lib/gpu/lal_answer.cpp b/lib/gpu/lal_answer.cpp index 4a68466d05..9b5c0beca1 100644 --- a/lib/gpu/lal_answer.cpp +++ b/lib/gpu/lal_answer.cpp @@ -23,7 +23,7 @@ namespace LAMMPS_AL { template AnswerT::Answer() : _allocated(false),_eflag(false),_vflag(false), - _inum(0),_ilist(nullptr),_newton(false) { + _inum(0),_ilist(nullptr),_newton(false) { } template diff --git a/lib/gpu/lal_answer.h b/lib/gpu/lal_answer.h index ae52e64f16..9b857d33b6 100644 --- a/lib/gpu/lal_answer.h +++ b/lib/gpu/lal_answer.h @@ -127,9 +127,8 @@ class Answer { /// Add forces and torques from the GPU into a LAMMPS pointer void get_answers(double **f, double **tor); - inline double get_answers(double **f, double **tor, double *eatom, - double **vatom, double *virial, double &ecoul, - int &error_flag_in) { + inline double get_answers(double **f, double **tor, double *eatom, double **vatom, + double *virial, double &ecoul, int &error_flag_in) { double ta=MPI_Wtime(); time_answer.sync_stop(); _time_cpu_idle+=MPI_Wtime()-ta; diff --git a/lib/gpu/lal_device.cpp b/lib/gpu/lal_device.cpp index e43e77a761..9dbd02dd3e 100644 --- a/lib/gpu/lal_device.cpp +++ b/lib/gpu/lal_device.cpp @@ -348,7 +348,7 @@ int DeviceT::init_device(MPI_Comm world, MPI_Comm replica, const int ngpu, } template -int DeviceT::set_ocl_params(std::string s_config, std::string extra_args) { +int DeviceT::set_ocl_params(std::string s_config, const std::string &extra_args) { #ifdef USE_OPENCL #include "lal_pre_ocl_config.h" @@ -368,7 +368,7 @@ int DeviceT::set_ocl_params(std::string s_config, std::string extra_args) { int token_count=0; std::string params[18]; char ocl_config[2048]; - strcpy(ocl_config,s_config.c_str()); + strncpy(ocl_config,s_config.c_str(),2047); char *pch = strtok(ocl_config,","); _ocl_config_name=pch; pch = strtok(nullptr,","); @@ -984,18 +984,16 @@ int DeviceT::compile_kernels() { _max_bio_shared_types=gpu_lib_data[17]; _pppm_max_spline=gpu_lib_data[18]; - if (static_cast(_block_pair)>gpu->group_size_dim(0) || - static_cast(_block_bio_pair)>gpu->group_size_dim(0) || - static_cast(_block_ellipse)>gpu->group_size_dim(0) || - static_cast(_pppm_block)>gpu->group_size_dim(0) || - static_cast(_block_nbor_build)>gpu->group_size_dim(0) || - static_cast(_block_cell_2d)>gpu->group_size_dim(0) || - static_cast(_block_cell_2d)>gpu->group_size_dim(1) || - static_cast(_block_cell_id)>gpu->group_size_dim(0) || - static_cast(_max_shared_types*_max_shared_types* - sizeof(numtyp)*17 > gpu->slm_size()) || - static_cast(_max_bio_shared_types*2*sizeof(numtyp) > - gpu->slm_size())) + if (static_cast(_block_pair) > gpu->group_size_dim(0) || + static_cast(_block_bio_pair) > gpu->group_size_dim(0) || + static_cast(_block_ellipse) > gpu->group_size_dim(0) || + static_cast(_pppm_block) > gpu->group_size_dim(0) || + static_cast(_block_nbor_build) > gpu->group_size_dim(0) || + static_cast(_block_cell_2d) > gpu->group_size_dim(0) || + static_cast(_block_cell_2d) > gpu->group_size_dim(1) || + static_cast(_block_cell_id) > gpu->group_size_dim(0) || + static_cast(_max_shared_types*_max_shared_types*sizeof(numtyp)*17 > gpu->slm_size()) || + static_cast(_max_bio_shared_types*2*sizeof(numtyp) > gpu->slm_size())) return -13; if (_block_pair % _simd_size != 0 || _block_bio_pair % _simd_size != 0 || @@ -1071,9 +1069,8 @@ void lmp_clear_device() { global_device.clear_device(); } -double lmp_gpu_forces(double **f, double **tor, double *eatom, - double **vatom, double *virial, double &ecoul, - int &error_flag) { +double lmp_gpu_forces(double **f, double **tor, double *eatom, double **vatom, + double *virial, double &ecoul, int &error_flag) { return global_device.fix_gpu(f,tor,eatom,vatom,virial,ecoul,error_flag); } diff --git a/lib/gpu/lal_device.h b/lib/gpu/lal_device.h index 933a3508b5..54fcf2f4e8 100644 --- a/lib/gpu/lal_device.h +++ b/lib/gpu/lal_device.h @@ -163,17 +163,15 @@ class Device { { ans_queue.push(ans); } /// Add "answers" (force,energies,etc.) into LAMMPS structures - inline double fix_gpu(double **f, double **tor, double *eatom, - double **vatom, double *virial, double &ecoul, - int &error_flag) { + inline double fix_gpu(double **f, double **tor, double *eatom, double **vatom, + double *virial, double &ecoul, int &error_flag) { error_flag=0; atom.data_unavail(); if (ans_queue.empty()==false) { stop_host_timer(); double evdw=0.0; while (ans_queue.empty()==false) { - evdw+=ans_queue.front()->get_answers(f,tor,eatom,vatom,virial,ecoul, - error_flag); + evdw += ans_queue.front()->get_answers(f,tor,eatom,vatom,virial,ecoul,error_flag); ans_queue.pop(); } return evdw; @@ -350,7 +348,7 @@ class Device { int _data_in_estimate, _data_out_estimate; std::string _ocl_config_name, _ocl_config_string, _ocl_compile_string; - int set_ocl_params(std::string, std::string); + int set_ocl_params(std::string, const std::string &); }; } diff --git a/lib/gpu/lal_neighbor.cpp b/lib/gpu/lal_neighbor.cpp index a0d2eaa8c3..36bf4765e2 100644 --- a/lib/gpu/lal_neighbor.cpp +++ b/lib/gpu/lal_neighbor.cpp @@ -39,7 +39,7 @@ bool Neighbor::init(NeighborShared *shared, const int inum, const int block_cell_2d, const int block_cell_id, const int block_nbor_build, const int threads_per_atom, const int simd_size, const bool time_device, - const std::string compile_flags, const bool ilist_map) { + const std::string &compile_flags, const bool ilist_map) { clear(); _ilist_map = ilist_map; @@ -743,7 +743,7 @@ void Neighbor::build_nbor_list(double **x, const int inum, const int host_inum, mn = _max_nbors; const numtyp i_cell_size=static_cast(1.0/_cell_size); const int neigh_block=_block_cell_id; - const int GX=(int)ceil((float)nall/neigh_block); + const int GX=(int)ceil((double)nall/neigh_block); const numtyp sublo0=static_cast(sublo[0]); const numtyp sublo1=static_cast(sublo[1]); const numtyp sublo2=static_cast(sublo[2]); diff --git a/lib/gpu/lal_neighbor.h b/lib/gpu/lal_neighbor.h index b9db9c8992..5b569f804a 100644 --- a/lib/gpu/lal_neighbor.h +++ b/lib/gpu/lal_neighbor.h @@ -71,7 +71,7 @@ class Neighbor { const int block_cell_2d, const int block_cell_id, const int block_nbor_build, const int threads_per_atom, const int simd_size, const bool time_device, - const std::string compile_flags, const bool ilist_map); + const std::string &compile_flags, const bool ilist_map); /// Set the cutoff+skin inline void set_cutoff(const double cutoff) { diff --git a/lib/gpu/lal_neighbor_shared.cpp b/lib/gpu/lal_neighbor_shared.cpp index e1c3f5ca68..ee5b675665 100644 --- a/lib/gpu/lal_neighbor_shared.cpp +++ b/lib/gpu/lal_neighbor_shared.cpp @@ -89,7 +89,7 @@ double NeighborShared::best_cell_size(const double subx, const double suby, } void NeighborShared::compile_kernels(UCL_Device &dev, const int gpu_nbor, - const std::string flags) { + const std::string &flags) { if (_compiled) return; diff --git a/lib/gpu/lal_neighbor_shared.h b/lib/gpu/lal_neighbor_shared.h index e574aaeaeb..317fdd7679 100644 --- a/lib/gpu/lal_neighbor_shared.h +++ b/lib/gpu/lal_neighbor_shared.h @@ -87,7 +87,7 @@ class NeighborShared { /// Compile kernels for neighbor lists void compile_kernels(UCL_Device &dev, const int gpu_nbor, - const std::string flags); + const std::string &flags); // ----------------------------- Kernels UCL_Program *nbor_program, *build_program; diff --git a/lib/gpu/lal_pppm.cpp b/lib/gpu/lal_pppm.cpp index 6e8fe237a6..8f95d38532 100644 --- a/lib/gpu/lal_pppm.cpp +++ b/lib/gpu/lal_pppm.cpp @@ -54,7 +54,7 @@ int PPPMT::bytes_per_atom() const { } template -grdtyp * PPPMT::init(const int nlocal, const int nall, FILE *_screen, +grdtyp *PPPMT::init(const int nlocal, const int nall, FILE *_screen, const int order, const int nxlo_out, const int nylo_out, const int nzlo_out, const int nxhi_out, const int nyhi_out, @@ -69,14 +69,14 @@ grdtyp * PPPMT::init(const int nlocal, const int nall, FILE *_screen, flag=device->init(*ans,nlocal,nall); if (flag!=0) - return 0; + return nullptr; if (sizeof(grdtyp)==sizeof(double) && device->double_precision()==false) { flag=-15; - return 0; + return nullptr; } if (device->ptx_arch()>0.0 && device->ptx_arch()<1.1) { flag=-4; - return 0; + return nullptr; } ucl_device=device->gpu; @@ -168,7 +168,7 @@ grdtyp * PPPMT::init(const int nlocal, const int nall, FILE *_screen, UCL_READ_WRITE)==UCL_SUCCESS); if (!success) { flag=-3; - return 0; + return nullptr; } error_flag.device.zero(); @@ -342,13 +342,15 @@ void PPPMT::interp(const grdtyp qqrd2e_scale) { vd_brick.update_device(true); time_in.stop(); + int ainum=this->ans->inum(); + if (ainum==0) + return; + time_interp.start(); // Compute the block size and grid size to keep all cores busy int BX=this->block_size(); int GX=static_cast(ceil(static_cast(this->ans->inum())/BX)); - int ainum=this->ans->inum(); - k_interp.set_size(GX,BX); k_interp.run(&atom->x, &atom->q, &ainum, &vd_brick, &d_rho_coeff, &_npts_x, &_npts_yx, &_brick_x, &_brick_y, &_brick_z, &_delxinv, diff --git a/python/lammps/numpy_wrapper.py b/python/lammps/numpy_wrapper.py index 2f0f74594e..20ec85d001 100644 --- a/python/lammps/numpy_wrapper.py +++ b/python/lammps/numpy_wrapper.py @@ -92,8 +92,12 @@ class numpy_wrapper: if dim == LAMMPS_AUTODETECT: if dtype in (LAMMPS_INT_2D, LAMMPS_DOUBLE_2D, LAMMPS_INT64_2D): # TODO add other fields - if name in ("x", "v", "f", "angmom", "torque", "csforce", "vforce"): + if name in ("x", "v", "f", "x0", "omega", "angmom", "torque", "vforce", "vest"): dim = 3 + elif name == "smd_data_9": + dim = 9 + elif name == "smd_stress": + dim = 6 else: dim = 2 else: @@ -386,6 +390,9 @@ class numpy_wrapper: # ------------------------------------------------------------------------- def iarray(self, c_int_type, raw_ptr, nelem, dim=1): + if raw_ptr is None: + return None + import numpy as np np_int_type = self._ctype_to_numpy_int(c_int_type) @@ -405,7 +412,11 @@ class numpy_wrapper: # ------------------------------------------------------------------------- def darray(self, raw_ptr, nelem, dim=1): + if raw_ptr is None: + return None + import numpy as np + if dim == 1: ptr = cast(raw_ptr, POINTER(c_double * nelem)) else: diff --git a/src/ASPHERE/pair_line_lj.cpp b/src/ASPHERE/pair_line_lj.cpp index c8a3e04dca..07b3ea4e9f 100644 --- a/src/ASPHERE/pair_line_lj.cpp +++ b/src/ASPHERE/pair_line_lj.cpp @@ -301,8 +301,7 @@ void PairLineLJ::compute(int eflag, int vflag) } } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } diff --git a/src/ASPHERE/pair_tri_lj.cpp b/src/ASPHERE/pair_tri_lj.cpp index 8585b5792b..6ed422f7a4 100644 --- a/src/ASPHERE/pair_tri_lj.cpp +++ b/src/ASPHERE/pair_tri_lj.cpp @@ -375,8 +375,7 @@ void PairTriLJ::compute(int eflag, int vflag) } } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } diff --git a/src/AWPMD/pair_awpmd_cut.cpp b/src/AWPMD/pair_awpmd_cut.cpp index aa740a15ed..682a0dd3d6 100644 --- a/src/AWPMD/pair_awpmd_cut.cpp +++ b/src/AWPMD/pair_awpmd_cut.cpp @@ -39,7 +39,6 @@ #include #include #include -#include using namespace LAMMPS_NS; diff --git a/src/BOCS/fix_bocs.cpp b/src/BOCS/fix_bocs.cpp index 89ff3d8e4e..a3ec4b6b56 100644 --- a/src/BOCS/fix_bocs.cpp +++ b/src/BOCS/fix_bocs.cpp @@ -37,7 +37,6 @@ #include #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/BODY/fix_wall_body_polygon.cpp b/src/BODY/fix_wall_body_polygon.cpp index ec506b15f0..e4d25e8489 100644 --- a/src/BODY/fix_wall_body_polygon.cpp +++ b/src/BODY/fix_wall_body_polygon.cpp @@ -337,8 +337,7 @@ void FixWallBodyPolygon::post_force(int /*vflag*/) num_contacts = 0; facc[0] = facc[1] = facc[2] = 0; - vertex_against_wall(i, wall_pos, x, f, torque, side, - contact_list, num_contacts, facc); + vertex_against_wall(i, wall_pos, x, f, torque, side, contact_list, num_contacts, facc); if (num_contacts >= 2) { diff --git a/src/BODY/pair_body_nparticle.cpp b/src/BODY/pair_body_nparticle.cpp index 8c7c671cb8..c3e146aff0 100644 --- a/src/BODY/pair_body_nparticle.cpp +++ b/src/BODY/pair_body_nparticle.cpp @@ -324,8 +324,7 @@ void PairBodyNparticle::compute(int eflag, int vflag) } } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } diff --git a/src/BODY/pair_body_rounded_polygon.cpp b/src/BODY/pair_body_rounded_polygon.cpp index 23a4da7f07..14f305e7d4 100644 --- a/src/BODY/pair_body_rounded_polygon.cpp +++ b/src/BODY/pair_body_rounded_polygon.cpp @@ -207,8 +207,7 @@ void PairBodyRoundedPolygon::compute(int eflag, int vflag) if (r > radi + radj + cut_inner) continue; if (npi == 1 && npj == 1) { - sphere_against_sphere(i, j, delx, dely, delz, rsq, - k_nij, k_naij, x, v, f, evflag); + sphere_against_sphere(i, j, delx, dely, delz, rsq, k_nij, k_naij, x, v, f, evflag); continue; } diff --git a/src/BROWNIAN/fix_brownian.cpp b/src/BROWNIAN/fix_brownian.cpp index b811ede721..4994b304e1 100644 --- a/src/BROWNIAN/fix_brownian.cpp +++ b/src/BROWNIAN/fix_brownian.cpp @@ -20,17 +20,11 @@ #include "fix_brownian.h" #include "atom.h" -#include "comm.h" #include "domain.h" #include "error.h" -#include "force.h" -#include "math_extra.h" -#include "memory.h" #include "random_mars.h" -#include "update.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/BROWNIAN/fix_brownian_asphere.cpp b/src/BROWNIAN/fix_brownian_asphere.cpp index fccc6b5040..c2904aea64 100644 --- a/src/BROWNIAN/fix_brownian_asphere.cpp +++ b/src/BROWNIAN/fix_brownian_asphere.cpp @@ -21,17 +21,10 @@ #include "atom.h" #include "atom_vec_ellipsoid.h" -#include "comm.h" #include "domain.h" #include "error.h" -#include "force.h" #include "math_extra.h" -#include "memory.h" #include "random_mars.h" -#include "update.h" - -#include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/BROWNIAN/fix_brownian_base.cpp b/src/BROWNIAN/fix_brownian_base.cpp index 0fa928bebf..369d36bf70 100644 --- a/src/BROWNIAN/fix_brownian_base.cpp +++ b/src/BROWNIAN/fix_brownian_base.cpp @@ -17,15 +17,12 @@ Contributing author: Sam Cameron (University of Bristol) ------------------------------------------------------------------------- */ -#include "fix_brownian.h" +#include "fix_brownian_base.h" -#include "atom.h" #include "comm.h" #include "domain.h" #include "error.h" #include "force.h" -#include "math_extra.h" -#include "memory.h" #include "random_mars.h" #include "update.h" diff --git a/src/BROWNIAN/fix_brownian_sphere.cpp b/src/BROWNIAN/fix_brownian_sphere.cpp index cf835dcdc1..c6664b18ef 100644 --- a/src/BROWNIAN/fix_brownian_sphere.cpp +++ b/src/BROWNIAN/fix_brownian_sphere.cpp @@ -20,17 +20,12 @@ #include "fix_brownian_sphere.h" #include "atom.h" -#include "comm.h" #include "domain.h" #include "error.h" -#include "force.h" #include "math_extra.h" -#include "memory.h" #include "random_mars.h" -#include "update.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/BROWNIAN/fix_propel_self.cpp b/src/BROWNIAN/fix_propel_self.cpp index f2ff366be4..ea7a3c6834 100644 --- a/src/BROWNIAN/fix_propel_self.cpp +++ b/src/BROWNIAN/fix_propel_self.cpp @@ -23,14 +23,11 @@ #include "atom.h" #include "atom_vec_ellipsoid.h" -#include "comm.h" #include "domain.h" #include "error.h" -#include "force.h" #include "math_extra.h" -#include "memory.h" -#include "update.h" +#include #include using namespace LAMMPS_NS; diff --git a/src/CG-DNA/atom_vec_oxdna.cpp b/src/CG-DNA/atom_vec_oxdna.cpp index 2da35b37b3..e1c99d7ca5 100644 --- a/src/CG-DNA/atom_vec_oxdna.cpp +++ b/src/CG-DNA/atom_vec_oxdna.cpp @@ -14,7 +14,6 @@ #include "atom_vec_oxdna.h" #include "atom.h" -#include "comm.h" #include "error.h" #include "force.h" diff --git a/src/CG-DNA/pair_oxdna_stk.cpp b/src/CG-DNA/pair_oxdna_stk.cpp index 2f1a0bf1b6..4980408986 100644 --- a/src/CG-DNA/pair_oxdna_stk.cpp +++ b/src/CG-DNA/pair_oxdna_stk.cpp @@ -19,7 +19,6 @@ #include "atom.h" #include "atom_vec_ellipsoid.h" -#include "atom_vec_oxdna.h" #include "comm.h" #include "error.h" #include "force.h" @@ -30,7 +29,6 @@ #include #include -#include using namespace LAMMPS_NS; using namespace MFOxdna; diff --git a/src/CG-DNA/pair_oxrna2_excv.cpp b/src/CG-DNA/pair_oxrna2_excv.cpp index 2c1e4ca89f..422c7e2d89 100644 --- a/src/CG-DNA/pair_oxrna2_excv.cpp +++ b/src/CG-DNA/pair_oxrna2_excv.cpp @@ -17,8 +17,6 @@ #include "pair_oxrna2_excv.h" -#include - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- diff --git a/src/CG-DNA/pair_oxrna2_stk.cpp b/src/CG-DNA/pair_oxrna2_stk.cpp index 4d733f53b5..18cd798fc7 100644 --- a/src/CG-DNA/pair_oxrna2_stk.cpp +++ b/src/CG-DNA/pair_oxrna2_stk.cpp @@ -19,7 +19,6 @@ #include "atom.h" #include "atom_vec_ellipsoid.h" -#include "atom_vec_oxdna.h" #include "comm.h" #include "error.h" #include "force.h" @@ -31,7 +30,6 @@ #include #include -#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/CG-SDK/pair_lj_sdk_coul_msm.cpp b/src/CG-SDK/pair_lj_sdk_coul_msm.cpp index b05f4043fb..fb7a1fdddc 100644 --- a/src/CG-SDK/pair_lj_sdk_coul_msm.cpp +++ b/src/CG-SDK/pair_lj_sdk_coul_msm.cpp @@ -18,13 +18,15 @@ ------------------------------------------------------------------------- */ #include "pair_lj_sdk_coul_msm.h" -#include -#include + #include "atom.h" +#include "error.h" #include "force.h" #include "kspace.h" #include "neigh_list.h" -#include "error.h" + +#include +#include #include "lj_sdk_common.h" diff --git a/src/CLASS2/dihedral_class2.cpp b/src/CLASS2/dihedral_class2.cpp index 13cfdc7550..7b5406a7e9 100644 --- a/src/CLASS2/dihedral_class2.cpp +++ b/src/CLASS2/dihedral_class2.cpp @@ -25,7 +25,6 @@ #include "math_const.h" #include "memory.h" #include "neighbor.h" -#include "update.h" #include #include diff --git a/src/CLASS2/improper_class2.cpp b/src/CLASS2/improper_class2.cpp index f9e4c7bee5..72e146f76d 100644 --- a/src/CLASS2/improper_class2.cpp +++ b/src/CLASS2/improper_class2.cpp @@ -25,7 +25,6 @@ #include "math_const.h" #include "memory.h" #include "neighbor.h" -#include "update.h" #include #include diff --git a/src/CLASS2/pair_lj_class2.cpp b/src/CLASS2/pair_lj_class2.cpp index 84e571436f..7762e261cd 100644 --- a/src/CLASS2/pair_lj_class2.cpp +++ b/src/CLASS2/pair_lj_class2.cpp @@ -397,8 +397,7 @@ void PairLJClass2::compute_outer(int eflag, int vflag) fpair = factor_lj*forcelj*r2inv; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } diff --git a/src/COLLOID/fix_wall_colloid.cpp b/src/COLLOID/fix_wall_colloid.cpp index b4441d94e4..6f6374e2ac 100644 --- a/src/COLLOID/fix_wall_colloid.cpp +++ b/src/COLLOID/fix_wall_colloid.cpp @@ -18,10 +18,11 @@ #include "fix_wall_colloid.h" -#include #include "atom.h" #include "error.h" +#include + using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/COLVARS/colvarproxy_lammps.cpp b/src/COLVARS/colvarproxy_lammps.cpp index b1c9877599..dd1f7eb06d 100644 --- a/src/COLVARS/colvarproxy_lammps.cpp +++ b/src/COLVARS/colvarproxy_lammps.cpp @@ -10,13 +10,6 @@ #include "colvarproxy_lammps.h" -#include -#include -#include -#include -#include -#include -#include #include "lammps.h" #include "error.h" @@ -26,6 +19,12 @@ #include "colvarmodule.h" #include "colvarproxy.h" +#include +#include +#include +#include +#include + #define HASH_FAIL -1 //////////////////////////////////////////////////////////////////////// diff --git a/src/COLVARS/colvarproxy_lammps.h b/src/COLVARS/colvarproxy_lammps.h index b7b2799802..e10838cc15 100644 --- a/src/COLVARS/colvarproxy_lammps.h +++ b/src/COLVARS/colvarproxy_lammps.h @@ -12,11 +12,6 @@ #include "colvarproxy_lammps_version.h" // IWYU pragma: export -#include -#include -#include -#include - #include "colvarmodule.h" #include "colvarproxy.h" #include "colvartypes.h" diff --git a/src/COLVARS/fix_colvars.cpp b/src/COLVARS/fix_colvars.cpp index 45e12951bb..5ee77768c6 100644 --- a/src/COLVARS/fix_colvars.cpp +++ b/src/COLVARS/fix_colvars.cpp @@ -44,7 +44,6 @@ #include #include #include -#include static const char colvars_pub[] = "fix colvars command:\n\n" @@ -1000,7 +999,7 @@ double FixColvars::compute_scalar() /* ---------------------------------------------------------------------- */ /* local memory usage. approximately. */ -double FixColvars::memory_usage(void) +double FixColvars::memory_usage() { double bytes = (double) (num_coords * (2*sizeof(int)+3*sizeof(double))); bytes += (double)(double) (nmax*size_one) + sizeof(this); diff --git a/src/COMPRESS/dump_atom_gz.cpp b/src/COMPRESS/dump_atom_gz.cpp index aab9be34e8..38229a71bb 100644 --- a/src/COMPRESS/dump_atom_gz.cpp +++ b/src/COMPRESS/dump_atom_gz.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -12,27 +11,25 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "domain.h" #include "dump_atom_gz.h" + +#include "domain.h" #include "error.h" +#include "file_writer.h" #include "update.h" #include using namespace LAMMPS_NS; -DumpAtomGZ::DumpAtomGZ(LAMMPS *lmp, int narg, char **arg) : - DumpAtom(lmp, narg, arg) +DumpAtomGZ::DumpAtomGZ(LAMMPS *lmp, int narg, char **arg) : DumpAtom(lmp, narg, arg) { - if (!compressed) - error->all(FLERR,"Dump atom/gz only writes compressed files"); + if (!compressed) error->all(FLERR, "Dump atom/gz only writes compressed files"); } /* ---------------------------------------------------------------------- */ -DumpAtomGZ::~DumpAtomGZ() -{ -} +DumpAtomGZ::~DumpAtomGZ() {} /* ---------------------------------------------------------------------- generic opening of a dump file @@ -55,16 +52,15 @@ void DumpAtomGZ::openfile() if (multifile) { char *filestar = filecurrent; filecurrent = new char[strlen(filestar) + 16]; - char *ptr = strchr(filestar,'*'); + char *ptr = strchr(filestar, '*'); *ptr = '\0'; if (padflag == 0) - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filestar,update->ntimestep,ptr+1); + sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar, update->ntimestep, ptr + 1); else { - char bif[8],pad[16]; - strcpy(bif,BIGINT_FORMAT); - sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); - sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1); + char bif[8], pad[16]; + strcpy(bif, BIGINT_FORMAT); + sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]); + sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1); } *ptr = '*'; if (maxfiles > 0) { @@ -94,7 +90,7 @@ void DumpAtomGZ::openfile() // delete string with timestep replaced - if (multifile) delete [] filecurrent; + if (multifile) delete[] filecurrent; } /* ---------------------------------------------------------------------- */ @@ -106,12 +102,10 @@ void DumpAtomGZ::write_header(bigint ndump) if ((multiproc) || (!multiproc && me == 0)) { if (unit_flag && !unit_count) { ++unit_count; - header = fmt::format("ITEM: UNITS\n{}\n",update->unit_style); + header = fmt::format("ITEM: UNITS\n{}\n", update->unit_style); } - if (time_flag) { - header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); - } + if (time_flag) { header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); } header += fmt::format("ITEM: TIMESTEP\n{}\n", update->ntimestep); header += fmt::format("ITEM: NUMBER OF ATOMS\n{}\n", ndump); @@ -145,14 +139,14 @@ void DumpAtomGZ::write_data(int n, double *mybuf) for (int i = 0; i < n; i++) { int written = 0; if (image_flag == 1) { - written = snprintf(vbuffer, VBUFFER_SIZE, format, - static_cast (mybuf[m]), static_cast (mybuf[m+1]), - mybuf[m+2],mybuf[m+3],mybuf[m+4], static_cast (mybuf[m+5]), - static_cast (mybuf[m+6]), static_cast (mybuf[m+7])); + written = snprintf(vbuffer, VBUFFER_SIZE, format, static_cast(mybuf[m]), + static_cast(mybuf[m + 1]), mybuf[m + 2], mybuf[m + 3], mybuf[m + 4], + static_cast(mybuf[m + 5]), static_cast(mybuf[m + 6]), + static_cast(mybuf[m + 7])); } else { - written = snprintf(vbuffer, VBUFFER_SIZE, format, - static_cast (mybuf[m]), static_cast (mybuf[m+1]), - mybuf[m+2],mybuf[m+3],mybuf[m+4]); + written = + snprintf(vbuffer, VBUFFER_SIZE, format, static_cast(mybuf[m]), + static_cast(mybuf[m + 1]), mybuf[m + 2], mybuf[m + 3], mybuf[m + 4]); } if (written > 0) { writer.write(vbuffer, written); @@ -174,9 +168,7 @@ void DumpAtomGZ::write() if (multifile) { writer.close(); } else { - if (flush_flag && writer.isopen()) { - writer.flush(); - } + if (flush_flag && writer.isopen()) { writer.flush(); } } } } @@ -188,14 +180,14 @@ int DumpAtomGZ::modify_param(int narg, char **arg) int consumed = DumpAtom::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); writer.setCompressionLevel(compression_level); return 2; } } catch (FileWriterException &e) { - error->one(FLERR,"Illegal dump_modify command: {}", e.what()); + error->one(FLERR, "Illegal dump_modify command: {}", e.what()); } } return consumed; diff --git a/src/COMPRESS/dump_atom_zstd.cpp b/src/COMPRESS/dump_atom_zstd.cpp index bb837fc7ef..aa9d14b324 100644 --- a/src/COMPRESS/dump_atom_zstd.cpp +++ b/src/COMPRESS/dump_atom_zstd.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -19,6 +18,7 @@ #ifdef LAMMPS_ZSTD #include "domain.h" + #include "dump_atom_zstd.h" #include "error.h" #include "file_writer.h" @@ -26,21 +26,16 @@ #include - using namespace LAMMPS_NS; -DumpAtomZstd::DumpAtomZstd(LAMMPS *lmp, int narg, char **arg) : - DumpAtom(lmp, narg, arg) +DumpAtomZstd::DumpAtomZstd(LAMMPS *lmp, int narg, char **arg) : DumpAtom(lmp, narg, arg) { - if (!compressed) - error->all(FLERR,"Dump atom/zstd only writes compressed files"); + if (!compressed) error->all(FLERR, "Dump atom/zstd only writes compressed files"); } /* ---------------------------------------------------------------------- */ -DumpAtomZstd::~DumpAtomZstd() -{ -} +DumpAtomZstd::~DumpAtomZstd() {} /* ---------------------------------------------------------------------- generic opening of a dump file @@ -63,16 +58,15 @@ void DumpAtomZstd::openfile() if (multifile) { char *filestar = filecurrent; filecurrent = new char[strlen(filestar) + 16]; - char *ptr = strchr(filestar,'*'); + char *ptr = strchr(filestar, '*'); *ptr = '\0'; if (padflag == 0) - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filestar,update->ntimestep,ptr+1); + sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar, update->ntimestep, ptr + 1); else { - char bif[8],pad[16]; - strcpy(bif,BIGINT_FORMAT); - sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); - sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1); + char bif[8], pad[16]; + strcpy(bif, BIGINT_FORMAT); + sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]); + sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1); } *ptr = '*'; if (maxfiles > 0) { @@ -102,7 +96,7 @@ void DumpAtomZstd::openfile() // delete string with timestep replaced - if (multifile) delete [] filecurrent; + if (multifile) delete[] filecurrent; } /* ---------------------------------------------------------------------- */ @@ -114,12 +108,10 @@ void DumpAtomZstd::write_header(bigint ndump) if ((multiproc) || (!multiproc && me == 0)) { if (unit_flag && !unit_count) { ++unit_count; - header = fmt::format("ITEM: UNITS\n{}\n",update->unit_style); + header = fmt::format("ITEM: UNITS\n{}\n", update->unit_style); } - if (time_flag) { - header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); - } + if (time_flag) { header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); } header += fmt::format("ITEM: TIMESTEP\n{}\n", update->ntimestep); header += fmt::format("ITEM: NUMBER OF ATOMS\n{}\n", ndump); @@ -153,14 +145,14 @@ void DumpAtomZstd::write_data(int n, double *mybuf) for (int i = 0; i < n; i++) { int written = 0; if (image_flag == 1) { - written = snprintf(vbuffer, VBUFFER_SIZE, format, - static_cast (mybuf[m]), static_cast (mybuf[m+1]), - mybuf[m+2],mybuf[m+3],mybuf[m+4], static_cast (mybuf[m+5]), - static_cast (mybuf[m+6]), static_cast (mybuf[m+7])); + written = snprintf(vbuffer, VBUFFER_SIZE, format, static_cast(mybuf[m]), + static_cast(mybuf[m + 1]), mybuf[m + 2], mybuf[m + 3], mybuf[m + 4], + static_cast(mybuf[m + 5]), static_cast(mybuf[m + 6]), + static_cast(mybuf[m + 7])); } else { - written = snprintf(vbuffer, VBUFFER_SIZE, format, - static_cast (mybuf[m]), static_cast (mybuf[m+1]), - mybuf[m+2],mybuf[m+3],mybuf[m+4]); + written = + snprintf(vbuffer, VBUFFER_SIZE, format, static_cast(mybuf[m]), + static_cast(mybuf[m + 1]), mybuf[m + 2], mybuf[m + 3], mybuf[m + 4]); } if (written > 0) { writer.write(vbuffer, written); @@ -182,9 +174,7 @@ void DumpAtomZstd::write() if (multifile) { writer.close(); } else { - if (flush_flag && writer.isopen()) { - writer.flush(); - } + if (flush_flag && writer.isopen()) { writer.flush(); } } } } @@ -196,20 +186,23 @@ int DumpAtomZstd::modify_param(int narg, char **arg) int consumed = DumpAtom::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"checksum") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) writer.setChecksum(true); - else if (strcmp(arg[1],"no") == 0) writer.setChecksum(false); - else error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "checksum") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); + if (strcmp(arg[1], "yes") == 0) + writer.setChecksum(true); + else if (strcmp(arg[1], "no") == 0) + writer.setChecksum(false); + else + error->all(FLERR, "Illegal dump_modify command"); return 2; - } else if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + } else if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); writer.setCompressionLevel(compression_level); return 2; } } catch (FileWriterException &e) { - error->one(FLERR,"Illegal dump_modify command: {}", e.what()); + error->one(FLERR, "Illegal dump_modify command: {}", e.what()); } } return consumed; diff --git a/src/COMPRESS/dump_cfg_gz.cpp b/src/COMPRESS/dump_cfg_gz.cpp index 37c4fb3536..ea51ce87c3 100644 --- a/src/COMPRESS/dump_cfg_gz.cpp +++ b/src/COMPRESS/dump_cfg_gz.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -12,10 +11,12 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ +#include "dump_cfg_gz.h" + #include "atom.h" #include "domain.h" -#include "dump_cfg_gz.h" #include "error.h" +#include "file_writer.h" #include "update.h" #include @@ -23,18 +24,14 @@ using namespace LAMMPS_NS; #define UNWRAPEXPAND 10.0 -DumpCFGGZ::DumpCFGGZ(LAMMPS *lmp, int narg, char **arg) : - DumpCFG(lmp, narg, arg) +DumpCFGGZ::DumpCFGGZ(LAMMPS *lmp, int narg, char **arg) : DumpCFG(lmp, narg, arg) { - if (!compressed) - error->all(FLERR,"Dump cfg/gz only writes compressed files"); + if (!compressed) error->all(FLERR, "Dump cfg/gz only writes compressed files"); } /* ---------------------------------------------------------------------- */ -DumpCFGGZ::~DumpCFGGZ() -{ -} +DumpCFGGZ::~DumpCFGGZ() {} /* ---------------------------------------------------------------------- generic opening of a dump file @@ -57,16 +54,15 @@ void DumpCFGGZ::openfile() if (multifile) { char *filestar = filecurrent; filecurrent = new char[strlen(filestar) + 16]; - char *ptr = strchr(filestar,'*'); + char *ptr = strchr(filestar, '*'); *ptr = '\0'; if (padflag == 0) - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filestar,update->ntimestep,ptr+1); + sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar, update->ntimestep, ptr + 1); else { - char bif[8],pad[16]; - strcpy(bif,BIGINT_FORMAT); - sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); - sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1); + char bif[8], pad[16]; + strcpy(bif, BIGINT_FORMAT); + sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]); + sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1); } *ptr = '*'; if (maxfiles > 0) { @@ -96,7 +92,7 @@ void DumpCFGGZ::openfile() // delete string with timestep replaced - if (multifile) delete [] filecurrent; + if (multifile) delete[] filecurrent; } /* ---------------------------------------------------------------------- */ @@ -111,24 +107,25 @@ void DumpCFGGZ::write_header(bigint n) // so molecules are not split across periodic box boundaries double scale = 1.0; - if (atom->peri_flag) scale = atom->pdscale; - else if (unwrapflag == 1) scale = UNWRAPEXPAND; + if (atom->peri_flag) + scale = atom->pdscale; + else if (unwrapflag == 1) + scale = UNWRAPEXPAND; std::string header = fmt::format("Number of particles = {}\n", n); header += fmt::format("A = {0:g} Angstrom (basic length-scale)\n", scale); - header += fmt::format("H0(1,1) = {0:g} A\n",domain->xprd); + header += fmt::format("H0(1,1) = {0:g} A\n", domain->xprd); header += fmt::format("H0(1,2) = 0 A \n"); header += fmt::format("H0(1,3) = 0 A \n"); - header += fmt::format("H0(2,1) = {0:g} A \n",domain->xy); - header += fmt::format("H0(2,2) = {0:g} A\n",domain->yprd); + header += fmt::format("H0(2,1) = {0:g} A \n", domain->xy); + header += fmt::format("H0(2,2) = {0:g} A\n", domain->yprd); header += fmt::format("H0(2,3) = 0 A \n"); - header += fmt::format("H0(3,1) = {0:g} A \n",domain->xz); - header += fmt::format("H0(3,2) = {0:g} A \n",domain->yz); - header += fmt::format("H0(3,3) = {0:g} A\n",domain->zprd); + header += fmt::format("H0(3,1) = {0:g} A \n", domain->xz); + header += fmt::format("H0(3,2) = {0:g} A \n", domain->yz); + header += fmt::format("H0(3,3) = {0:g} A\n", domain->zprd); header += fmt::format(".NO_VELOCITY.\n"); - header += fmt::format("entry_count = {}\n",nfield-2); - for (int i = 0; i < nfield-5; i++) - header += fmt::format("auxiliary[{}] = {}\n",i,auxname[i]); + header += fmt::format("entry_count = {}\n", nfield - 2); + for (int i = 0; i < nfield - 5; i++) header += fmt::format("auxiliary[{}] = {}\n", i, auxname[i]); writer.write(header.c_str(), header.length()); } @@ -153,13 +150,13 @@ void DumpCFGGZ::write_data(int n, double *mybuf) written = snprintf(vbuffer, VBUFFER_SIZE, "%s \n", typenames[(int) mybuf[m]]); } else if (j >= 2) { if (vtype[j] == Dump::INT) - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); else if (vtype[j] == Dump::DOUBLE) written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], mybuf[m]); else if (vtype[j] == Dump::STRING) written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], typenames[(int) mybuf[m]]); else if (vtype[j] == Dump::BIGINT) - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } if (written > 0) { writer.write(vbuffer, written); @@ -180,17 +177,17 @@ void DumpCFGGZ::write_data(int n, double *mybuf) } else if (j == 1) { written = snprintf(vbuffer, VBUFFER_SIZE, "%s \n", typenames[(int) mybuf[m]]); } else if (j >= 2 && j <= 4) { - double unwrap_coord = (mybuf[m] - 0.5)/UNWRAPEXPAND + 0.5; + double unwrap_coord = (mybuf[m] - 0.5) / UNWRAPEXPAND + 0.5; written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], unwrap_coord); } else if (j >= 5) { if (vtype[j] == Dump::INT) - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); else if (vtype[j] == Dump::DOUBLE) written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], mybuf[m]); else if (vtype[j] == Dump::STRING) written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], typenames[(int) mybuf[m]]); else if (vtype[j] == Dump::BIGINT) - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } if (written > 0) { writer.write(vbuffer, written); @@ -214,9 +211,7 @@ void DumpCFGGZ::write() if (multifile) { writer.close(); } else { - if (flush_flag && writer.isopen()) { - writer.flush(); - } + if (flush_flag && writer.isopen()) { writer.flush(); } } } } @@ -228,14 +223,14 @@ int DumpCFGGZ::modify_param(int narg, char **arg) int consumed = DumpCFG::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); writer.setCompressionLevel(compression_level); return 2; } } catch (FileWriterException &e) { - error->one(FLERR,"Illegal dump_modify command: {}", e.what()); + error->one(FLERR, "Illegal dump_modify command: {}", e.what()); } } return consumed; diff --git a/src/COMPRESS/dump_cfg_zstd.cpp b/src/COMPRESS/dump_cfg_zstd.cpp index eb725491bb..15ea1e540c 100644 --- a/src/COMPRESS/dump_cfg_zstd.cpp +++ b/src/COMPRESS/dump_cfg_zstd.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -18,10 +17,12 @@ #ifdef LAMMPS_ZSTD +#include "dump_cfg_zstd.h" + #include "atom.h" #include "domain.h" -#include "dump_cfg_zstd.h" #include "error.h" +#include "file_writer.h" #include "update.h" #include @@ -29,20 +30,14 @@ using namespace LAMMPS_NS; #define UNWRAPEXPAND 10.0 -DumpCFGZstd::DumpCFGZstd(LAMMPS *lmp, int narg, char **arg) : - DumpCFG(lmp, narg, arg) +DumpCFGZstd::DumpCFGZstd(LAMMPS *lmp, int narg, char **arg) : DumpCFG(lmp, narg, arg) { - if (!compressed) - error->all(FLERR,"Dump cfg/zstd only writes compressed files"); + if (!compressed) error->all(FLERR, "Dump cfg/zstd only writes compressed files"); } - /* ---------------------------------------------------------------------- */ -DumpCFGZstd::~DumpCFGZstd() -{ -} - +DumpCFGZstd::~DumpCFGZstd() {} /* ---------------------------------------------------------------------- generic opening of a dump file @@ -65,16 +60,15 @@ void DumpCFGZstd::openfile() if (multifile) { char *filestar = filecurrent; filecurrent = new char[strlen(filestar) + 16]; - char *ptr = strchr(filestar,'*'); + char *ptr = strchr(filestar, '*'); *ptr = '\0'; if (padflag == 0) - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filestar,update->ntimestep,ptr+1); + sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar, update->ntimestep, ptr + 1); else { - char bif[8],pad[16]; - strcpy(bif,BIGINT_FORMAT); - sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); - sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1); + char bif[8], pad[16]; + strcpy(bif, BIGINT_FORMAT); + sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]); + sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1); } *ptr = '*'; if (maxfiles > 0) { @@ -95,9 +89,7 @@ void DumpCFGZstd::openfile() // each proc with filewriter = 1 opens a file if (filewriter) { - if (append_flag) { - error->one(FLERR, "dump cfg/zstd currently doesn't support append"); - } + if (append_flag) { error->one(FLERR, "dump cfg/zstd currently doesn't support append"); } try { writer.open(filecurrent); @@ -108,7 +100,7 @@ void DumpCFGZstd::openfile() // delete string with timestep replaced - if (multifile) delete [] filecurrent; + if (multifile) delete[] filecurrent; } /* ---------------------------------------------------------------------- */ @@ -123,24 +115,25 @@ void DumpCFGZstd::write_header(bigint n) // so molecules are not split across periodic box boundaries double scale = 1.0; - if (atom->peri_flag) scale = atom->pdscale; - else if (unwrapflag == 1) scale = UNWRAPEXPAND; + if (atom->peri_flag) + scale = atom->pdscale; + else if (unwrapflag == 1) + scale = UNWRAPEXPAND; std::string header = fmt::format("Number of particles = {}\n", n); header += fmt::format("A = {0:g} Angstrom (basic length-scale)\n", scale); - header += fmt::format("H0(1,1) = {0:g} A\n",domain->xprd); + header += fmt::format("H0(1,1) = {0:g} A\n", domain->xprd); header += fmt::format("H0(1,2) = 0 A \n"); header += fmt::format("H0(1,3) = 0 A \n"); - header += fmt::format("H0(2,1) = {0:g} A \n",domain->xy); - header += fmt::format("H0(2,2) = {0:g} A\n",domain->yprd); + header += fmt::format("H0(2,1) = {0:g} A \n", domain->xy); + header += fmt::format("H0(2,2) = {0:g} A\n", domain->yprd); header += fmt::format("H0(2,3) = 0 A \n"); - header += fmt::format("H0(3,1) = {0:g} A \n",domain->xz); - header += fmt::format("H0(3,2) = {0:g} A \n",domain->yz); - header += fmt::format("H0(3,3) = {0:g} A\n",domain->zprd); + header += fmt::format("H0(3,1) = {0:g} A \n", domain->xz); + header += fmt::format("H0(3,2) = {0:g} A \n", domain->yz); + header += fmt::format("H0(3,3) = {0:g} A\n", domain->zprd); header += fmt::format(".NO_VELOCITY.\n"); - header += fmt::format("entry_count = {}\n",nfield-2); - for (int i = 0; i < nfield-5; i++) - header += fmt::format("auxiliary[{}] = {}\n",i,auxname[i]); + header += fmt::format("entry_count = {}\n", nfield - 2); + for (int i = 0; i < nfield - 5; i++) header += fmt::format("auxiliary[{}] = {}\n", i, auxname[i]); writer.write(header.c_str(), header.length()); } @@ -165,13 +158,13 @@ void DumpCFGZstd::write_data(int n, double *mybuf) written = snprintf(vbuffer, VBUFFER_SIZE, "%s \n", typenames[(int) mybuf[m]]); } else if (j >= 2) { if (vtype[j] == Dump::INT) - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); else if (vtype[j] == Dump::DOUBLE) written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], mybuf[m]); else if (vtype[j] == Dump::STRING) written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], typenames[(int) mybuf[m]]); else if (vtype[j] == Dump::BIGINT) - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } if (written > 0) { writer.write(vbuffer, written); @@ -192,17 +185,17 @@ void DumpCFGZstd::write_data(int n, double *mybuf) } else if (j == 1) { written = snprintf(vbuffer, VBUFFER_SIZE, "%s \n", typenames[(int) mybuf[m]]); } else if (j >= 2 && j <= 4) { - double unwrap_coord = (mybuf[m] - 0.5)/UNWRAPEXPAND + 0.5; + double unwrap_coord = (mybuf[m] - 0.5) / UNWRAPEXPAND + 0.5; written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], unwrap_coord); } else if (j >= 5) { if (vtype[j] == Dump::INT) - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); else if (vtype[j] == Dump::DOUBLE) written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], mybuf[m]); else if (vtype[j] == Dump::STRING) written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], typenames[(int) mybuf[m]]); else if (vtype[j] == Dump::BIGINT) - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } if (written > 0) { writer.write(vbuffer, written); @@ -226,9 +219,7 @@ void DumpCFGZstd::write() if (multifile) { writer.close(); } else { - if (flush_flag && writer.isopen()) { - writer.flush(); - } + if (flush_flag && writer.isopen()) { writer.flush(); } } } } @@ -240,14 +231,17 @@ int DumpCFGZstd::modify_param(int narg, char **arg) int consumed = DumpCFG::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"checksum") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) writer.setChecksum(true); - else if (strcmp(arg[1],"no") == 0) writer.setChecksum(false); - else error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "checksum") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); + if (strcmp(arg[1], "yes") == 0) + writer.setChecksum(true); + else if (strcmp(arg[1], "no") == 0) + writer.setChecksum(false); + else + error->all(FLERR, "Illegal dump_modify command"); return 2; - } else if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + } else if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); writer.setCompressionLevel(compression_level); return 2; diff --git a/src/COMPRESS/dump_custom_gz.cpp b/src/COMPRESS/dump_custom_gz.cpp index 3fa9fb4516..7cbab10cb4 100644 --- a/src/COMPRESS/dump_custom_gz.cpp +++ b/src/COMPRESS/dump_custom_gz.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -12,27 +11,25 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "domain.h" #include "dump_custom_gz.h" + +#include "domain.h" #include "error.h" +#include "file_writer.h" #include "update.h" #include using namespace LAMMPS_NS; -DumpCustomGZ::DumpCustomGZ(LAMMPS *lmp, int narg, char **arg) : - DumpCustom(lmp, narg, arg) +DumpCustomGZ::DumpCustomGZ(LAMMPS *lmp, int narg, char **arg) : DumpCustom(lmp, narg, arg) { - if (!compressed) - error->all(FLERR,"Dump custom/gz only writes compressed files"); + if (!compressed) error->all(FLERR, "Dump custom/gz only writes compressed files"); } /* ---------------------------------------------------------------------- */ -DumpCustomGZ::~DumpCustomGZ() -{ -} +DumpCustomGZ::~DumpCustomGZ() {} /* ---------------------------------------------------------------------- generic opening of a dump file @@ -55,16 +52,15 @@ void DumpCustomGZ::openfile() if (multifile) { char *filestar = filecurrent; filecurrent = new char[strlen(filestar) + 16]; - char *ptr = strchr(filestar,'*'); + char *ptr = strchr(filestar, '*'); *ptr = '\0'; if (padflag == 0) - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filestar,update->ntimestep,ptr+1); + sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar, update->ntimestep, ptr + 1); else { - char bif[8],pad[16]; - strcpy(bif,BIGINT_FORMAT); - sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); - sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1); + char bif[8], pad[16]; + strcpy(bif, BIGINT_FORMAT); + sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]); + sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1); } *ptr = '*'; if (maxfiles > 0) { @@ -94,7 +90,7 @@ void DumpCustomGZ::openfile() // delete string with timestep replaced - if (multifile) delete [] filecurrent; + if (multifile) delete[] filecurrent; } void DumpCustomGZ::write_header(bigint ndump) @@ -104,12 +100,10 @@ void DumpCustomGZ::write_header(bigint ndump) if ((multiproc) || (!multiproc && me == 0)) { if (unit_flag && !unit_count) { ++unit_count; - header = fmt::format("ITEM: UNITS\n{}\n",update->unit_style); + header = fmt::format("ITEM: UNITS\n{}\n", update->unit_style); } - if (time_flag) { - header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); - } + if (time_flag) { header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); } header += fmt::format("ITEM: TIMESTEP\n{}\n", update->ntimestep); header += fmt::format("ITEM: NUMBER OF ATOMS\n{}\n", ndump); @@ -144,13 +138,13 @@ void DumpCustomGZ::write_data(int n, double *mybuf) for (int j = 0; j < nfield; j++) { int written = 0; if (vtype[j] == Dump::INT) { - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } else if (vtype[j] == Dump::DOUBLE) { written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], mybuf[m]); } else if (vtype[j] == Dump::STRING) { written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], typenames[(int) mybuf[m]]); } else if (vtype[j] == Dump::BIGINT) { - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } if (written > 0) { @@ -174,9 +168,7 @@ void DumpCustomGZ::write() if (multifile) { writer.close(); } else { - if (flush_flag && writer.isopen()) { - writer.flush(); - } + if (flush_flag && writer.isopen()) { writer.flush(); } } } } @@ -188,14 +180,14 @@ int DumpCustomGZ::modify_param(int narg, char **arg) int consumed = DumpCustom::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); writer.setCompressionLevel(compression_level); return 2; } } catch (FileWriterException &e) { - error->one(FLERR,"Illegal dump_modify command: {}", e.what()); + error->one(FLERR, "Illegal dump_modify command: {}", e.what()); } } return consumed; diff --git a/src/COMPRESS/dump_custom_zstd.cpp b/src/COMPRESS/dump_custom_zstd.cpp index 9580644567..3824709d5e 100644 --- a/src/COMPRESS/dump_custom_zstd.cpp +++ b/src/COMPRESS/dump_custom_zstd.cpp @@ -18,8 +18,10 @@ #ifdef LAMMPS_ZSTD -#include "domain.h" #include "dump_custom_zstd.h" + +#include "file_writer.h" +#include "domain.h" #include "error.h" #include "update.h" diff --git a/src/COMPRESS/dump_custom_zstd.h b/src/COMPRESS/dump_custom_zstd.h index fb8c7c7543..a687cfb928 100644 --- a/src/COMPRESS/dump_custom_zstd.h +++ b/src/COMPRESS/dump_custom_zstd.h @@ -28,7 +28,6 @@ DumpStyle(custom/zstd,DumpCustomZstd); #include "dump_custom.h" #include "zstd_file_writer.h" -#include namespace LAMMPS_NS { diff --git a/src/COMPRESS/dump_local_gz.cpp b/src/COMPRESS/dump_local_gz.cpp index 4d5faeeb9e..206e2aeb09 100644 --- a/src/COMPRESS/dump_local_gz.cpp +++ b/src/COMPRESS/dump_local_gz.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -12,27 +11,25 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "domain.h" #include "dump_local_gz.h" + +#include "domain.h" #include "error.h" +#include "file_writer.h" #include "update.h" #include using namespace LAMMPS_NS; -DumpLocalGZ::DumpLocalGZ(LAMMPS *lmp, int narg, char **arg) : - DumpLocal(lmp, narg, arg) +DumpLocalGZ::DumpLocalGZ(LAMMPS *lmp, int narg, char **arg) : DumpLocal(lmp, narg, arg) { - if (!compressed) - error->all(FLERR,"Dump local/gz only writes compressed files"); + if (!compressed) error->all(FLERR, "Dump local/gz only writes compressed files"); } /* ---------------------------------------------------------------------- */ -DumpLocalGZ::~DumpLocalGZ() -{ -} +DumpLocalGZ::~DumpLocalGZ() {} /* ---------------------------------------------------------------------- generic opening of a dump file @@ -55,16 +52,15 @@ void DumpLocalGZ::openfile() if (multifile) { char *filestar = filecurrent; filecurrent = new char[strlen(filestar) + 16]; - char *ptr = strchr(filestar,'*'); + char *ptr = strchr(filestar, '*'); *ptr = '\0'; if (padflag == 0) - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filestar,update->ntimestep,ptr+1); + sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar, update->ntimestep, ptr + 1); else { - char bif[8],pad[16]; - strcpy(bif,BIGINT_FORMAT); - sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); - sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1); + char bif[8], pad[16]; + strcpy(bif, BIGINT_FORMAT); + sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]); + sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1); } *ptr = '*'; if (maxfiles > 0) { @@ -94,7 +90,7 @@ void DumpLocalGZ::openfile() // delete string with timestep replaced - if (multifile) delete [] filecurrent; + if (multifile) delete[] filecurrent; } void DumpLocalGZ::write_header(bigint ndump) @@ -104,12 +100,10 @@ void DumpLocalGZ::write_header(bigint ndump) if ((multiproc) || (!multiproc && me == 0)) { if (unit_flag && !unit_count) { ++unit_count; - header = fmt::format("ITEM: UNITS\n{}\n",update->unit_style); + header = fmt::format("ITEM: UNITS\n{}\n", update->unit_style); } - if (time_flag) { - header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); - } + if (time_flag) { header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); } header += fmt::format("ITEM: TIMESTEP\n{}\n", update->ntimestep); header += fmt::format("ITEM: NUMBER OF {}\n{}\n", label, ndump); @@ -135,7 +129,7 @@ void DumpLocalGZ::write_header(bigint ndump) void DumpLocalGZ::write_data(int n, double *mybuf) { if (buffer_flag == 1) { - writer.write(mybuf, sizeof(char)*n); + writer.write(mybuf, sizeof(char) * n); } else { constexpr size_t VBUFFER_SIZE = 256; char vbuffer[VBUFFER_SIZE]; @@ -144,11 +138,11 @@ void DumpLocalGZ::write_data(int n, double *mybuf) for (int j = 0; j < size_one; j++) { int written = 0; if (vtype[j] == Dump::INT) { - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } else if (vtype[j] == Dump::DOUBLE) { written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], mybuf[m]); } else if (vtype[j] == Dump::BIGINT) { - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } else { written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], mybuf[m]); } @@ -174,9 +168,7 @@ void DumpLocalGZ::write() if (multifile) { writer.close(); } else { - if (flush_flag && writer.isopen()) { - writer.flush(); - } + if (flush_flag && writer.isopen()) { writer.flush(); } } } } @@ -188,14 +180,14 @@ int DumpLocalGZ::modify_param(int narg, char **arg) int consumed = DumpLocal::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); writer.setCompressionLevel(compression_level); return 2; } } catch (FileWriterException &e) { - error->one(FLERR,"Illegal dump_modify command: {}", e.what()); + error->one(FLERR, "Illegal dump_modify command: {}", e.what()); } } return consumed; diff --git a/src/COMPRESS/dump_local_zstd.cpp b/src/COMPRESS/dump_local_zstd.cpp index 4f386a8231..cf233aff19 100644 --- a/src/COMPRESS/dump_local_zstd.cpp +++ b/src/COMPRESS/dump_local_zstd.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -18,28 +17,25 @@ #ifdef LAMMPS_ZSTD -#include "domain.h" #include "dump_local_zstd.h" + +#include "domain.h" #include "error.h" +#include "file_writer.h" #include "update.h" #include using namespace LAMMPS_NS; -DumpLocalZstd::DumpLocalZstd(LAMMPS *lmp, int narg, char **arg) : - DumpLocal(lmp, narg, arg) +DumpLocalZstd::DumpLocalZstd(LAMMPS *lmp, int narg, char **arg) : DumpLocal(lmp, narg, arg) { - if (!compressed) - error->all(FLERR,"Dump local/zstd only writes compressed files"); + if (!compressed) error->all(FLERR, "Dump local/zstd only writes compressed files"); } - /* ---------------------------------------------------------------------- */ -DumpLocalZstd::~DumpLocalZstd() -{ -} +DumpLocalZstd::~DumpLocalZstd() {} /* ---------------------------------------------------------------------- generic opening of a dump file @@ -62,16 +58,15 @@ void DumpLocalZstd::openfile() if (multifile) { char *filestar = filecurrent; filecurrent = new char[strlen(filestar) + 16]; - char *ptr = strchr(filestar,'*'); + char *ptr = strchr(filestar, '*'); *ptr = '\0'; if (padflag == 0) - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filestar,update->ntimestep,ptr+1); + sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar, update->ntimestep, ptr + 1); else { - char bif[8],pad[16]; - strcpy(bif,BIGINT_FORMAT); - sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); - sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1); + char bif[8], pad[16]; + strcpy(bif, BIGINT_FORMAT); + sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]); + sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1); } *ptr = '*'; if (maxfiles > 0) { @@ -92,9 +87,7 @@ void DumpLocalZstd::openfile() // each proc with filewriter = 1 opens a file if (filewriter) { - if (append_flag) { - error->one(FLERR, "dump cfg/zstd currently doesn't support append"); - } + if (append_flag) { error->one(FLERR, "dump cfg/zstd currently doesn't support append"); } try { writer.open(filecurrent); @@ -105,7 +98,7 @@ void DumpLocalZstd::openfile() // delete string with timestep replaced - if (multifile) delete [] filecurrent; + if (multifile) delete[] filecurrent; } void DumpLocalZstd::write_header(bigint ndump) @@ -115,12 +108,10 @@ void DumpLocalZstd::write_header(bigint ndump) if ((multiproc) || (!multiproc && me == 0)) { if (unit_flag && !unit_count) { ++unit_count; - header = fmt::format("ITEM: UNITS\n{}\n",update->unit_style); + header = fmt::format("ITEM: UNITS\n{}\n", update->unit_style); } - if (time_flag) { - header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); - } + if (time_flag) { header += fmt::format("ITEM: TIME\n{0:.16g}\n", compute_time()); } header += fmt::format("ITEM: TIMESTEP\n{}\n", update->ntimestep); header += fmt::format("ITEM: NUMBER OF {}\n{}\n", label, ndump); @@ -146,7 +137,7 @@ void DumpLocalZstd::write_header(bigint ndump) void DumpLocalZstd::write_data(int n, double *mybuf) { if (buffer_flag == 1) { - writer.write(mybuf, sizeof(char)*n); + writer.write(mybuf, sizeof(char) * n); } else { constexpr size_t VBUFFER_SIZE = 256; char vbuffer[VBUFFER_SIZE]; @@ -155,11 +146,11 @@ void DumpLocalZstd::write_data(int n, double *mybuf) for (int j = 0; j < size_one; j++) { int written = 0; if (vtype[j] == Dump::INT) { - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } else if (vtype[j] == Dump::DOUBLE) { written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], mybuf[m]); } else if (vtype[j] == Dump::BIGINT) { - written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast (mybuf[m])); + written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], static_cast(mybuf[m])); } else { written = snprintf(vbuffer, VBUFFER_SIZE, vformat[j], mybuf[m]); } @@ -185,9 +176,7 @@ void DumpLocalZstd::write() if (multifile) { writer.close(); } else { - if (flush_flag && writer.isopen()) { - writer.flush(); - } + if (flush_flag && writer.isopen()) { writer.flush(); } } } } @@ -199,20 +188,23 @@ int DumpLocalZstd::modify_param(int narg, char **arg) int consumed = DumpLocal::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"checksum") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) writer.setChecksum(true); - else if (strcmp(arg[1],"no") == 0) writer.setChecksum(false); - else error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "checksum") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); + if (strcmp(arg[1], "yes") == 0) + writer.setChecksum(true); + else if (strcmp(arg[1], "no") == 0) + writer.setChecksum(false); + else + error->all(FLERR, "Illegal dump_modify command"); return 2; - } else if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + } else if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); writer.setCompressionLevel(compression_level); return 2; } } catch (FileWriterException &e) { - error->one(FLERR,"Illegal dump_modify command: {}", e.what()); + error->one(FLERR, "Illegal dump_modify command: {}", e.what()); } } return consumed; diff --git a/src/COMPRESS/dump_xyz_gz.cpp b/src/COMPRESS/dump_xyz_gz.cpp index ac4efebe4b..a1acad7fc2 100644 --- a/src/COMPRESS/dump_xyz_gz.cpp +++ b/src/COMPRESS/dump_xyz_gz.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -13,26 +12,23 @@ ------------------------------------------------------------------------- */ #include "dump_xyz_gz.h" + #include "error.h" +#include "file_writer.h" #include "update.h" #include using namespace LAMMPS_NS; -DumpXYZGZ::DumpXYZGZ(LAMMPS *lmp, int narg, char **arg) : - DumpXYZ(lmp, narg, arg) +DumpXYZGZ::DumpXYZGZ(LAMMPS *lmp, int narg, char **arg) : DumpXYZ(lmp, narg, arg) { - if (!compressed) - error->all(FLERR,"Dump xyz/gz only writes compressed files"); + if (!compressed) error->all(FLERR, "Dump xyz/gz only writes compressed files"); } - /* ---------------------------------------------------------------------- */ -DumpXYZGZ::~DumpXYZGZ() -{ -} +DumpXYZGZ::~DumpXYZGZ() {} /* ---------------------------------------------------------------------- generic opening of a dump file @@ -55,16 +51,15 @@ void DumpXYZGZ::openfile() if (multifile) { char *filestar = filecurrent; filecurrent = new char[strlen(filestar) + 16]; - char *ptr = strchr(filestar,'*'); + char *ptr = strchr(filestar, '*'); *ptr = '\0'; if (padflag == 0) - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filestar,update->ntimestep,ptr+1); + sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar, update->ntimestep, ptr + 1); else { - char bif[8],pad[16]; - strcpy(bif,BIGINT_FORMAT); - sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); - sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1); + char bif[8], pad[16]; + strcpy(bif, BIGINT_FORMAT); + sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]); + sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1); } *ptr = '*'; if (maxfiles > 0) { @@ -94,7 +89,7 @@ void DumpXYZGZ::openfile() // delete string with timestep replaced - if (multifile) delete [] filecurrent; + if (multifile) delete[] filecurrent; } void DumpXYZGZ::write_header(bigint ndump) @@ -117,9 +112,9 @@ void DumpXYZGZ::write_data(int n, double *mybuf) char vbuffer[VBUFFER_SIZE]; int m = 0; for (int i = 0; i < n; i++) { - int written = snprintf(vbuffer, VBUFFER_SIZE, format, - typenames[static_cast (mybuf[m+1])], - mybuf[m+2],mybuf[m+3],mybuf[m+4]); + int written = + snprintf(vbuffer, VBUFFER_SIZE, format, typenames[static_cast(mybuf[m + 1])], + mybuf[m + 2], mybuf[m + 3], mybuf[m + 4]); if (written > 0) { writer.write(vbuffer, written); } else if (written < 0) { @@ -139,9 +134,7 @@ void DumpXYZGZ::write() if (multifile) { writer.close(); } else { - if (flush_flag && writer.isopen()) { - writer.flush(); - } + if (flush_flag && writer.isopen()) { writer.flush(); } } } } @@ -153,14 +146,14 @@ int DumpXYZGZ::modify_param(int narg, char **arg) int consumed = DumpXYZ::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); writer.setCompressionLevel(compression_level); return 2; } } catch (FileWriterException &e) { - error->one(FLERR,"Illegal dump_modify command: {}", e.what()); + error->one(FLERR, "Illegal dump_modify command: {}", e.what()); } } return consumed; diff --git a/src/COMPRESS/dump_xyz_zstd.cpp b/src/COMPRESS/dump_xyz_zstd.cpp index f1ca6586d4..d5c79d181b 100644 --- a/src/COMPRESS/dump_xyz_zstd.cpp +++ b/src/COMPRESS/dump_xyz_zstd.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -19,27 +18,23 @@ #ifdef LAMMPS_ZSTD #include "dump_xyz_zstd.h" + #include "error.h" +#include "file_writer.h" #include "update.h" #include using namespace LAMMPS_NS; -DumpXYZZstd::DumpXYZZstd(LAMMPS *lmp, int narg, char **arg) : - DumpXYZ(lmp, narg, arg) +DumpXYZZstd::DumpXYZZstd(LAMMPS *lmp, int narg, char **arg) : DumpXYZ(lmp, narg, arg) { - if (!compressed) - error->all(FLERR,"Dump xyz/zstd only writes compressed files"); + if (!compressed) error->all(FLERR, "Dump xyz/zstd only writes compressed files"); } - /* ---------------------------------------------------------------------- */ -DumpXYZZstd::~DumpXYZZstd() -{ -} - +DumpXYZZstd::~DumpXYZZstd() {} /* ---------------------------------------------------------------------- generic opening of a dump file @@ -62,16 +57,15 @@ void DumpXYZZstd::openfile() if (multifile) { char *filestar = filecurrent; filecurrent = new char[strlen(filestar) + 16]; - char *ptr = strchr(filestar,'*'); + char *ptr = strchr(filestar, '*'); *ptr = '\0'; if (padflag == 0) - sprintf(filecurrent,"%s" BIGINT_FORMAT "%s", - filestar,update->ntimestep,ptr+1); + sprintf(filecurrent, "%s" BIGINT_FORMAT "%s", filestar, update->ntimestep, ptr + 1); else { - char bif[8],pad[16]; - strcpy(bif,BIGINT_FORMAT); - sprintf(pad,"%%s%%0%d%s%%s",padflag,&bif[1]); - sprintf(filecurrent,pad,filestar,update->ntimestep,ptr+1); + char bif[8], pad[16]; + strcpy(bif, BIGINT_FORMAT); + sprintf(pad, "%%s%%0%d%s%%s", padflag, &bif[1]); + sprintf(filecurrent, pad, filestar, update->ntimestep, ptr + 1); } *ptr = '*'; if (maxfiles > 0) { @@ -92,9 +86,7 @@ void DumpXYZZstd::openfile() // each proc with filewriter = 1 opens a file if (filewriter) { - if (append_flag) { - error->one(FLERR, "dump cfg/zstd currently doesn't support append"); - } + if (append_flag) { error->one(FLERR, "dump cfg/zstd currently doesn't support append"); } try { writer.open(filecurrent); @@ -105,7 +97,7 @@ void DumpXYZZstd::openfile() // delete string with timestep replaced - if (multifile) delete [] filecurrent; + if (multifile) delete[] filecurrent; } void DumpXYZZstd::write_header(bigint ndump) @@ -128,9 +120,9 @@ void DumpXYZZstd::write_data(int n, double *mybuf) char vbuffer[VBUFFER_SIZE]; int m = 0; for (int i = 0; i < n; i++) { - int written = snprintf(vbuffer, VBUFFER_SIZE, format, - typenames[static_cast (mybuf[m+1])], - mybuf[m+2],mybuf[m+3],mybuf[m+4]); + int written = + snprintf(vbuffer, VBUFFER_SIZE, format, typenames[static_cast(mybuf[m + 1])], + mybuf[m + 2], mybuf[m + 3], mybuf[m + 4]); if (written > 0) { writer.write(vbuffer, written); } else if (written < 0) { @@ -150,9 +142,7 @@ void DumpXYZZstd::write() if (multifile) { writer.close(); } else { - if (flush_flag && writer.isopen()) { - writer.flush(); - } + if (flush_flag && writer.isopen()) { writer.flush(); } } } } @@ -164,20 +154,23 @@ int DumpXYZZstd::modify_param(int narg, char **arg) int consumed = DumpXYZ::modify_param(narg, arg); if (consumed == 0) { try { - if (strcmp(arg[0],"checksum") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - if (strcmp(arg[1],"yes") == 0) writer.setChecksum(true); - else if (strcmp(arg[1],"no") == 0) writer.setChecksum(false); - else error->all(FLERR,"Illegal dump_modify command"); + if (strcmp(arg[0], "checksum") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); + if (strcmp(arg[1], "yes") == 0) + writer.setChecksum(true); + else if (strcmp(arg[1], "no") == 0) + writer.setChecksum(false); + else + error->all(FLERR, "Illegal dump_modify command"); return 2; - } else if (strcmp(arg[0],"compression_level") == 0) { - if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); + } else if (strcmp(arg[0], "compression_level") == 0) { + if (narg < 2) error->all(FLERR, "Illegal dump_modify command"); int compression_level = utils::inumeric(FLERR, arg[1], false, lmp); writer.setCompressionLevel(compression_level); return 2; } } catch (FileWriterException &e) { - error->one(FLERR,"Illegal dump_modify command: {}", e.what()); + error->one(FLERR, "Illegal dump_modify command: {}", e.what()); } } return consumed; diff --git a/src/COMPRESS/gz_file_writer.cpp b/src/COMPRESS/gz_file_writer.cpp index d56c389d60..cd02832cca 100644 --- a/src/COMPRESS/gz_file_writer.cpp +++ b/src/COMPRESS/gz_file_writer.cpp @@ -1,4 +1,3 @@ -// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -17,46 +16,41 @@ ------------------------------------------------------------------------- */ #include "gz_file_writer.h" -#include #include "fmt/format.h" +#include using namespace LAMMPS_NS; -GzFileWriter::GzFileWriter() : FileWriter(), - compression_level(Z_BEST_COMPRESSION), - gzFp(nullptr) -{ -} +GzFileWriter::GzFileWriter() : FileWriter(), compression_level(Z_BEST_COMPRESSION), gzFp(nullptr) {} /* ---------------------------------------------------------------------- */ GzFileWriter::~GzFileWriter() { - close(); + GzFileWriter::close(); } /* ---------------------------------------------------------------------- */ void GzFileWriter::open(const std::string &path, bool append) { - if (isopen()) return; + if (isopen()) return; - std::string mode; - if (append) { - mode = fmt::format("ab{}", mode, compression_level); - } else { - mode = fmt::format("wb{}", mode, compression_level); - } + std::string mode; + if (append) { + mode = fmt::format("ab{}", mode, compression_level); + } else { + mode = fmt::format("wb{}", mode, compression_level); + } - gzFp = gzopen(path.c_str(), mode.c_str()); + gzFp = gzopen(path.c_str(), mode.c_str()); - if (gzFp == nullptr) - throw FileWriterException(fmt::format("Could not open file '{}'", path)); + if (gzFp == nullptr) throw FileWriterException(fmt::format("Could not open file '{}'", path)); } /* ---------------------------------------------------------------------- */ -size_t GzFileWriter::write(const void * buffer, size_t length) +size_t GzFileWriter::write(const void *buffer, size_t length) { if (!isopen()) return 0; @@ -76,7 +70,7 @@ void GzFileWriter::flush() void GzFileWriter::close() { - if (!isopen()) return; + if (!GzFileWriter::isopen()) return; gzclose(gzFp); gzFp = nullptr; @@ -100,7 +94,8 @@ void GzFileWriter::setCompressionLevel(int level) const int max_level = Z_BEST_COMPRESSION; if (level < min_level || level > max_level) - throw FileWriterException(fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); + throw FileWriterException( + fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); compression_level = level; } diff --git a/src/COMPRESS/gz_file_writer.h b/src/COMPRESS/gz_file_writer.h index 48ad0f42a8..3de1d0d2b8 100644 --- a/src/COMPRESS/gz_file_writer.h +++ b/src/COMPRESS/gz_file_writer.h @@ -20,7 +20,6 @@ #include "file_writer.h" -#include #include #include diff --git a/src/COMPRESS/zstd_file_writer.cpp b/src/COMPRESS/zstd_file_writer.cpp index 609a78b216..c628cc0078 100644 --- a/src/COMPRESS/zstd_file_writer.cpp +++ b/src/COMPRESS/zstd_file_writer.cpp @@ -1,4 +1,3 @@ -// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -19,16 +18,13 @@ #ifdef LAMMPS_ZSTD #include "zstd_file_writer.h" -#include #include "fmt/format.h" +#include using namespace LAMMPS_NS; -ZstdFileWriter::ZstdFileWriter() : FileWriter(), - compression_level(0), - checksum_flag(1), - cctx(nullptr), - fp(nullptr) +ZstdFileWriter::ZstdFileWriter() : + FileWriter(), compression_level(0), checksum_flag(1), cctx(nullptr), fp(nullptr) { out_buffer_size = ZSTD_CStreamOutSize(); out_buffer = new char[out_buffer_size]; @@ -38,9 +34,9 @@ ZstdFileWriter::ZstdFileWriter() : FileWriter(), ZstdFileWriter::~ZstdFileWriter() { - close(); + ZstdFileWriter::close(); - delete [] out_buffer; + delete[] out_buffer; out_buffer = nullptr; out_buffer_size = 0; } @@ -49,41 +45,39 @@ ZstdFileWriter::~ZstdFileWriter() void ZstdFileWriter::open(const std::string &path, bool append) { - if (isopen()) return; + if (isopen()) return; - if (append) { - fp = fopen(path.c_str(), "ab"); - } else { - fp = fopen(path.c_str(), "wb"); - } + if (append) { + fp = fopen(path.c_str(), "ab"); + } else { + fp = fopen(path.c_str(), "wb"); + } - if (!fp) { - throw FileWriterException(fmt::format("Could not open file '{}'", path)); - } + if (!fp) { throw FileWriterException(fmt::format("Could not open file '{}'", path)); } - cctx = ZSTD_createCCtx(); + cctx = ZSTD_createCCtx(); - if (!cctx) { - fclose(fp); - fp = nullptr; - throw FileWriterException("Could not create Zstd context"); - } + if (!cctx) { + fclose(fp); + fp = nullptr; + throw FileWriterException("Could not create Zstd context"); + } - ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, compression_level); - ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, checksum_flag); + ZSTD_CCtx_setParameter(cctx, ZSTD_c_compressionLevel, compression_level); + ZSTD_CCtx_setParameter(cctx, ZSTD_c_checksumFlag, checksum_flag); } /* ---------------------------------------------------------------------- */ -size_t ZstdFileWriter::write(const void * buffer, size_t length) +size_t ZstdFileWriter::write(const void *buffer, size_t length) { if (!isopen()) return 0; - ZSTD_inBuffer input = { buffer, length, 0 }; + ZSTD_inBuffer input = {buffer, length, 0}; ZSTD_EndDirective mode = ZSTD_e_continue; do { - ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; + ZSTD_outBuffer output = {out_buffer, out_buffer_size, 0}; ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); } while (input.pos < input.size); @@ -98,11 +92,11 @@ void ZstdFileWriter::flush() if (!isopen()) return; size_t remaining; - ZSTD_inBuffer input = { nullptr, 0, 0 }; + ZSTD_inBuffer input = {nullptr, 0, 0}; ZSTD_EndDirective mode = ZSTD_e_flush; do { - ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; + ZSTD_outBuffer output = {out_buffer, out_buffer_size, 0}; remaining = ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); } while (remaining); @@ -114,14 +108,14 @@ void ZstdFileWriter::flush() void ZstdFileWriter::close() { - if (!isopen()) return; + if (!ZstdFileWriter::isopen()) return; size_t remaining; - ZSTD_inBuffer input = { nullptr, 0, 0 }; + ZSTD_inBuffer input = {nullptr, 0, 0}; ZSTD_EndDirective mode = ZSTD_e_end; do { - ZSTD_outBuffer output = { out_buffer, out_buffer_size, 0 }; + ZSTD_outBuffer output = {out_buffer, out_buffer_size, 0}; remaining = ZSTD_compressStream2(cctx, &output, &input, mode); fwrite(out_buffer, sizeof(char), output.pos, fp); } while (remaining); @@ -150,7 +144,8 @@ void ZstdFileWriter::setCompressionLevel(int level) const int max_level = ZSTD_maxCLevel(); if (level < min_level || level > max_level) - throw FileWriterException(fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); + throw FileWriterException( + fmt::format("Compression level must in the range of [{}, {}]", min_level, max_level)); compression_level = level; } @@ -159,8 +154,7 @@ void ZstdFileWriter::setCompressionLevel(int level) void ZstdFileWriter::setChecksum(bool enabled) { - if (isopen()) - throw FileWriterException("Checksum flag can not be changed while file is open"); + if (isopen()) throw FileWriterException("Checksum flag can not be changed while file is open"); checksum_flag = enabled ? 1 : 0; } diff --git a/src/CORESHELL/pair_born_coul_dsf_cs.cpp b/src/CORESHELL/pair_born_coul_dsf_cs.cpp index 42df5d4fb5..bb9b9693e4 100644 --- a/src/CORESHELL/pair_born_coul_dsf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_dsf_cs.cpp @@ -18,13 +18,14 @@ ------------------------------------------------------------------------- */ #include "pair_born_coul_dsf_cs.h" -#include + #include "atom.h" -#include "comm.h" #include "force.h" -#include "neigh_list.h" #include "math_const.h" #include "math_special.h" +#include "neigh_list.h" + +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/CORESHELL/pair_born_coul_wolf_cs.cpp b/src/CORESHELL/pair_born_coul_wolf_cs.cpp index 237c167552..00d557a14e 100644 --- a/src/CORESHELL/pair_born_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_wolf_cs.cpp @@ -14,12 +14,13 @@ #include "pair_born_coul_wolf_cs.h" -#include + #include "atom.h" -#include "comm.h" #include "force.h" -#include "neigh_list.h" #include "math_const.h" +#include "neigh_list.h" + +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/CORESHELL/pair_coul_wolf_cs.cpp b/src/CORESHELL/pair_coul_wolf_cs.cpp index 6f83b66ed8..19798dd034 100644 --- a/src/CORESHELL/pair_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_coul_wolf_cs.cpp @@ -13,13 +13,14 @@ ------------------------------------------------------------------------- */ #include "pair_coul_wolf_cs.h" -#include + #include "atom.h" -#include "comm.h" #include "force.h" #include "neigh_list.h" #include "math_const.h" +#include + using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/DIELECTRIC/atom_vec_dielectric.cpp b/src/DIELECTRIC/atom_vec_dielectric.cpp index cc182251e9..2d6d6d00b1 100644 --- a/src/DIELECTRIC/atom_vec_dielectric.cpp +++ b/src/DIELECTRIC/atom_vec_dielectric.cpp @@ -17,6 +17,9 @@ #include "atom.h" #include "citeme.h" +#include +#include + using namespace LAMMPS_NS; static const char cite_user_dielectric_package[] = diff --git a/src/DIELECTRIC/compute_efield_atom.cpp b/src/DIELECTRIC/compute_efield_atom.cpp index c6ea0db94f..6f4bfd742a 100644 --- a/src/DIELECTRIC/compute_efield_atom.cpp +++ b/src/DIELECTRIC/compute_efield_atom.cpp @@ -33,12 +33,14 @@ #include "pppm_dielectric.h" #include "update.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ ComputeEfieldAtom::ComputeEfieldAtom(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), efield(NULL) + Compute(lmp, narg, arg), efield(nullptr) { if (narg < 3) error->all(FLERR,"Illegal compute efield/atom command"); diff --git a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp index 62febf13c2..538ce15575 100644 --- a/src/DIELECTRIC/fix_polarize_bem_gmres.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_gmres.cpp @@ -41,11 +41,9 @@ #include "comm.h" #include "error.h" #include "force.h" -#include "group.h" #include "kspace.h" #include "math_const.h" #include "memory.h" -#include "modify.h" #include "msm_dielectric.h" #include "pair_coul_cut_dielectric.h" #include "pair_coul_long_dielectric.h" @@ -54,7 +52,6 @@ #include "pair_lj_cut_coul_msm_dielectric.h" #include "pppm_dielectric.h" #include "random_park.h" -#include "timer.h" #include "update.h" #include @@ -69,8 +66,8 @@ using namespace MathConst; /* ---------------------------------------------------------------------- */ FixPolarizeBEMGMRES::FixPolarizeBEMGMRES(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), q_backup(NULL), c(NULL), g(NULL), h(NULL), r(NULL), s(NULL), v(NULL), - y(NULL) + Fix(lmp, narg, arg), q_backup(nullptr), c(nullptr), g(nullptr), h(nullptr), r(nullptr), s(nullptr), v(nullptr), + y(nullptr) { if (narg < 5) error->all(FLERR, "Illegal fix polarize/bem/gmres command"); @@ -110,7 +107,7 @@ FixPolarizeBEMGMRES::FixPolarizeBEMGMRES(LAMMPS *lmp, int narg, char **arg) : if (atom->torque_flag) torqueflag = 1; if (atom->avec->forceclearflag) extraflag = 1; - grow_arrays(atom->nmax); + FixPolarizeBEMGMRES::grow_arrays(atom->nmax); atom->add_callback(0); // to ensure to work with atom->sort() // output the residual and actual number of iterations @@ -133,7 +130,7 @@ FixPolarizeBEMGMRES::~FixPolarizeBEMGMRES() memory->destroy(mat2tag); memory->destroy(tag2mat); - if (allocated) deallocate(); + if (allocated) FixPolarizeBEMGMRES::deallocate(); atom->delete_callback(id, 0); } diff --git a/src/DIELECTRIC/fix_polarize_bem_icc.cpp b/src/DIELECTRIC/fix_polarize_bem_icc.cpp index da9b8eb055..4c137878a2 100644 --- a/src/DIELECTRIC/fix_polarize_bem_icc.cpp +++ b/src/DIELECTRIC/fix_polarize_bem_icc.cpp @@ -33,7 +33,6 @@ #include "group.h" #include "kspace.h" #include "math_const.h" -#include "memory.h" #include "msm_dielectric.h" #include "pair_coul_cut_dielectric.h" #include "pair_coul_long_dielectric.h" diff --git a/src/DIELECTRIC/fix_polarize_functional.cpp b/src/DIELECTRIC/fix_polarize_functional.cpp index 84f68e79b1..2d67bca0a7 100644 --- a/src/DIELECTRIC/fix_polarize_functional.cpp +++ b/src/DIELECTRIC/fix_polarize_functional.cpp @@ -33,13 +33,11 @@ #include "domain.h" #include "error.h" #include "force.h" -#include "group.h" #include "kspace.h" #include "math_const.h" #include "math_extra.h" #include "math_special.h" #include "memory.h" -#include "modify.h" #include "msm_dielectric.h" #include "neigh_list.h" #include "neigh_request.h" @@ -50,8 +48,6 @@ #include "pair_lj_cut_coul_long_dielectric.h" #include "pair_lj_cut_coul_msm_dielectric.h" #include "pppm_dielectric.h" -#include "random_park.h" -#include "timer.h" #include "update.h" #include @@ -131,7 +127,7 @@ FixPolarizeFunctional::FixPolarizeFunctional(LAMMPS *lmp, int narg, char **arg) cg_r = cg_p = cg_Ap = nullptr; cg_A = nullptr; - grow_arrays(atom->nmax); + FixPolarizeFunctional::grow_arrays(atom->nmax); atom->add_callback(0); // to ensure to work with atom->sort() } diff --git a/src/DIELECTRIC/msm_dielectric.cpp b/src/DIELECTRIC/msm_dielectric.cpp index 8ee1c19ac3..329218a94f 100644 --- a/src/DIELECTRIC/msm_dielectric.cpp +++ b/src/DIELECTRIC/msm_dielectric.cpp @@ -23,15 +23,9 @@ #include "comm.h" #include "domain.h" #include "error.h" -#include "force.h" #include "gridcomm.h" #include "math_const.h" #include "memory.h" -#include "neighbor.h" -#include "pair.h" - -#include -#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/DIELECTRIC/pair_coul_cut_dielectric.cpp b/src/DIELECTRIC/pair_coul_cut_dielectric.cpp index 9c3be2a80a..9596ce5be2 100644 --- a/src/DIELECTRIC/pair_coul_cut_dielectric.cpp +++ b/src/DIELECTRIC/pair_coul_cut_dielectric.cpp @@ -19,7 +19,6 @@ #include "atom.h" #include "atom_vec_dielectric.h" -#include "comm.h" #include "error.h" #include "force.h" #include "math_const.h" @@ -29,7 +28,6 @@ #include "neighbor.h" #include -#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/DIELECTRIC/pair_coul_long_dielectric.cpp b/src/DIELECTRIC/pair_coul_long_dielectric.cpp index fd5110cdb6..4bf7d48c2b 100644 --- a/src/DIELECTRIC/pair_coul_long_dielectric.cpp +++ b/src/DIELECTRIC/pair_coul_long_dielectric.cpp @@ -19,7 +19,6 @@ #include "atom.h" #include "atom_vec_dielectric.h" -#include "comm.h" #include "error.h" #include "force.h" #include "kspace.h" @@ -30,7 +29,6 @@ #include "neighbor.h" #include -#include using namespace LAMMPS_NS; using namespace MathConst; @@ -221,10 +219,10 @@ void PairCoulLongDielectric::init_style() // insure use of KSpace long-range solver, set g_ewald - if (force->kspace == NULL) error->all(FLERR, "Pair style requires a KSpace style"); + if (force->kspace == nullptr) error->all(FLERR, "Pair style requires a KSpace style"); g_ewald = force->kspace->g_ewald; // setup force tables - if (ncoultablebits) init_tables(cut_coul, NULL); + if (ncoultablebits) init_tables(cut_coul, nullptr); } diff --git a/src/DIELECTRIC/pair_lj_cut_coul_cut_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_cut_dielectric.cpp index e4b330d485..3e840459b7 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_cut_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_cut_dielectric.cpp @@ -19,7 +19,6 @@ #include "atom.h" #include "atom_vec_dielectric.h" -#include "comm.h" #include "error.h" #include "force.h" #include "math_const.h" diff --git a/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp index 4f3b46b14d..5220be7b62 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_debye_dielectric.cpp @@ -19,7 +19,6 @@ #include "atom.h" #include "atom_vec_dielectric.h" -#include "comm.h" #include "error.h" #include "force.h" #include "math_const.h" @@ -29,7 +28,6 @@ #include "neighbor.h" #include -#include using namespace LAMMPS_NS; using namespace MathConst; @@ -40,8 +38,8 @@ using namespace MathConst; PairLJCutCoulDebyeDielectric::PairLJCutCoulDebyeDielectric(LAMMPS *lmp) : PairLJCutCoulDebye(lmp) { - efield = NULL; - epot = NULL; + efield = nullptr; + epot = nullptr; nmax = 0; } diff --git a/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp index 7f5b67a22b..b256dd5a6c 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_long_dielectric.cpp @@ -19,7 +19,6 @@ #include "atom.h" #include "atom_vec_dielectric.h" -#include "comm.h" #include "error.h" #include "force.h" #include "kspace.h" @@ -257,7 +256,7 @@ void PairLJCutCoulLongDielectric::init_style() // insure use of KSpace long-range solver, set g_ewald - if (force->kspace == NULL) error->all(FLERR, "Pair style requires a KSpace style"); + if (force->kspace == nullptr) error->all(FLERR, "Pair style requires a KSpace style"); g_ewald = force->kspace->g_ewald; // setup force tables diff --git a/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp b/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp index 5fd8b499f8..b729abef8b 100644 --- a/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_cut_coul_msm_dielectric.cpp @@ -19,10 +19,8 @@ #include "atom.h" #include "atom_vec_dielectric.h" -#include "comm.h" #include "error.h" #include "force.h" -#include "integrate.h" #include "kspace.h" #include "math_const.h" #include "memory.h" @@ -31,6 +29,7 @@ #include "neighbor.h" #include +#include using namespace LAMMPS_NS; using namespace MathConst; @@ -365,7 +364,7 @@ void PairLJCutCoulMSMDielectric::init_style() // insure use of KSpace long-range solver, set g_ewald - if (force->kspace == NULL) error->all(FLERR, "Pair style requires a KSpace style"); + if (force->kspace == nullptr) error->all(FLERR, "Pair style requires a KSpace style"); g_ewald = force->kspace->g_ewald; // setup force tables @@ -382,5 +381,5 @@ void *PairLJCutCoulMSMDielectric::extract(const char *str, int &dim) dim = 2; if (strcmp(str, "epsilon") == 0) return (void *) epsilon; if (strcmp(str, "sigma") == 0) return (void *) sigma; - return NULL; + return nullptr; } diff --git a/src/DIELECTRIC/pair_lj_long_coul_long_dielectric.cpp b/src/DIELECTRIC/pair_lj_long_coul_long_dielectric.cpp index 922e24f0ea..25a533632b 100644 --- a/src/DIELECTRIC/pair_lj_long_coul_long_dielectric.cpp +++ b/src/DIELECTRIC/pair_lj_long_coul_long_dielectric.cpp @@ -19,19 +19,14 @@ #include "atom.h" #include "atom_vec_dielectric.h" -#include "comm.h" #include "error.h" #include "force.h" -#include "integrate.h" -#include "kspace.h" #include "math_const.h" #include "math_extra.h" #include "memory.h" #include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" -#include "respa.h" -#include "update.h" #include #include diff --git a/src/DIELECTRIC/pppm_dielectric.cpp b/src/DIELECTRIC/pppm_dielectric.cpp index f044387852..597f51010e 100644 --- a/src/DIELECTRIC/pppm_dielectric.cpp +++ b/src/DIELECTRIC/pppm_dielectric.cpp @@ -23,15 +23,11 @@ #include "comm.h" #include "domain.h" #include "error.h" -#include "fft3d_wrap.h" #include "force.h" #include "gridcomm.h" #include "math_const.h" #include "math_special.h" #include "memory.h" -#include "neighbor.h" -#include "pair.h" -#include "remap_wrap.h" #include diff --git a/src/DIELECTRIC/pppm_disp_dielectric.cpp b/src/DIELECTRIC/pppm_disp_dielectric.cpp index 8c423543c2..2a7febd304 100644 --- a/src/DIELECTRIC/pppm_disp_dielectric.cpp +++ b/src/DIELECTRIC/pppm_disp_dielectric.cpp @@ -21,21 +21,14 @@ #include "angle.h" #include "atom.h" #include "atom_vec_dielectric.h" -#include "bond.h" -#include "comm.h" #include "domain.h" #include "error.h" -#include "fft3d_wrap.h" #include "force.h" #include "gridcomm.h" #include "math_const.h" #include "memory.h" -#include "neighbor.h" -#include "pair.h" -#include "remap_wrap.h" #include -#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/DPD-MESO/pair_edpd.cpp b/src/DPD-MESO/pair_edpd.cpp index 53469e4e3d..836ea27e8b 100644 --- a/src/DPD-MESO/pair_edpd.cpp +++ b/src/DPD-MESO/pair_edpd.cpp @@ -31,7 +31,6 @@ #include "update.h" #include -#include #include using namespace LAMMPS_NS; diff --git a/src/DPD-REACT/fix_rx.cpp b/src/DPD-REACT/fix_rx.cpp index 91eb3f54df..526c2d508f 100644 --- a/src/DPD-REACT/fix_rx.cpp +++ b/src/DPD-REACT/fix_rx.cpp @@ -34,7 +34,6 @@ #include // DBL_EPSILON #include #include -#include // std::vector<> using namespace LAMMPS_NS; using namespace FixConst; @@ -59,7 +58,7 @@ namespace /* anonymous */ { typedef double TimerType; -TimerType getTimeStamp(void) { return MPI_Wtime(); } +TimerType getTimeStamp() { return MPI_Wtime(); } double getElapsedTime( const TimerType &t0, const TimerType &t1) { return t1-t0; } } // end namespace @@ -1246,7 +1245,7 @@ int FixRX::rkf45_h0 (const int neq, const double t, const double /*t_stop*/, return (iter + 1); } -void FixRX::odeDiagnostics(void) +void FixRX::odeDiagnostics() { TimerType timer_start = getTimeStamp(); diff --git a/src/DPD-SMOOTH/fix_meso_move.cpp b/src/DPD-SMOOTH/fix_meso_move.cpp index 85eee5ffbe..ba32962b3c 100644 --- a/src/DPD-SMOOTH/fix_meso_move.cpp +++ b/src/DPD-SMOOTH/fix_meso_move.cpp @@ -224,7 +224,7 @@ FixMesoMove::FixMesoMove (LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class - grow_arrays(atom->nmax); + FixMesoMove::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); diff --git a/src/DRUDE/fix_drude.cpp b/src/DRUDE/fix_drude.cpp index e0b313c35e..20d6749c8a 100644 --- a/src/DRUDE/fix_drude.cpp +++ b/src/DRUDE/fix_drude.cpp @@ -25,7 +25,6 @@ #include #include #include -#include using namespace LAMMPS_NS; using namespace FixConst; @@ -55,7 +54,7 @@ FixDrude::FixDrude(LAMMPS *lmp, int narg, char **arg) : } drudeid = nullptr; - grow_arrays(atom->nmax); + FixDrude::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); atom->add_callback(Atom::BORDER); @@ -516,7 +515,8 @@ void FixDrude::ring_copy_drude(int size, char *cbuf, void *ptr) { * ----------------------------------------------------------------------*/ void FixDrude::set_arrays(int i) { if (drudetype[atom->type[i]] != NOPOL_TYPE) { - if (atom->nspecial[i] ==0) error->all(FLERR, "Polarizable atoms cannot be inserted with special lists info from the molecule template"); + if (atom->nspecial[i] == nullptr) + error->all(FLERR, "Polarizable atoms cannot be inserted with special lists info from the molecule template"); drudeid[i] = atom->special[i][0]; // Drude partner should be at first place in the special list } else { drudeid[i] = 0; diff --git a/src/DRUDE/fix_tgnh_drude.cpp b/src/DRUDE/fix_tgnh_drude.cpp index 475a81e843..fe8cf448f0 100644 --- a/src/DRUDE/fix_tgnh_drude.cpp +++ b/src/DRUDE/fix_tgnh_drude.cpp @@ -24,6 +24,7 @@ #include "domain.h" #include "error.h" #include "fix_deform.h" +#include "fix_drude.h" #include "force.h" #include "irregular.h" #include "kspace.h" diff --git a/src/DRUDE/fix_tgnh_drude.h b/src/DRUDE/fix_tgnh_drude.h index 617a99f856..598a407ff4 100644 --- a/src/DRUDE/fix_tgnh_drude.h +++ b/src/DRUDE/fix_tgnh_drude.h @@ -15,7 +15,6 @@ #define LMP_FIX_TGNH_DRUDE_H #include "fix.h" -#include "fix_drude.h" namespace LAMMPS_NS { diff --git a/src/EXTRA-DUMP/dump_dcd.cpp b/src/EXTRA-DUMP/dump_dcd.cpp index 268c273064..97c9bec646 100644 --- a/src/EXTRA-DUMP/dump_dcd.cpp +++ b/src/EXTRA-DUMP/dump_dcd.cpp @@ -18,17 +18,19 @@ ------------------------------------------------------------------------- */ #include "dump_dcd.h" -#include -#include -#include -#include "domain.h" + #include "atom.h" -#include "update.h" -#include "output.h" -#include "group.h" -#include "memory.h" +#include "domain.h" #include "error.h" #include "fmt/chrono.h" +#include "group.h" +#include "memory.h" +#include "output.h" +#include "update.h" + +#include +#include +#include using namespace LAMMPS_NS; @@ -78,7 +80,7 @@ DumpDCD::DumpDCD(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg), yf = &coords[1*natoms]; zf = &coords[2*natoms]; - openfile(); + DumpDCD::openfile(); headerflag = 0; nevery_save = 0; ntotal = 0; diff --git a/src/EXTRA-DUMP/dump_xtc.cpp b/src/EXTRA-DUMP/dump_xtc.cpp index 5f7016ee50..7de6d03561 100644 --- a/src/EXTRA-DUMP/dump_xtc.cpp +++ b/src/EXTRA-DUMP/dump_xtc.cpp @@ -92,7 +92,7 @@ DumpXTC::DumpXTC(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg), "format conventions possible for units lj"); } - openfile(); + DumpXTC::openfile(); nevery_save = 0; ntotal = 0; } diff --git a/src/EXTRA-FIX/fix_ave_correlate_long.cpp b/src/EXTRA-FIX/fix_ave_correlate_long.cpp index 32a304d08f..6e4e26754f 100644 --- a/src/EXTRA-FIX/fix_ave_correlate_long.cpp +++ b/src/EXTRA-FIX/fix_ave_correlate_long.cpp @@ -156,18 +156,14 @@ FixAveCorrelateLong::FixAveCorrelateLong(LAMMPS * lmp, int narg, char **arg): } else if (strcmp(arg[iarg],"title1") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate/long command"); - delete [] title1; - int n = strlen(arg[iarg+1]) + 1; - title1 = new char[n]; - strcpy(title1,arg[iarg+1]); + delete[] title1; + title1 = utils::strdup(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"title2") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/correlate/long command"); - delete [] title2; - int n = strlen(arg[iarg+1]) + 1; - title2 = new char[n]; - strcpy(title2,arg[iarg+1]); + delete[] title2; + title2 = utils::strdup(arg[iarg+1]); iarg += 2; } else error->all(FLERR,"Illegal fix ave/correlate/long command"); } diff --git a/src/EXTRA-FIX/fix_ffl.cpp b/src/EXTRA-FIX/fix_ffl.cpp index fc7c986ce3..9cc9d4e179 100644 --- a/src/EXTRA-FIX/fix_ffl.cpp +++ b/src/EXTRA-FIX/fix_ffl.cpp @@ -110,7 +110,7 @@ FixFFL::FixFFL(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) // allocates space for temporaries ffl_tmp1=ffl_tmp2=nullptr; - grow_arrays(atom->nmax); + FixFFL::grow_arrays(atom->nmax); // add callbacks to enable restarts atom->add_callback(Atom::GROW); diff --git a/src/EXTRA-FIX/fix_filter_corotate.cpp b/src/EXTRA-FIX/fix_filter_corotate.cpp index a398491df5..50ce65bac0 100644 --- a/src/EXTRA-FIX/fix_filter_corotate.cpp +++ b/src/EXTRA-FIX/fix_filter_corotate.cpp @@ -155,7 +155,7 @@ FixFilterCorotate::FixFilterCorotate(LAMMPS *lmp, int narg, char **arg) : shake_atom = nullptr; shake_type = nullptr; - grow_arrays(atom->nmax); + FixFilterCorotate::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); //calls grow_arrays x_store = nullptr; diff --git a/src/EXTRA-FIX/fix_flow_gauss.cpp b/src/EXTRA-FIX/fix_flow_gauss.cpp index 1a48488ab6..415f1eecc0 100644 --- a/src/EXTRA-FIX/fix_flow_gauss.cpp +++ b/src/EXTRA-FIX/fix_flow_gauss.cpp @@ -84,14 +84,14 @@ FixFlowGauss::FixFlowGauss(LAMMPS *lmp, int narg, char **arg) : // by default, do not compute work done - workflag=0; + workflag=false; // process optional keyword int iarg = 6; while (iarg < narg) { if (strcmp(arg[iarg],"energy") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal energy keyword"); - if (strcmp(arg[iarg+1],"yes") == 0) workflag = 1; + if (strcmp(arg[iarg+1],"yes") == 0) workflag = true; else if (strcmp(arg[iarg+1],"no") != 0) error->all(FLERR,"Illegal energy keyword"); iarg += 2; @@ -139,7 +139,7 @@ void FixFlowGauss::setup(int vflag) { // need to compute work done if fix_modify energy yes is set - if (thermo_energy) workflag = 1; + if (thermo_energy) workflag = true; // get total mass of group diff --git a/src/EXTRA-FIX/fix_gld.cpp b/src/EXTRA-FIX/fix_gld.cpp index 2e30882206..3f807d0f51 100644 --- a/src/EXTRA-FIX/fix_gld.cpp +++ b/src/EXTRA-FIX/fix_gld.cpp @@ -91,7 +91,7 @@ FixGLD::FixGLD(LAMMPS *lmp, int narg, char **arg) : memory->create(prony_tau, prony_terms, "gld:prony_tau"); // allocate memory for Prony series extended variables s_gld = nullptr; - grow_arrays(atom->nmax); + FixGLD::grow_arrays(atom->nmax); // add callbacks to enable restarts atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); diff --git a/src/EXTRA-FIX/fix_gle.cpp b/src/EXTRA-FIX/fix_gle.cpp index 563295d8c1..8f31613188 100644 --- a/src/EXTRA-FIX/fix_gle.cpp +++ b/src/EXTRA-FIX/fix_gle.cpp @@ -350,7 +350,7 @@ FixGLE::FixGLE(LAMMPS *lmp, int narg, char **arg) : // allocates space for temporaries gle_tmp1=gle_tmp2=nullptr; - grow_arrays(atom->nmax); + FixGLE::grow_arrays(atom->nmax); init_gles(); // add callbacks to enable restarts diff --git a/src/EXTRA-FIX/fix_npt_cauchy.cpp b/src/EXTRA-FIX/fix_npt_cauchy.cpp index e58632635f..6a7d91dd16 100644 --- a/src/EXTRA-FIX/fix_npt_cauchy.cpp +++ b/src/EXTRA-FIX/fix_npt_cauchy.cpp @@ -276,9 +276,7 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : else { allremap = 0; delete [] id_dilate; - int n = strlen(arg[iarg+1]) + 1; - id_dilate = new char[n]; - strcpy(id_dilate,arg[iarg+1]); + id_dilate = utils::strdup(arg[iarg+1]); int idilate = group->find(id_dilate); if (idilate == -1) error->all(FLERR,"Fix npt/cauchy dilate group ID does not exist"); @@ -1445,9 +1443,7 @@ int FixNPTCauchy::modify_param(int narg, char **arg) tcomputeflag = 0; } delete [] id_temp; - int n = strlen(arg[1]) + 1; - id_temp = new char[n]; - strcpy(id_temp,arg[1]); + id_temp = utils::strdup(arg[1]); int icompute = modify->find_compute(arg[1]); if (icompute < 0) @@ -1479,9 +1475,7 @@ int FixNPTCauchy::modify_param(int narg, char **arg) pcomputeflag = 0; } delete [] id_press; - int n = strlen(arg[1]) + 1; - id_press = new char[n]; - strcpy(id_press,arg[1]); + id_press = utils::strdup(arg[1]); int icompute = modify->find_compute(arg[1]); if (icompute < 0) error->all(FLERR,"Could not find fix_modify pressure ID"); @@ -2460,30 +2454,17 @@ double FixNPTCauchy::memory_usage() void FixNPTCauchy::CauchyStat_init() { if (comm->me == 0) { - if (screen) { - fprintf(screen,"Using fix npt/cauchy with alpha=%f\n",alpha); - if (restartPK==1) { - fprintf(screen," (this is a continuation run)\n"); - } else { - fprintf(screen," (this is NOT a continuation run)\n"); - } - } - if (logfile) { - fprintf(logfile,"Using fix npt/cauchy with alpha=%f\n",alpha); - if (restartPK==1) { - fprintf(logfile," this is a continuation run\n"); - } else { - fprintf(logfile," this is NOT a continuation run\n"); - } + std::string mesg = fmt::format("Using fix npt/cauchy with alpha={:f.8}\n",alpha); + if (restartPK==1) { + mesg += " (this is a continuation run)\n"; + } else { + mesg += " (this is NOT a continuation run)\n"; } + utils::logmesg(lmp, mesg); } - if (!id_store) { - int n = strlen(id) + 14; - id_store = new char[n]; - strcpy(id_store,id); - strcat(id_store,"_FIX_NH_STORE"); - } + if (!id_store) + id_store = utils::strdup(std::string(id) + "_FIX_NH_STORE"); restart_stored = modify->find_fix(id_store); if (restartPK==1 && restart_stored < 0) @@ -2491,19 +2472,10 @@ void FixNPTCauchy::CauchyStat_init() " must follow a previously equilibrated npt/cauchy run"); if (alpha<=0.0) - error->all(FLERR,"Illegal fix npt/cauchy command: " - " Alpha cannot be zero or negative."); + error->all(FLERR,"Illegal fix npt/cauchy command: Alpha cannot be zero or negative."); if (restart_stored < 0) { - char **newarg = new char *[6]; - newarg[0] = id_store; - newarg[1] = (char *) "all"; - newarg[2] = (char *) "STORE"; - newarg[3] = (char *) "global"; - newarg[4] = (char *) "1"; - newarg[5] = (char *) "6"; - modify->add_fix(6,newarg); - delete[] newarg; + modify->add_fix(std::string(id_store) + "all STORE global 1 6"); restart_stored = modify->find_fix(id_store); } init_store = (FixStore *)modify->fix[restart_stored]; diff --git a/src/EXTRA-FIX/fix_numdiff.cpp b/src/EXTRA-FIX/fix_numdiff.cpp index dbe2f0a9dc..4c9c08b681 100644 --- a/src/EXTRA-FIX/fix_numdiff.cpp +++ b/src/EXTRA-FIX/fix_numdiff.cpp @@ -57,8 +57,7 @@ FixNumDiff::FixNumDiff(LAMMPS *lmp, int narg, char **arg) : error->all(FLERR,"Illegal fix numdiff command"); std::string cmd = id + std::string("_pe"); - id_pe = new char[cmd.size()+1]; - strcpy(id_pe,cmd.c_str()); + id_pe = utils::strdup(cmd); cmd += " all pe"; modify->add_compute(cmd); diff --git a/src/EXTRA-FIX/fix_pafi.cpp b/src/EXTRA-FIX/fix_pafi.cpp index eea8a2c1d3..3b51906ae1 100644 --- a/src/EXTRA-FIX/fix_pafi.cpp +++ b/src/EXTRA-FIX/fix_pafi.cpp @@ -593,7 +593,6 @@ void FixPAFI::initial_integrate(int /*vflag*/) if (rmass) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - dtfm = dtf / rmass[i]; v[i][0] = 0.; v[i][1] = 0.; v[i][2] = 0.; @@ -604,7 +603,6 @@ void FixPAFI::initial_integrate(int /*vflag*/) } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - dtfm = dtf / mass[type[i]]; v[i][0] = 0.; v[i][1] = 0.; v[i][2] = 0.; diff --git a/src/EXTRA-FIX/fix_ti_spring.cpp b/src/EXTRA-FIX/fix_ti_spring.cpp index c6a3ed47ea..231da9e8ee 100644 --- a/src/EXTRA-FIX/fix_ti_spring.cpp +++ b/src/EXTRA-FIX/fix_ti_spring.cpp @@ -77,7 +77,7 @@ FixTISpring::FixTISpring(LAMMPS *lmp, int narg, char **arg) : // Perform initial allocation of atom-based array // Register with Atom class xoriginal = nullptr; - grow_arrays(atom->nmax); + FixTISpring::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); diff --git a/src/EXTRA-FIX/fix_tmd.cpp b/src/EXTRA-FIX/fix_tmd.cpp index 335c1a5e6b..a46eb89713 100644 --- a/src/EXTRA-FIX/fix_tmd.cpp +++ b/src/EXTRA-FIX/fix_tmd.cpp @@ -56,7 +56,7 @@ nfileevery(0), fp(nullptr), xf(nullptr), xold(nullptr) // perform initial allocation of atom-based arrays // register with Atom class - grow_arrays(atom->nmax); + FixTMD::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); // make sure an atom map exists before reading in target coordinates diff --git a/src/EXTRA-FIX/fix_ttm.cpp b/src/EXTRA-FIX/fix_ttm.cpp index a8db3ad9de..abcbd2ba1e 100644 --- a/src/EXTRA-FIX/fix_ttm.cpp +++ b/src/EXTRA-FIX/fix_ttm.cpp @@ -30,7 +30,6 @@ #include "potential_file_reader.h" #include "tokenizer.h" #include "update.h" -#include "fmt/chrono.h" #include #include @@ -142,7 +141,7 @@ FixTTM::FixTTM(LAMMPS *lmp, int narg, char **arg) : // allocate per-atom flangevin and zero it flangevin = nullptr; - grow_arrays(atom->nmax); + FixTTM::grow_arrays(atom->nmax); for (int i = 0; i < atom->nmax; i++) { flangevin[i][0] = 0.0; @@ -173,7 +172,7 @@ FixTTM::~FixTTM() memory->destroy(flangevin); - if (!deallocate_flag) deallocate_grid(); + if (!deallocate_flag) FixTTM::deallocate_grid(); } /* ---------------------------------------------------------------------- */ @@ -527,14 +526,11 @@ void FixTTM::write_electron_temperatures(const std::string &filename) { if (comm->me) return; - time_t tv = time(nullptr); - std::tm current_date = fmt::localtime(tv); - FILE *fp = fopen(filename.c_str(),"w"); if (!fp) error->one(FLERR,"Fix ttm could not open output file {}: {}", filename,utils::getsyserror()); - fmt::print(fp,"# DATE: {:%Y-%m-%d} UNITS: {} COMMENT: Electron temperature " - "{}x{}x{} grid at step {}. Created by fix {}\n", current_date, + fmt::print(fp,"# DATE: {} UNITS: {} COMMENT: Electron temperature " + "{}x{}x{} grid at step {}. Created by fix {}\n", utils::current_date(), update->unit_style, nxgrid, nygrid, nzgrid, update->ntimestep, style); int ix,iy,iz; diff --git a/src/EXTRA-FIX/fix_ttm_grid.cpp b/src/EXTRA-FIX/fix_ttm_grid.cpp index 3c1c1b2695..7b3f434907 100644 --- a/src/EXTRA-FIX/fix_ttm_grid.cpp +++ b/src/EXTRA-FIX/fix_ttm_grid.cpp @@ -23,18 +23,16 @@ #include "comm.h" #include "domain.h" #include "error.h" -#include "force.h" #include "gridcomm.h" #include "memory.h" #include "neighbor.h" #include "random_mars.h" #include "tokenizer.h" #include "update.h" -#include "fmt/chrono.h" #include #include -#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -55,7 +53,7 @@ FixTTMGrid::FixTTMGrid(LAMMPS *lmp, int narg, char **arg) : FixTTMGrid::~FixTTMGrid() { - deallocate_grid(); + FixTTMGrid::deallocate_grid(); deallocate_flag = 1; } @@ -355,18 +353,15 @@ void FixTTMGrid::read_electron_temperatures(const std::string &filename) void FixTTMGrid::write_electron_temperatures(const std::string &filename) { if (comm->me == 0) { - time_t tv = time(nullptr); - std::tm current_date = fmt::localtime(tv); - FPout = fopen(filename.c_str(), "w"); if (!FPout) error->one(FLERR, "Fix ttm/grid could not open output file"); - fmt::print(FPout,"# DATE: {:%Y-%m-%d} UNITS: {} COMMENT: Electron temperature " - "{}x{}x{} grid at step {}. Created by fix {}\n", current_date, + fmt::print(FPout,"# DATE: {} UNITS: {} COMMENT: Electron temperature " + "{}x{}x{} grid at step {}. Created by fix {}\n", utils::current_date(), update->unit_style, nxgrid, nygrid, nzgrid, update->ntimestep, style); } - gc->gather(GridComm::FIX, this, 1, sizeof(double), 1, NULL, MPI_DOUBLE); + gc->gather(GridComm::FIX, this, 1, sizeof(double), 1, nullptr, MPI_DOUBLE); if (comm->me == 0) fclose(FPout); } diff --git a/src/EXTRA-FIX/fix_ttm_mod.cpp b/src/EXTRA-FIX/fix_ttm_mod.cpp index 905232ff08..0aef2ec4ff 100644 --- a/src/EXTRA-FIX/fix_ttm_mod.cpp +++ b/src/EXTRA-FIX/fix_ttm_mod.cpp @@ -33,7 +33,6 @@ #include "potential_file_reader.h" #include "tokenizer.h" #include "update.h" -#include "fmt/chrono.h" #include #include @@ -101,7 +100,7 @@ FixTTMMod::FixTTMMod(LAMMPS *lmp, int narg, char **arg) : nzgrid = utils::inumeric(FLERR,arg[7],false,lmp); double tinit = 0.0; - infile = outfile = NULL; + infile = outfile = nullptr; int iarg = 8; while (iarg < narg) { @@ -620,14 +619,11 @@ void FixTTMMod::write_electron_temperatures(const std::string &filename) { if (comm->me) return; - time_t tv = time(nullptr); - std::tm current_date = fmt::localtime(tv); - FILE *fp = fopen(filename.c_str(),"w"); if (!fp) error->one(FLERR,"Fix ttm/mod could not open output file {}: {}", filename, utils::getsyserror()); - fmt::print(fp,"# DATE: {:%Y-%m-%d} UNITS: {} COMMENT: Electron temperature " - "{}x{}x{} grid at step {}. Created by fix {}\n", current_date, + fmt::print(fp,"# DATE: {} UNITS: {} COMMENT: Electron temperature " + "{}x{}x{} grid at step {}. Created by fix {}\n", utils::current_date(), update->unit_style, nxgrid, nygrid, nzgrid, update->ntimestep, style); int ix,iy,iz; diff --git a/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp b/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp index 5c43193d85..419cfe5d3f 100644 --- a/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp +++ b/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp @@ -18,16 +18,15 @@ #include "dihedral_cosine_shift_exp.h" -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "force.h" -#include "update.h" -#include "memory.h" -#include "math_const.h" #include "error.h" +#include "force.h" +#include "math_const.h" +#include "memory.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; diff --git a/src/EXTRA-MOLECULE/dihedral_fourier.cpp b/src/EXTRA-MOLECULE/dihedral_fourier.cpp index b88c866e7c..4303e67755 100644 --- a/src/EXTRA-MOLECULE/dihedral_fourier.cpp +++ b/src/EXTRA-MOLECULE/dihedral_fourier.cpp @@ -19,16 +19,15 @@ #include "dihedral_fourier.h" -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" +#include "error.h" #include "force.h" -#include "update.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/EXTRA-MOLECULE/dihedral_helix.cpp b/src/EXTRA-MOLECULE/dihedral_helix.cpp index 4726dd3bce..4bbf8edcf4 100644 --- a/src/EXTRA-MOLECULE/dihedral_helix.cpp +++ b/src/EXTRA-MOLECULE/dihedral_helix.cpp @@ -26,7 +26,6 @@ #include "math_const.h" #include "memory.h" #include "neighbor.h" -#include "update.h" #include diff --git a/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp b/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp index 5e2a69fb2f..41a3d66ba6 100644 --- a/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp +++ b/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp @@ -19,15 +19,14 @@ #include "dihedral_nharmonic.h" -#include #include "atom.h" -#include "neighbor.h" #include "comm.h" -#include "force.h" -#include "update.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; diff --git a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp index 5f531fa785..9b1ae5f9cb 100644 --- a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp +++ b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp @@ -19,16 +19,15 @@ #include "dihedral_quadratic.h" -#include #include "atom.h" -#include "neighbor.h" #include "comm.h" +#include "error.h" #include "force.h" -#include "update.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/EXTRA-MOLECULE/dihedral_table_cut.cpp b/src/EXTRA-MOLECULE/dihedral_table_cut.cpp index 5c7bc30862..b132104bdd 100644 --- a/src/EXTRA-MOLECULE/dihedral_table_cut.cpp +++ b/src/EXTRA-MOLECULE/dihedral_table_cut.cpp @@ -27,7 +27,6 @@ #include "math_const.h" #include "memory.h" #include "neighbor.h" -#include "update.h" #include #include // IWYU pragma: keep diff --git a/src/EXTRA-MOLECULE/improper_cossq.cpp b/src/EXTRA-MOLECULE/improper_cossq.cpp index 2952a15d8b..ea5bd1b43e 100644 --- a/src/EXTRA-MOLECULE/improper_cossq.cpp +++ b/src/EXTRA-MOLECULE/improper_cossq.cpp @@ -26,7 +26,6 @@ #include "math_const.h" #include "memory.h" #include "neighbor.h" -#include "update.h" #include diff --git a/src/EXTRA-MOLECULE/improper_fourier.cpp b/src/EXTRA-MOLECULE/improper_fourier.cpp index eeb1cbb7dc..56200fec8c 100644 --- a/src/EXTRA-MOLECULE/improper_fourier.cpp +++ b/src/EXTRA-MOLECULE/improper_fourier.cpp @@ -19,15 +19,14 @@ #include "improper_fourier.h" -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "force.h" -#include "update.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; diff --git a/src/EXTRA-PAIR/pair_lj96_cut.cpp b/src/EXTRA-PAIR/pair_lj96_cut.cpp index b20ebf2c88..a762e7de6b 100644 --- a/src/EXTRA-PAIR/pair_lj96_cut.cpp +++ b/src/EXTRA-PAIR/pair_lj96_cut.cpp @@ -376,8 +376,7 @@ void PairLJ96Cut::compute_outer(int eflag, int vflag) r2inv = 1.0/rsq; r6inv = r2inv*r2inv*r2inv; r3inv = sqrt(r6inv); - evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - - offset[itype][jtype]; + evdwl = r6inv*(lj3[itype][jtype]*r3inv-lj4[itype][jtype]) - offset[itype][jtype]; evdwl *= factor_lj; } @@ -392,8 +391,7 @@ void PairLJ96Cut::compute_outer(int eflag, int vflag) fpair = factor_lj*forcelj*r2inv; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } diff --git a/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp b/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp index 685871db3b..2791c28747 100644 --- a/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp +++ b/src/EXTRA-PAIR/pair_lj_expand_coul_long.cpp @@ -195,14 +195,12 @@ void PairLJExpandCoulLong::compute(int eflag, int vflag) } else ecoul = 0.0; if (rsq < cut_ljsq[itype][jtype]) { - evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]; + evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - offset[itype][jtype]; evdwl *= factor_lj; } else evdwl = 0.0; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz); } } } @@ -980,8 +978,7 @@ double PairLJExpandCoulLong::single(int i, int j, int itype, int jtype, } if (rsq < cut_ljsq[itype][jtype]) { - philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - - offset[itype][jtype]; + philj = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype]) - offset[itype][jtype]; eng += factor_lj*philj; } diff --git a/src/EXTRA-PAIR/pair_lj_gromacs_coul_gromacs.cpp b/src/EXTRA-PAIR/pair_lj_gromacs_coul_gromacs.cpp index 9db42342d9..96b8985b6b 100644 --- a/src/EXTRA-PAIR/pair_lj_gromacs_coul_gromacs.cpp +++ b/src/EXTRA-PAIR/pair_lj_gromacs_coul_gromacs.cpp @@ -164,16 +164,14 @@ void PairLJGromacsCoulGromacs::compute(int eflag, int vflag) evdwl = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]); evdwl += ljsw5[itype][jtype]; if (rsq > cut_lj_innersq) { - eswitch = tlj*tlj*tlj * - (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj); + eswitch = tlj*tlj*tlj * (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj); evdwl += eswitch; } evdwl *= factor_lj; } else evdwl = 0.0; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz); } } } @@ -487,8 +485,7 @@ double PairLJGromacsCoulGromacs::single(int i, int j, int itype, int jtype, if (rsq < cut_coulsq) { phicoul = force->qqrd2e * atom->q[i]*atom->q[j] * (sqrt(r2inv)-coulsw5); if (rsq > cut_coul_innersq) { - phiswitchcoul = force->qqrd2e * atom->q[i]*atom->q[j] * - tc*tc*tc * (coulsw3 + coulsw4*tc); + phiswitchcoul = force->qqrd2e * atom->q[i]*atom->q[j] * tc*tc*tc * (coulsw3 + coulsw4*tc); phicoul += phiswitchcoul; } eng += factor_coul*phicoul; @@ -498,8 +495,7 @@ double PairLJGromacsCoulGromacs::single(int i, int j, int itype, int jtype, philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]); philj += ljsw5[itype][jtype]; if (rsq > cut_lj_innersq) { - phiswitch = tlj*tlj*tlj * - (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj); + phiswitch = tlj*tlj*tlj * (ljsw3[itype][jtype] + ljsw4[itype][jtype]*tlj); philj += phiswitch; } eng += factor_lj*philj; diff --git a/src/EXTRA-PAIR/pair_lj_relres.cpp b/src/EXTRA-PAIR/pair_lj_relres.cpp index 1ea3684171..5d1ed4fdf0 100644 --- a/src/EXTRA-PAIR/pair_lj_relres.cpp +++ b/src/EXTRA-PAIR/pair_lj_relres.cpp @@ -183,15 +183,13 @@ void PairLJRelRes::compute(int eflag, int vflag) if (eflag) { if (rsq < cutf_inner_sq[itype][jtype]) { - evdwl = r6inv*(ljf3[itype][jtype]*r6inv- - ljf4[itype][jtype])-offsetsm[itype][jtype]; + evdwl = r6inv*(ljf3[itype][jtype]*r6inv-ljf4[itype][jtype])-offsetsm[itype][jtype]; } else if (rsq < cutfsq[itype][jtype]) { evdwl = ljswf0[itype][jtype]-ljswf1[itype][jtype]*t- ljswf2[itype][jtype]*tsq/2.0-ljswf3[itype][jtype]*tsq*t/3.0- ljswf4[itype][jtype]*tsq*tsq/4.0-offsetsp[itype][jtype]; } else if (rsq < cut_inner_sq[itype][jtype]) { - evdwl = r6inv*(lj3[itype][jtype]*r6inv- - lj4[itype][jtype])-offset[itype][jtype]; + evdwl = r6inv*(lj3[itype][jtype]*r6inv-lj4[itype][jtype])-offset[itype][jtype]; } else { evdwl = ljsw0[itype][jtype]-ljsw1[itype][jtype]*t- ljsw2[itype][jtype]*tsq/2.0-ljsw3[itype][jtype]*tsq*t/3.0- @@ -200,8 +198,7 @@ void PairLJRelRes::compute(int eflag, int vflag) evdwl *= factor_lj; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } @@ -726,15 +723,13 @@ double PairLJRelRes::single(int /*i*/, int /*j*/, int itype, int jtype, fforce = factor_lj*forcelj*r2inv; if (rsq < cutf_inner_sq[itype][jtype]) { - philj = r6inv*(ljf3[itype][jtype]*r6inv- - ljf4[itype][jtype])-offsetsm[itype][jtype]; + philj = r6inv*(ljf3[itype][jtype]*r6inv-ljf4[itype][jtype])-offsetsm[itype][jtype]; } else if (rsq < cutfsq[itype][jtype]) { philj = ljswf0[itype][jtype]-ljswf1[itype][jtype]*t- ljswf2[itype][jtype]*tsq/2.0-ljswf3[itype][jtype]*tsq*t/3.0- ljswf4[itype][jtype]*tsq*tsq/4.0-offsetsp[itype][jtype]; } else if (rsq < cut_inner_sq[itype][jtype]) { - philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - - offset[itype][jtype]; + philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - offset[itype][jtype]; } else { philj = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t - ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 - diff --git a/src/EXTRA-PAIR/pair_lj_smooth.cpp b/src/EXTRA-PAIR/pair_lj_smooth.cpp index f1aba212a3..5346a39e62 100644 --- a/src/EXTRA-PAIR/pair_lj_smooth.cpp +++ b/src/EXTRA-PAIR/pair_lj_smooth.cpp @@ -136,8 +136,7 @@ void PairLJSmooth::compute(int eflag, int vflag) if (eflag) { if (rsq < cut_inner_sq[itype][jtype]) - evdwl = r6inv * (lj3[itype][jtype]*r6inv - - lj4[itype][jtype]) - offset[itype][jtype]; + evdwl = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - offset[itype][jtype]; else evdwl = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t - ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 - @@ -145,8 +144,7 @@ void PairLJSmooth::compute(int eflag, int vflag) evdwl *= factor_lj; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } @@ -446,8 +444,7 @@ double PairLJSmooth::single(int /*i*/, int /*j*/, int itype, int jtype, double r fforce = factor_lj*forcelj*r2inv; if (rsq < cut_inner_sq[itype][jtype]) - philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - - offset[itype][jtype]; + philj = r6inv * (lj3[itype][jtype]*r6inv - lj4[itype][jtype]) - offset[itype][jtype]; else philj = ljsw0[itype][jtype] - ljsw1[itype][jtype]*t - ljsw2[itype][jtype]*tsq/2.0 - ljsw3[itype][jtype]*tsq*t/3.0 - diff --git a/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp b/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp index 6c2dd433de..a0e31d3070 100644 --- a/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp +++ b/src/EXTRA-PAIR/pair_nm_cut_coul_cut.cpp @@ -147,17 +147,13 @@ void PairNMCutCoulCut::compute(int eflag, int vflag) ecoul = factor_coul * qqrd2e * qtmp*q[j]*sqrt(r2inv); else ecoul = 0.0; if (rsq < cut_ljsq[itype][jtype]) { - evdwl = e0nm[itype][jtype]*(mm[itype][jtype] * - r0n[itype][jtype]*rninv - - nn[itype][jtype] * - r0m[itype][jtype]*rminv) - - offset[itype][jtype]; + evdwl = e0nm[itype][jtype]*(mm[itype][jtype] * r0n[itype][jtype]*rninv - + nn[itype][jtype] * r0m[itype][jtype]*rminv) - offset[itype][jtype]; evdwl *= factor_lj; } else evdwl = 0.0; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz); } } } diff --git a/src/FEP/fix_adapt_fep.cpp b/src/FEP/fix_adapt_fep.cpp index 3b4290f2c9..a6891c8742 100644 --- a/src/FEP/fix_adapt_fep.cpp +++ b/src/FEP/fix_adapt_fep.cpp @@ -282,13 +282,9 @@ void FixAdaptFEP::init() anypair = 1; Pair *pair = nullptr; - if (lmp->suffix_enable) { - char psuffix[128]; - strcpy(psuffix,ad->pstyle); - strcat(psuffix,"/"); - strcat(psuffix,lmp->suffix); - pair = force->pair_match(psuffix,1); - } + if (lmp->suffix_enable) + pair = force->pair_match(std::string(ad->pstyle)+"/"+lmp->suffix,1); + if (pair == nullptr) pair = force->pair_match(ad->pstyle,1); if (pair == nullptr) error->all(FLERR, "Fix adapt/fep pair style does not exist"); diff --git a/src/FEP/pair_lj_cut_coul_long_soft.cpp b/src/FEP/pair_lj_cut_coul_long_soft.cpp index 0d81fb17cd..0e43e72a17 100644 --- a/src/FEP/pair_lj_cut_coul_long_soft.cpp +++ b/src/FEP/pair_lj_cut_coul_long_soft.cpp @@ -178,8 +178,7 @@ void PairLJCutCoulLongSoft::compute(int eflag, int vflag) } else evdwl = 0.0; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,ecoul,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,ecoul,fpair,delx,dely,delz); } } } diff --git a/src/FEP/pair_lj_cut_soft.cpp b/src/FEP/pair_lj_cut_soft.cpp index 0934a91255..e4c2d19e95 100644 --- a/src/FEP/pair_lj_cut_soft.cpp +++ b/src/FEP/pair_lj_cut_soft.cpp @@ -410,8 +410,7 @@ void PairLJCutSoft::compute_outer(int eflag, int vflag) fpair = factor_lj*forcelj; } - if (evflag) ev_tally(i,j,nlocal,newton_pair, - evdwl,0.0,fpair,delx,dely,delz); + if (evflag) ev_tally(i,j,nlocal,newton_pair,evdwl,0.0,fpair,delx,dely,delz); } } } diff --git a/src/FEP/pair_morse_soft.cpp b/src/FEP/pair_morse_soft.cpp index c7c10b249e..56c63d758d 100644 --- a/src/FEP/pair_morse_soft.cpp +++ b/src/FEP/pair_morse_soft.cpp @@ -352,7 +352,7 @@ void PairMorseSoft::read_restart_settings(FILE *fp) utils::sfread(FLERR, &offset_flag, sizeof(int), 1, fp, nullptr, error); utils::sfread(FLERR, &mix_flag, sizeof(int), 1, fp, nullptr, error); } - MPI_Bcast(&nlambda, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&nlambda, 1, MPI_INT, 0, world); MPI_Bcast(&shift_range, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&cut_global, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&offset_flag, 1, MPI_INT, 0, world); diff --git a/src/GPU/fix_gpu.cpp b/src/GPU/fix_gpu.cpp index 843bff2a35..d26493e57b 100644 --- a/src/GPU/fix_gpu.cpp +++ b/src/GPU/fix_gpu.cpp @@ -17,16 +17,13 @@ #include "atom.h" #include "citeme.h" #include "comm.h" -#include "domain.h" #include "error.h" #include "force.h" #include "gpu_extra.h" -#include "input.h" #include "modify.h" #include "neighbor.h" #include "pair.h" #include "pair_hybrid.h" -#include "pair_hybrid_overlay.h" #include "respa.h" #include "timer.h" #include "universe.h" @@ -50,12 +47,10 @@ extern int lmp_init_device(MPI_Comm world, MPI_Comm replica, const int ngpu, const int ocl_platform, char *device_type_flags, const int block_pair); extern void lmp_clear_device(); -extern double lmp_gpu_forces(double **f, double **tor, double *eatom, - double **vatom, double *virial, double &ecoul, - int &err_flag); -extern double lmp_gpu_update_bin_size(const double subx, const double suby, - const double subz, const int nlocal, - const double cut); +extern double lmp_gpu_forces(double **f, double **tor, double *eatom, double **vatom, + double *virial, double &ecoul, int &err_flag); +extern double lmp_gpu_update_bin_size(const double subx, const double suby, const double subz, + const int nlocal, const double cut); static const char cite_gpu_package[] = "GPU package (short-range, long-range and three-body potentials):\n\n" @@ -203,7 +198,7 @@ FixGPU::FixGPU(LAMMPS *lmp, int narg, char **arg) : #if (LAL_USE_OMP == 0) if (nthreads > 1) - error->all(FLERR,"No OpenMP support compiled in"); + error->all(FLERR,"No OpenMP support compiled into the GPU package"); #else if (nthreads > 0) { omp_set_num_threads(nthreads); @@ -326,15 +321,12 @@ void FixGPU::post_force(int /* vflag */) timer->stamp(); double lvirial[6]; for (int i = 0; i < 6; i++) lvirial[i] = 0.0; - int err_flag; - double my_eng = lmp_gpu_forces(atom->f, atom->torque, force->pair->eatom, - force->pair->vatom, lvirial, - force->pair->eng_coul, err_flag); - if (err_flag) { - if (err_flag==1) - error->one(FLERR, - "Too many neighbors on GPU. Use neigh_modify one to increase limit."); - } + int err_flag = 0; + double my_eng = lmp_gpu_forces(atom->f, atom->torque, force->pair->eatom, force->pair->vatom, + lvirial, force->pair->eng_coul, err_flag); + if (err_flag==1) + error->one(FLERR,"Neighbor list problem on the GPU. Try increasing the value of 'neigh_modify one' " + "or the GPU neighbor list 'binsize'."); force->pair->eng_vdwl += my_eng; force->pair->virial[0] += lvirial[0]; diff --git a/src/GPU/fix_nh_gpu.cpp b/src/GPU/fix_nh_gpu.cpp index 82d1717597..fb09245fa4 100644 --- a/src/GPU/fix_nh_gpu.cpp +++ b/src/GPU/fix_nh_gpu.cpp @@ -28,7 +28,6 @@ #include "neighbor.h" #include "update.h" -#include #include using namespace LAMMPS_NS; diff --git a/src/GPU/fix_nve_gpu.cpp b/src/GPU/fix_nve_gpu.cpp index 49edae58a6..6612b8f65d 100644 --- a/src/GPU/fix_nve_gpu.cpp +++ b/src/GPU/fix_nve_gpu.cpp @@ -17,7 +17,7 @@ ------------------------------------------------------------------------- */ #include "fix_nve_gpu.h" -#include + #include "atom.h" #include "comm.h" #include "force.h" diff --git a/src/GPU/fix_nvt_gpu.cpp b/src/GPU/fix_nvt_gpu.cpp index 7c8336333a..c1d23090d5 100644 --- a/src/GPU/fix_nvt_gpu.cpp +++ b/src/GPU/fix_nvt_gpu.cpp @@ -18,8 +18,6 @@ #include "group.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/GPU/pair_beck_gpu.cpp b/src/GPU/pair_beck_gpu.cpp index 5833677d0e..a2a3133a24 100644 --- a/src/GPU/pair_beck_gpu.cpp +++ b/src/GPU/pair_beck_gpu.cpp @@ -17,27 +17,21 @@ ------------------------------------------------------------------------- */ #include "pair_beck_gpu.h" -#include -#include -#include #include "atom.h" #include "atom_vec.h" -#include "comm.h" -#include "force.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "integrate.h" -#include "memory.h" -#include "error.h" -#include "neigh_request.h" -#include "universe.h" -#include "update.h" #include "domain.h" +#include "error.h" +#include "force.h" #include "gpu_extra.h" #include "math_special.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" #include "suffix.h" +#include + using namespace LAMMPS_NS; using namespace MathSpecial; diff --git a/src/GPU/pair_eam_alloy_gpu.cpp b/src/GPU/pair_eam_alloy_gpu.cpp index 9c4ee76f15..fcfbc69dc7 100644 --- a/src/GPU/pair_eam_alloy_gpu.cpp +++ b/src/GPU/pair_eam_alloy_gpu.cpp @@ -71,6 +71,7 @@ double eam_alloy_gpu_bytes(); PairEAMAlloyGPU::PairEAMAlloyGPU(LAMMPS *lmp) : PairEAM(lmp), gpu_mode(GPU_FORCE) { + one_coeff = 1; respa_enable = 0; reinitflag = 0; cpu_time = 0.0; @@ -316,7 +317,7 @@ void PairEAMAlloyGPU::coeff(int narg, char **arg) if (setfl) { for (i = 0; i < setfl->nelements; i++) delete [] setfl->elements[i]; delete [] setfl->elements; - delete [] setfl->mass; + memory->destroy(setfl->mass); memory->destroy(setfl->frho); memory->destroy(setfl->rhor); memory->destroy(setfl->z2r); @@ -357,6 +358,7 @@ void PairEAMAlloyGPU::coeff(int narg, char **arg) if (i == j) atom->set_mass(FLERR,i,setfl->mass[map[i]]); count++; } + scale[i][j] = 1.0; } } @@ -373,8 +375,7 @@ void PairEAMAlloyGPU::read_file(char *filename) // read potential file if (comm->me == 0) { - PotentialFileReader reader(PairEAM::lmp, filename, - "eam/alloy", unit_convert_flag); + PotentialFileReader reader(PairEAM::lmp, filename, "eam/alloy", unit_convert_flag); // transparently convert units for supported conversions @@ -394,12 +395,8 @@ void PairEAMAlloyGPU::read_file(char *filename) error->one(FLERR,"Incorrect element names in EAM potential file"); file->elements = new char*[file->nelements]; - for (int i = 0; i < file->nelements; i++) { - const std::string word = values.next_string(); - const int n = word.length() + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i], word.c_str()); - } + for (int i = 0; i < file->nelements; i++) + file->elements[i] = utils::strdup(values.next_string()); // diff --git a/src/GPU/pair_eam_fs_gpu.cpp b/src/GPU/pair_eam_fs_gpu.cpp index b4c14d62cd..c84fd328d6 100644 --- a/src/GPU/pair_eam_fs_gpu.cpp +++ b/src/GPU/pair_eam_fs_gpu.cpp @@ -70,6 +70,7 @@ double eam_fs_gpu_bytes(); PairEAMFSGPU::PairEAMFSGPU(LAMMPS *lmp) : PairEAM(lmp), gpu_mode(GPU_FORCE) { + one_coeff = 1; respa_enable = 0; reinitflag = 0; cpu_time = 0.0; @@ -315,7 +316,7 @@ void PairEAMFSGPU::coeff(int narg, char **arg) if (fs) { for (i = 0; i < fs->nelements; i++) delete [] fs->elements[i]; delete [] fs->elements; - delete [] fs->mass; + memory->destroy(fs->mass); memory->destroy(fs->frho); memory->destroy(fs->rhor); memory->destroy(fs->z2r); @@ -356,6 +357,7 @@ void PairEAMFSGPU::coeff(int narg, char **arg) if (i == j) atom->set_mass(FLERR,i,fs->mass[map[i]]); count++; } + scale[i][j] = 1.0; } } @@ -395,9 +397,7 @@ void PairEAMFSGPU::read_file(char *filename) file->elements = new char*[file->nelements]; for (int i = 0; i < file->nelements; i++) { const std::string word = values.next_string(); - const int n = word.length() + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i], word.c_str()); + file->elements[i] = utils::strdup(word); } // @@ -408,6 +408,7 @@ void PairEAMFSGPU::read_file(char *filename) file->nr = values.next_int(); file->dr = values.next_double(); file->cut = values.next_double(); + rhomax = 0.0; if ((file->nrho <= 0) || (file->nr <= 0) || (file->dr <= 0.0)) error->one(FLERR,"Invalid EAM potential file"); @@ -455,6 +456,7 @@ void PairEAMFSGPU::read_file(char *filename) MPI_Bcast(&file->nr, 1, MPI_INT, 0, world); MPI_Bcast(&file->dr, 1, MPI_DOUBLE, 0, world); MPI_Bcast(&file->cut, 1, MPI_DOUBLE, 0, world); + MPI_Bcast(&rhomax, 1, MPI_DOUBLE, 0, world); // allocate memory on other procs if (comm->me != 0) { diff --git a/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp b/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp index afc4d15224..f1b2da38fd 100644 --- a/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp +++ b/src/GPU/pair_lj_cut_coul_dsf_gpu.cpp @@ -17,7 +17,6 @@ ------------------------------------------------------------------------- */ #include "pair_lj_cut_coul_dsf_gpu.h" -#include #include "atom.h" #include "domain.h" diff --git a/src/GPU/pair_lj_smooth_gpu.cpp b/src/GPU/pair_lj_smooth_gpu.cpp index 58ce6dadc6..fabf47ae94 100644 --- a/src/GPU/pair_lj_smooth_gpu.cpp +++ b/src/GPU/pair_lj_smooth_gpu.cpp @@ -18,23 +18,16 @@ #include "pair_lj_smooth_gpu.h" #include "atom.h" -#include "atom_vec.h" -#include "comm.h" #include "domain.h" #include "error.h" #include "force.h" #include "gpu_extra.h" -#include "integrate.h" -#include "memory.h" #include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" #include "suffix.h" -#include "universe.h" -#include "update.h" #include -#include using namespace LAMMPS_NS; diff --git a/src/GPU/pppm_gpu.cpp b/src/GPU/pppm_gpu.cpp index 4b72613e6a..d5f7e6c5af 100644 --- a/src/GPU/pppm_gpu.cpp +++ b/src/GPU/pppm_gpu.cpp @@ -18,10 +18,7 @@ #include "pppm_gpu.h" -#include "angle.h" #include "atom.h" -#include "bond.h" -#include "comm.h" #include "domain.h" #include "error.h" #include "fft3d_wrap.h" @@ -31,15 +28,12 @@ #include "gridcomm.h" #include "math_const.h" #include "memory.h" +#include "modify.h" #include "neighbor.h" -#include "pair.h" #include "remap_wrap.h" #include "universe.h" #include "update.h" -#include -#include -#include #include using namespace LAMMPS_NS; diff --git a/src/GRANULAR/compute_fabric.cpp b/src/GRANULAR/compute_fabric.cpp index 341e32b867..ac8d434b7a 100644 --- a/src/GRANULAR/compute_fabric.cpp +++ b/src/GRANULAR/compute_fabric.cpp @@ -17,7 +17,6 @@ #include "error.h" #include "force.h" #include "memory.h" -#include "modify.h" #include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" @@ -37,7 +36,7 @@ enum { CN, BR, FN, FT }; /* ---------------------------------------------------------------------- */ ComputeFabric::ComputeFabric(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), tensor_style(NULL) + Compute(lmp, narg, arg), tensor_style(nullptr) { if (narg < 3) error->all(FLERR, "Illegal compute fabric command"); @@ -80,9 +79,8 @@ ComputeFabric::ComputeFabric(LAMMPS *lmp, int narg, char **arg) : if (iarg + 1 >= narg) error->all(FLERR, "Invalid keyword in compute fabric command"); int ntypes = atom->ntypes; - int i, j, itype, jtype, in, jn, infield, jnfield; + int i, j, itype, jtype; int inlo, inhi, jnlo, jnhi; - char *istr, *jstr; if (!type_filter) { memory->create(type_filter, ntypes + 1, ntypes + 1, "compute/fabric:type_filter"); @@ -91,24 +89,12 @@ ComputeFabric::ComputeFabric(LAMMPS *lmp, int narg, char **arg) : } } - in = strlen(arg[iarg + 1]) + 1; - istr = new char[in]; - strcpy(istr, arg[iarg + 1]); - std::vector iwords = Tokenizer(istr, ",").as_vector(); - infield = iwords.size(); - - jn = strlen(arg[iarg + 2]) + 1; - jstr = new char[jn]; - strcpy(jstr, arg[iarg + 2]); - std::vector jwords = Tokenizer(jstr, ",").as_vector(); - jnfield = jwords.size(); - - for (i = 0; i < infield; i++) { - const char *ifield = iwords[i].c_str(); + std::vector iwords = Tokenizer(arg[iarg+1], ",").as_vector(); + std::vector jwords = Tokenizer(arg[iarg+2], ",").as_vector(); + for (const auto &ifield : iwords) { utils::bounds(FLERR, ifield, 1, ntypes, inlo, inhi, error); - for (j = 0; j < jnfield; j++) { - const char *jfield = jwords[j].c_str(); + for (const auto &jfield : jwords) { utils::bounds(FLERR, jfield, 1, ntypes, jnlo, jnhi, error); for (itype = inlo; itype <= inhi; itype++) { @@ -119,10 +105,6 @@ ComputeFabric::ComputeFabric(LAMMPS *lmp, int narg, char **arg) : } } } - - delete[] istr; - delete[] jstr; - iarg += 2; } else error->all(FLERR, "Illegal compute fabric command"); @@ -152,7 +134,7 @@ ComputeFabric::~ComputeFabric() void ComputeFabric::init() { - if (force->pair == NULL) error->all(FLERR, "No pair style is defined for compute fabric"); + if (force->pair == nullptr) error->all(FLERR, "No pair style is defined for compute fabric"); if (force->pair->single_enable == 0 && (fn_flag || ft_flag)) error->all(FLERR, "Pair style does not support compute fabric normal or tangential force"); diff --git a/src/GRANULAR/fix_wall_gran_region.cpp b/src/GRANULAR/fix_wall_gran_region.cpp index 37afe9632c..45905aea1c 100644 --- a/src/GRANULAR/fix_wall_gran_region.cpp +++ b/src/GRANULAR/fix_wall_gran_region.cpp @@ -46,8 +46,7 @@ FixWallGranRegion::FixWallGranRegion(LAMMPS *lmp, int narg, char **arg) : if (iregion == -1) error->all(FLERR,"Region ID for fix wall/gran/region does not exist"); region = domain->regions[iregion]; - region_style = new char[strlen(region->style)+1]; - strcpy(region_style,region->style); + region_style = utils::strdup(region->style); nregion = region->nregion; tmax = domain->regions[iregion]->tmax; diff --git a/src/INTEL/angle_charmm_intel.cpp b/src/INTEL/angle_charmm_intel.cpp index 26943934be..154e343135 100644 --- a/src/INTEL/angle_charmm_intel.cpp +++ b/src/INTEL/angle_charmm_intel.cpp @@ -29,6 +29,7 @@ #include "suffix.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/angle_harmonic_intel.cpp b/src/INTEL/angle_harmonic_intel.cpp index e392730edc..a4aedb7ddd 100644 --- a/src/INTEL/angle_harmonic_intel.cpp +++ b/src/INTEL/angle_harmonic_intel.cpp @@ -29,6 +29,7 @@ #include "suffix.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/bond_fene_intel.cpp b/src/INTEL/bond_fene_intel.cpp index 1ab8da68d9..4c92b3109f 100644 --- a/src/INTEL/bond_fene_intel.cpp +++ b/src/INTEL/bond_fene_intel.cpp @@ -28,8 +28,10 @@ #include "modify.h" #include "neighbor.h" #include "suffix.h" +#include "update.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/bond_harmonic_intel.cpp b/src/INTEL/bond_harmonic_intel.cpp index 35b194f0fa..4df95305d6 100644 --- a/src/INTEL/bond_harmonic_intel.cpp +++ b/src/INTEL/bond_harmonic_intel.cpp @@ -28,6 +28,7 @@ #include "suffix.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/dihedral_charmm_intel.cpp b/src/INTEL/dihedral_charmm_intel.cpp index 4116d9134f..5d013121b9 100644 --- a/src/INTEL/dihedral_charmm_intel.cpp +++ b/src/INTEL/dihedral_charmm_intel.cpp @@ -16,20 +16,21 @@ Contributing author: W. Michael Brown (Intel) ------------------------------------------------------------------------- */ -#include "omp_compat.h" - -#include #include "dihedral_charmm_intel.h" + #include "atom.h" #include "comm.h" #include "memory.h" +#include "error.h" +#include "force.h" #include "modify.h" #include "neighbor.h" -#include "domain.h" -#include "force.h" #include "pair.h" -#include "update.h" -#include "error.h" + +#include +#include + +#include "omp_compat.h" #ifdef LMP_USE_AVXCD #if (__INTEL_COMPILER_BUILD_DATE > 20160414) diff --git a/src/INTEL/dihedral_fourier_intel.cpp b/src/INTEL/dihedral_fourier_intel.cpp index d952ac7506..e2b0098410 100644 --- a/src/INTEL/dihedral_fourier_intel.cpp +++ b/src/INTEL/dihedral_fourier_intel.cpp @@ -26,9 +26,9 @@ #include "modify.h" #include "neighbor.h" #include "suffix.h" -#include "update.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/dihedral_harmonic_intel.cpp b/src/INTEL/dihedral_harmonic_intel.cpp index df9304b6ba..0f55f72560 100644 --- a/src/INTEL/dihedral_harmonic_intel.cpp +++ b/src/INTEL/dihedral_harmonic_intel.cpp @@ -26,9 +26,9 @@ #include "modify.h" #include "neighbor.h" #include "suffix.h" -#include "update.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/dihedral_opls_intel.cpp b/src/INTEL/dihedral_opls_intel.cpp index 89f06773d5..46ae91ae5c 100644 --- a/src/INTEL/dihedral_opls_intel.cpp +++ b/src/INTEL/dihedral_opls_intel.cpp @@ -26,9 +26,9 @@ #include "modify.h" #include "neighbor.h" #include "suffix.h" -#include "update.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/fix_nh_intel.cpp b/src/INTEL/fix_nh_intel.cpp index a4fdecbd96..91709aa13f 100644 --- a/src/INTEL/fix_nh_intel.cpp +++ b/src/INTEL/fix_nh_intel.cpp @@ -27,7 +27,6 @@ #include "neighbor.h" #include "update.h" -#include #include using namespace LAMMPS_NS; diff --git a/src/INTEL/fix_nvt_intel.cpp b/src/INTEL/fix_nvt_intel.cpp index 6ef0c9bedc..c54bd37bc6 100644 --- a/src/INTEL/fix_nvt_intel.cpp +++ b/src/INTEL/fix_nvt_intel.cpp @@ -18,8 +18,6 @@ #include "group.h" #include "modify.h" -#include - using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/INTEL/improper_cvff_intel.cpp b/src/INTEL/improper_cvff_intel.cpp index 4d473de7aa..04eede6517 100644 --- a/src/INTEL/improper_cvff_intel.cpp +++ b/src/INTEL/improper_cvff_intel.cpp @@ -27,9 +27,9 @@ #include "modify.h" #include "neighbor.h" #include "suffix.h" -#include "update.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/improper_harmonic_intel.cpp b/src/INTEL/improper_harmonic_intel.cpp index 1a637fa1a6..beda76bc09 100644 --- a/src/INTEL/improper_harmonic_intel.cpp +++ b/src/INTEL/improper_harmonic_intel.cpp @@ -28,9 +28,9 @@ #include "modify.h" #include "neighbor.h" #include "suffix.h" -#include "update.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/intel_buffers.cpp b/src/INTEL/intel_buffers.cpp index 4efd61bac9..d86570b0d3 100644 --- a/src/INTEL/intel_buffers.cpp +++ b/src/INTEL/intel_buffers.cpp @@ -18,6 +18,8 @@ #include "force.h" #include "memory.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/INTEL/intel_buffers.h b/src/INTEL/intel_buffers.h index 607cc2fd82..9e855c4959 100644 --- a/src/INTEL/intel_buffers.h +++ b/src/INTEL/intel_buffers.h @@ -26,7 +26,6 @@ #include "neighbor.h" #include "neigh_list.h" #include "intel_preprocess.h" -#include namespace LAMMPS_NS { @@ -35,7 +34,7 @@ namespace LAMMPS_NS { #define FORCE_T typename IntelBuffers::vec3_acc_t struct IntelNeighListPtrs { - void * list_ptr; + void *list_ptr; int *cnumneigh; int *numneighhalf; int size; diff --git a/src/INTEL/npair_full_bin_ghost_intel.cpp b/src/INTEL/npair_full_bin_ghost_intel.cpp index e96f2c713d..1f4e41be49 100644 --- a/src/INTEL/npair_full_bin_ghost_intel.cpp +++ b/src/INTEL/npair_full_bin_ghost_intel.cpp @@ -20,11 +20,13 @@ #include "atom.h" #include "comm.h" +#include "domain.h" #include "error.h" -#include "molecule.h" #include "neigh_list.h" #include "neighbor.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/INTEL/npair_full_bin_intel.cpp b/src/INTEL/npair_full_bin_intel.cpp index 82c73ec940..c0f3874eee 100644 --- a/src/INTEL/npair_full_bin_intel.cpp +++ b/src/INTEL/npair_full_bin_intel.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "neigh_list.h" #include "neighbor.h" diff --git a/src/INTEL/npair_half_bin_newton_intel.cpp b/src/INTEL/npair_half_bin_newton_intel.cpp index 21145ad647..accef78573 100644 --- a/src/INTEL/npair_half_bin_newton_intel.cpp +++ b/src/INTEL/npair_half_bin_newton_intel.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "neigh_list.h" #include "neighbor.h" diff --git a/src/INTEL/npair_half_bin_newton_tri_intel.cpp b/src/INTEL/npair_half_bin_newton_tri_intel.cpp index 1ad4d5fc68..db517f6da4 100644 --- a/src/INTEL/npair_half_bin_newton_tri_intel.cpp +++ b/src/INTEL/npair_half_bin_newton_tri_intel.cpp @@ -20,6 +20,7 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "neigh_list.h" #include "neighbor.h" diff --git a/src/INTEL/npair_halffull_newton_intel.cpp b/src/INTEL/npair_halffull_newton_intel.cpp index 9b9e96aeca..a30ff76cdb 100644 --- a/src/INTEL/npair_halffull_newton_intel.cpp +++ b/src/INTEL/npair_halffull_newton_intel.cpp @@ -24,7 +24,6 @@ #include "modify.h" #include "my_page.h" #include "neigh_list.h" -#include "neighbor.h" using namespace LAMMPS_NS; diff --git a/src/INTEL/pair_airebo_intel.cpp b/src/INTEL/pair_airebo_intel.cpp index be38bbe418..95b80fe801 100644 --- a/src/INTEL/pair_airebo_intel.cpp +++ b/src/INTEL/pair_airebo_intel.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "force.h" #include "math_const.h" #include "memory.h" #include "modify.h" diff --git a/src/INTEL/pair_buck_coul_cut_intel.cpp b/src/INTEL/pair_buck_coul_cut_intel.cpp index 2633fd4ab2..b8d12c1453 100644 --- a/src/INTEL/pair_buck_coul_cut_intel.cpp +++ b/src/INTEL/pair_buck_coul_cut_intel.cpp @@ -22,9 +22,6 @@ #include "comm.h" #include "error.h" #include "force.h" -#include "force.h" -#include "group.h" -#include "kspace.h" #include "math_const.h" #include "memory.h" #include "modify.h" diff --git a/src/INTEL/pair_buck_coul_long_intel.cpp b/src/INTEL/pair_buck_coul_long_intel.cpp index d9d618e4a8..0050037ca6 100644 --- a/src/INTEL/pair_buck_coul_long_intel.cpp +++ b/src/INTEL/pair_buck_coul_long_intel.cpp @@ -22,8 +22,6 @@ #include "comm.h" #include "error.h" #include "force.h" -#include "force.h" -#include "group.h" #include "kspace.h" #include "math_const.h" #include "memory.h" diff --git a/src/INTEL/pair_buck_intel.cpp b/src/INTEL/pair_buck_intel.cpp index 9bad314fcf..b21514c3ac 100644 --- a/src/INTEL/pair_buck_intel.cpp +++ b/src/INTEL/pair_buck_intel.cpp @@ -21,6 +21,7 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "force.h" #include "math_const.h" #include "memory.h" #include "modify.h" @@ -30,6 +31,7 @@ #include "suffix.h" #include +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/INTEL/pair_dpd_intel.cpp b/src/INTEL/pair_dpd_intel.cpp index e6ffd1ca44..d3527355a6 100644 --- a/src/INTEL/pair_dpd_intel.cpp +++ b/src/INTEL/pair_dpd_intel.cpp @@ -18,6 +18,7 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "memory.h" #include "modify.h" @@ -28,6 +29,9 @@ #include +#if defined(_OPENMP) +#include +#endif using namespace LAMMPS_NS; #define LMP_MKL_RNG VSL_BRNG_MT19937 diff --git a/src/INTEL/pair_gayberne_intel.cpp b/src/INTEL/pair_gayberne_intel.cpp index 139792e543..ea2115c06b 100644 --- a/src/INTEL/pair_gayberne_intel.cpp +++ b/src/INTEL/pair_gayberne_intel.cpp @@ -27,6 +27,7 @@ #include "atom.h" #include "atom_vec_ellipsoid.h" #include "comm.h" +#include "error.h" #include "force.h" #include "memory.h" #include "modify.h" @@ -35,6 +36,8 @@ #include "neighbor.h" #include "suffix.h" +#include + using namespace LAMMPS_NS; #define FC_PACKED1_T typename ForceConst::fc_packed1 diff --git a/src/INTEL/pair_lj_charmm_coul_long_intel.cpp b/src/INTEL/pair_lj_charmm_coul_long_intel.cpp index 696f5948ac..29efc27b07 100644 --- a/src/INTEL/pair_lj_charmm_coul_long_intel.cpp +++ b/src/INTEL/pair_lj_charmm_coul_long_intel.cpp @@ -17,11 +17,10 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" -#include "group.h" #include "kspace.h" #include "memory.h" -#include "memory.h" #include "modify.h" #include "neigh_list.h" #include "neigh_request.h" @@ -29,6 +28,7 @@ #include "suffix.h" #include +#include using namespace LAMMPS_NS; diff --git a/src/INTEL/pair_lj_cut_coul_long_intel.cpp b/src/INTEL/pair_lj_cut_coul_long_intel.cpp index f78f579a9a..e5b0285439 100644 --- a/src/INTEL/pair_lj_cut_coul_long_intel.cpp +++ b/src/INTEL/pair_lj_cut_coul_long_intel.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "kspace.h" #include "memory.h" @@ -27,6 +28,7 @@ #include "suffix.h" #include +#include using namespace LAMMPS_NS; diff --git a/src/INTEL/pair_lj_cut_intel.cpp b/src/INTEL/pair_lj_cut_intel.cpp index afd01e9919..8ecb72928c 100644 --- a/src/INTEL/pair_lj_cut_intel.cpp +++ b/src/INTEL/pair_lj_cut_intel.cpp @@ -17,6 +17,7 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "memory.h" #include "modify.h" @@ -25,7 +26,7 @@ #include "neighbor.h" #include "suffix.h" -#include +#include using namespace LAMMPS_NS; diff --git a/src/INTEL/pair_lj_long_coul_long_intel.cpp b/src/INTEL/pair_lj_long_coul_long_intel.cpp index eb70745318..9f720d9c06 100644 --- a/src/INTEL/pair_lj_long_coul_long_intel.cpp +++ b/src/INTEL/pair_lj_long_coul_long_intel.cpp @@ -18,20 +18,10 @@ #include "pair_lj_long_coul_long_intel.h" -#include "atom.h" -#include "comm.h" -#include "memory.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "neighbor.h" #include "suffix.h" using namespace LAMMPS_NS; -#define C_FORCE_T typename ForceConst::c_force_t -#define C_ENERGY_T typename ForceConst::c_energy_t -#define TABLE_T typename ForceConst::table_t - PairLJLongCoulLongIntel::PairLJLongCoulLongIntel(LAMMPS *lmp) : PairLJLongCoulLong(lmp) { diff --git a/src/INTEL/pair_sw_intel.cpp b/src/INTEL/pair_sw_intel.cpp index 0a7e3baca0..fd043ae5a1 100644 --- a/src/INTEL/pair_sw_intel.cpp +++ b/src/INTEL/pair_sw_intel.cpp @@ -21,12 +21,12 @@ #include "atom.h" #include "comm.h" #include "error.h" +#include "force.h" #include "memory.h" #include "modify.h" #include "neigh_list.h" #include "neigh_request.h" #include "neighbor.h" -#include "neighbor.h" #include "suffix.h" #include diff --git a/src/INTEL/pair_tersoff_intel.cpp b/src/INTEL/pair_tersoff_intel.cpp index 3c963cb850..3165776c19 100644 --- a/src/INTEL/pair_tersoff_intel.cpp +++ b/src/INTEL/pair_tersoff_intel.cpp @@ -18,17 +18,13 @@ #include "pair_tersoff_intel.h" -#include "atom.h" -#include "neighbor.h" +#include "comm.h" +#include "error.h" +#include "force.h" +#include "memory.h" #include "neigh_list.h" #include "neigh_request.h" -#include "force.h" -#include "comm.h" -#include "memory.h" -#include "error.h" - -#include -#include +#include "neighbor.h" using namespace LAMMPS_NS; diff --git a/src/INTEL/pppm_disp_intel.cpp b/src/INTEL/pppm_disp_intel.cpp index 61c4ea3a7c..67dd788653 100644 --- a/src/INTEL/pppm_disp_intel.cpp +++ b/src/INTEL/pppm_disp_intel.cpp @@ -22,6 +22,7 @@ #include "comm.h" #include "domain.h" #include "error.h" +#include "force.h" #include "gridcomm.h" #include "math_const.h" #include "math_special.h" @@ -30,6 +31,7 @@ #include "suffix.h" #include +#include #include "omp_compat.h" diff --git a/src/INTEL/pppm_intel.cpp b/src/INTEL/pppm_intel.cpp index 2392f84aa0..4c79ccecf5 100644 --- a/src/INTEL/pppm_intel.cpp +++ b/src/INTEL/pppm_intel.cpp @@ -25,6 +25,7 @@ #include "comm.h" #include "domain.h" #include "error.h" +#include "force.h" #include "gridcomm.h" #include "math_const.h" #include "math_special.h" @@ -32,7 +33,6 @@ #include "modify.h" #include "suffix.h" -#include #include #include "omp_compat.h" diff --git a/src/INTEL/verlet_lrt_intel.cpp b/src/INTEL/verlet_lrt_intel.cpp index 150a6ebd7b..216ba98302 100644 --- a/src/INTEL/verlet_lrt_intel.cpp +++ b/src/INTEL/verlet_lrt_intel.cpp @@ -12,28 +12,28 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include #include "verlet_lrt_intel.h" -#include "neighbor.h" -#include "domain.h" -#include "comm.h" + +#include "angle.h" #include "atom.h" #include "atom_vec.h" -#include "force.h" -#include "pair.h" #include "bond.h" -#include "angle.h" +#include "comm.h" +#include "compute.h" #include "dihedral.h" +#include "domain.h" +#include "error.h" +#include "fix.h" +#include "force.h" #include "improper.h" #include "kspace.h" -#include "output.h" -#include "update.h" -#include "modify.h" -#include "compute.h" -#include "fix.h" -#include "timer.h" #include "memory.h" -#include "error.h" +#include "modify.h" +#include "neighbor.h" +#include "output.h" +#include "pair.h" +#include "timer.h" +#include "update.h" #if defined(_OPENMP) #include diff --git a/src/KIM/kim_units.cpp b/src/KIM/kim_units.cpp index 82bbc46227..1377e3c4ee 100644 --- a/src/KIM/kim_units.cpp +++ b/src/KIM/kim_units.cpp @@ -54,10 +54,9 @@ Designed for use with the kim-api-2.0.2 (and newer) package ------------------------------------------------------------------------- */ -#include -#include -#include +#include #include +#include #include using namespace std; diff --git a/src/KSPACE/fft3d.cpp b/src/KSPACE/fft3d.cpp index 130aaebf21..d35028f280 100644 --- a/src/KSPACE/fft3d.cpp +++ b/src/KSPACE/fft3d.cpp @@ -308,10 +308,9 @@ struct fft_plan_3d *fft_3d_create_plan( first_jhi = (ip1+1)*nmid/np1 - 1; first_klo = ip2*nslow/np2; first_khi = (ip2+1)*nslow/np2 - 1; - plan->pre_plan = - remap_3d_create_plan(comm,in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi, - first_ilo,first_ihi,first_jlo,first_jhi, - first_klo,first_khi,2,0,0,FFT_PRECISION,0); + plan->pre_plan = remap_3d_create_plan(comm,in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi, + first_ilo,first_ihi,first_jlo,first_jhi, + first_klo,first_khi,2,0,0,FFT_PRECISION,0); if (plan->pre_plan == nullptr) return nullptr; } @@ -330,13 +329,10 @@ struct fft_plan_3d *fft_3d_create_plan( second_jhi = nmid - 1; second_klo = ip2*nslow/np2; second_khi = (ip2+1)*nslow/np2 - 1; - plan->mid1_plan = - remap_3d_create_plan(comm, - first_ilo,first_ihi,first_jlo,first_jhi, - first_klo,first_khi, - second_ilo,second_ihi,second_jlo,second_jhi, - second_klo,second_khi,2,1,0,FFT_PRECISION, - usecollective); + plan->mid1_plan = remap_3d_create_plan(comm, first_ilo,first_ihi,first_jlo,first_jhi, + first_klo,first_khi,second_ilo,second_ihi, + second_jlo,second_jhi,second_klo,second_khi, + 2,1,0,FFT_PRECISION,usecollective); if (plan->mid1_plan == nullptr) return nullptr; // 1d FFTs along mid axis diff --git a/src/KSPACE/fft3d_wrap.h b/src/KSPACE/fft3d_wrap.h index 58a6957a2b..1deccc801b 100644 --- a/src/KSPACE/fft3d_wrap.h +++ b/src/KSPACE/fft3d_wrap.h @@ -14,7 +14,7 @@ #ifndef LMP_FFT3D_WRAP_H #define LMP_FFT3D_WRAP_H -#include "fft3d.h" +#include "fft3d.h" // IWYU pragma: export #include "pointers.h" namespace LAMMPS_NS { diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index c54a115ab2..b6739d43fd 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -174,9 +174,9 @@ PPPM::~PPPM() if (copymode) return; delete [] factors; - deallocate(); - if (peratom_allocate_flag) deallocate_peratom(); - if (group_allocate_flag) deallocate_groups(); + PPPM::deallocate(); + if (peratom_allocate_flag) PPPM::deallocate_peratom(); + if (group_allocate_flag) PPPM::deallocate_groups(); memory->destroy(part2grid); memory->destroy(acons); } diff --git a/src/KSPACE/pppm_dipole.cpp b/src/KSPACE/pppm_dipole.cpp index c2e6eca585..a39973c6ae 100644 --- a/src/KSPACE/pppm_dipole.cpp +++ b/src/KSPACE/pppm_dipole.cpp @@ -88,8 +88,8 @@ PPPMDipole::~PPPMDipole() { if (copymode) return; - deallocate(); - if (peratom_allocate_flag) deallocate_peratom(); + PPPMDipole::deallocate(); + if (peratom_allocate_flag) PPPMDipole::deallocate_peratom(); } /* ---------------------------------------------------------------------- diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index 530995cae2..a523fcce9e 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -245,8 +245,8 @@ PPPMDisp::~PPPMDisp() cii = nullptr; delete [] csumi; csumi = nullptr; - deallocate(); - deallocate_peratom(); + PPPMDisp::deallocate(); + PPPMDisp::deallocate_peratom(); memory->destroy(part2grid); memory->destroy(part2grid_6); part2grid = part2grid_6 = nullptr; diff --git a/src/MANIFOLD/manifold_factory.cpp b/src/MANIFOLD/manifold_factory.cpp index 6fa73643b5..9524791916 100644 --- a/src/MANIFOLD/manifold_factory.cpp +++ b/src/MANIFOLD/manifold_factory.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -42,35 +41,43 @@ #include "manifold_plane.h" #include "manifold_plane_wiggle.h" #include "manifold_sphere.h" -#include "manifold_supersphere.h" #include "manifold_spine.h" +#include "manifold_supersphere.h" #include "manifold_thylakoid.h" #include "manifold_torus.h" -using namespace LAMMPS_NS; -using namespace user_manifold; +#include +namespace LAMMPS_NS { +namespace user_manifold { -manifold* LAMMPS_NS::user_manifold::create_manifold(const char *mname, - LAMMPS *lmp, - int narg, char **arg ) -{ - manifold *man = nullptr; - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); - make_manifold_if ( &man, mname, lmp, narg, arg ); + template + void make_manifold_if(manifold **man_ptr, const char *name, LAMMPS *lmp, int narg, char **arg) + { + if (strcmp(m_type::type(), name) == 0) { + if (*man_ptr == nullptr) { *man_ptr = new m_type(lmp, narg, arg); } + } + } + manifold *create_manifold(const char *mname, LAMMPS *lmp, int narg, char **arg) + { + manifold *man = nullptr; + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); + make_manifold_if(&man, mname, lmp, narg, arg); - return man; -} + return man; + } +} // namespace user_manifold +} // namespace LAMMPS_NS diff --git a/src/MANIFOLD/manifold_factory.h b/src/MANIFOLD/manifold_factory.h index 4cf27b0b83..b242b8ec36 100644 --- a/src/MANIFOLD/manifold_factory.h +++ b/src/MANIFOLD/manifold_factory.h @@ -34,28 +34,11 @@ #ifndef LMP_MANIFOLD_FACTORY_H #define LMP_MANIFOLD_FACTORY_H -#include -#include - namespace LAMMPS_NS { class LAMMPS; - namespace user_manifold { - - // forward declaration class manifold; - - // Templated, so needs to be in header. - template - void make_manifold_if(manifold **man_ptr, const char *name, LAMMPS *lmp, int narg, char **arg) - { - if (strcmp(m_type::type(), name) == 0) { - if (*man_ptr == nullptr) { *man_ptr = new m_type(lmp, narg, arg); } - } - } - manifold *create_manifold(const char *, LAMMPS *, int, char **); - } // namespace user_manifold } // namespace LAMMPS_NS diff --git a/src/MANYBODY/pair_airebo.cpp b/src/MANYBODY/pair_airebo.cpp index 67ff81d4a3..a02a5718ff 100644 --- a/src/MANYBODY/pair_airebo.cpp +++ b/src/MANYBODY/pair_airebo.cpp @@ -35,7 +35,6 @@ #include "neighbor.h" #include "potential_file_reader.h" #include "text_file_reader.h" -#include "tokenizer.h" #include #include diff --git a/src/MANYBODY/pair_bop.cpp b/src/MANYBODY/pair_bop.cpp index e2a677c2a0..397259ee21 100644 --- a/src/MANYBODY/pair_bop.cpp +++ b/src/MANYBODY/pair_bop.cpp @@ -50,11 +50,10 @@ #include "neighbor.h" #include "potential_file_reader.h" #include "tabular_function.h" -#include "utils.h" +#include "tokenizer.h" #include #include -#include using namespace LAMMPS_NS; using MathSpecial::square; diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 689ba992d8..75906cd7df 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -28,6 +28,7 @@ #include "group.h" #include "math_const.h" #include "math_extra.h" +#include "math_special.h" #include "memory.h" #include "my_page.h" #include "neigh_list.h" @@ -42,6 +43,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathExtra; +using namespace MathSpecial; #define DELTA 4 #define PGDELTA 1 @@ -712,7 +714,7 @@ void PairComb::setup_params() params[m].Qo1 = (params[m].QU1+params[m].QL1)/2.0; // (A22) params[m].dQ1 = (params[m].QU1-params[m].QL1)/2.0; // (A21) params[m].aB1 = 1.0 / - (1.0-pow(fabs(params[m].Qo1/params[m].dQ1),10.0)); // (A20) + (1.0-powint(fabs(params[m].Qo1/params[m].dQ1),10)); // (A20) params[m].bB1 = pow(fabs(params[m].aB1),0.1)/params[m].dQ1; // (A19) params[m].nD1 = log(params[m].DU1/(params[m].DU1-params[m].DL1))/ log(params[m].QU1/(params[m].QU1-params[m].QL1)); @@ -722,7 +724,7 @@ void PairComb::setup_params() params[m].Qo2 = (params[m].QU2+params[m].QL2)/2.0; // (A22) params[m].dQ2 = (params[m].QU2-params[m].QL2)/2.0; // (A21) params[m].aB2 = 1.0 / - (1.0-pow(fabs(params[m].Qo2/params[m].dQ2),10.0)); // (A20) + (1.0-powint(fabs(params[m].Qo2/params[m].dQ2),10)); // (A20) params[m].bB2 = pow(fabs(params[m].aB2),0.1)/params[m].dQ2; // (A19) params[m].nD2 = log(params[m].DU2/(params[m].DU2-params[m].DL2))/ log(params[m].QU2/(params[m].QU2-params[m].QL2)); @@ -789,7 +791,7 @@ void PairComb::repulsive(Param *param, double rsq, double &fforce, vrcs = 0.0; fvrcs = 0.0; if (romi > 0.0) { if (!cor_flag) { - vrcs = romi * pow((1.0-r/rrcs),2.0); + vrcs = romi * square(1.0-r/rrcs); fvrcs= romi * 2.0 * (r/rrcs-1.0)/rrcs; } else if (cor_flag) { rslp = ((arr1-r)/(arr1-arr2)); @@ -818,7 +820,7 @@ double PairComb::zeta(Param *param, double rsqij, double rsqik, rik = sqrt(rsqik); costheta = dot3(delrij,delrik) / (rij*rik); - if (param->powermint == 3) arg = pow(param->rlm2 * (rij-rik),3.0); + if (param->powermint == 3) arg = cube(param->rlm2 * (rij-rik)); else arg = param->rlm2 * (rij-rik); if (arg > 69.0776) ex_delr = 1.e30; @@ -1071,8 +1073,8 @@ double PairComb::self(Param *param, double qi, double selfpot) self_tmp = qi*(s1+qi*(s2+selfpot+qi*(s3+qi*(s4+qi*qi*s5)))); - if (qi < qmin) self_tmp += cmin * pow((qi-qmin),4.0); - if (qi > qmax) self_tmp += cmax * pow((qi-qmax),4.0); + if (qi < qmin) self_tmp += cmin * powint(qi-qmin,4); + if (qi > qmax) self_tmp += cmax * powint(qi-qmax,4); return self_tmp; } @@ -1090,9 +1092,9 @@ double PairComb::comb_fa(double r, Param *param, double iq, double jq) Di = param->DU1 + pow(fabs(param->bD1*(param->QU1-qi)),param->nD1); Dj = param->DU2 + pow(fabs(param->bD2*(param->QU2-qj)),param->nD2); Bsi = param->bigb1 * exp(param->lam21*Di)* - (param->aB1-fabs(pow(param->bB1*(qi-param->Qo1),10.0))); + (param->aB1-fabs(powint(param->bB1*(qi-param->Qo1),10))); Bsj = param->bigb2 * exp(param->lam22*Dj)* - (param->aB2-fabs(pow(param->bB2*(qj-param->Qo2),10.0))); + (param->aB2-fabs(powint(param->bB2*(qj-param->Qo2),10))); if (Bsi > 0.0 && Bsj > 0.0) bigB = sqrt(Bsi*Bsj)*param->romigb; else bigB = 0.0; @@ -1112,9 +1114,9 @@ double PairComb::comb_fa_d(double r, Param *param, double iq, double jq) Di = param->DU1 + pow(fabs(param->bD1*(param->QU1-qi)),param->nD1); Dj = param->DU2 + pow(fabs(param->bD2*(param->QU2-qj)),param->nD2); Bsi = param->bigb1 * exp(param->lam21*Di)* - (param->aB1-fabs(pow(param->bB1*(qi-param->Qo1),10.0))); + (param->aB1-fabs(powint(param->bB1*(qi-param->Qo1),10))); Bsj = param->bigb2 * exp(param->lam22*Dj)* - (param->aB2-fabs(pow(param->bB2*(qj-param->Qo2),10.0))); + (param->aB2-fabs(powint(param->bB2*(qj-param->Qo2),10))); if (Bsi > 0.0 && Bsj > 0.0) bigB = sqrt(Bsi*Bsj)*param->romigb; else bigB = 0.0; @@ -1188,7 +1190,7 @@ void PairComb::comb_zetaterm_d(double prefactor, double *rij_hat, double rij, fc = comb_fc(rik,param); dfc = comb_fc_d(rik,param); - if (param->powermint == 3) tmp = pow(param->rlm2 * (rij-rik),3.0); + if (param->powermint == 3) tmp = cube(param->rlm2 * (rij-rik)); else tmp = param->rlm2 * (rij-rik); if (tmp > 69.0776) ex_delr = 1.e30; @@ -1196,7 +1198,7 @@ void PairComb::comb_zetaterm_d(double prefactor, double *rij_hat, double rij, else ex_delr = exp(tmp); // ex_delr is Ygexp if (param->powermint == 3) - ex_delr_d = 3.0*pow(param->rlm2,3.0) * pow(rij-rik,2.0)*ex_delr; // com3 + ex_delr_d = 3.0*cube(param->rlm2) * square(rij-rik)*ex_delr; // com3 else ex_delr_d = param->rlm2 * ex_delr; // com3 cos_theta = dot3(rij_hat,rik_hat); @@ -1723,20 +1725,11 @@ double PairComb::qfo_self(Param *param, double qi, double selfpot) self_d = s1+qi*(2.0*(s2+selfpot)+qi*(3.0*s3+qi*(4.0*s4+qi*qi*6.0*s5))); - if (qi < qmin) { - // char str[128]; - // sprintf(str,"Pair COMB charge %.10f with force %.10f hit min barrier", - // qi,self_d); - // error->warning(FLERR,str,0); - self_d += 4.0 * cmin * pow((qi-qmin),3.0); - } - if (qi > qmax) { - // char str[128]; - // sprintf(str,"Pair COMB charge %.10f with force %.10f hit max barrier", - // qi,self_d); - // error->warning(FLERR,str,0); - self_d += 4.0 * cmax * pow((qi-qmax),3.0); - } + if (qi < qmin) + self_d += 4.0 * cmin * cube(qi-qmin); + + if (qi > qmax) + self_d += 4.0 * cmax * cube(qi-qmax); return self_d; } @@ -1820,7 +1813,7 @@ void PairComb::qfo_short(Param *param, int i, int j, double rsq, vrcs = 0.0; if (romi > 0.0) { - if (!cor_flag) vrcs = romi * pow((1.0-r/rrcs),2.0); + if (!cor_flag) vrcs = romi * cube(1.0-r/rrcs); else if (cor_flag) { rslp = ((arr1-r)/(arr1-arr2)); rslp2 = rslp * rslp; rslp4 = rslp2 * rslp2; @@ -1834,9 +1827,9 @@ void PairComb::qfo_short(Param *param, int i, int j, double rsq, Asi = param->biga1 * exp(param->lam11*Di); Asj = param->biga2 * exp(param->lam12*Dj); Bsi = param->bigb1 * exp(param->lam21*Di)* - (param->aB1-fabs(pow(param->bB1*(qi-param->Qo1),10.0))); + (param->aB1-fabs(powint(param->bB1*(qi-param->Qo1),10))); Bsj = param->bigb2 * exp(param->lam22*Dj)* - (param->aB2-fabs(pow(param->bB2*(qj-param->Qo2),10.0))); + (param->aB2-fabs(powint(param->bB2*(qj-param->Qo2),10))); QUchi = (param->QU1-qi)*param->bD1; QUchj = (param->QU2-qj)*param->bD2; @@ -1858,13 +1851,13 @@ void PairComb::qfo_short(Param *param, int i, int j, double rsq, YYBsiqp=Bsi*param->lam21*YYDiqp; else YYBsiqp=Bsi*param->lam21*YYDiqp-param->bigb1*exp(param->lam21*Di)* - 10.0*QOchi*param->bB1*pow(fabs(QOchi),(10.0-2.0)); + 10.0*QOchi*param->bB1*powint(fabs(QOchi),(10-2)); if (QOchj == 0.0) YYBsjqp=Bsj*param->lam22*YYDjqp; else YYBsjqp=Bsj*param->lam22*YYDjqp-param->bigb2*exp(param->lam22*Dj)* - 10.0*QOchj*param->bB2*pow(fabs(QOchj),(10.0-2.0)); + 10.0*QOchj*param->bB2*powint(fabs(QOchj),(10-2)); if (Asi > 0.0 && Asj > 0.0) caj = 1.0/(2.0*sqrt(Asi*Asj)) * romie; else caj = 0.0; diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index eee97849b9..f0ded17258 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -27,6 +27,7 @@ #include "group.h" #include "math_const.h" #include "math_extra.h" +#include "math_special.h" #include "memory.h" #include "my_page.h" #include "neigh_list.h" @@ -34,7 +35,6 @@ #include "neighbor.h" #include "potential_file_reader.h" #include "text_file_reader.h" -#include "tokenizer.h" #include #include @@ -42,6 +42,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathExtra; +using namespace MathSpecial; #define DELTA 4 #define PGDELTA 1 @@ -398,6 +399,24 @@ void PairComb3::read_lib() } } + k = 0; + for (i=0; i<4; i++) + for (j=0; j<4; j++) { + iin2[k][0] = i; + iin2[k][1] = j; + k++; + } + + l = 0; + for (i=0; i<4; i++) + for (j=0; j<4; j++) + for (k=0; k<4; k++) { + iin3[l][0] = i; + iin3[l][1] = j; + iin3[l][2] = k; + l++; + } + } catch (FileReaderException &fre) { error->one(FLERR, fre.what()); } catch (TokenizerException &e) { @@ -405,24 +424,6 @@ void PairComb3::read_lib() } } - k = 0; - for (i=0; i<4; i++) - for (j=0; j<4; j++) { - iin2[k][0] = i; - iin2[k][1] = j; - k ++; - } - - l = 0; - for (i=0; i<4; i++) - for (j=0; j<4; j++) - for (k=0; k<4; k++) { - iin3[l][0] = i; - iin3[l][1] = j; - iin3[l][2] = k; - l ++; - } - MPI_Bcast(&ccutoff[0],6,MPI_DOUBLE,0,world); MPI_Bcast(&ch_a[0],7,MPI_DOUBLE,0,world); MPI_Bcast(&nsplpcn,1,MPI_INT,0,world); @@ -459,8 +460,8 @@ void PairComb3::read_lib() MPI_Bcast(&tor_gridz[0][0][0][0],275,MPI_DOUBLE,0,world); MPI_Bcast(&tor_spl[0][0][0][0][0],10240,MPI_DOUBLE,0,world); - MPI_Bcast(&iin2[0][0],32,MPI_INT,0,world); - MPI_Bcast(&iin3[0][0],192,MPI_INT,0,world); + MPI_Bcast(&iin2[0][0],32,MPI_DOUBLE,0,world); + MPI_Bcast(&iin3[0][0],192,MPI_DOUBLE,0,world); } /* ---------------------------------------------------------------------- */ @@ -666,7 +667,7 @@ void PairComb3::setup_params() params[m].Qo = (params[m].QU+params[m].QL)/2.0; // (A22) params[m].dQ = (params[m].QU-params[m].QL)/2.0; // (A21) params[m].aB = 1.0 / - (1.0-pow(fabs(params[m].Qo/params[m].dQ),10)); // (A20) + (1.0-powint(fabs(params[m].Qo/params[m].dQ),10)); // (A20) params[m].bB = pow(fabs(params[m].aB),0.1)/params[m].dQ; // (A19) params[m].nD = log(params[m].DU/(params[m].DU-params[m].DL))/ log(params[m].QU/(params[m].QU-params[m].QL)); @@ -1432,7 +1433,7 @@ void PairComb3::repulsive(Param *parami, Param *paramj, double rsq, vrcs = 1.0; fvrcs = 0.0; if (romi != 0.0 && r < addr) { - vrcs += romi * pow((1.0-r/addr),2.0); + vrcs += romi * square(1.0-r/addr); fvrcs = romi * 2.0 * (r/addr-1.0)/addr; fforce = fforce*vrcs - caj * tmp_fc * vrcs * fvrcs; } @@ -1455,7 +1456,7 @@ double PairComb3::zeta(Param *parami, Param *paramj, double rsqij, costheta = dot3(delrij,delrik) / (rij*rik); rlm3 = parami->beta; - arg = pow(rlm3*(rij-rik),int(parami->powermint)); + arg = powint(rlm3*(rij-rik),int(parami->powermint)); if (arg > 69.0776) ex_delr = 1.e30; else if (arg < -69.0776) ex_delr = 0.0; else ex_delr = exp(arg); @@ -1776,8 +1777,8 @@ double PairComb3::self(Param *param, double qi) self_tmp = qi*(s1+qi*(s2+qi*(s3+qi*s4))); - if (qi < qmin) self_tmp += cmin * pow((qi-qmin),4); - if (qi > qmax) self_tmp += cmax * pow((qi-qmax),4); + if (qi < qmin) self_tmp += cmin * powint((qi-qmin),4); + if (qi > qmax) self_tmp += cmax * powint((qi-qmax),4); return self_tmp; } @@ -1802,8 +1803,8 @@ void PairComb3::comb_fa(double r, Param *parami, Param *paramj, double iq, Di = Dj = Bsi = 0.0; Di = parami->DU + pow(fabs(parami->bD*(parami->QU-qi)),parami->nD); Dj = paramj->DU + pow(fabs(paramj->bD*(paramj->QU-qj)),paramj->nD); - YYBn = (parami->aB-fabs(pow(parami->bB*(qi-parami->Qo),10))); - YYBj = (paramj->aB-fabs(pow(paramj->bB*(qj-paramj->Qo),10))); + YYBn = (parami->aB-fabs(powint(parami->bB*(qi-parami->Qo),10))); + YYBj = (paramj->aB-fabs(powint(paramj->bB*(qj-paramj->Qo),10))); if (YYBn*YYBj > 0.0) { AlfDiAlfDj = exp(0.5*(parami->alfi*Di+paramj->alfi*Dj)); @@ -2124,7 +2125,7 @@ void PairComb3::comb_zetaterm_d(double prefac_ij1, double prefac_ij2, fc_k = comb_fc(rik,paramk); dfc_k = comb_fc_d(rik,paramk); rlm3 = parami->beta; - tmp = pow(rlm3*(rij-rik),mint); + tmp = powint(rlm3*(rij-rik),mint); if (tmp > 69.0776) ex_delr = 1.e30; else if (tmp < -69.0776) ex_delr = 0.0; @@ -2155,7 +2156,7 @@ void PairComb3::comb_zetaterm_d(double prefac_ij1, double prefac_ij2, com3k = 0.0; } - ex_delr_d = mint*pow(rlm3,mint)*pow((rij-rik),(mint-1))*ex_delr; // com3 + ex_delr_d = mint*powint(rlm3,mint)*powint((rij-rik),(mint-1))*ex_delr; // com3 scale3(-dfc_k*gijk*ex_delr,rik_hat,dri); // com1 scaleadd3(fc_k*gijk_d*ex_delr,dcosdri,dri,dri); // com2 scaleadd3(fc_k*gijk*ex_delr_d,rik_hat,dri,dri); // com3 cont'd @@ -2690,10 +2691,10 @@ void PairComb3::field(Param *parami, Param *paramj, double rsq, double iq, pcmi1 = parami->pcmn1; pcmi2 = parami->pcmn2; - rf3i = r3/(pow(r3,2)+pow(pcmi1,3)); - rcf3i = rc3/(pow(rc3,2)+pow(pcmi1,3)); - rf5i = r5/(pow(r5,2)+pow(pcmi2,5)); - rcf5i = rc5/(pow(rc5,2)+pow(pcmi2,5)); + rf3i = r3/(square(r3)+cube(pcmi1)); + rcf3i = rc3/(square(rc3)+cube(pcmi1)); + rf5i = r5/(square(r5)+powint(pcmi2,5)); + rcf5i = rc5/(square(rc5)+powint(pcmi2,5)); drf3i = 3/r*rf3i-6*rsq*rf3i*rf3i; drcf3i = 3/rc*rcf3i-6*rc2*rcf3i*rcf3i; @@ -2742,7 +2743,7 @@ void PairComb3::rad_calc(double r, Param *parami, Param *paramj, vrad = pradx = prady = pradz = 0.0; xrad = -comb_fc(r,parami)*parami->pcross + xcn; yrad = -comb_fc(r,paramj)*paramj->pcross + ycn; - zcon = 1.0 + pow(kconjug,2) + pow(lconjug,2); + zcon = 1.0 + square(kconjug) + square(lconjug); if (xrad < 0.0) xrad = 0.0; if (yrad < 0.0) yrad = 0.0; @@ -2893,14 +2894,14 @@ double PairComb3::bbtor1(int torindx, Param *paramk, Param *paraml, tork[2] = delrk[0]*delrj[1] - delrk[1]*delrj[0]; torl[2] = delrj[0]*delrl[1] - delrj[1]*delrl[0]; TT2 = dot3(tork,torl); - rmut = pow((TT2/TT1),2); + rmut = square(TT2/TT1); if (torindx>=1) { btt = 1.0 - rmut; return btt * fc1k * fc1l; } else { btt=paramk->ptork1-TT2/TT1; - btt=paramk->ptork2*pow(btt,2); + btt=paramk->ptork2*square(btt); return btt * fc1k * fc1l; } @@ -2930,7 +2931,7 @@ void PairComb3::tor_calc(double r, Param *parami, Param *paramj, } else { xtor = -comb_fc(r, parami) * parami->pcross + xcn; ytor = -comb_fc(r, paramj) * paramj->pcross + ycn; - zcon = 1.0 + pow(kconjug,2) + pow(lconjug,2); + zcon = 1.0 + square(kconjug) + square(lconjug); if (xtor < 0.0) xtor = 0.0; if (ytor < 0.0) ytor = 0.0; if (zcon < 1.0) zcon = 1.0; @@ -2981,9 +2982,9 @@ void PairComb3::tor_int(int torindx,double xtor, double ytor, double zcon, int l * pow(ytor,iin3[j][1]) * pow(zcon,iin3[j][2]); vtor += x; - if (xtor > 1.0e-8 ) dtorx += x*iin3[j][0]/xtor; - if (ytor > 1.0e-8 ) dtory += x*iin3[j][1]/ytor; - if (zcon > 1.0e-8 ) dtorz += x*iin3[j][2]/zcon; + if (xtor > 1.0e-8) dtorx += x*iin3[j][0]/xtor; + if (ytor > 1.0e-8) dtory += x*iin3[j][1]/ytor; + if (zcon > 1.0e-8) dtorz += x*iin3[j][2]/zcon; } } @@ -3022,10 +3023,10 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, fcp1k = comb_fc_d(rik,paramk); fc1l = comb_fc(rjl,paraml); fcp1l = comb_fc_d(rjl,paraml); - srmul2 = pow(srmul,2); + srmul2 = square(srmul); TT1 = rik*rjl*rij*rij*srmu*srmul; - dt1dik = -rmu/pow(srmu,2); + dt1dik = -rmu/square(srmu); dt1djl = -rmul/srmul2; tork[0] = delrk[1]*delrj[2] - delrk[2]*delrj[1]; torl[0] = delrj[1]*delrl[2] - delrj[2]*delrl[1]; @@ -3051,12 +3052,12 @@ void PairComb3::tor_force(int torindx, Param *paramk, Param *paraml, rmut = TT2/TT1; if (torindx>=1) { - btt = 1.0 - pow(rmut,2); + btt = 1.0 - square(rmut); AA = -2.0 * ptorr * rmut * fc1k * fc1l / TT1; } else { btt=paramk->ptork1-rmut; - btt=paramk->ptork2*pow(btt,2); + btt=paramk->ptork2*square(btt); AA = -2.0 * ptorr * paramk->ptork2 * (paramk->ptork1-rmut) * fc1k * fc1l /TT1; } @@ -3300,8 +3301,8 @@ double PairComb3::qfo_self(Param *param, double qi) cmin = cmax = 100.0; self_d = s1+qi*(2.0*s2+qi*(3.0*s3+qi*4.0*s4)); - if (qi < qmin) self_d += 4.0 * cmin * pow((qi-qmin),3); - if (qi > qmax) self_d += 4.0 * cmax * pow((qi-qmax),3); + if (qi < qmin) self_d += 4.0 * cmin * cube((qi-qmin)); + if (qi > qmax) self_d += 4.0 * cmax * cube((qi-qmax)); return self_d; } @@ -3392,10 +3393,10 @@ void PairComb3::qfo_field(Param *parami, Param *paramj, double rsq, pcmi1 = parami->pcmn1; pcmi2 = parami->pcmn2; - rf3i = r3/(pow(r3,2)+pow(pcmi1,3)); - rcf3i = rc3/(pow(rc3,2)+pow(pcmi1,3)); - rf5i = r5/(pow(r5,2)+pow(pcmi2,5)); - rcf5i = rc5/(pow(rc5,2)+pow(pcmi2,5)); + rf3i = r3/(square(r3)+cube(pcmi1)); + rcf3i = rc3/(square(rc3)+cube(pcmi1)); + rf5i = r5/(square(r5)+powint(pcmi2,5)); + rcf5i = rc5/(square(rc5)+powint(pcmi2,5)); drcf3i = 3/rc*rcf3i-6*rc2*rcf3i*rcf3i; drcf5i = 5/rc*rcf5i-10*rc4*rcf5i*rcf5i; @@ -3477,7 +3478,7 @@ void PairComb3::qfo_short(Param *parami, Param *paramj, double rsq, Di = parami->DU + pow(QUchi,parami->nD); // YYDin dDi = -parami->nD * parami->bD * pow(QUchi,(parami->nD-1.0)); // YYDiqp Bsi = parami->aB - pow(QOchi,10); // YYBsin - dBsi = -parami->bB * 10.0 * pow(QOchi,9.0); // YYBsiqp + dBsi = -parami->bB * 10.0 * powint(QOchi,9); // YYBsiqp } if (jq < paramj->QL-0.2) { @@ -3492,7 +3493,7 @@ void PairComb3::qfo_short(Param *parami, Param *paramj, double rsq, Dj = paramj->DU + pow(QUchj,paramj->nD); // YYDij dDj = -paramj->nD * paramj->bD * pow(QUchj,(paramj->nD-1.0)); // YYDiqpj Bsj = paramj->aB - pow(QOchj,10); // YYBsij - dBsj = -paramj->bB * 10.0 * pow(QOchj,9.0); // YYBsiqpj + dBsj = -paramj->bB * 10.0 * powint(QOchj,9); // YYBsiqpj } LamDiLamDj = exp(0.5*(parami->lami*Di+paramj->lami*Dj)-rlm1*r); diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index c2953f0d20..7dae6c1571 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -394,9 +394,7 @@ void PairEAM::coeff(int narg, char **arg) funcfl = (Funcfl *) memory->srealloc(funcfl,nfuncfl*sizeof(Funcfl),"pair:funcfl"); read_file(arg[2]); - int n = strlen(arg[2]) + 1; - funcfl[ifuncfl].file = new char[n]; - strcpy(funcfl[ifuncfl].file,arg[2]); + funcfl[ifuncfl].file = utils::strdup(arg[2]); } // set setflag and map only for i,i type pairs diff --git a/src/MANYBODY/pair_eam_alloy.cpp b/src/MANYBODY/pair_eam_alloy.cpp index bea1502a4f..7fc9b2c7b1 100644 --- a/src/MANYBODY/pair_eam_alloy.cpp +++ b/src/MANYBODY/pair_eam_alloy.cpp @@ -139,12 +139,8 @@ void PairEAMAlloy::read_file(char *filename) error->one(FLERR,"Incorrect element names in EAM potential file"); file->elements = new char*[file->nelements]; - for (int i = 0; i < file->nelements; i++) { - const std::string word = values.next_string(); - const int n = word.length() + 1; - file->elements[i] = new char[n]; - strcpy(file->elements[i], word.c_str()); - } + for (int i = 0; i < file->nelements; i++) + file->elements[i] = utils::strdup(values.next_string()); // diff --git a/src/MANYBODY/pair_eam_fs.cpp b/src/MANYBODY/pair_eam_fs.cpp index b4596a297b..cf552995d0 100644 --- a/src/MANYBODY/pair_eam_fs.cpp +++ b/src/MANYBODY/pair_eam_fs.cpp @@ -125,8 +125,6 @@ void PairEAMFS::read_file(char *filename) // transparently convert units for supported conversions - // transparently convert units for supported conversions - int unit_convert = reader.get_unit_convert(); double conversion_factor = utils::get_conversion_factor(utils::ENERGY, unit_convert); diff --git a/src/MANYBODY/pair_edip.cpp b/src/MANYBODY/pair_edip.cpp index 837ec2a3c7..0efa509cb3 100644 --- a/src/MANYBODY/pair_edip.cpp +++ b/src/MANYBODY/pair_edip.cpp @@ -527,7 +527,7 @@ void PairEDIP::allocateGrids(void) pre-calculated structures ------------------------------------------------------------------------- */ -void PairEDIP::allocatePreLoops(void) +void PairEDIP::allocatePreLoops() { int nthreads = comm->nthreads; @@ -545,7 +545,7 @@ void PairEDIP::allocatePreLoops(void) deallocate grids ------------------------------------------------------------------------- */ -void PairEDIP::deallocateGrids(void) +void PairEDIP::deallocateGrids() { memory->destroy(cutoffFunction); memory->destroy(cutoffFunctionDerived); @@ -562,7 +562,7 @@ void PairEDIP::deallocateGrids(void) deallocate preLoops ------------------------------------------------------------------------- */ -void PairEDIP::deallocatePreLoops(void) +void PairEDIP::deallocatePreLoops() { memory->destroy(preInvR_ij); memory->destroy(preExp3B_ij); @@ -597,7 +597,7 @@ void PairEDIP::settings(int narg, char ** /*arg*/) /* ---------------------------------------------------------------------- */ -void PairEDIP::initGrids(void) +void PairEDIP::initGrids() { int l; int numGridPointsOneCutoffFunction; diff --git a/src/MANYBODY/pair_eim.cpp b/src/MANYBODY/pair_eim.cpp index 6013677376..242f83b84b 100644 --- a/src/MANYBODY/pair_eim.cpp +++ b/src/MANYBODY/pair_eim.cpp @@ -231,7 +231,6 @@ void PairEIM::compute(int eflag, int vflag) for (ii = 0; ii < inum; ii++) { i = ilist[ii]; - itype = type[i]; if (eflag) { phi = 0.5*rho[i]*fp[i]; if (eflag_global) eng_vdwl += phi; diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index aa269ae6ea..f12d369e0d 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -36,7 +36,6 @@ #include "tokenizer.h" #include -#include using namespace LAMMPS_NS; using namespace MathExtra; diff --git a/src/MANYBODY/pair_tersoff_table.cpp b/src/MANYBODY/pair_tersoff_table.cpp index 94c4d88b09..f6a3525f1e 100644 --- a/src/MANYBODY/pair_tersoff_table.cpp +++ b/src/MANYBODY/pair_tersoff_table.cpp @@ -296,7 +296,6 @@ void PairTersoffTable::compute(int eflag, int vflag) k &= NEIGHMASK; ktype = map[type[k]]; ikparam = elem3param[itype][ktype][ktype]; - ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k][0]; dr_ik[1] = ytmp -x[k][1]; @@ -321,7 +320,6 @@ void PairTersoffTable::compute(int eflag, int vflag) k &= NEIGHMASK; ktype = map[type[k]]; ikparam = elem3param[itype][ktype][ktype]; - ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k][0]; dr_ik[1] = ytmp -x[k][1]; @@ -380,7 +378,6 @@ void PairTersoffTable::compute(int eflag, int vflag) k &= NEIGHMASK; ktype = map[type[k]]; ikparam = elem3param[itype][ktype][ktype]; - ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k][0]; dr_ik[1] = ytmp -x[k][1]; @@ -442,7 +439,6 @@ void PairTersoffTable::compute(int eflag, int vflag) k &= NEIGHMASK; ktype = map[type[k]]; ikparam = elem3param[itype][ktype][ktype]; - ijkparam = elem3param[itype][jtype][ktype]; dr_ik[0] = xtmp -x[k][0]; dr_ik[1] = ytmp -x[k][1]; @@ -506,7 +502,7 @@ void PairTersoffTable::compute(int eflag, int vflag) /* ---------------------------------------------------------------------- */ -void PairTersoffTable::deallocatePreLoops(void) +void PairTersoffTable::deallocatePreLoops() { memory->destroy(preGtetaFunction); memory->destroy(preGtetaFunctionDerived); @@ -514,7 +510,7 @@ void PairTersoffTable::deallocatePreLoops(void) memory->destroy(preCutoffFunctionDerived); } -void PairTersoffTable::allocatePreLoops(void) +void PairTersoffTable::allocatePreLoops() { deallocatePreLoops(); memory->create(preGtetaFunction,leadingDimensionInteractionList, @@ -538,7 +534,7 @@ void PairTersoffTable::deallocateGrids() memory->destroy(betaZetaPowerDerived); } -void PairTersoffTable::allocateGrids(void) +void PairTersoffTable::allocateGrids() { int i, j, k, l; @@ -583,7 +579,6 @@ void PairTersoffTable::allocateGrids(void) memory->create(gtetaFunction,nelements,numGridPointsGtetaFunction,"tersofftable:gtetaFunction"); memory->create(gtetaFunctionDerived,nelements,numGridPointsGtetaFunction,"tersofftable:gtetaFunctionDerived"); - r = minArgumentExponential; for (i=0; inmax); + FixBondCreate::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); countflag = 0; @@ -1430,7 +1430,7 @@ double FixBondCreate::memory_usage() { int nmax = atom->nmax; double bytes = (double)nmax * sizeof(int); - bytes = 2*nmax * sizeof(tagint); + bytes += 2*nmax * sizeof(tagint); bytes += (double)nmax * sizeof(double); return bytes; } diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index 3420c23e82..38007b8e2e 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -68,9 +68,9 @@ enum{MOVEATOM,MOVEMOL}; // movemode FixGCMC::FixGCMC(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), - idregion(nullptr), full_flag(0), ngroups(0), groupstrings(nullptr), ngrouptypes(0), grouptypestrings(nullptr), - grouptypebits(nullptr), grouptypes(nullptr), local_gas_list(nullptr), molcoords(nullptr), molq(nullptr), molimage(nullptr), - random_equal(nullptr), random_unequal(nullptr), + idregion(nullptr), full_flag(false), ngroups(0), groupstrings(nullptr), ngrouptypes(0), + grouptypestrings(nullptr), grouptypebits(nullptr), grouptypes(nullptr), local_gas_list(nullptr), + molcoords(nullptr), molq(nullptr), molimage(nullptr), random_equal(nullptr), random_unequal(nullptr), fixrigid(nullptr), fixshake(nullptr), idrigid(nullptr), idshake(nullptr) { if (narg < 11) error->all(FLERR,"Illegal fix gcmc command"); diff --git a/src/MC/fix_widom.cpp b/src/MC/fix_widom.cpp index f3204ca800..cc0ea7981e 100644 --- a/src/MC/fix_widom.cpp +++ b/src/MC/fix_widom.cpp @@ -59,9 +59,8 @@ enum{EXCHATOM,EXCHMOL}; // exchmode FixWidom::FixWidom(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), - idregion(nullptr), full_flag(0), - local_gas_list(nullptr), molcoords(nullptr), molq(nullptr), molimage(nullptr), - random_equal(nullptr) + idregion(nullptr), full_flag(false), local_gas_list(nullptr), molcoords(nullptr), + molq(nullptr), molimage(nullptr), random_equal(nullptr) { if (narg < 8) error->all(FLERR,"Illegal fix widom command"); diff --git a/src/MDI/fix_mdi_engine.cpp b/src/MDI/fix_mdi_engine.cpp index a898647563..8024623e43 100644 --- a/src/MDI/fix_mdi_engine.cpp +++ b/src/MDI/fix_mdi_engine.cpp @@ -25,15 +25,15 @@ #include "domain.h" #include "error.h" #include "force.h" +#include "integrate.h" #include "irregular.h" -#include "library.h" #include "memory.h" #include "modify.h" #include "update.h" -#include "verlet.h" +#include +#include #include -#include enum { NONE, REAL, METAL }; // LAMMPS units which MDI supports diff --git a/src/MDI/fix_mdi_engine.h b/src/MDI/fix_mdi_engine.h index e3d6b37772..bcba62c063 100644 --- a/src/MDI/fix_mdi_engine.h +++ b/src/MDI/fix_mdi_engine.h @@ -21,7 +21,7 @@ FixStyle(mdi/engine, FixMDIEngine); #define LMP_FIX_MDI_ENGINE_H #include "fix.h" -#include "mdi.h" +#include // IWYU pragma: export namespace LAMMPS_NS { @@ -37,7 +37,6 @@ class FixMDIEngine : public Fix { // receive and update forces - //void setup(int); void min_setup(int); void post_integrate(); void post_force(int); diff --git a/src/MDI/mdi_engine.cpp b/src/MDI/mdi_engine.cpp index 9bd9258dfc..4be739d187 100644 --- a/src/MDI/mdi_engine.cpp +++ b/src/MDI/mdi_engine.cpp @@ -20,19 +20,17 @@ #include "atom.h" #include "error.h" +#include "integrate.h" #include "fix_mdi_engine.h" -#include "force.h" #include "mdi.h" #include "min.h" -#include "minimize.h" #include "modify.h" #include "output.h" #include "timer.h" #include "update.h" -#include "verlet.h" +#include #include -#include using namespace LAMMPS_NS; diff --git a/src/MEAM/meam_impl.cpp b/src/MEAM/meam_impl.cpp index d518e5fa79..499a2b1520 100644 --- a/src/MEAM/meam_impl.cpp +++ b/src/MEAM/meam_impl.cpp @@ -20,8 +20,6 @@ #include "memory.h" -#include - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/MEAM/meam_setup_done.cpp b/src/MEAM/meam_setup_done.cpp index 5c9979167d..1d7598d2c0 100644 --- a/src/MEAM/meam_setup_done.cpp +++ b/src/MEAM/meam_setup_done.cpp @@ -17,13 +17,11 @@ #include "memory.h" #include -#include #include using namespace LAMMPS_NS; -void -MEAM::meam_setup_done(double* cutmax) +void MEAM::meam_setup_done(double* cutmax) { int nv2, nv3, m, n, p; @@ -99,8 +97,7 @@ MEAM::meam_setup_done(double* cutmax) // ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc // Fill off-diagonal alloy parameters -void -MEAM::alloyparams(void) +void MEAM::alloyparams() { int i, j, k; @@ -175,8 +172,7 @@ MEAM::alloyparams(void) // compute MEAM pair potential for each pair of element types // -void -MEAM::compute_pair_meam(void) +void MEAM::compute_pair_meam() { double r; int j, a, b, nv2; @@ -320,8 +316,7 @@ MEAM::compute_pair_meam(void) //----------------------------------------------------------------------c // Compute MEAM pair potential for distance r, element types a and b // -double -MEAM::phi_meam(double r, int a, int b) +double MEAM::phi_meam(double r, int a, int b) { /*unused:double a1,a2,a12;*/ double t11av, t21av, t31av, t12av, t22av, t32av; @@ -533,8 +528,8 @@ MEAM::phi_meam(double r, int a, int b) // To avoid nan values of phir due to rapid decrease of b2nn^n or/and // argument of phi_meam, i.e. r*arat^n, in some cases (3NN dia with low Cmin value) // -double -MEAM::phi_meam_series(const double scrn, const int Z1, const int Z2, const int a, const int b, const double r, const double arat) +double MEAM::phi_meam_series(const double scrn, const int Z1, const int Z2, const int a, const int b, + const double r, const double arat) { double phi_sum = 0.0; double b2nn, phi_val; @@ -555,8 +550,7 @@ MEAM::phi_meam_series(const double scrn, const int Z1, const int Z2, const int a //----------------------------------------------------------------------c // Compute background density for reference structure of each element -void -MEAM::compute_reference_density(void) +void MEAM::compute_reference_density() { int a, Z, Z2, errorflag; double gam, Gbar, shp[3]; @@ -594,10 +588,9 @@ MEAM::compute_reference_density(void) //------------------------------------------------------------------------------c // Average weighting factors for the reference structure -void -MEAM::get_tavref(double* t11av, double* t21av, double* t31av, double* t12av, double* t22av, double* t32av, - double t11, double t21, double t31, double t12, double t22, double t32, double r, int a, - int b, lattice_t latt) +void MEAM::get_tavref(double* t11av, double* t21av, double* t31av, double* t12av, double* t22av, double* t32av, + double t11, double t21, double t31, double t12, double t22, double t32, double r, int a, + int b, lattice_t latt) { double rhoa01, rhoa02, a1, a2, rho01 /*,rho02*/; @@ -650,8 +643,7 @@ MEAM::get_tavref(double* t11av, double* t21av, double* t31av, double* t12av, dou } //------------------------------------------------------------------------------c -void -MEAM::get_sijk(double C, int i, int j, int k, double* sijk) +void MEAM::get_sijk(double C, int i, int j, int k, double* sijk) { double x; x = (C - this->Cmin_meam[i][j][k]) / (this->Cmax_meam[i][j][k] - this->Cmin_meam[i][j][k]); @@ -660,9 +652,8 @@ MEAM::get_sijk(double C, int i, int j, int k, double* sijk) //------------------------------------------------------------------------------c // Calculate density functions, assuming reference configuration -void -MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, double* rho21, double* rho31, - double* rho02, double* rho12, double* rho22, double* rho32) +void MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, double* rho21, double* rho31, + double* rho02, double* rho12, double* rho22, double* rho32) { double a1, a2; double s[3]; @@ -858,8 +849,7 @@ MEAM::get_densref(double r, int a, int b, double* rho01, double* rho11, double* } -void -MEAM::interpolate_meam(int ind) +void MEAM::interpolate_meam(int ind) { int j; double drar; diff --git a/src/MEAM/meam_setup_param.cpp b/src/MEAM/meam_setup_param.cpp index 946a245e63..081612f70e 100644 --- a/src/MEAM/meam_setup_param.cpp +++ b/src/MEAM/meam_setup_param.cpp @@ -15,13 +15,13 @@ #include "meam.h" #include "math_const.h" + #include #include using namespace LAMMPS_NS; using namespace MathConst; -// // do a sanity check on index parameters void MEAM::meam_checkindex(int num, int lim, int nidx, int* idx /*idx(3)*/, int* ierr) diff --git a/src/MEAM/pair_meam.h b/src/MEAM/pair_meam.h index 06be670eb9..347869c293 100644 --- a/src/MEAM/pair_meam.h +++ b/src/MEAM/pair_meam.h @@ -23,8 +23,6 @@ PairStyle(meam/c,PairMEAM); #include "pair.h" -#include - namespace LAMMPS_NS { class PairMEAM : public Pair { diff --git a/src/MESONT/compute_mesont.cpp b/src/MESONT/compute_mesont.cpp index 6560699cf8..aa17328ed6 100644 --- a/src/MESONT/compute_mesont.cpp +++ b/src/MESONT/compute_mesont.cpp @@ -15,16 +15,14 @@ ------------------------------------------------------------------------- */ #include "compute_mesont.h" -#include -#include "atom.h" -#include "update.h" -#include "comm.h" -#include "force.h" -#include "modify.h" -#include "memory.h" -#include "error.h" -#include "pair.h" +#include "atom.h" +#include "comm.h" +#include "error.h" +#include "force.h" +#include "memory.h" +#include "pair.h" +#include "update.h" using namespace LAMMPS_NS; @@ -33,6 +31,7 @@ using namespace LAMMPS_NS; ComputeMesoNT::ComputeMesoNT(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg), energy(nullptr) { if (narg != 4) error->all(FLERR,"Illegal compute mesont command"); + std::string ctype = arg[3]; if (ctype == "estretch") compute_type = ES; else if (ctype == "ebend") compute_type = EB; diff --git a/src/MESONT/pair_mesocnt.cpp b/src/MESONT/pair_mesocnt.cpp index 6ff33bc130..9ba677b31d 100644 --- a/src/MESONT/pair_mesocnt.cpp +++ b/src/MESONT/pair_mesocnt.cpp @@ -19,22 +19,19 @@ #include "pair_mesocnt.h" -#include -#include - -#include - #include "atom.h" -#include "comm.h" -#include "force.h" -#include "neighbor.h" -#include "neigh_list.h" -#include "neigh_request.h" -#include "memory.h" #include "error.h" -#include "update.h" +#include "force.h" #include "math_const.h" #include "math_extra.h" +#include "memory.h" +#include "neigh_list.h" +#include "neigh_request.h" +#include "neighbor.h" +#include "update.h" + +#include +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/MESONT/pair_mesont_tpm.cpp b/src/MESONT/pair_mesont_tpm.cpp index f75258eb36..64aeeeeadd 100644 --- a/src/MESONT/pair_mesont_tpm.cpp +++ b/src/MESONT/pair_mesont_tpm.cpp @@ -27,12 +27,10 @@ #include "neigh_request.h" #include -#include #include #include #include -#include #include using namespace LAMMPS_NS; @@ -354,14 +352,11 @@ void PairMESONTTPM::compute(int eflag, int vflag) { int i = list->ilist[ii]; if (Lmax < l[i]) Lmax = l[i]; } - double Rcut_min = std::max(2.0*Lmax, std::sqrt(0.5*Lmax*Lmax + - std::pow((2.0*RT + TPBRcutoff),2))); + double Rcut_min = std::max(2.0*Lmax, std::sqrt(0.5*Lmax*Lmax + std::pow((2.0*RT + TPBRcutoff),2))); if (cut_global < Rcut_min) { - std::stringstream err; - err << "The selected cutoff is too small for the current system : " << - "L_max = " << Lmax << ", R_max = " << RT << ", Rc = " << cut_global << - ", Rcut_min = " << Rcut_min; - error->all(FLERR, err.str().c_str()); + error->all(FLERR, "The selected cutoff is too small for the current system : " + "L_max = {:.8}, R_max = {:.8}, Rc = {:.8}, Rcut_min = {:.8}", + Lmax, RT, cut_global, Rcut_min); } //generate bonds and chain nblist @@ -494,14 +489,11 @@ void PairMESONTTPM::compute(int eflag, int vflag) { } //check if cutoff is chosen correctly - Rcut_min = std::max(2.0*Lmax, std::sqrt(0.5*Lmax*Lmax + - std::pow((2.0*Rmax + TPBRcutoff),2))); + Rcut_min = std::max(2.0*Lmax, std::sqrt(0.5*Lmax*Lmax + std::pow((2.0*Rmax + TPBRcutoff),2))); if (cut_global < Rcut_min) { - std::stringstream err; - err << "The selected cutoff is too small for the current system : " << - "L_max = " << Lmax << ", R_max = " << RT << ", Rc = " << cut_global << - ", Rcut_min = " << Rcut_min; - error->all(FLERR, err.str().c_str()); + error->all(FLERR, "The selected cutoff is too small for the current system : " + "L_max = {:.8}, R_max = {:.8}, Rc = {:.8}, Rcut_min = {:.8}", + Lmax, RT, cut_global, Rcut_min); } //convert from sorted representation diff --git a/src/MESSAGE/fix_client_md.cpp b/src/MESSAGE/fix_client_md.cpp index e33434e81e..960f4e144b 100644 --- a/src/MESSAGE/fix_client_md.cpp +++ b/src/MESSAGE/fix_client_md.cpp @@ -13,15 +13,16 @@ ------------------------------------------------------------------------- */ #include "fix_client_md.h" -#include -#include -#include "update.h" + #include "atom.h" #include "comm.h" #include "domain.h" +#include "error.h" #include "force.h" #include "memory.h" -#include "error.h" +#include "update.h" + +#include // CSlib interface diff --git a/src/MESSAGE/server_md.cpp b/src/MESSAGE/server_md.cpp index 53bdaf7879..80e349c89b 100644 --- a/src/MESSAGE/server_md.cpp +++ b/src/MESSAGE/server_md.cpp @@ -13,20 +13,21 @@ ------------------------------------------------------------------------- */ #include "server_md.h" -#include -#include + #include "atom.h" #include "atom_vec.h" -#include "update.h" -#include "integrate.h" -#include "kspace.h" -#include "force.h" -#include "pair.h" -#include "neighbor.h" #include "comm.h" #include "domain.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "integrate.h" +#include "kspace.h" +#include "memory.h" +#include "neighbor.h" +#include "pair.h" +#include "update.h" + +#include // CSlib interface diff --git a/src/MGPT/pair_mgpt.h b/src/MGPT/pair_mgpt.h index e2ccda14da..106c2cc8f0 100644 --- a/src/MGPT/pair_mgpt.h +++ b/src/MGPT/pair_mgpt.h @@ -31,7 +31,6 @@ PairStyle(mgpt,PairMGPT); #ifndef LMP_PAIR_MGPT_H #define LMP_PAIR_MGPT_H -#include #include #include "pair.h" diff --git a/src/MISC/fix_imd.cpp b/src/MISC/fix_imd.cpp index 199cabc644..abba37cf3f 100644 --- a/src/MISC/fix_imd.cpp +++ b/src/MISC/fix_imd.cpp @@ -75,7 +75,7 @@ negotiate an appropriate license for such distribution." #include #endif -#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -413,8 +413,8 @@ typedef struct { int sd; /* socket file descriptor */ } imdsocket; -static int imdsock_init(void); -static void *imdsock_create(void); +static int imdsock_init(); +static void *imdsock_create(); static int imdsock_bind(void *, int); static int imdsock_listen(void *); static void *imdsock_accept(void *); /* return new socket */ @@ -1160,7 +1160,7 @@ void FixIMD::post_force_respa(int vflag, int ilevel, int /*iloop*/) /* ---------------------------------------------------------------------- */ /* local memory usage. approximately. */ -double FixIMD::memory_usage(void) +double FixIMD::memory_usage() { return static_cast(num_coords+maxbuf+imd_forces)*size_one; } @@ -1178,7 +1178,7 @@ double FixIMD::memory_usage(void) * Socket interface, abstracts machine dependent APIs/routines. ***************************************************************************/ -int imdsock_init(void) { +int imdsock_init() { #if defined(_MSC_VER) || defined(__MINGW32__) int rc = 0; static int initialized=0; @@ -1197,7 +1197,7 @@ int imdsock_init(void) { } -void * imdsock_create(void) { +void * imdsock_create() { imdsocket * s; s = (imdsocket *) malloc(sizeof(imdsocket)); diff --git a/src/MISC/fix_pair_tracker.cpp b/src/MISC/fix_pair_tracker.cpp index 755025baed..95151375c4 100644 --- a/src/MISC/fix_pair_tracker.cpp +++ b/src/MISC/fix_pair_tracker.cpp @@ -12,16 +12,14 @@ ------------------------------------------------------------------------- */ #include "fix_pair_tracker.h" + #include "atom.h" -#include "atom_vec.h" #include "error.h" -#include "group.h" #include "memory.h" -#include "modify.h" #include "tokenizer.h" #include "update.h" -#include +#include using namespace LAMMPS_NS; using namespace FixConst; @@ -31,7 +29,7 @@ using namespace FixConst; /* ---------------------------------------------------------------------- */ FixPairTracker::FixPairTracker(LAMMPS *lmp, int narg, char **arg) : - Fix(lmp, narg, arg), nvalues(0), vector(NULL), array(NULL), pack_choice(NULL) + Fix(lmp, narg, arg), nvalues(0), vector(nullptr), array(nullptr), pack_choice(nullptr) { if (narg < 3) error->all(FLERR, "Illegal fix pair/tracker command"); local_flag = 1; @@ -93,24 +91,12 @@ FixPairTracker::FixPairTracker(LAMMPS *lmp, int narg, char **arg) : } } - in = strlen(arg[iarg + 1]) + 1; - istr = new char[in]; - strcpy(istr, arg[iarg + 1]); - std::vector iwords = Tokenizer(istr, ",").as_vector(); - infield = iwords.size(); + auto iwords = Tokenizer(arg[iarg + 1], ",").as_vector(); + auto jwords = Tokenizer(arg[iarg + 2], ",").as_vector(); - jn = strlen(arg[iarg + 2]) + 1; - jstr = new char[jn]; - strcpy(jstr, arg[iarg + 2]); - std::vector jwords = Tokenizer(jstr, ",").as_vector(); - jnfield = jwords.size(); - - for (i = 0; i < infield; i++) { - const char *ifield = iwords[i].c_str(); + for (const auto &ifield : iwords) { utils::bounds(FLERR, ifield, 1, ntypes, inlo, inhi, error); - - for (j = 0; j < jnfield; j++) { - const char *jfield = jwords[j].c_str(); + for (const auto &jfield : jwords) { utils::bounds(FLERR, jfield, 1, ntypes, jnlo, jnhi, error); for (itype = inlo; itype <= inhi; itype++) { @@ -121,10 +107,6 @@ FixPairTracker::FixPairTracker(LAMMPS *lmp, int narg, char **arg) : } } } - - delete[] istr; - delete[] jstr; - iarg += 2; } else @@ -140,8 +122,8 @@ FixPairTracker::FixPairTracker(LAMMPS *lmp, int narg, char **arg) : nmax = 0; ncount = 0; - vector = NULL; - array = NULL; + vector = nullptr; + array = nullptr; } /* ---------------------------------------------------------------------- */ diff --git a/src/MISC/fix_srp.cpp b/src/MISC/fix_srp.cpp index 35ee162fc9..393be42bb2 100644 --- a/src/MISC/fix_srp.cpp +++ b/src/MISC/fix_srp.cpp @@ -57,7 +57,7 @@ FixSRP::FixSRP(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) // initial allocation of atom-based array // register with Atom class array = nullptr; - grow_arrays(atom->nmax); + FixSRP::grow_arrays(atom->nmax); // extends pack_exchange() atom->add_callback(Atom::GROW); diff --git a/src/MISC/pair_srp.cpp b/src/MISC/pair_srp.cpp index 0fef989c88..456d45c0ae 100644 --- a/src/MISC/pair_srp.cpp +++ b/src/MISC/pair_srp.cpp @@ -359,11 +359,11 @@ void PairSRP::settings(int narg, char **arg) } // settings - midpoint = 0; - min = 0; + midpoint = false; + min = false; - if (strcmp(arg[2],"min") == 0) min = 1; - else if (strcmp(arg[2],"mid") == 0) midpoint = 1; + if (strcmp(arg[2],"min") == 0) min = true; + else if (strcmp(arg[2],"mid") == 0) midpoint = true; else error->all(FLERR,"Illegal pair_style command"); diff --git a/src/MISC/pair_tracker.cpp b/src/MISC/pair_tracker.cpp index 003f2f3dd0..0e55cf367d 100644 --- a/src/MISC/pair_tracker.cpp +++ b/src/MISC/pair_tracker.cpp @@ -28,6 +28,9 @@ #include "neighbor.h" #include "update.h" +#include +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/ML-HDNNP/pair_hdnnp.cpp b/src/ML-HDNNP/pair_hdnnp.cpp index eabc0bcfa0..c27f93c132 100644 --- a/src/ML-HDNNP/pair_hdnnp.cpp +++ b/src/ML-HDNNP/pair_hdnnp.cpp @@ -30,6 +30,8 @@ #include "neighbor.h" #include "update.h" +#include + #include "InterfaceLammps.h" // n2p2 interface header using namespace LAMMPS_NS; diff --git a/src/ML-IAP/mliap_descriptor_so3.cpp b/src/ML-IAP/mliap_descriptor_so3.cpp index d28a2fdc42..d816bd0638 100644 --- a/src/ML-IAP/mliap_descriptor_so3.cpp +++ b/src/ML-IAP/mliap_descriptor_so3.cpp @@ -25,7 +25,6 @@ #include "pair_mliap.h" #include "tokenizer.h" -#include #include using namespace LAMMPS_NS; diff --git a/src/ML-IAP/mliap_model.cpp b/src/ML-IAP/mliap_model.cpp index 47c3cd54a6..d998cc4973 100644 --- a/src/ML-IAP/mliap_model.cpp +++ b/src/ML-IAP/mliap_model.cpp @@ -75,7 +75,7 @@ void MLIAPModel::set_ndescriptors(int ndescriptors_in) MLIAPModelSimple::MLIAPModelSimple(LAMMPS *lmp, char *coefffilename) : MLIAPModel(lmp, coefffilename) { - if (coefffilename) read_coeffs(coefffilename); + if (coefffilename) MLIAPModelSimple::read_coeffs(coefffilename); } /* ---------------------------------------------------------------------- */ diff --git a/src/ML-IAP/mliap_model_nn.cpp b/src/ML-IAP/mliap_model_nn.cpp index 2dc29200a1..10ef97300e 100644 --- a/src/ML-IAP/mliap_model_nn.cpp +++ b/src/ML-IAP/mliap_model_nn.cpp @@ -17,15 +17,16 @@ ------------------------------------------------------------------------- */ #include "mliap_model_nn.h" -#include "pair_mliap.h" + #include "mliap_data.h" +#include "pair_mliap.h" #include "comm.h" #include "error.h" #include "memory.h" #include "tokenizer.h" -#include +#include using namespace LAMMPS_NS; @@ -39,7 +40,7 @@ MLIAPModelNN::MLIAPModelNN(LAMMPS* lmp, char* coefffilename) : nnodes = nullptr; activation = nullptr; scale = nullptr; - if (coefffilename) read_coeffs(coefffilename); + if (coefffilename) MLIAPModelNN::read_coeffs(coefffilename); nonlinearflag = 1; } @@ -156,8 +157,8 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) memory->create(scale,nelements,2,ndescriptors,"mliap_model:scale"); for (int ilayer = 0; ilayer < nlayers; ilayer++) { - tstr = strtok(NULL,"' \t\n\r\f"); - nnodes[ilayer] = atoi(strtok(NULL,"' \t\n\r\f")); + tstr = strtok(nullptr,"' \t\n\r\f"); + nnodes[ilayer] = atoi(strtok(nullptr,"' \t\n\r\f")); if (strncmp(tstr, "linear", 6) == 0) activation[ilayer] = 0; else if (strncmp(tstr, "sigmoid", 7) == 0) activation[ilayer] = 1; diff --git a/src/ML-IAP/mliap_model_nn.h b/src/ML-IAP/mliap_model_nn.h index 2795678c05..5a45a34b5f 100644 --- a/src/ML-IAP/mliap_model_nn.h +++ b/src/ML-IAP/mliap_model_nn.h @@ -16,6 +16,8 @@ #include "mliap_model.h" +#include + namespace LAMMPS_NS { class MLIAPModelNN : public MLIAPModel { diff --git a/src/ML-IAP/mliap_model_quadratic.cpp b/src/ML-IAP/mliap_model_quadratic.cpp index 638b4a22f7..a881c7848c 100644 --- a/src/ML-IAP/mliap_model_quadratic.cpp +++ b/src/ML-IAP/mliap_model_quadratic.cpp @@ -17,7 +17,7 @@ ------------------------------------------------------------------------- */ #include "mliap_model_quadratic.h" -#include "pair_mliap.h" + #include "mliap_data.h" #include "error.h" #include diff --git a/src/ML-IAP/mliap_so3.cpp b/src/ML-IAP/mliap_so3.cpp index b600b29ebd..0733ffa198 100644 --- a/src/ML-IAP/mliap_so3.cpp +++ b/src/ML-IAP/mliap_so3.cpp @@ -17,7 +17,6 @@ #include "mliap_so3.h" -#include "comm.h" #include "error.h" #include "math_const.h" #include "math_special.h" diff --git a/src/ML-PACE/pair_pace.cpp b/src/ML-PACE/pair_pace.cpp index fba622546e..f0d6547083 100644 --- a/src/ML-PACE/pair_pace.cpp +++ b/src/ML-PACE/pair_pace.cpp @@ -23,7 +23,6 @@ Copyright 2021 Yury Lysogorskiy^1, Cas van der Oord^2, Anton Bochkarev^1, ^4: University of British Columbia, Vancouver, BC, Canada */ - // // Created by Lysogorskiy Yury on 27.02.20. // @@ -42,6 +41,7 @@ Copyright 2021 Yury Lysogorskiy^1, Cas van der Oord^2, Anton Bochkarev^1, #include "update.h" #include +#include #include "ace_evaluator.h" #include "ace_recursive.h" diff --git a/src/ML-RANN/pair_rann.cpp b/src/ML-RANN/pair_rann.cpp index faab2d1b2f..60ed776c41 100644 --- a/src/ML-RANN/pair_rann.cpp +++ b/src/ML-RANN/pair_rann.cpp @@ -33,9 +33,7 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 #include "atom.h" #include "citeme.h" -#include "comm.h" #include "error.h" -#include "force.h" #include "math_special.h" #include "memory.h" #include "neighbor.h" diff --git a/src/ML-RANN/pair_rann.h b/src/ML-RANN/pair_rann.h index adc3431ba7..71b4dcd4e6 100644 --- a/src/ML-RANN/pair_rann.h +++ b/src/ML-RANN/pair_rann.h @@ -39,9 +39,6 @@ PairStyle(rann,PairRANN); #include "pair.h" -#include -#include - namespace LAMMPS_NS { namespace RANN { diff --git a/src/ML-RANN/rann_fingerprint.cpp b/src/ML-RANN/rann_fingerprint.cpp index b90e04f9a5..1b6e15466c 100644 --- a/src/ML-RANN/rann_fingerprint.cpp +++ b/src/ML-RANN/rann_fingerprint.cpp @@ -29,6 +29,9 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #include "rann_fingerprint.h" +#include "pair_rann.h" + +#include using namespace LAMMPS_NS::RANN; diff --git a/src/ML-RANN/rann_fingerprint.h b/src/ML-RANN/rann_fingerprint.h index 628a4c025a..eb23ea04fb 100644 --- a/src/ML-RANN/rann_fingerprint.h +++ b/src/ML-RANN/rann_fingerprint.h @@ -32,9 +32,11 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 #ifndef LMP_RANN_FINGERPRINT_H #define LMP_RANN_FINGERPRINT_H -#include "pair_rann.h" +#include +#include namespace LAMMPS_NS { +class PairRANN; namespace RANN { class Fingerprint { public: diff --git a/src/ML-RANN/rann_fingerprint_bond.cpp b/src/ML-RANN/rann_fingerprint_bond.cpp index f5912324cd..dd2a309415 100644 --- a/src/ML-RANN/rann_fingerprint_bond.cpp +++ b/src/ML-RANN/rann_fingerprint_bond.cpp @@ -30,7 +30,9 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #include "rann_fingerprint_bond.h" +#include "pair_rann.h" +#include using namespace LAMMPS_NS::RANN; diff --git a/src/ML-RANN/rann_fingerprint_bondscreened.cpp b/src/ML-RANN/rann_fingerprint_bondscreened.cpp index c9ba15963c..0e9d562f6e 100644 --- a/src/ML-RANN/rann_fingerprint_bondscreened.cpp +++ b/src/ML-RANN/rann_fingerprint_bondscreened.cpp @@ -30,6 +30,9 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #include "rann_fingerprint_bondscreened.h" +#include "pair_rann.h" + +#include using namespace LAMMPS_NS::RANN; diff --git a/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp b/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp index 49829b41a1..5fb81dc5b1 100644 --- a/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp +++ b/src/ML-RANN/rann_fingerprint_bondscreenedspin.cpp @@ -29,7 +29,9 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #include "rann_fingerprint_bondscreenedspin.h" +#include "pair_rann.h" +#include using namespace LAMMPS_NS::RANN; diff --git a/src/ML-RANN/rann_fingerprint_bondspin.cpp b/src/ML-RANN/rann_fingerprint_bondspin.cpp index 452846cfb1..77749fa3c7 100644 --- a/src/ML-RANN/rann_fingerprint_bondspin.cpp +++ b/src/ML-RANN/rann_fingerprint_bondspin.cpp @@ -29,7 +29,9 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #include "rann_fingerprint_bondspin.h" +#include "pair_rann.h" +#include using namespace LAMMPS_NS::RANN; diff --git a/src/ML-RANN/rann_fingerprint_radial.cpp b/src/ML-RANN/rann_fingerprint_radial.cpp index 93cab2f363..29eeb07a65 100644 --- a/src/ML-RANN/rann_fingerprint_radial.cpp +++ b/src/ML-RANN/rann_fingerprint_radial.cpp @@ -30,8 +30,9 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #include "rann_fingerprint_radial.h" +#include "pair_rann.h" - +#include using namespace LAMMPS_NS::RANN; diff --git a/src/ML-RANN/rann_fingerprint_radialscreened.cpp b/src/ML-RANN/rann_fingerprint_radialscreened.cpp index a933703db8..9ac98d183c 100644 --- a/src/ML-RANN/rann_fingerprint_radialscreened.cpp +++ b/src/ML-RANN/rann_fingerprint_radialscreened.cpp @@ -30,8 +30,9 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #include "rann_fingerprint_radialscreened.h" +#include "pair_rann.h" - +#include using namespace LAMMPS_NS::RANN; diff --git a/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp b/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp index ecd0e4a2f0..3caeaa84da 100644 --- a/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp +++ b/src/ML-RANN/rann_fingerprint_radialscreenedspin.cpp @@ -29,8 +29,9 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #include "rann_fingerprint_radialscreenedspin.h" +#include "pair_rann.h" - +#include using namespace LAMMPS_NS::RANN; diff --git a/src/ML-RANN/rann_fingerprint_radialspin.cpp b/src/ML-RANN/rann_fingerprint_radialspin.cpp index 137f7ac162..b48fad80d0 100644 --- a/src/ML-RANN/rann_fingerprint_radialspin.cpp +++ b/src/ML-RANN/rann_fingerprint_radialspin.cpp @@ -29,8 +29,9 @@ do not necessarily reflect the views of the United States Army.​” DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 */ #include "rann_fingerprint_radialspin.h" +#include "pair_rann.h" - +#include using namespace LAMMPS_NS::RANN; diff --git a/src/ML-SNAP/pair_snap.cpp b/src/ML-SNAP/pair_snap.cpp index 645dc7a213..d7cd953615 100644 --- a/src/ML-SNAP/pair_snap.cpp +++ b/src/ML-SNAP/pair_snap.cpp @@ -26,6 +26,7 @@ #include "tokenizer.h" #include +#include using namespace LAMMPS_NS; diff --git a/src/MOFFF/angle_class2_p6.cpp b/src/MOFFF/angle_class2_p6.cpp index ae5a6b0852..0fccf6c4cb 100644 --- a/src/MOFFF/angle_class2_p6.cpp +++ b/src/MOFFF/angle_class2_p6.cpp @@ -465,10 +465,6 @@ double AngleClass2P6::single(int type, int i1, int i2, int i3) if (c > 1.0) c = 1.0; if (c < -1.0) c = -1.0; - double s = sqrt(1.0 - c*c); - if (s < SMALL) s = SMALL; - s = 1.0/s; - double dtheta = acos(c) - theta0[type]; double dtheta2 = dtheta*dtheta; double dtheta3 = dtheta2*dtheta; diff --git a/src/MOFFF/angle_cosine_buck6d.cpp b/src/MOFFF/angle_cosine_buck6d.cpp index 711db0373a..6fc4fbd123 100644 --- a/src/MOFFF/angle_cosine_buck6d.cpp +++ b/src/MOFFF/angle_cosine_buck6d.cpp @@ -68,7 +68,7 @@ void AngleCosineBuck6d::compute(int eflag, int vflag) double term1,term2,term3,term4,term5,ebuck6d,evdwl; double rcu,rqu,sme,smf; - eangle = evdwl = 0.0; + eangle = 0.0; ev_init(eflag,vflag); // insure pair->ev_tally() will use 1-3 virial contribution @@ -340,7 +340,7 @@ void AngleCosineBuck6d::read_restart(FILE *fp) MPI_Bcast(&k[1],atom->nangletypes,MPI_DOUBLE,0,world); MPI_Bcast(&multiplicity[1],atom->nangletypes,MPI_INT,0,world); - MPI_Bcast(&th0[1],atom->nangletypes,MPI_INT,0,world); + MPI_Bcast(&th0[1],atom->nangletypes,MPI_DOUBLE,0,world); for (int i = 1; i <= atom->nangletypes; i++) setflag[i] = 1; } diff --git a/src/MOLECULE/dihedral_harmonic.cpp b/src/MOLECULE/dihedral_harmonic.cpp index 5ab866fa33..a582987de1 100644 --- a/src/MOLECULE/dihedral_harmonic.cpp +++ b/src/MOLECULE/dihedral_harmonic.cpp @@ -24,7 +24,6 @@ #include "force.h" #include "memory.h" #include "neighbor.h" -#include "update.h" #include diff --git a/src/MOLECULE/dihedral_multi_harmonic.cpp b/src/MOLECULE/dihedral_multi_harmonic.cpp index 958db6d0c5..5527dd600c 100644 --- a/src/MOLECULE/dihedral_multi_harmonic.cpp +++ b/src/MOLECULE/dihedral_multi_harmonic.cpp @@ -18,15 +18,14 @@ #include "dihedral_multi_harmonic.h" -#include #include "atom.h" -#include "neighbor.h" #include "comm.h" -#include "force.h" -#include "update.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; diff --git a/src/MOLECULE/dihedral_opls.cpp b/src/MOLECULE/dihedral_opls.cpp index d09fbc32d3..2f99019ef7 100644 --- a/src/MOLECULE/dihedral_opls.cpp +++ b/src/MOLECULE/dihedral_opls.cpp @@ -18,15 +18,14 @@ #include "dihedral_opls.h" -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "force.h" -#include "update.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; diff --git a/src/MOLECULE/fix_cmap.cpp b/src/MOLECULE/fix_cmap.cpp index fb1ead126b..4bc035fdf5 100644 --- a/src/MOLECULE/fix_cmap.cpp +++ b/src/MOLECULE/fix_cmap.cpp @@ -112,7 +112,7 @@ FixCMAP::FixCMAP(LAMMPS *lmp, int narg, char **arg) : crossterm_atom5 = nullptr; nmax_previous = 0; - grow_arrays(atom->nmax); + FixCMAP::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); diff --git a/src/MOLECULE/improper_cvff.cpp b/src/MOLECULE/improper_cvff.cpp index 91dac5b173..a6ed5ea2d9 100644 --- a/src/MOLECULE/improper_cvff.cpp +++ b/src/MOLECULE/improper_cvff.cpp @@ -14,15 +14,14 @@ #include "improper_cvff.h" -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" -#include "force.h" -#include "update.h" -#include "memory.h" #include "error.h" +#include "force.h" +#include "memory.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; diff --git a/src/MOLECULE/improper_harmonic.cpp b/src/MOLECULE/improper_harmonic.cpp index 4b93d8653e..b0414e301b 100644 --- a/src/MOLECULE/improper_harmonic.cpp +++ b/src/MOLECULE/improper_harmonic.cpp @@ -14,16 +14,15 @@ #include "improper_harmonic.h" -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" +#include "error.h" #include "force.h" -#include "update.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/MOLECULE/improper_umbrella.cpp b/src/MOLECULE/improper_umbrella.cpp index 0cf2351cef..2c4c686cc3 100644 --- a/src/MOLECULE/improper_umbrella.cpp +++ b/src/MOLECULE/improper_umbrella.cpp @@ -18,16 +18,15 @@ #include "improper_umbrella.h" -#include #include "atom.h" #include "comm.h" -#include "neighbor.h" +#include "error.h" #include "force.h" -#include "update.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neighbor.h" +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/MOLFILE/molfile_interface.cpp b/src/MOLFILE/molfile_interface.cpp index 1cdc698a97..8e1174d8f4 100644 --- a/src/MOLFILE/molfile_interface.cpp +++ b/src/MOLFILE/molfile_interface.cpp @@ -19,7 +19,6 @@ #include "molfile_interface.h" #include "molfile_plugin.h" -#include #include #include #include diff --git a/src/OPENMP/dihedral_charmm_omp.cpp b/src/OPENMP/dihedral_charmm_omp.cpp index 4835669158..7efd6d367b 100644 --- a/src/OPENMP/dihedral_charmm_omp.cpp +++ b/src/OPENMP/dihedral_charmm_omp.cpp @@ -16,18 +16,17 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" #include "dihedral_charmm_omp.h" -#include + #include "atom.h" #include "comm.h" -#include "neighbor.h" - #include "force.h" +#include "neighbor.h" #include "pair.h" -#include "update.h" -#include "error.h" +#include + +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/dihedral_class2_omp.cpp b/src/OPENMP/dihedral_class2_omp.cpp index 2f922b0bdf..f843def3ec 100644 --- a/src/OPENMP/dihedral_class2_omp.cpp +++ b/src/OPENMP/dihedral_class2_omp.cpp @@ -20,11 +20,9 @@ #include "atom.h" #include "comm.h" -#include "error.h" #include "force.h" #include "neighbor.h" #include "suffix.h" -#include "update.h" #include diff --git a/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp b/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp index b4dbc4538a..9da2a5b8b5 100644 --- a/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp +++ b/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "dihedral_cosine_shift_exp_omp.h" + #include "atom.h" #include "comm.h" +#include "force.h" #include "neighbor.h" -#include "force.h" -#include "update.h" -#include "error.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/dihedral_fourier_omp.cpp b/src/OPENMP/dihedral_fourier_omp.cpp index e735f01953..a7c5264fa5 100644 --- a/src/OPENMP/dihedral_fourier_omp.cpp +++ b/src/OPENMP/dihedral_fourier_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" #include "dihedral_fourier_omp.h" -#include + #include "atom.h" #include "comm.h" +#include "force.h" #include "neighbor.h" -#include "force.h" -#include "update.h" -#include "error.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/dihedral_harmonic_omp.cpp b/src/OPENMP/dihedral_harmonic_omp.cpp index c780bf0b30..6bbfd6ff12 100644 --- a/src/OPENMP/dihedral_harmonic_omp.cpp +++ b/src/OPENMP/dihedral_harmonic_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "dihedral_harmonic_omp.h" + #include "atom.h" #include "comm.h" +#include "force.h" #include "neighbor.h" -#include "force.h" -#include "update.h" -#include "error.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/dihedral_helix_omp.cpp b/src/OPENMP/dihedral_helix_omp.cpp index a2f2778935..c73622ed9d 100644 --- a/src/OPENMP/dihedral_helix_omp.cpp +++ b/src/OPENMP/dihedral_helix_omp.cpp @@ -20,16 +20,14 @@ #include "atom.h" #include "comm.h" -#include "error.h" #include "force.h" #include "math_const.h" #include "neighbor.h" -#include "suffix.h" -#include "update.h" #include #include "omp_compat.h" +#include "suffix.h" using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/OPENMP/dihedral_multi_harmonic_omp.cpp b/src/OPENMP/dihedral_multi_harmonic_omp.cpp index 19519ea644..cf7e991c9d 100644 --- a/src/OPENMP/dihedral_multi_harmonic_omp.cpp +++ b/src/OPENMP/dihedral_multi_harmonic_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "dihedral_multi_harmonic_omp.h" + #include "atom.h" #include "comm.h" +#include "force.h" #include "neighbor.h" -#include "force.h" -#include "update.h" -#include "error.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/dihedral_nharmonic_omp.cpp b/src/OPENMP/dihedral_nharmonic_omp.cpp index 66f7ab5fe9..f2ec46190e 100644 --- a/src/OPENMP/dihedral_nharmonic_omp.cpp +++ b/src/OPENMP/dihedral_nharmonic_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "dihedral_nharmonic_omp.h" + #include "atom.h" #include "comm.h" -#include "neighbor.h" #include "force.h" -#include "update.h" -#include "error.h" +#include "neighbor.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/dihedral_opls_omp.cpp b/src/OPENMP/dihedral_opls_omp.cpp index e24d658350..543485aa0f 100644 --- a/src/OPENMP/dihedral_opls_omp.cpp +++ b/src/OPENMP/dihedral_opls_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "dihedral_opls_omp.h" + #include "atom.h" #include "comm.h" +#include "force.h" #include "neighbor.h" -#include "force.h" -#include "update.h" -#include "error.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/dihedral_quadratic_omp.cpp b/src/OPENMP/dihedral_quadratic_omp.cpp index 30ab8ff413..f6582d3bc0 100644 --- a/src/OPENMP/dihedral_quadratic_omp.cpp +++ b/src/OPENMP/dihedral_quadratic_omp.cpp @@ -16,18 +16,17 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "dihedral_quadratic_omp.h" + #include "atom.h" #include "comm.h" -#include "neighbor.h" #include "force.h" -#include "update.h" #include "math_const.h" -#include "error.h" +#include "neighbor.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/OPENMP/domain_omp.cpp b/src/OPENMP/domain_omp.cpp index 40be2f997a..af4d41a585 100644 --- a/src/OPENMP/domain_omp.cpp +++ b/src/OPENMP/domain_omp.cpp @@ -20,6 +20,8 @@ #include "error.h" #include "omp_compat.h" +#include + using namespace LAMMPS_NS; typedef struct { diff --git a/src/OPENMP/fix_gravity_omp.cpp b/src/OPENMP/fix_gravity_omp.cpp index c9f9104547..7354ec2aa4 100644 --- a/src/OPENMP/fix_gravity_omp.cpp +++ b/src/OPENMP/fix_gravity_omp.cpp @@ -16,14 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" #include "fix_gravity_omp.h" + #include "atom.h" #include "update.h" #include "input.h" #include "modify.h" #include "variable.h" +#include "omp_compat.h" + using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/OPENMP/fix_neigh_history_omp.cpp b/src/OPENMP/fix_neigh_history_omp.cpp index 50599b2669..8dd3816ec7 100644 --- a/src/OPENMP/fix_neigh_history_omp.cpp +++ b/src/OPENMP/fix_neigh_history_omp.cpp @@ -12,21 +12,23 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "omp_compat.h" #include "fix_neigh_history_omp.h" -#include -#include "my_page.h" + #include "atom.h" #include "comm.h" +#include "error.h" +#include "memory.h" +#include "my_page.h" #include "neigh_list.h" #include "pair.h" -#include "memory.h" -#include "error.h" #if defined(_OPENMP) #include #endif +#include + +#include "omp_compat.h" using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/OPENMP/improper_class2_omp.cpp b/src/OPENMP/improper_class2_omp.cpp index ae3bad0f19..ad53ecd735 100644 --- a/src/OPENMP/improper_class2_omp.cpp +++ b/src/OPENMP/improper_class2_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "improper_class2_omp.h" + #include "atom.h" #include "comm.h" +#include "force.h" #include "neighbor.h" -#include "force.h" -#include "update.h" -#include "error.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/improper_cossq_omp.cpp b/src/OPENMP/improper_cossq_omp.cpp index 0a41ec45e2..24d7919995 100644 --- a/src/OPENMP/improper_cossq_omp.cpp +++ b/src/OPENMP/improper_cossq_omp.cpp @@ -20,15 +20,13 @@ #include "atom.h" #include "comm.h" -#include "error.h" #include "force.h" #include "neighbor.h" -#include "suffix.h" -#include "update.h" #include #include "omp_compat.h" +#include "suffix.h" using namespace LAMMPS_NS; #define TOLERANCE 0.05 diff --git a/src/OPENMP/improper_cvff_omp.cpp b/src/OPENMP/improper_cvff_omp.cpp index cb71bb802b..3cceb856a9 100644 --- a/src/OPENMP/improper_cvff_omp.cpp +++ b/src/OPENMP/improper_cvff_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "improper_cvff_omp.h" + #include "atom.h" #include "comm.h" +#include "force.h" #include "neighbor.h" -#include "force.h" -#include "update.h" -#include "error.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/improper_fourier_omp.cpp b/src/OPENMP/improper_fourier_omp.cpp index 3f5e270633..ef92e49e67 100644 --- a/src/OPENMP/improper_fourier_omp.cpp +++ b/src/OPENMP/improper_fourier_omp.cpp @@ -20,16 +20,13 @@ #include "atom.h" #include "comm.h" -#include "error.h" #include "force.h" #include "neighbor.h" -#include "suffix.h" - -#include "update.h" #include #include "omp_compat.h" +#include "suffix.h" using namespace LAMMPS_NS; #define TOLERANCE 0.05 diff --git a/src/OPENMP/improper_harmonic_omp.cpp b/src/OPENMP/improper_harmonic_omp.cpp index 5b96aad793..97d8ad174d 100644 --- a/src/OPENMP/improper_harmonic_omp.cpp +++ b/src/OPENMP/improper_harmonic_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "improper_harmonic_omp.h" + #include "atom.h" #include "comm.h" +#include "force.h" #include "neighbor.h" -#include "force.h" -#include "update.h" -#include "error.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/improper_umbrella_omp.cpp b/src/OPENMP/improper_umbrella_omp.cpp index cfd9778be0..91c9237826 100644 --- a/src/OPENMP/improper_umbrella_omp.cpp +++ b/src/OPENMP/improper_umbrella_omp.cpp @@ -16,17 +16,16 @@ Contributing author: Axel Kohlmeyer (Temple U) ------------------------------------------------------------------------- */ -#include "omp_compat.h" -#include #include "improper_umbrella_omp.h" + #include "atom.h" #include "comm.h" +#include "force.h" #include "neighbor.h" -#include "force.h" -#include "update.h" -#include "error.h" +#include +#include "omp_compat.h" #include "suffix.h" using namespace LAMMPS_NS; diff --git a/src/OPENMP/npair_half_bin_atomonly_newton_omp.cpp b/src/OPENMP/npair_half_bin_atomonly_newton_omp.cpp index bd8999560c..2add88d358 100644 --- a/src/OPENMP/npair_half_bin_atomonly_newton_omp.cpp +++ b/src/OPENMP/npair_half_bin_atomonly_newton_omp.cpp @@ -15,7 +15,6 @@ #include "npair_half_bin_atomonly_newton_omp.h" #include "atom.h" -#include "atom_vec.h" #include "error.h" #include "my_page.h" #include "neigh_list.h" diff --git a/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp b/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp index eadcde2154..65fca6ed17 100644 --- a/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp +++ b/src/OPENMP/npair_half_size_multi_old_newtoff_omp.cpp @@ -12,15 +12,14 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "omp_compat.h" #include "npair_half_size_multi_old_newtoff_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" #include "atom.h" -#include "atom_vec.h" -#include "my_page.h" #include "error.h" +#include "my_page.h" +#include "neigh_list.h" +#include "npair_omp.h" +#include "omp_compat.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp b/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp index eb154dce3a..907ce7dca8 100644 --- a/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp +++ b/src/OPENMP/npair_half_size_multi_old_newton_omp.cpp @@ -12,15 +12,15 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "omp_compat.h" #include "npair_half_size_multi_old_newton_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "my_page.h" -#include "error.h" +#include "atom.h" +#include "error.h" +#include "my_page.h" +#include "neigh_list.h" +#include "npair_omp.h" + +#include "omp_compat.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp b/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp index e67c1463f7..a2bbf9cae0 100644 --- a/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp +++ b/src/OPENMP/npair_half_size_multi_old_newton_tri_omp.cpp @@ -12,15 +12,15 @@ See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include "omp_compat.h" #include "npair_half_size_multi_old_newton_tri_omp.h" -#include "npair_omp.h" -#include "neigh_list.h" -#include "atom.h" -#include "atom_vec.h" -#include "my_page.h" -#include "error.h" +#include "atom.h" +#include "error.h" +#include "my_page.h" +#include "neigh_list.h" +#include "npair_omp.h" + +#include "omp_compat.h" using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_cut_coul_cut_dielectric_omp.cpp b/src/OPENMP/pair_lj_cut_coul_cut_dielectric_omp.cpp index 2bcc710d42..43e2fb15e4 100644 --- a/src/OPENMP/pair_lj_cut_coul_cut_dielectric_omp.cpp +++ b/src/OPENMP/pair_lj_cut_coul_cut_dielectric_omp.cpp @@ -19,13 +19,10 @@ #include "atom.h" #include "comm.h" -#include "error.h" #include "force.h" #include "math_const.h" #include "memory.h" #include "neigh_list.h" -#include "neigh_request.h" -#include "neighbor.h" #include diff --git a/src/OPENMP/pair_lj_long_tip4p_long_omp.cpp b/src/OPENMP/pair_lj_long_tip4p_long_omp.cpp index d6068c6e7a..606e57188a 100644 --- a/src/OPENMP/pair_lj_long_tip4p_long_omp.cpp +++ b/src/OPENMP/pair_lj_long_tip4p_long_omp.cpp @@ -390,7 +390,7 @@ void PairLJLongTIP4PLongOMP::compute_inner() loop_setup_thr(ifrom, ito, tid, inum, nthreads); ThrData *thr = fix->get_thr(tid); thr->timer(Timer::START); - ev_setup_thr(0, 0, nall, 0, 0, nullptr, thr); + ev_setup_thr(0, 0, nall, nullptr, nullptr, nullptr, thr); eval_inner(ifrom, ito, thr); thr->timer(Timer::PAIR); @@ -415,7 +415,7 @@ void PairLJLongTIP4PLongOMP::compute_middle() loop_setup_thr(ifrom, ito, tid, inum, nthreads); ThrData *thr = fix->get_thr(tid); thr->timer(Timer::START); - ev_setup_thr(0, 0, nall, 0, 0, nullptr, thr); + ev_setup_thr(0, 0, nall, nullptr, nullptr, nullptr, thr); eval_middle(ifrom, ito, thr); thr->timer(Timer::PAIR); diff --git a/src/OPENMP/pair_lj_sdk_coul_msm_omp.cpp b/src/OPENMP/pair_lj_sdk_coul_msm_omp.cpp index b9e62b7bdf..53c058fba1 100644 --- a/src/OPENMP/pair_lj_sdk_coul_msm_omp.cpp +++ b/src/OPENMP/pair_lj_sdk_coul_msm_omp.cpp @@ -19,6 +19,7 @@ #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" #include "kspace.h" #include "neigh_list.h" diff --git a/src/OPENMP/pair_reaxff_omp.h b/src/OPENMP/pair_reaxff_omp.h index 3e8ebac284..4424c90b39 100644 --- a/src/OPENMP/pair_reaxff_omp.h +++ b/src/OPENMP/pair_reaxff_omp.h @@ -22,7 +22,7 @@ PairStyle(reax/c/omp,PairReaxFFOMP); #define LMP_PAIR_REAXFF_OMP_H #include "pair_reaxff.h" -#include "thr_omp.h" +#include "thr_omp.h" // IWYU pragma: export namespace LAMMPS_NS { diff --git a/src/PERI/compute_dilatation_atom.cpp b/src/PERI/compute_dilatation_atom.cpp index 492b192f3b..7735bbbaac 100644 --- a/src/PERI/compute_dilatation_atom.cpp +++ b/src/PERI/compute_dilatation_atom.cpp @@ -17,18 +17,19 @@ ------------------------------------------------------------------------- */ #include "compute_dilatation_atom.h" -#include + #include "atom.h" -#include "update.h" -#include "modify.h" #include "comm.h" -#include "fix.h" +#include "error.h" #include "force.h" +#include "memory.h" +#include "modify.h" +#include "pair_peri_eps.h" #include "pair_peri_lps.h" #include "pair_peri_ves.h" -#include "pair_peri_eps.h" -#include "memory.h" -#include "error.h" +#include "update.h" + +#include using namespace LAMMPS_NS; diff --git a/src/PERI/pair_peri_pmb.cpp b/src/PERI/pair_peri_pmb.cpp index 49e8ce6218..fa96ef0f26 100644 --- a/src/PERI/pair_peri_pmb.cpp +++ b/src/PERI/pair_peri_pmb.cpp @@ -30,8 +30,8 @@ #include "neigh_list.h" #include "neighbor.h" -#include #include +#include using namespace LAMMPS_NS; diff --git a/src/PLUGIN/plugin.cpp b/src/PLUGIN/plugin.cpp index 78538be2ff..270c9958f5 100644 --- a/src/PLUGIN/plugin.cpp +++ b/src/PLUGIN/plugin.cpp @@ -19,9 +19,9 @@ #include "error.h" #include "input.h" #include "force.h" -#include "lammps.h" #include "modify.h" +#include #include #include diff --git a/src/PLUGIN/plugin.h b/src/PLUGIN/plugin.h index 5f54a4dc58..d98430bae6 100644 --- a/src/PLUGIN/plugin.h +++ b/src/PLUGIN/plugin.h @@ -21,7 +21,7 @@ CommandStyle(plugin,Plugin); #define LMP_PLUGIN_H #include "command.h" -#include "lammpsplugin.h" +#include "lammpsplugin.h" // IWYU pragma: export namespace LAMMPS_NS { diff --git a/src/PLUMED/fix_plumed.cpp b/src/PLUMED/fix_plumed.cpp index c34afe6d3f..b38e745b7a 100644 --- a/src/PLUMED/fix_plumed.cpp +++ b/src/PLUMED/fix_plumed.cpp @@ -176,11 +176,7 @@ FixPlumed::FixPlumed(LAMMPS *lmp, int narg, char **arg) : if (universe->existflag == 1) { // Each replica writes an independent log file // with suffix equal to the replica id - char str_num[32], logFile[1024]; - sprintf(str_num,".%d",universe->iworld); - strncpy(logFile,arg[i],1024-32); - strcat(logFile,str_num); - p->cmd("setLogFile",logFile); + p->cmd("setLogFile",fmt::format("{}.{}",arg[i],universe->iworld).c_str()); next=0; } else { // partition option not used diff --git a/src/PTM/compute_ptm_atom.cpp b/src/PTM/compute_ptm_atom.cpp index 74880adcd5..3e7ea775ac 100644 --- a/src/PTM/compute_ptm_atom.cpp +++ b/src/PTM/compute_ptm_atom.cpp @@ -35,7 +35,6 @@ under #include #include #include -#include #include "ptm_constants.h" #include "ptm_functions.h" diff --git a/src/PYTHON/fix_python_invoke.cpp b/src/PYTHON/fix_python_invoke.cpp index 15242d4868..78ffe99ad3 100644 --- a/src/PYTHON/fix_python_invoke.cpp +++ b/src/PYTHON/fix_python_invoke.cpp @@ -18,7 +18,6 @@ #include "fix_python_invoke.h" -#include "comm.h" #include "error.h" #include "lmppython.h" #include "python_compat.h" diff --git a/src/PYTHON/fix_python_move.cpp b/src/PYTHON/fix_python_move.cpp index eef2c4083f..cdfce4a969 100644 --- a/src/PYTHON/fix_python_move.cpp +++ b/src/PYTHON/fix_python_move.cpp @@ -18,13 +18,11 @@ #include "fix_python_move.h" -#include "comm.h" #include "error.h" #include "lmppython.h" #include "python_compat.h" #include "python_utils.h" -#include #include // IWYU pragma: export using namespace LAMMPS_NS; diff --git a/src/PYTHON/pair_python.cpp b/src/PYTHON/pair_python.cpp index 5b4e841927..43b6f9ea6c 100644 --- a/src/PYTHON/pair_python.cpp +++ b/src/PYTHON/pair_python.cpp @@ -28,7 +28,7 @@ #include "python_utils.h" #include "update.h" -#include +#include #include // IWYU pragma: export using namespace LAMMPS_NS; diff --git a/src/QEQ/fix_qeq_point.cpp b/src/QEQ/fix_qeq_point.cpp index 6c22ab85cf..e836c0dad8 100644 --- a/src/QEQ/fix_qeq_point.cpp +++ b/src/QEQ/fix_qeq_point.cpp @@ -32,6 +32,7 @@ #include "update.h" #include +#include using namespace LAMMPS_NS; diff --git a/src/QEQ/fix_qeq_shielded.cpp b/src/QEQ/fix_qeq_shielded.cpp index ff8c87ba4e..4cc254a361 100644 --- a/src/QEQ/fix_qeq_shielded.cpp +++ b/src/QEQ/fix_qeq_shielded.cpp @@ -33,6 +33,7 @@ #include "update.h" #include +#include using namespace LAMMPS_NS; diff --git a/src/QMMM/fix_qmmm.cpp b/src/QMMM/fix_qmmm.cpp index 1f24728eca..4222a82247 100644 --- a/src/QMMM/fix_qmmm.cpp +++ b/src/QMMM/fix_qmmm.cpp @@ -16,17 +16,17 @@ Contributing author: Axel Kohlmeyer (ICTP) ------------------------------------------------------------------------- */ - -#include #include "fix_qmmm.h" + #include "atom.h" -#include "domain.h" #include "comm.h" -#include "update.h" -#include "force.h" +#include "domain.h" #include "error.h" #include "group.h" #include "memory.h" +#include "update.h" + +#include #include "libqmmm.h" diff --git a/src/REAXFF/fix_qeq_reaxff.cpp b/src/REAXFF/fix_qeq_reaxff.cpp index 06c9414fbd..b58d10a643 100644 --- a/src/REAXFF/fix_qeq_reaxff.cpp +++ b/src/REAXFF/fix_qeq_reaxff.cpp @@ -34,7 +34,6 @@ #include "pair.h" #include "respa.h" #include "text_file_reader.h" -#include "tokenizer.h" #include "update.h" #include "pair_reaxff.h" @@ -42,6 +41,7 @@ #include #include +#include using namespace LAMMPS_NS; using namespace FixConst; diff --git a/src/REAXFF/reaxff_api.h b/src/REAXFF/reaxff_api.h index 68eb7d25a2..043a1ebbf6 100644 --- a/src/REAXFF/reaxff_api.h +++ b/src/REAXFF/reaxff_api.h @@ -21,7 +21,7 @@ #ifndef LMP_REAXFF_API_H #define LMP_REAXFF_API_H -#include "reaxff_types.h" +#include "reaxff_types.h" // IWYU pragma: export #include diff --git a/src/REAXFF/reaxff_control.cpp b/src/REAXFF/reaxff_control.cpp index c84c3afe9d..2020e8a5c3 100644 --- a/src/REAXFF/reaxff_control.cpp +++ b/src/REAXFF/reaxff_control.cpp @@ -31,7 +31,6 @@ #include "utils.h" #include "text_file_reader.h" -#include #include #include #include diff --git a/src/REAXFF/reaxff_ffield.cpp b/src/REAXFF/reaxff_ffield.cpp index f43ab440ff..6297f4cf94 100644 --- a/src/REAXFF/reaxff_ffield.cpp +++ b/src/REAXFF/reaxff_ffield.cpp @@ -34,6 +34,8 @@ #include #include +#include +#include #include using LAMMPS_NS::utils::open_potential; diff --git a/src/REAXFF/reaxff_forces.cpp b/src/REAXFF/reaxff_forces.cpp index ec783102b4..a4edfeee5c 100644 --- a/src/REAXFF/reaxff_forces.cpp +++ b/src/REAXFF/reaxff_forces.cpp @@ -27,7 +27,6 @@ #include "reaxff_api.h" -#include #include #include diff --git a/src/REAXFF/reaxff_reset_tools.cpp b/src/REAXFF/reaxff_reset_tools.cpp index 30a58e84a5..bebb2e2cfc 100644 --- a/src/REAXFF/reaxff_reset_tools.cpp +++ b/src/REAXFF/reaxff_reset_tools.cpp @@ -29,7 +29,6 @@ #include "error.h" -#include #include namespace ReaxFF { diff --git a/src/REAXFF/reaxff_tool_box.cpp b/src/REAXFF/reaxff_tool_box.cpp index 550668197c..5ebed0360e 100644 --- a/src/REAXFF/reaxff_tool_box.cpp +++ b/src/REAXFF/reaxff_tool_box.cpp @@ -28,7 +28,6 @@ #include #include -#include #include "error.h" diff --git a/src/REAXFF/reaxff_types.h b/src/REAXFF/reaxff_types.h index 6bd752f58a..c124a2639d 100644 --- a/src/REAXFF/reaxff_types.h +++ b/src/REAXFF/reaxff_types.h @@ -23,8 +23,8 @@ #include "lmptype.h" -#include "reaxff_defs.h" -#include "reaxff_inline.h" +#include "reaxff_defs.h" // IWYU pragma: export +#include "reaxff_inline.h" // IWYU pragma: export // forward declarations namespace LAMMPS_NS { diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 0ed3a0b95e..9e6e32772d 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -15,7 +15,6 @@ #include "neb.h" #include "atom.h" -#include "comm.h" #include "domain.h" #include "error.h" #include "finish.h" diff --git a/src/RIGID/fix_ehex.cpp b/src/RIGID/fix_ehex.cpp index f0c633c7a8..866d5b81b7 100644 --- a/src/RIGID/fix_ehex.cpp +++ b/src/RIGID/fix_ehex.cpp @@ -129,7 +129,7 @@ FixEHEX::FixEHEX(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), scale = 1.0; scalingmask = nullptr; - grow_arrays(atom->nmax); + FixEHEX::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); } diff --git a/src/RIGID/fix_rattle.cpp b/src/RIGID/fix_rattle.cpp index 9bd391d26d..9143c48116 100644 --- a/src/RIGID/fix_rattle.cpp +++ b/src/RIGID/fix_rattle.cpp @@ -62,7 +62,7 @@ FixRattle::FixRattle(LAMMPS *lmp, int narg, char **arg) : // allocate memory for unconstrained velocity update vp = nullptr; - grow_arrays(atom->nmax); + FixRattle::grow_arrays(atom->nmax); // default communication mode // necessary for compatibility with SHAKE diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index 461574a034..6f3486945c 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -82,7 +82,7 @@ FixRigid::FixRigid(LAMMPS *lmp, int narg, char **arg) : eflags = nullptr; orient = nullptr; dorient = nullptr; - grow_arrays(atom->nmax); + FixRigid::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); // parse args for rigid body specification diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 4a9a74f225..40bfc3ce2d 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -89,7 +89,7 @@ FixRigidSmall::FixRigidSmall(LAMMPS *lmp, int narg, char **arg) : eflags = nullptr; orient = nullptr; dorient = nullptr; - grow_arrays(atom->nmax); + FixRigidSmall::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); // parse args for rigid body specification diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 709327b1d6..f1c1d30fc5 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -84,7 +84,7 @@ FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : ftmp = nullptr; vtmp = nullptr; - grow_arrays(atom->nmax); + FixShake::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); // set comm size needed by this fix diff --git a/src/SMTBQ/pair_smtbq.cpp b/src/SMTBQ/pair_smtbq.cpp index ff2da85789..4b7a1f2ac5 100644 --- a/src/SMTBQ/pair_smtbq.cpp +++ b/src/SMTBQ/pair_smtbq.cpp @@ -58,7 +58,6 @@ #include #include -#include #include #include diff --git a/src/SPIN/atom_vec_spin.cpp b/src/SPIN/atom_vec_spin.cpp index 645f86dde2..4f3d0a3aab 100644 --- a/src/SPIN/atom_vec_spin.cpp +++ b/src/SPIN/atom_vec_spin.cpp @@ -82,7 +82,6 @@ void AtomVecSpin::grow_pointers() void AtomVecSpin::force_clear(int n, size_t nbytes) { - memset(&f[n][0],0,3*nbytes); memset(&fm[n][0],0,3*nbytes); memset(&fm_long[n][0],0,3*nbytes); } diff --git a/src/SPIN/compute_spin.cpp b/src/SPIN/compute_spin.cpp index cebc0d9573..174cec7d59 100644 --- a/src/SPIN/compute_spin.cpp +++ b/src/SPIN/compute_spin.cpp @@ -36,7 +36,6 @@ #include "update.h" #include -#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/SPIN/pair_spin_dipole_cut.cpp b/src/SPIN/pair_spin_dipole_cut.cpp index 06d896ed2f..b4e1e17b88 100644 --- a/src/SPIN/pair_spin_dipole_cut.cpp +++ b/src/SPIN/pair_spin_dipole_cut.cpp @@ -463,7 +463,7 @@ void PairSpinDipoleCut::read_restart(FILE *fp) if (me == 0) { utils::sfread(FLERR,&cut_spin_long[i][j],sizeof(int),1,fp,nullptr,error); } - MPI_Bcast(&cut_spin_long[i][j],1,MPI_INT,0,world); + MPI_Bcast(&cut_spin_long[i][j],1,MPI_DOUBLE,0,world); } } } diff --git a/src/SPIN/pair_spin_dipole_long.cpp b/src/SPIN/pair_spin_dipole_long.cpp index 860a5c5eb9..e551f7c4fe 100644 --- a/src/SPIN/pair_spin_dipole_long.cpp +++ b/src/SPIN/pair_spin_dipole_long.cpp @@ -538,7 +538,7 @@ void PairSpinDipoleLong::read_restart(FILE *fp) if (me == 0) { utils::sfread(FLERR,&cut_spin_long[i][j],sizeof(int),1,fp,nullptr,error); } - MPI_Bcast(&cut_spin_long[i][j],1,MPI_INT,0,world); + MPI_Bcast(&cut_spin_long[i][j],1,MPI_DOUBLE,0,world); } } } diff --git a/src/TALLY/compute_heat_flux_virial_tally.cpp b/src/TALLY/compute_heat_flux_virial_tally.cpp index ddf56cb4d8..61f00bac7f 100644 --- a/src/TALLY/compute_heat_flux_virial_tally.cpp +++ b/src/TALLY/compute_heat_flux_virial_tally.cpp @@ -22,8 +22,6 @@ #include "pair.h" #include "update.h" -#include - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/VORONOI/compute_voronoi_atom.cpp b/src/VORONOI/compute_voronoi_atom.cpp index 04277ed3c0..5808b8d17c 100644 --- a/src/VORONOI/compute_voronoi_atom.cpp +++ b/src/VORONOI/compute_voronoi_atom.cpp @@ -18,9 +18,6 @@ #include "compute_voronoi_atom.h" -#include -#include -#include #include "atom.h" #include "group.h" #include "update.h" @@ -30,9 +27,10 @@ #include "comm.h" #include "variable.h" #include "input.h" -#include "force.h" -#include +#include +#include +#include using namespace LAMMPS_NS; using namespace voro; diff --git a/src/YAFF/pair_lj_switch3_coulgauss_long.cpp b/src/YAFF/pair_lj_switch3_coulgauss_long.cpp index 2b366560ca..7d12ecbe04 100644 --- a/src/YAFF/pair_lj_switch3_coulgauss_long.cpp +++ b/src/YAFF/pair_lj_switch3_coulgauss_long.cpp @@ -27,7 +27,6 @@ #include "memory.h" #include "neighbor.h" #include "neigh_list.h" -#include "update.h" #include #include diff --git a/src/YAFF/pair_mm3_switch3_coulgauss_long.cpp b/src/YAFF/pair_mm3_switch3_coulgauss_long.cpp index ec9e1d8c5a..84c33e6b9a 100644 --- a/src/YAFF/pair_mm3_switch3_coulgauss_long.cpp +++ b/src/YAFF/pair_mm3_switch3_coulgauss_long.cpp @@ -27,7 +27,6 @@ #include "memory.h" #include "neighbor.h" #include "neigh_list.h" -#include "update.h" #include #include diff --git a/src/atom.cpp b/src/atom.cpp index 111ce7c93c..43d2578828 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -35,7 +35,6 @@ #include "library.h" #include -#include #include #ifdef LMP_INTEL @@ -44,6 +43,7 @@ #ifdef LMP_GPU #include "fix_gpu.h" +#include #endif using namespace LAMMPS_NS; @@ -269,7 +269,7 @@ Atom::Atom(LAMMPS *lmp) : Pointers(lmp) #define ATOM_CLASS #define AtomStyle(key,Class) \ (*avec_map)[#key] = &avec_creator; -#include "style_atom.h" +#include "style_atom.h" // IWYU pragma: keep #undef AtomStyle #undef ATOM_CLASS } @@ -351,7 +351,7 @@ Atom::~Atom() // delete mapping data structures - map_delete(); + Atom::map_delete(); delete unique_tags; } @@ -665,7 +665,7 @@ void Atom::set_atomflag_defaults() void Atom::create_avec(const std::string &style, int narg, char **arg, int trysuffix) { - delete [] atom_style; + delete[] atom_style; if (avec) delete avec; atom_style = nullptr; avec = nullptr; @@ -689,11 +689,9 @@ void Atom::create_avec(const std::string &style, int narg, char **arg, int trysu std::string estyle = style + "/"; if (sflag == 1) estyle += lmp->suffix; else estyle += lmp->suffix2; - atom_style = new char[estyle.size()+1]; - strcpy(atom_style,estyle.c_str()); + atom_style = utils::strdup(estyle); } else { - atom_style = new char[style.size()+1]; - strcpy(atom_style,style.c_str()); + atom_style = utils::strdup(style); } // if molecular system: @@ -2533,27 +2531,27 @@ void Atom::remove_custom(int index, int flag, int cols) { if (flag == 0 && cols == 0) { memory->destroy(ivector[index]); - ivector[index] = NULL; + ivector[index] = nullptr; delete [] ivname[index]; - ivname[index] = NULL; + ivname[index] = nullptr; } else if (flag == 1 && cols == 0) { memory->destroy(dvector[index]); - dvector[index] = NULL; + dvector[index] = nullptr; delete [] dvname[index]; - dvname[index] = NULL; + dvname[index] = nullptr; } else if (flag == 0 && cols) { memory->destroy(iarray[index]); - iarray[index] = NULL; + iarray[index] = nullptr; delete [] ianame[index]; - ianame[index] = NULL; + ianame[index] = nullptr; } else if (flag == 1 && cols) { memory->destroy(darray[index]); - darray[index] = NULL; + darray[index] = nullptr; delete [] daname[index]; - daname[index] = NULL; + daname[index] = nullptr; } } @@ -2786,9 +2784,9 @@ void *Atom::extract(const char *name) if (!array) index = find_custom(&name[2],flag,cols); else index = find_custom(&name[3],flag,cols); - if (index < 0) return NULL; - if (which != flag) return NULL; - if ((!array && cols) || (array && !cols)) return NULL; + if (index < 0) return nullptr; + if (which != flag) return nullptr; + if ((!array && cols) || (array && !cols)) return nullptr; if (!which && !array) return (void *) ivector[index]; if (which && !array) return (void *) dvector[index]; diff --git a/src/atom_vec_body.cpp b/src/atom_vec_body.cpp index 4670b88af8..a1ef126069 100644 --- a/src/atom_vec_body.cpp +++ b/src/atom_vec_body.cpp @@ -112,7 +112,7 @@ void AtomVecBody::process_args(int narg, char **arg) #define BodyStyle(key,Class) \ } else if (strcmp(arg[0],#key) == 0) { \ bptr = new Class(lmp,narg,arg); -#include "style_body.h" +#include "style_body.h" // IWYU pragma: keep #undef BodyStyle #undef BODY_CLASS diff --git a/src/atom_vec_hybrid.cpp b/src/atom_vec_hybrid.cpp index 0bffde2129..87d42403e6 100644 --- a/src/atom_vec_hybrid.cpp +++ b/src/atom_vec_hybrid.cpp @@ -187,20 +187,20 @@ void AtomVecHybrid::process_args(int narg, char **arg) // save concat_grow to check for duplicates of special-case fields char *concat_grow;; - char *null = nullptr; + char *dummyptr = nullptr; fields_grow = merge_fields(0,fields_grow,1,concat_grow); - fields_copy = merge_fields(1,fields_copy,0,null); - fields_comm = merge_fields(2,fields_comm,0,null); - fields_comm_vel = merge_fields(3,fields_comm_vel,0,null); - fields_reverse = merge_fields(4,fields_reverse,0,null); - fields_border = merge_fields(5,fields_border,0,null); - fields_border_vel = merge_fields(6,fields_border_vel,0,null); - fields_exchange = merge_fields(7,fields_exchange,0,null); - fields_restart = merge_fields(8,fields_restart,0,null); - fields_create = merge_fields(9,fields_create,0,null); - fields_data_atom = merge_fields(10,fields_data_atom,0,null); - fields_data_vel = merge_fields(11,fields_data_vel,0,null); + fields_copy = merge_fields(1,fields_copy,0,dummyptr); + fields_comm = merge_fields(2,fields_comm,0,dummyptr); + fields_comm_vel = merge_fields(3,fields_comm_vel,0,dummyptr); + fields_reverse = merge_fields(4,fields_reverse,0,dummyptr); + fields_border = merge_fields(5,fields_border,0,dummyptr); + fields_border_vel = merge_fields(6,fields_border_vel,0,dummyptr); + fields_exchange = merge_fields(7,fields_exchange,0,dummyptr); + fields_restart = merge_fields(8,fields_restart,0,dummyptr); + fields_create = merge_fields(9,fields_create,0,dummyptr); + fields_data_atom = merge_fields(10,fields_data_atom,0,dummyptr); + fields_data_vel = merge_fields(11,fields_data_vel,0,dummyptr); fields_allocated = 1; @@ -545,56 +545,38 @@ void AtomVecHybrid::pack_property_atom(int multiindex, double *buf, char *AtomVecHybrid::merge_fields(int inum, char *root, int concat_flag, char *&concat_str) { - // create concatenated string of length size from root + all substyles - - int size = strlen(root) + 1; - for (int k = 0; k < nstyles; k++) - size += strlen(fieldstrings[k].fstr[inum]) + 1; - - char *concat = new char[size]; - strcpy(concat,root); + // create vector with all words combined + std::string concat; + if (root) concat += root; for (int k = 0; k < nstyles; k++) { - if (strlen(concat)) strcat(concat," "); - strcat(concat,fieldstrings[k].fstr[inum]); + if (concat.size() > 0) concat += " "; + concat += fieldstrings[k].fstr[inum]; + } + if (concat_flag) concat_str = utils::strdup(concat); + + // remove duplicate words without changing the order + + auto words = Tokenizer(concat, " ").as_vector(); + std::vector dedup; + for (auto &w : words) { + bool found = false; + for (auto &d : dedup) { + if (w == d) found = true; + } + if (!found) dedup.push_back(w); } - // identify unique words in concatenated string - - std::vector words = Tokenizer(concat, " ").as_vector(); - int nwords = words.size(); - - int *unique = new int[nwords]; - - for (int i = 0; i < nwords; i++) { - unique[i] = 1; - for (int j = 0; j < i; j++) - if (words[i] == words[j]) unique[i] = 0; + // create final concatenated, deduped string + concat.clear(); + for (auto &d : dedup) { + concat += d; + concat += " "; } - // construct a new deduped string - - char *dedup = new char[size]; - dedup[0] = '\0'; - - for (int i = 0; i < nwords; i++) { - if (!unique[i]) continue; - strcat(dedup,words[i].c_str()); - if (i < nwords-1) strcat(dedup," "); - } - - // clean up or return concat - - if (concat_flag) concat_str = concat; - else delete [] concat; - - // clean up - - delete [] unique; - - // return final concatenated, deduped string - - return dedup; + // remove trailing blank + if (concat.size() > 0) concat.pop_back(); + return utils::strdup(concat); } /* ---------------------------------------------------------------------- diff --git a/src/balance.cpp b/src/balance.cpp index c8d21f1ac6..06a3463db5 100644 --- a/src/balance.cpp +++ b/src/balance.cpp @@ -196,8 +196,8 @@ void Balance::command(int narg, char **arg) if (style != -1) error->all(FLERR,"Illegal balance command"); if (iarg+4 > narg) error->all(FLERR,"Illegal balance command"); style = SHIFT; - if (strlen(arg[iarg+1]) > 3) error->all(FLERR,"Illegal balance command"); - strcpy(bstr,arg[iarg+1]); + if (strlen(arg[iarg+1]) > BSTR_SIZE) error->all(FLERR,"Illegal balance command"); + strncpy(bstr,arg[iarg+1],BSTR_SIZE+1); nitermax = utils::inumeric(FLERR,arg[iarg+2],false,lmp); if (nitermax <= 0) error->all(FLERR,"Illegal balance command"); stopthresh = utils::numeric(FLERR,arg[iarg+3],false,lmp); diff --git a/src/balance.h b/src/balance.h index e427c8bd9b..df8ac307b4 100644 --- a/src/balance.h +++ b/src/balance.h @@ -45,6 +45,7 @@ class Balance : public Command { int *bisection(int sortflag = 0); void dumpout(bigint); + static constexpr int BSTR_SIZE = 3; private: int me, nprocs; @@ -56,7 +57,7 @@ class Balance : public Command { int nitermax; // params for shift LB double stopthresh; - char bstr[4]; + char bstr[BSTR_SIZE+1]; int shift_allocate; // 1 if SHIFT vectors have been allocated int ndim; // length of balance string bstr diff --git a/src/bond.cpp b/src/bond.cpp index cc13ad6b86..e636ae9bf8 100644 --- a/src/bond.cpp +++ b/src/bond.cpp @@ -23,9 +23,6 @@ #include "neighbor.h" #include "suffix.h" #include "update.h" -#include "fmt/chrono.h" - -#include using namespace LAMMPS_NS; @@ -276,26 +273,21 @@ void Bond::write_file(int narg, char **arg) if (utils::file_is_readable(table_file)) { std::string units = utils::get_potential_units(table_file,"table"); if (!units.empty() && (units != update->unit_style)) { - error->one(FLERR,"Trying to append to a table file " - "with UNITS: {} while units are {}", - units, update->unit_style); + error->one(FLERR,"Trying to append to a table file with UNITS: {} while units are {}", + units, update->unit_style); } std::string date = utils::get_potential_date(table_file,"table"); - utils::logmesg(lmp,"Appending to table file {} with " - "DATE: {}\n", table_file, date); + utils::logmesg(lmp,"Appending to table file {} with DATE: {}\n", table_file, date); fp = fopen(table_file.c_str(),"a"); } else { - time_t tv = time(nullptr); - std::tm current_date = fmt::localtime(tv); - utils::logmesg(lmp,"Creating table file {} with " - "DATE: {:%Y-%m-%d}\n", table_file, current_date); + utils::logmesg(lmp,"Creating table file {} with DATE: {}\n", + table_file, utils::current_date()); fp = fopen(table_file.c_str(),"w"); - if (fp) fmt::print(fp,"# DATE: {:%Y-%m-%d} UNITS: {} Created by bond_write\n", - current_date, update->unit_style); + if (fp) fmt::print(fp,"# DATE: {} UNITS: {} Created by bond_write\n", + utils::current_date(), update->unit_style); } if (fp == nullptr) - error->one(FLERR,"Cannot open bond_write file {}: {}", - arg[4], utils::getsyserror()); + error->one(FLERR,"Cannot open bond_write file {}: {}", arg[4], utils::getsyserror()); } // initialize potentials before evaluating bond potential diff --git a/src/citeme.cpp b/src/citeme.cpp index 35ff062874..c0ab27e37e 100644 --- a/src/citeme.cpp +++ b/src/citeme.cpp @@ -16,7 +16,7 @@ #include "comm.h" #include "universe.h" -#include +#include // IWYU pragma: keep using namespace LAMMPS_NS; @@ -101,7 +101,7 @@ void CiteMe::add(const std::string &reference) if (logfile_flag == VERBOSE) logbuffer += "\n"; } - std::size_t found = reference.find_first_of("\n"); + std::size_t found = reference.find_first_of('\n'); std::string header = reference.substr(0,found+1); if (screen_flag == VERBOSE) scrbuffer += "- " + reference; if (screen_flag == TERSE) scrbuffer += "- " + header; diff --git a/src/comm_brick.cpp b/src/comm_brick.cpp index ab1b27f1b2..8f5cab723b 100644 --- a/src/comm_brick.cpp +++ b/src/comm_brick.cpp @@ -31,7 +31,6 @@ #include #include -#include using namespace LAMMPS_NS; @@ -60,14 +59,14 @@ CommBrick::CommBrick(LAMMPS *lmp) : CommBrick::~CommBrick() { - free_swap(); + CommBrick::free_swap(); if (mode == Comm::MULTI) { - free_multi(); + CommBrick::free_multi(); memory->destroy(cutghostmulti); } if (mode == Comm::MULTIOLD) { - free_multiold(); + CommBrick::free_multiold(); memory->destroy(cutghostmultiold); } @@ -112,12 +111,12 @@ void CommBrick::init_buffers() buf_send = buf_recv = nullptr; maxsend = maxrecv = BUFMIN; - grow_send(maxsend,2); + CommBrick::grow_send(maxsend,2); memory->create(buf_recv,maxrecv,"comm:buf_recv"); nswap = 0; maxswap = 6; - allocate_swap(maxswap); + CommBrick::allocate_swap(maxswap); sendlist = (int **) memory->smalloc(maxswap*sizeof(int *),"comm:sendlist"); memory->create(maxsendlist,maxswap,"comm:maxsendlist"); diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index e9175094f8..482b90c4c2 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -32,7 +32,6 @@ #include #include -#include using namespace LAMMPS_NS; diff --git a/src/compute_angle_local.cpp b/src/compute_angle_local.cpp index fa0b52f39c..7401d8b214 100644 --- a/src/compute_angle_local.cpp +++ b/src/compute_angle_local.cpp @@ -220,7 +220,7 @@ int ComputeAngleLocal::compute_angles(int flag) Angle *angle = force->angle; - m = n = 0; + m = 0; for (atom2 = 0; atom2 < nlocal; atom2++) { if (!(mask[atom2] & groupbit)) continue; @@ -292,7 +292,7 @@ int ComputeAngleLocal::compute_angles(int flag) if (tstr) input->variable->internal_set(tvar,theta); } - for (n = 0; n < nvalues; n++) { + for (int n = 0; n < nvalues; n++) { switch (bstyle[n]) { case THETA: ptr[n] = 180.0*theta/MY_PI; diff --git a/src/compute_bond_local.cpp b/src/compute_bond_local.cpp index 275924d0e5..ab0fa3fb0a 100644 --- a/src/compute_bond_local.cpp +++ b/src/compute_bond_local.cpp @@ -221,7 +221,7 @@ void ComputeBondLocal::compute_local() int ComputeBondLocal::compute_bonds(int flag) { - int i,m,n,nb,atom1,atom2,imol,iatom,btype,ivar; + int i,m,nb,atom1,atom2,imol,iatom,btype,ivar; tagint tagprev; double dx,dy,dz,rsq; double mass1,mass2,masstotal,invmasstotal; @@ -261,7 +261,7 @@ int ComputeBondLocal::compute_bonds(int flag) // loop over all atoms and their bonds - m = n = 0; + m = 0; for (atom1 = 0; atom1 < nlocal; atom1++) { if (!(mask[atom1] & groupbit)) continue; @@ -299,11 +299,12 @@ int ComputeBondLocal::compute_bonds(int flag) rsq = dx*dx + dy*dy + dz*dz; if (btype == 0) { - engpot = fbond = 0.0; - engvib = engrot = engtrans = omegasq = vvib = 0.0; + fbond = 0.0; } else { if (singleflag) engpot = bond->single(btype,rsq,atom1,atom2,fbond); + else fbond = engpot = 0.0; + engvib = engrot = engtrans = omegasq = vvib = 0.0; if (velflag) { if (rmass) { @@ -383,7 +384,7 @@ int ComputeBondLocal::compute_bonds(int flag) if (dstr) input->variable->internal_set(dvar,sqrt(rsq)); } - for (n = 0; n < nvalues; n++) { + for (int n = 0; n < nvalues; n++) { switch (bstyle[n]) { case DIST: ptr[n] = sqrt(rsq); diff --git a/src/compute_dihedral_local.cpp b/src/compute_dihedral_local.cpp index dbb02ff795..062741bad1 100644 --- a/src/compute_dihedral_local.cpp +++ b/src/compute_dihedral_local.cpp @@ -192,7 +192,7 @@ void ComputeDihedralLocal::compute_local() int ComputeDihedralLocal::compute_dihedrals(int flag) { - int i,m,n,nd,atom1,atom2,atom3,atom4,imol,iatom,ivar; + int i,m,nd,atom1,atom2,atom3,atom4,imol,iatom,ivar; tagint tagprev; double vb1x,vb1y,vb1z,vb2x,vb2y,vb2z,vb3x,vb3y,vb3z,vb2xm,vb2ym,vb2zm; double ax,ay,az,bx,by,bz,rasq,rbsq,rgsq,rg,ra2inv,rb2inv,rabinv; @@ -217,7 +217,7 @@ int ComputeDihedralLocal::compute_dihedrals(int flag) // loop over all atoms and their dihedrals - m = n = 0; + m = 0; for (atom2 = 0; atom2 < nlocal; atom2++) { if (!(mask[atom2] & groupbit)) continue; @@ -306,7 +306,7 @@ int ComputeDihedralLocal::compute_dihedrals(int flag) if (pstr) input->variable->internal_set(pvar,phi); } - for (n = 0; n < nvalues; n++) { + for (int n = 0; n < nvalues; n++) { switch (bstyle[n]) { case PHI: ptr[n] = 180.0*phi/MY_PI; diff --git a/src/compute_dipole.cpp b/src/compute_dipole.cpp index b67c3df3ce..7486baefd6 100644 --- a/src/compute_dipole.cpp +++ b/src/compute_dipole.cpp @@ -16,10 +16,10 @@ #include "atom.h" #include "domain.h" #include "error.h" -#include "group.h" #include "update.h" #include +#include using namespace LAMMPS_NS; diff --git a/src/compute_pressure.cpp b/src/compute_pressure.cpp index 435ef7a3e9..26a524dc5a 100644 --- a/src/compute_pressure.cpp +++ b/src/compute_pressure.cpp @@ -237,18 +237,16 @@ double ComputePressure::compute_scalar() // invoke temperature if it hasn't been already - double t; if (keflag) { if (temperature->invoked_scalar != update->ntimestep) - t = temperature->compute_scalar(); - else t = temperature->scalar; + temperature->compute_scalar(); } if (dimension == 3) { inv_volume = 1.0 / (domain->xprd * domain->yprd * domain->zprd); virial_compute(3,3); if (keflag) - scalar = (temperature->dof * boltz * t + + scalar = (temperature->dof * boltz * temperature->scalar + virial[0] + virial[1] + virial[2]) / 3.0 * inv_volume * nktv2p; else scalar = (virial[0] + virial[1] + virial[2]) / 3.0 * inv_volume * nktv2p; @@ -256,7 +254,7 @@ double ComputePressure::compute_scalar() inv_volume = 1.0 / (domain->xprd * domain->yprd); virial_compute(2,2); if (keflag) - scalar = (temperature->dof * boltz * t + + scalar = (temperature->dof * boltz * temperature->scalar + virial[0] + virial[1]) / 2.0 * inv_volume * nktv2p; else scalar = (virial[0] + virial[1]) / 2.0 * inv_volume * nktv2p; @@ -351,7 +349,5 @@ void ComputePressure::virial_compute(int n, int ndiag) void ComputePressure::reset_extra_compute_fix(const char *id_new) { delete [] id_temp; - int n = strlen(id_new) + 1; - id_temp = new char[n]; - strcpy(id_temp,id_new); + id_temp = utils::strdup(id_new); } diff --git a/src/compute_temp_deform.cpp b/src/compute_temp_deform.cpp index 915e682219..83875febcc 100644 --- a/src/compute_temp_deform.cpp +++ b/src/compute_temp_deform.cpp @@ -171,7 +171,7 @@ void ComputeTempDeform::compute_vector() double *h_ratelo = domain->h_ratelo; double massone, t[6]; - for (int i = 0; i < 6; i++) t[i] = 0.0; + for (auto &ti : t) ti = 0.0; for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index a1e3665cc9..7e5e97a42f 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -276,7 +276,7 @@ void ComputeTempSphere::compute_vector() // point particles will not contribute rotation due to radius = 0 double massone,inertiaone,t[6]; - for (int i = 0; i < 6; i++) t[i] = 0.0; + for (auto &ti : t) ti = 0.0; if (mode == ALL) { for (int i = 0; i < nlocal; i++) diff --git a/src/compute_vacf.cpp b/src/compute_vacf.cpp index 90dcbf8d4f..64d5ddb3f7 100644 --- a/src/compute_vacf.cpp +++ b/src/compute_vacf.cpp @@ -21,8 +21,6 @@ #include "fix_store.h" #include "error.h" -#include - using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ diff --git a/src/create_atoms.cpp b/src/create_atoms.cpp index 2d11a5a3bc..cdcdc42a45 100644 --- a/src/create_atoms.cpp +++ b/src/create_atoms.cpp @@ -176,28 +176,20 @@ void CreateAtoms::command(int narg, char **arg) } else if (strcmp(arg[iarg],"var") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal create_atoms command"); delete [] vstr; - int n = strlen(arg[iarg+1]) + 1; - vstr = new char[n]; - strcpy(vstr,arg[iarg+1]); + vstr = utils::strdup(arg[iarg+1]); varflag = 1; iarg += 2; } else if (strcmp(arg[iarg],"set") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal create_atoms command"); if (strcmp(arg[iarg+1],"x") == 0) { delete [] xstr; - int n = strlen(arg[iarg+2]) + 1; - xstr = new char[n]; - strcpy(xstr,arg[iarg+2]); + xstr = utils::strdup(arg[iarg+2]); } else if (strcmp(arg[iarg+1],"y") == 0) { delete [] ystr; - int n = strlen(arg[iarg+2]) + 1; - ystr = new char[n]; - strcpy(ystr,arg[iarg+2]); + ystr = utils::strdup(arg[iarg+2]); } else if (strcmp(arg[iarg+1],"z") == 0) { delete [] zstr; - int n = strlen(arg[iarg+2]) + 1; - zstr = new char[n]; - strcpy(zstr,arg[iarg+2]); + zstr = utils::strdup(arg[iarg+2]); } else error->all(FLERR,"Illegal create_atoms command"); iarg += 3; } else if (strcmp(arg[iarg],"rotate") == 0) { diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 7446c65c04..16c67927bf 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -28,8 +28,8 @@ #include "region.h" #include "update.h" #include "variable.h" -#include "fmt/format.h" -#include "utils.h" + +#include using namespace LAMMPS_NS; @@ -281,7 +281,7 @@ void DumpCustom::init_style() error->all(FLERR,"Dump_modify format line is too short"); int i=0; - for (auto word : words) { + for (const auto &word : words) { delete[] vformat[i]; if (format_column_user[i]) diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 437d5c353c..f9a970d2b2 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -87,15 +87,13 @@ DumpLocal::DumpLocal(LAMMPS *lmp, int narg, char **arg) : // setup format strings vformat = new char*[size_one]; - - format_default = new char[3*size_one+1]; - format_default[0] = '\0'; - + std::string fdefault; for (int i = 0; i < size_one; i++) { - if (vtype[i] == Dump::INT) strcat(format_default,"%d "); - else if (vtype[i] == Dump::DOUBLE) strcat(format_default,"%g "); + if (vtype[i] == Dump::INT) fdefault += "%d "; + else if (vtype[i] == Dump::DOUBLE) fdefault += "%g "; vformat[i] = nullptr; } + format_default = utils::strdup(fdefault); format_column_user = new char*[size_one]; for (int i = 0; i < size_one; i++) format_column_user[i] = nullptr; @@ -116,7 +114,7 @@ DumpLocal::DumpLocal(LAMMPS *lmp, int narg, char **arg) : // if wildcard expansion occurred, free earg memory from expand_args() if (expand) { - for (int i = 0; i < nfield; i++) delete [] earg[i]; + for (int i = 0; i < nfield; i++) delete[] earg[i]; memory->sfree(earg); } } @@ -125,27 +123,27 @@ DumpLocal::DumpLocal(LAMMPS *lmp, int narg, char **arg) : DumpLocal::~DumpLocal() { - delete [] pack_choice; - delete [] vtype; - delete [] field2index; - delete [] argindex; + delete[] pack_choice; + delete[] vtype; + delete[] field2index; + delete[] argindex; - for (int i = 0; i < ncompute; i++) delete [] id_compute[i]; + for (int i = 0; i < ncompute; i++) delete[] id_compute[i]; memory->sfree(id_compute); - delete [] compute; + delete[] compute; - for (int i = 0; i < nfix; i++) delete [] id_fix[i]; + for (int i = 0; i < nfix; i++) delete[] id_fix[i]; memory->sfree(id_fix); - delete [] fix; + delete[] fix; - for (int i = 0; i < size_one; i++) delete [] vformat[i]; - delete [] vformat; + for (int i = 0; i < size_one; i++) delete[] vformat[i]; + delete[] vformat; - for (int i = 0; i < size_one; i++) delete [] format_column_user[i]; - delete [] format_column_user; + for (int i = 0; i < size_one; i++) delete[] format_column_user[i]; + delete[] format_column_user; - delete [] columns; - delete [] label; + delete[] columns; + delete[] label; } /* ---------------------------------------------------------------------- */ @@ -157,7 +155,7 @@ void DumpLocal::init_style() // format = copy of default or user-specified line format - delete [] format; + delete[] format; if (format_line_user) format = utils::strdup(format_line_user); else format = utils::strdup(format_default); @@ -171,8 +169,8 @@ void DumpLocal::init_style() error->all(FLERR,"Dump_modify format line is too short"); int i=0; - for (auto word : words) { - delete [] vformat[i]; + for (const auto &word : words) { + delete[] vformat[i]; if (format_column_user[i]) vformat[i] = utils::strdup(std::string(format_column_user[i]) + " "); @@ -223,7 +221,7 @@ int DumpLocal::modify_param(int narg, char **arg) { if (strcmp(arg[0],"label") == 0) { if (narg < 2) error->all(FLERR,"Illegal dump_modify command"); - delete [] label; + delete[] label; label = utils::strdup(arg[1]); return 2; } else if (strcmp(arg[0],"format") == 0) { @@ -232,14 +230,14 @@ int DumpLocal::modify_param(int narg, char **arg) if (strcmp(arg[1],"none") == 0) { // just clear format_column_user allocated by this dump child class for (int i = 0; i < nfield; i++) { - delete [] format_column_user[i]; + delete[] format_column_user[i]; format_column_user[i] = nullptr; } return 2; } else if (strcmp(arg[1],"int") == 0) { - delete [] format_int_user; + delete[] format_int_user; format_int_user = utils::strdup(arg[2]); - delete [] format_bigint_user; + delete[] format_bigint_user; int n = strlen(format_int_user) + 8; format_bigint_user = new char[n]; // replace "d" in format_int_user with bigint format specifier @@ -255,14 +253,14 @@ int DumpLocal::modify_param(int narg, char **arg) *ptr = 'd'; } else if (strcmp(arg[1],"float") == 0) { - delete [] format_float_user; + delete[] format_float_user; format_float_user = utils::strdup(arg[2]); } else { int i = utils::inumeric(FLERR,arg[1],false,lmp) - 1; if (i < 0 || i >= nfield) error->all(FLERR,"Illegal dump_modify command"); - if (format_column_user[i]) delete [] format_column_user[i]; + if (format_column_user[i]) delete[] format_column_user[i]; format_column_user[i] = utils::strdup(arg[2]); } return 3; @@ -516,7 +514,7 @@ int DumpLocal::add_compute(const char *id) id_compute = (char **) memory->srealloc(id_compute,(ncompute+1)*sizeof(char *),"dump:id_compute"); - delete [] compute; + delete[] compute; compute = new Compute*[ncompute+1]; id_compute[ncompute] = utils::strdup(id); @@ -539,7 +537,7 @@ int DumpLocal::add_fix(const char *id) id_fix = (char **) memory->srealloc(id_fix,(nfix+1)*sizeof(char *),"dump:id_fix"); - delete [] fix; + delete[] fix; fix = new Fix*[nfix+1]; id_fix[nfix] = utils::strdup(id); diff --git a/src/fix_adapt.cpp b/src/fix_adapt.cpp index 5efa70859a..358cf8045f 100644 --- a/src/fix_adapt.cpp +++ b/src/fix_adapt.cpp @@ -331,15 +331,9 @@ void FixAdapt::init() nsub = utils::inumeric(FLERR,cptr+1,false,lmp); } - if (lmp->suffix_enable) { - int len = 2 + strlen(pstyle) + strlen(lmp->suffix); - char *psuffix = new char[len]; - strcpy(psuffix,pstyle); - strcat(psuffix,"/"); - strcat(psuffix,lmp->suffix); - ad->pair = force->pair_match(psuffix,1,nsub); - delete[] psuffix; - } + if (lmp->suffix_enable) + ad->pair = force->pair_match(fmt::format("{}/{}",pstyle,lmp->suffix),1,nsub); + if (ad->pair == nullptr) ad->pair = force->pair_match(pstyle,1,nsub); if (ad->pair == nullptr) error->all(FLERR,"Fix adapt pair style does not exist"); @@ -374,15 +368,9 @@ void FixAdapt::init() anybond = 1; char *bstyle = utils::strdup(ad->bstyle); - if (lmp->suffix_enable) { - int len = 2 + strlen(bstyle) + strlen(lmp->suffix); - char *bsuffix = new char[len]; - strcpy(bsuffix,bstyle); - strcat(bsuffix,"/"); - strcat(bsuffix,lmp->suffix); - ad->bond = force->bond_match(bsuffix); - delete [] bsuffix; - } + if (lmp->suffix_enable) + ad->bond = force->bond_match(fmt::format("{}/{}",bstyle,lmp->suffix)); + if (ad->bond == nullptr) ad->bond = force->bond_match(bstyle); if (ad->bond == nullptr ) error->all(FLERR,"Fix adapt bond style does not exist"); diff --git a/src/fix_ave_atom.cpp b/src/fix_ave_atom.cpp index 1b55e65bb1..1e30761274 100644 --- a/src/fix_ave_atom.cpp +++ b/src/fix_ave_atom.cpp @@ -177,7 +177,7 @@ FixAveAtom::FixAveAtom(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class - grow_arrays(atom->nmax); + FixAveAtom::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); // zero the array since dump may access it on timestep 0 diff --git a/src/fix_balance.cpp b/src/fix_balance.cpp index 40fa7255f6..2c76f13bf0 100644 --- a/src/fix_balance.cpp +++ b/src/fix_balance.cpp @@ -64,14 +64,15 @@ FixBalance::FixBalance(LAMMPS *lmp, int narg, char **arg) : int iarg = 5; if (lbstyle == SHIFT) { if (iarg+4 > narg) error->all(FLERR,"Illegal fix balance command"); - if (strlen(arg[iarg+1]) > 3) + if (strlen(arg[iarg+1]) > Balance::BSTR_SIZE) error->all(FLERR,"Illegal fix balance command"); - strcpy(bstr,arg[iarg+1]); + strncpy(bstr,arg[iarg+1], Balance::BSTR_SIZE+1); nitermax = utils::inumeric(FLERR,arg[iarg+2],false,lmp); if (nitermax <= 0) error->all(FLERR,"Illegal fix balance command"); stopthresh = utils::numeric(FLERR,arg[iarg+3],false,lmp); if (stopthresh < 1.0) error->all(FLERR,"Illegal fix balance command"); iarg += 4; + } else if (lbstyle == BISECTION) { iarg++; } diff --git a/src/fix_box_relax.cpp b/src/fix_box_relax.cpp index 8783e12b75..e80a4db593 100644 --- a/src/fix_box_relax.cpp +++ b/src/fix_box_relax.cpp @@ -329,13 +329,12 @@ FixBoxRelax::FixBoxRelax(LAMMPS *lmp, int narg, char **arg) : // pass id_temp as 4th arg to pressure constructor id_press = utils::strdup(std::string(id) + "_press"); - modify->add_compute(fmt::format("{} all pressure {} virial", - id_press, id_temp)); + modify->add_compute(fmt::format("{} all pressure {} virial",id_press, id_temp)); pflag = 1; dimension = domain->dimension; nrigid = 0; - rfix = 0; + rfix = nullptr; current_lifo = 0; } diff --git a/src/fix_efield.cpp b/src/fix_efield.cpp index 98cecd8a01..f752585206 100644 --- a/src/fix_efield.cpp +++ b/src/fix_efield.cpp @@ -428,7 +428,7 @@ double FixEfield::memory_usage() return energy added by fix ------------------------------------------------------------------------- */ -double FixEfield::compute_scalar(void) +double FixEfield::compute_scalar() { if (force_flag == 0) { MPI_Allreduce(fsum,fsum_all,4,MPI_DOUBLE,MPI_SUM,world); diff --git a/src/fix_external.cpp b/src/fix_external.cpp index f95c30c28d..ecc1aaa670 100644 --- a/src/fix_external.cpp +++ b/src/fix_external.cpp @@ -61,7 +61,7 @@ FixExternal::FixExternal(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class - grow_arrays(atom->nmax); + FixExternal::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); user_energy = 0.0; diff --git a/src/fix_halt.cpp b/src/fix_halt.cpp index 95faca893c..3e207baae7 100644 --- a/src/fix_halt.cpp +++ b/src/fix_halt.cpp @@ -54,8 +54,7 @@ FixHalt::FixHalt(LAMMPS *lmp, int narg, char **arg) : attribute = TLIMIT; } else if (strcmp(arg[iarg],"diskfree") == 0) { attribute = DISKFREE; - dlimit_path = new char[2]; - strcpy(dlimit_path,"."); + dlimit_path = utils::strdup("."); } else if (strcmp(arg[iarg],"bondmax") == 0) { attribute = BONDMAX; } else { diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index 92fa6a42c5..ef1cb4eeaf 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -178,7 +178,7 @@ FixLangevin::FixLangevin(LAMMPS *lmp, int narg, char **arg) : // no need to set peratom_flag, b/c data is for internal use only if (gjfflag) { - grow_arrays(atom->nmax); + FixLangevin::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); // initialize franprev to zero diff --git a/src/fix_move.cpp b/src/fix_move.cpp index 2cd945f082..72fd9b75d2 100644 --- a/src/fix_move.cpp +++ b/src/fix_move.cpp @@ -246,7 +246,7 @@ FixMove::FixMove(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class - grow_arrays(atom->nmax); + FixMove::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); @@ -779,10 +779,8 @@ void FixMove::initial_integrate(int /*vflag*/) if (vxvarstyle == EQUAL) v[i][0] = vx; else v[i][0] = velocity[i][0]; if (rmass) { - dtfm = dtf / rmass[i]; x[i][0] += dtv * v[i][0]; } else { - dtfm = dtf / mass[type[i]]; x[i][0] += dtv * v[i][0]; } } else { @@ -809,10 +807,8 @@ void FixMove::initial_integrate(int /*vflag*/) if (vyvarstyle == EQUAL) v[i][1] = vy; else v[i][1] = velocity[i][1]; if (rmass) { - dtfm = dtf / rmass[i]; x[i][1] += dtv * v[i][1]; } else { - dtfm = dtf / mass[type[i]]; x[i][1] += dtv * v[i][1]; } } else { @@ -839,10 +835,8 @@ void FixMove::initial_integrate(int /*vflag*/) if (vzvarstyle == EQUAL) v[i][2] = vz; else v[i][2] = velocity[i][2]; if (rmass) { - dtfm = dtf / rmass[i]; x[i][2] += dtv * v[i][2]; } else { - dtfm = dtf / mass[type[i]]; x[i][2] += dtv * v[i][2]; } } else { diff --git a/src/fix_neigh_history.cpp b/src/fix_neigh_history.cpp index 4ff7e7841b..7156363334 100644 --- a/src/fix_neigh_history.cpp +++ b/src/fix_neigh_history.cpp @@ -14,7 +14,6 @@ #include "fix_neigh_history.h" -#include #include "my_page.h" #include "atom.h" #include "comm.h" @@ -26,6 +25,8 @@ #include "memory.h" #include "error.h" +#include + using namespace LAMMPS_NS; using namespace FixConst; @@ -66,7 +67,7 @@ FixNeighHistory::FixNeighHistory(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based arrays // register with atom class - grow_arrays(atom->nmax); + FixNeighHistory::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); diff --git a/src/fix_nvt_sllod.cpp b/src/fix_nvt_sllod.cpp index cd819f8705..bc5d3f7298 100644 --- a/src/fix_nvt_sllod.cpp +++ b/src/fix_nvt_sllod.cpp @@ -22,7 +22,6 @@ #include "compute.h" #include "domain.h" #include "error.h" -#include "fix.h" #include "fix_deform.h" #include "group.h" #include "math_extra.h" diff --git a/src/fix_property_atom.cpp b/src/fix_property_atom.cpp index 6864b1f843..8fcb0f2af0 100644 --- a/src/fix_property_atom.cpp +++ b/src/fix_property_atom.cpp @@ -181,7 +181,7 @@ FixPropertyAtom::FixPropertyAtom(LAMMPS *lmp, int narg, char **arg) : // register with Atom class nmax_old = 0; - if (!lmp->kokkos) grow_arrays(atom->nmax); + if (!lmp->kokkos) FixPropertyAtom::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); if (border) atom->add_callback(Atom::BORDER); diff --git a/src/fix_read_restart.cpp b/src/fix_read_restart.cpp index 1b22144643..20daa94f84 100644 --- a/src/fix_read_restart.cpp +++ b/src/fix_read_restart.cpp @@ -32,7 +32,7 @@ FixReadRestart::FixReadRestart(LAMMPS *lmp, int narg, char **arg) : // perform initial allocation of atom-based array // register with Atom class - grow_arrays(atom->nmax); + FixReadRestart::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); // extra = copy of atom->extra diff --git a/src/fix_respa.cpp b/src/fix_respa.cpp index 64cd44ed42..dba09b3c78 100644 --- a/src/fix_respa.cpp +++ b/src/fix_respa.cpp @@ -44,7 +44,7 @@ FixRespa::FixRespa(LAMMPS *lmp, int narg, char **arg) : f_level = nullptr; t_level = nullptr; - grow_arrays(atom->nmax); + FixRespa::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); } diff --git a/src/fix_spring_self.cpp b/src/fix_spring_self.cpp index 43fe9e40b6..5ea8bffd01 100644 --- a/src/fix_spring_self.cpp +++ b/src/fix_spring_self.cpp @@ -73,7 +73,7 @@ FixSpringSelf::FixSpringSelf(LAMMPS *lmp, int narg, char **arg) : // register with Atom class xoriginal = nullptr; - grow_arrays(atom->nmax); + FixSpringSelf::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); diff --git a/src/fix_store.cpp b/src/fix_store.cpp index c54e8b84be..eb23fbad97 100644 --- a/src/fix_store.cpp +++ b/src/fix_store.cpp @@ -82,7 +82,7 @@ vstore(nullptr), astore(nullptr), rbuf(nullptr) memory->create(rbuf,nrow*ncol+2,"fix/store:rbuf"); } if (flavor == PERATOM) { - grow_arrays(atom->nmax); + FixStore::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); if (restart_peratom) atom->add_callback(Atom::RESTART); rbuf = nullptr; diff --git a/src/fix_store_state.cpp b/src/fix_store_state.cpp index 1d3d48a06b..e4d1634a07 100644 --- a/src/fix_store_state.cpp +++ b/src/fix_store_state.cpp @@ -19,17 +19,16 @@ #include "compute.h" #include "update.h" #include "domain.h" -#include "force.h" #include "modify.h" #include "fix.h" #include "group.h" #include "input.h" #include "variable.h" -#include "variable.h" -#include "utils.h" #include "memory.h" #include "error.h" +#include + using namespace LAMMPS_NS; using namespace FixConst; @@ -338,7 +337,7 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : // register with Atom class values = nullptr; - grow_arrays(atom->nmax); + FixStoreState::grow_arrays(atom->nmax); atom->add_callback(Atom::GROW); atom->add_callback(Atom::RESTART); @@ -354,7 +353,7 @@ FixStoreState::FixStoreState(LAMMPS *lmp, int narg, char **arg) : kflag = 1; cfv_flag = 0; - end_of_step(); + FixStoreState::end_of_step(); firstflag = 1; } diff --git a/src/force.cpp b/src/force.cpp index 0f5d49e9c8..62d9738206 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -13,6 +13,7 @@ ------------------------------------------------------------------------- */ #include "force.h" + #include "style_angle.h" // IWYU pragma: keep #include "style_bond.h" // IWYU pragma: keep #include "style_dihedral.h" // IWYU pragma: keep @@ -20,18 +21,16 @@ #include "style_kspace.h" // IWYU pragma: keep #include "style_pair.h" // IWYU pragma: keep -#include "angle.h" -#include "atom.h" -#include "bond.h" +#include "angle_hybrid.h" #include "bond_hybrid.h" -#include "comm.h" -#include "dihedral.h" -#include "error.h" -#include "improper.h" -#include "kspace.h" -#include "pair.h" +#include "dihedral_hybrid.h" +#include "improper_hybrid.h" #include "pair_hybrid.h" -#include "pair_hybrid_overlay.h" +#include "kspace.h" + +#include "atom.h" +#include "comm.h" +#include "error.h" #include @@ -80,7 +79,7 @@ void _noopt Force::create_factories() #define PAIR_CLASS #define PairStyle(key,Class) \ (*pair_map)[#key] = &pair_creator; -#include "style_pair.h" +#include "style_pair.h" // IWYU pragma: keep #undef PairStyle #undef PAIR_CLASS @@ -89,7 +88,7 @@ void _noopt Force::create_factories() #define BOND_CLASS #define BondStyle(key,Class) \ (*bond_map)[#key] = &bond_creator; -#include "style_bond.h" +#include "style_bond.h" // IWYU pragma: keep #undef BondStyle #undef BOND_CLASS @@ -98,7 +97,7 @@ void _noopt Force::create_factories() #define ANGLE_CLASS #define AngleStyle(key,Class) \ (*angle_map)[#key] = &angle_creator; -#include "style_angle.h" +#include "style_angle.h" // IWYU pragma: keep #undef AngleStyle #undef ANGLE_CLASS @@ -107,7 +106,7 @@ void _noopt Force::create_factories() #define DIHEDRAL_CLASS #define DihedralStyle(key,Class) \ (*dihedral_map)[#key] = &dihedral_creator; -#include "style_dihedral.h" +#include "style_dihedral.h" // IWYU pragma: keep #undef DihedralStyle #undef DIHEDRAL_CLASS @@ -116,7 +115,7 @@ void _noopt Force::create_factories() #define IMPROPER_CLASS #define ImproperStyle(key,Class) \ (*improper_map)[#key] = &improper_creator; -#include "style_improper.h" +#include "style_improper.h" // IWYU pragma: keep #undef ImproperStyle #undef IMPROPER_CLASS @@ -125,7 +124,7 @@ void _noopt Force::create_factories() #define KSPACE_CLASS #define KSpaceStyle(key,Class) \ (*kspace_map)[#key] = &kspace_creator; -#include "style_kspace.h" +#include "style_kspace.h" // IWYU pragma: keep #undef KSpaceStyle #undef KSPACE_CLASS } @@ -737,9 +736,7 @@ void Force::store_style(char *&str, const std::string &style, int sflag) if (sflag == 1) estyle += std::string("/") + lmp->suffix; else if (sflag == 2) estyle += std::string("/") + lmp->suffix2; else if (sflag == 3) estyle += std::string("/") + lmp->suffixp; - - str = new char[estyle.size()+1]; - strcpy(str,estyle.c_str()); + str = utils::strdup(estyle); } /* ---------------------------------------------------------------------- diff --git a/src/group.cpp b/src/group.cpp index ab058b49da..57c701a7fa 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -37,7 +37,6 @@ #include #include #include -#include using namespace LAMMPS_NS; diff --git a/src/imbalance.cpp b/src/imbalance.cpp index 80cbd8654a..e6ecacbfa0 100644 --- a/src/imbalance.cpp +++ b/src/imbalance.cpp @@ -1,4 +1,3 @@ -// clang-format off /* -*- c++ -*- ---------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories diff --git a/src/imbalance_group.cpp b/src/imbalance_group.cpp index e674338e76..bbd6bc056a 100644 --- a/src/imbalance_group.cpp +++ b/src/imbalance_group.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -22,45 +21,43 @@ using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ -ImbalanceGroup::ImbalanceGroup(LAMMPS *lmp) : Imbalance(lmp), id(0), factor(0) -{} +ImbalanceGroup::ImbalanceGroup(LAMMPS *lmp) : Imbalance(lmp), id(nullptr), factor(nullptr) {} /* -------------------------------------------------------------------- */ ImbalanceGroup::~ImbalanceGroup() { - delete [] id; - delete [] factor; + delete[] id; + delete[] factor; } /* -------------------------------------------------------------------- */ int ImbalanceGroup::options(int narg, char **arg) { - if (narg < 3) error->all(FLERR,"Illegal balance weight command"); + if (narg < 3) error->all(FLERR, "Illegal balance weight command"); - num = utils::inumeric(FLERR,arg[0],false,lmp); - if (num < 1) error->all(FLERR,"Illegal balance weight command"); - if (2*num+1 > narg) error->all(FLERR,"Illegal balance weight command"); + num = utils::inumeric(FLERR, arg[0], false, lmp); + if (num < 1) error->all(FLERR, "Illegal balance weight command"); + if (2 * num + 1 > narg) error->all(FLERR, "Illegal balance weight command"); id = new int[num]; factor = new double[num]; for (int i = 0; i < num; ++i) { - id[i] = group->find(arg[2*i+1]); - if (id[i] < 0) - error->all(FLERR,"Unknown group in balance weight command: {}", arg[2*i+1]); - factor[i] = utils::numeric(FLERR,arg[2*i+2],false,lmp); - if (factor[i] <= 0.0) error->all(FLERR,"Illegal balance weight command"); + id[i] = group->find(arg[2 * i + 1]); + if (id[i] < 0) error->all(FLERR, "Unknown group in balance weight command: {}", arg[2 * i + 1]); + factor[i] = utils::numeric(FLERR, arg[2 * i + 2], false, lmp); + if (factor[i] <= 0.0) error->all(FLERR, "Illegal balance weight command"); } - return 2*num+1; + return 2 * num + 1; } /* -------------------------------------------------------------------- */ void ImbalanceGroup::compute(double *weight) { - const int * const mask = atom->mask; - const int * const bitmask = group->bitmask; + const int *const mask = atom->mask; + const int *const bitmask = group->bitmask; const int nlocal = atom->nlocal; if (num == 0) return; @@ -68,8 +65,7 @@ void ImbalanceGroup::compute(double *weight) for (int i = 0; i < nlocal; ++i) { const int imask = mask[i]; for (int j = 0; j < num; ++j) { - if (imask & bitmask[id[j]]) - weight[i] *= factor[j]; + if (imask & bitmask[id[j]]) weight[i] *= factor[j]; } } } @@ -81,11 +77,10 @@ std::string ImbalanceGroup::info() std::string mesg = ""; if (num > 0) { - const char * const * const names = group->names; + const char *const *const names = group->names; mesg += " group weights:"; - for (int i = 0; i < num; ++i) - mesg += fmt::format(" {}={}",names[id[i]],factor[i]); + for (int i = 0; i < num; ++i) mesg += fmt::format(" {}={}", names[id[i]], factor[i]); mesg += "\n"; } return mesg; diff --git a/src/imbalance_store.cpp b/src/imbalance_store.cpp index 2437395dda..598fb88bee 100644 --- a/src/imbalance_store.cpp +++ b/src/imbalance_store.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -21,20 +20,20 @@ using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ -ImbalanceStore::ImbalanceStore(LAMMPS *lmp) : Imbalance(lmp), name(0) {} +ImbalanceStore::ImbalanceStore(LAMMPS *lmp) : Imbalance(lmp), name(nullptr) {} /* -------------------------------------------------------------------- */ ImbalanceStore::~ImbalanceStore() { - delete [] name; + delete[] name; } /* -------------------------------------------------------------------- */ int ImbalanceStore::options(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal balance weight command"); + if (narg < 1) error->all(FLERR, "Illegal balance weight command"); name = utils::strdup(arg[0]); return 1; @@ -44,13 +43,13 @@ int ImbalanceStore::options(int narg, char **arg) void ImbalanceStore::compute(double *weight) { - int flag,cols; - int index = atom->find_custom(name,flag,cols); + int flag, cols; + int index = atom->find_custom(name, flag, cols); // property does not exist if (index < 0 || flag != 1 || cols) - error->all(FLERR,"Balance weight store vector does not exist"); + error->all(FLERR, "Balance weight store vector does not exist"); double *prop = atom->dvector[index]; const int nlocal = atom->nlocal; @@ -61,5 +60,5 @@ void ImbalanceStore::compute(double *weight) std::string ImbalanceStore::info() { - return fmt::format(" storing weight in atom property d_{}\n",name); + return fmt::format(" storing weight in atom property d_{}\n", name); } diff --git a/src/imbalance_time.cpp b/src/imbalance_time.cpp index 8c5104381d..8f27938a68 100644 --- a/src/imbalance_time.cpp +++ b/src/imbalance_time.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -30,9 +29,9 @@ ImbalanceTime::ImbalanceTime(LAMMPS *lmp) : Imbalance(lmp) {} int ImbalanceTime::options(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal balance weight command"); - factor = utils::numeric(FLERR,arg[0],false,lmp); - if (factor <= 0.0) error->all(FLERR,"Illegal balance weight command"); + if (narg < 1) error->all(FLERR, "Illegal balance weight command"); + factor = utils::numeric(FLERR, arg[0], false, lmp); + if (factor <= 0.0) error->all(FLERR, "Illegal balance weight command"); return 1; } @@ -71,14 +70,14 @@ void ImbalanceTime::compute(double *weight) cost += 0.1; double maxcost; - MPI_Allreduce(&cost,&maxcost,1,MPI_DOUBLE,MPI_MAX,world); + MPI_Allreduce(&cost, &maxcost, 1, MPI_DOUBLE, MPI_MAX, world); if (maxcost <= 0.1) return; int nlocal = atom->nlocal; double localwt = 0.0; - if (nlocal) localwt = cost/nlocal; + if (nlocal) localwt = cost / nlocal; - if (nlocal && localwt <= 0.0) error->one(FLERR,"Balance weight <= 0.0"); + if (nlocal && localwt <= 0.0) error->one(FLERR, "Balance weight <= 0.0"); // apply factor if specified != 1.0 // wtlo,wthi = lo/hi values excluding 0.0 due to no atoms on this proc @@ -87,15 +86,15 @@ void ImbalanceTime::compute(double *weight) // expand/contract all localwt values from lo->hi to lo->newhi if (factor != 1.0) { - double wtlo,wthi; + double wtlo, wthi; if (localwt == 0.0) localwt = BIG; - MPI_Allreduce(&localwt,&wtlo,1,MPI_DOUBLE,MPI_MIN,world); + MPI_Allreduce(&localwt, &wtlo, 1, MPI_DOUBLE, MPI_MIN, world); if (localwt == BIG) localwt = 0.0; - MPI_Allreduce(&localwt,&wthi,1,MPI_DOUBLE,MPI_MAX,world); + MPI_Allreduce(&localwt, &wthi, 1, MPI_DOUBLE, MPI_MAX, world); if (wtlo == wthi) return; - double newhi = wthi*factor; - localwt = wtlo + ((localwt-wtlo)/(wthi-wtlo)) * (newhi-wtlo); + double newhi = wthi * factor; + localwt = wtlo + ((localwt - wtlo) / (wthi - wtlo)) * (newhi - wtlo); } for (int i = 0; i < nlocal; i++) weight[i] *= localwt; @@ -109,5 +108,5 @@ void ImbalanceTime::compute(double *weight) std::string ImbalanceTime::info() { - return fmt::format(" time weight factor: {}\n",factor); + return fmt::format(" time weight factor: {}\n", factor); } diff --git a/src/imbalance_var.cpp b/src/imbalance_var.cpp index 8679216b94..4b1099c767 100644 --- a/src/imbalance_var.cpp +++ b/src/imbalance_var.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -25,20 +24,20 @@ using namespace LAMMPS_NS; /* -------------------------------------------------------------------- */ -ImbalanceVar::ImbalanceVar(LAMMPS *lmp) : Imbalance(lmp), name(0) {} +ImbalanceVar::ImbalanceVar(LAMMPS *lmp) : Imbalance(lmp), name(nullptr) {} /* -------------------------------------------------------------------- */ ImbalanceVar::~ImbalanceVar() { - delete [] name; + delete[] name; } /* -------------------------------------------------------------------- */ int ImbalanceVar::options(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal balance weight command"); + if (narg < 1) error->all(FLERR, "Illegal balance weight command"); name = utils::strdup(arg[0]); init(0); @@ -51,10 +50,10 @@ void ImbalanceVar::init(int /*flag*/) { id = input->variable->find(name); if (id < 0) { - error->all(FLERR,"Variable name for balance weight does not exist"); + error->all(FLERR, "Variable name for balance weight does not exist"); } else { if (input->variable->atomstyle(id) == 0) - error->all(FLERR,"Variable for balance weight has invalid style"); + error->all(FLERR, "Variable for balance weight has invalid style"); } } @@ -67,16 +66,16 @@ void ImbalanceVar::compute(double *weight) double *values; const int nlocal = atom->nlocal; - memory->create(values,nlocal,"imbalance:values"); + memory->create(values, nlocal, "imbalance:values"); - input->variable->compute_atom(id,all,values,1,0); + input->variable->compute_atom(id, all, values, 1, 0); int flag = 0; for (int i = 0; i < nlocal; i++) if (values[i] <= 0.0) flag = 1; int flagall; - MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world); - if (flagall) error->one(FLERR,"Balance weight <= 0.0"); + MPI_Allreduce(&flag, &flagall, 1, MPI_INT, MPI_SUM, world); + if (flagall) error->one(FLERR, "Balance weight <= 0.0"); for (int i = 0; i < nlocal; i++) weight[i] *= values[i]; @@ -87,5 +86,5 @@ void ImbalanceVar::compute(double *weight) std::string ImbalanceVar::info() { - return fmt::format(" weight variable: {}\n",name); + return fmt::format(" weight variable: {}\n", name); } diff --git a/src/info.cpp b/src/info.cpp index c6bf2663f4..137bf44b1a 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include #ifdef _WIN32 @@ -1331,18 +1333,31 @@ std::string Info::get_compiler_info() { std::string buf; #if defined(__INTEL_LLVM_COMPILER) - double version = static_cast(__INTEL_LLVM_COMPILER)*0.01; + constexpr double version = static_cast(__INTEL_LLVM_COMPILER)*0.01; buf = fmt::format("Intel LLVM C++ {:.1f} / {}", version, __VERSION__); +#elif defined(__ibmxl__) + buf = fmt::format("IBM XL C/C++ (Clang) {}.{}.{}", + __ibmxl_version__, __ibmxl_release__, __ibmxl_modification__); #elif defined(__clang__) buf = fmt::format("Clang C++ {}", __VERSION__); #elif defined(__PGI) - buf = fmt::format("PGI C++ {}.{}",__PGIC__,__PGIC_MINOR__); + buf = fmt::format("PGI C++ {}.{}",__PGIC__, __PGIC_MINOR__); #elif defined(__INTEL_COMPILER) double version = static_cast(__INTEL_COMPILER)*0.01; buf = fmt::format("Intel Classic C++ {:.2f}.{} / {}", version, __INTEL_COMPILER_UPDATE, __VERSION__); +#elif defined(__MINGW64__) + buf = fmt::format("MinGW-w64 64bit {}.{} / GNU C++ {}", __MINGW64_VERSION_MAJOR, + __MINGW64_VERSION_MINOR, __VERSION__); +#elif defined(__MINGW32__) + buf = fmt::format("MinGW-w64 32bit {}.{} / GNU C++ {}", __MINGW32_MAJOR_VERSION, + __MINGW32_MINOR_VERSION, __VERSION__); #elif defined(__GNUC__) buf = fmt::format("GNU C++ {}", __VERSION__); +#elif defined(_MSC_VER) && (_MSC_VER > 1920) && (_MSC_VER < 2000) + constexpr int major = _MSC_VER / 100; + constexpr int minor = _MSC_VER - major *100; + buf = fmt::format("Microsoft Visual Studio 20{}, C/C++ {}.{}", major, major-5, minor); #else buf = "(Unknown)"; #endif @@ -1428,8 +1443,10 @@ std::string Info::get_mpi_info(int &major, int &minor) std::string Info::get_cxx_info() { -#if __cplusplus > 201703L - return "newer than C++17"; +#if __cplusplus > 202002L + return "newer than C++20"; +#elif __cplusplus == 202002L + return "C++20"; #elif __cplusplus == 201703L return "C++17"; #elif __cplusplus == 201402L diff --git a/src/input.cpp b/src/input.cpp index 50e0d45aa0..f67438d635 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -38,7 +38,7 @@ #include "output.h" #include "pair.h" #include "special.h" -#include "style_command.h" +#include "style_command.h" // IWYU pragma: keep #include "thermo.h" #include "timer.h" #include "universe.h" @@ -46,7 +46,7 @@ #include "variable.h" #include -#include +#include #include #include #include @@ -126,7 +126,7 @@ Input::Input(LAMMPS *lmp, int argc, char **argv) : Pointers(lmp) #define COMMAND_CLASS #define CommandStyle(key,Class) \ (*command_map)[#key] = &command_creator; -#include "style_command.h" +#include "style_command.h" // IWYU pragma: keep #undef CommandStyle #undef COMMAND_CLASS @@ -614,8 +614,7 @@ void Input::substitute(char *&str, char *&str2, int &max, int &max2, int flag) } if (value == nullptr) - error->one(FLERR,"Substitution for illegal " - "variable {}",var); + error->one(FLERR,"Substitution for illegal variable {}",var); // check if storage in str2 needs to be expanded // re-initialize ptr and ptr2 to the point beyond the variable. @@ -1257,7 +1256,7 @@ void Input::shell() #else if (arg[i]) { std::string vardef(arg[i]); - auto found = vardef.find_first_of("="); + auto found = vardef.find_first_of('='); if (found == std::string::npos) { rv = setenv(vardef.c_str(),"",1); } else { diff --git a/src/lammps.cpp b/src/lammps.cpp index b00181452b..89c59bec3d 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -28,27 +28,28 @@ #include "style_minimize.h" // IWYU pragma: keep #include "style_pair.h" // IWYU pragma: keep #include "style_region.h" // IWYU pragma: keep -#include "universe.h" -#include "input.h" -#include "info.h" -#include "atom.h" // IWYU pragma: keep -#include "update.h" -#include "neighbor.h" // IWYU pragma: keep + +#include "accelerator_kokkos.h" +#include "accelerator_omp.h" +#include "atom.h" +#include "citeme.h" #include "comm.h" #include "comm_brick.h" -#include "domain.h" // IWYU pragma: keep -#include "force.h" -#include "modify.h" -#include "group.h" -#include "output.h" -#include "citeme.h" -#include "accelerator_kokkos.h" -#include "accelerator_omp.h" // IWYU pragma: keep -#include "timer.h" -#include "lmppython.h" -#include "version.h" -#include "memory.h" +#include "domain.h" #include "error.h" +#include "force.h" +#include "group.h" +#include "info.h" +#include "input.h" +#include "lmppython.h" +#include "memory.h" +#include "modify.h" +#include "neighbor.h" +#include "output.h" +#include "timer.h" +#include "universe.h" +#include "update.h" +#include "version.h" #include #include @@ -412,17 +413,11 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : if (strcmp(arg[iarg+1],"hybrid") == 0) { if (iarg+4 > narg) error->universe_all(FLERR,"Invalid command-line argument"); - int n = strlen(arg[iarg+2]) + 1; - suffix = new char[n]; - strcpy(suffix,arg[iarg+2]); - n = strlen(arg[iarg+3]) + 1; - suffix2 = new char[n]; - strcpy(suffix2,arg[iarg+3]); + suffix = utils::strdup(arg[iarg+2]); + suffix2 = utils::strdup(arg[iarg+3]); iarg += 4; } else { - int n = strlen(arg[iarg+1]) + 1; - suffix = new char[n]; - strcpy(suffix,arg[iarg+1]); + suffix = utils::strdup(arg[iarg+1]); iarg += 2; } @@ -512,7 +507,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : else if (strcmp(arg[inflag], "none") == 0) infile = stdin; else infile = fopen(arg[inflag],"r"); if (infile == nullptr) - error->one(FLERR,"Cannot open input script {}: {}",arg[inflag], utils::getsyserror()); + error->one(FLERR,"Cannot open input script {}: {}", arg[inflag], utils::getsyserror()); } if ((universe->me == 0) && !helpflag) @@ -870,14 +865,12 @@ void LAMMPS::post_create() // invoke any command-line package commands if (num_package) { - char str[256]; + std::string str; for (int i = 0; i < num_package; i++) { - strcpy(str,"package"); + str = "package"; for (char **ptr = packargs[i]; *ptr != nullptr; ++ptr) { - if (strlen(str) + strlen(*ptr) + 2 > 256) - error->all(FLERR,"Too many -pk arguments in command line"); - strcat(str," "); - strcat(str,*ptr); + str += " "; + str += *ptr; } input->one(str); } @@ -1193,7 +1186,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Atom styles:\n"); #define ATOM_CLASS #define AtomStyle(key,Class) print_style(fp,#key,pos); -#include "style_atom.h" +#include "style_atom.h" // IWYU pragma: keep #undef ATOM_CLASS fprintf(fp,"\n\n"); @@ -1201,7 +1194,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Integrate styles:\n"); #define INTEGRATE_CLASS #define IntegrateStyle(key,Class) print_style(fp,#key,pos); -#include "style_integrate.h" +#include "style_integrate.h" // IWYU pragma: keep #undef INTEGRATE_CLASS fprintf(fp,"\n\n"); @@ -1209,7 +1202,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Minimize styles:\n"); #define MINIMIZE_CLASS #define MinimizeStyle(key,Class) print_style(fp,#key,pos); -#include "style_minimize.h" +#include "style_minimize.h" // IWYU pragma: keep #undef MINIMIZE_CLASS fprintf(fp,"\n\n"); @@ -1217,7 +1210,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Pair styles:\n"); #define PAIR_CLASS #define PairStyle(key,Class) print_style(fp,#key,pos); -#include "style_pair.h" +#include "style_pair.h" // IWYU pragma: keep #undef PAIR_CLASS fprintf(fp,"\n\n"); @@ -1225,7 +1218,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Bond styles:\n"); #define BOND_CLASS #define BondStyle(key,Class) print_style(fp,#key,pos); -#include "style_bond.h" +#include "style_bond.h" // IWYU pragma: keep #undef BOND_CLASS fprintf(fp,"\n\n"); @@ -1233,7 +1226,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Angle styles:\n"); #define ANGLE_CLASS #define AngleStyle(key,Class) print_style(fp,#key,pos); -#include "style_angle.h" +#include "style_angle.h" // IWYU pragma: keep #undef ANGLE_CLASS fprintf(fp,"\n\n"); @@ -1241,7 +1234,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Dihedral styles:\n"); #define DIHEDRAL_CLASS #define DihedralStyle(key,Class) print_style(fp,#key,pos); -#include "style_dihedral.h" +#include "style_dihedral.h" // IWYU pragma: keep #undef DIHEDRAL_CLASS fprintf(fp,"\n\n"); @@ -1249,7 +1242,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Improper styles:\n"); #define IMPROPER_CLASS #define ImproperStyle(key,Class) print_style(fp,#key,pos); -#include "style_improper.h" +#include "style_improper.h" // IWYU pragma: keep #undef IMPROPER_CLASS fprintf(fp,"\n\n"); @@ -1257,7 +1250,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* KSpace styles:\n"); #define KSPACE_CLASS #define KSpaceStyle(key,Class) print_style(fp,#key,pos); -#include "style_kspace.h" +#include "style_kspace.h" // IWYU pragma: keep #undef KSPACE_CLASS fprintf(fp,"\n\n"); @@ -1265,7 +1258,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Fix styles\n"); #define FIX_CLASS #define FixStyle(key,Class) print_style(fp,#key,pos); -#include "style_fix.h" +#include "style_fix.h" // IWYU pragma: keep #undef FIX_CLASS fprintf(fp,"\n\n"); @@ -1273,7 +1266,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Compute styles:\n"); #define COMPUTE_CLASS #define ComputeStyle(key,Class) print_style(fp,#key,pos); -#include "style_compute.h" +#include "style_compute.h" // IWYU pragma: keep #undef COMPUTE_CLASS fprintf(fp,"\n\n"); @@ -1281,7 +1274,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Region styles:\n"); #define REGION_CLASS #define RegionStyle(key,Class) print_style(fp,#key,pos); -#include "style_region.h" +#include "style_region.h" // IWYU pragma: keep #undef REGION_CLASS fprintf(fp,"\n\n"); @@ -1289,7 +1282,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Dump styles:\n"); #define DUMP_CLASS #define DumpStyle(key,Class) print_style(fp,#key,pos); -#include "style_dump.h" +#include "style_dump.h" // IWYU pragma: keep #undef DUMP_CLASS fprintf(fp,"\n\n"); @@ -1297,7 +1290,7 @@ void _noopt LAMMPS::help() fprintf(fp,"* Command styles\n"); #define COMMAND_CLASS #define CommandStyle(key,Class) print_style(fp,#key,pos); -#include "style_command.h" +#include "style_command.h" // IWYU pragma: keep #undef COMMAND_CLASS fprintf(fp,"\n\n"); diff --git a/src/library.cpp b/src/library.cpp index 1acb61c66d..13f480ed03 100644 --- a/src/library.cpp +++ b/src/library.cpp @@ -52,7 +52,6 @@ #include "variable.h" #include -#include #if defined(LAMMPS_EXCEPTIONS) #include "exceptions.h" diff --git a/src/main.cpp b/src/main.cpp index 32420324ef..568da132e2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -28,10 +28,6 @@ #include #endif -#if defined(LAMMPS_EXCEPTIONS) -#include "exceptions.h" -#endif - // import MolSSI Driver Interface library #if defined(LMP_MDI) #include diff --git a/src/math_eigen_impl.h b/src/math_eigen_impl.h index 132434e547..a3dbf3d323 100644 --- a/src/math_eigen_impl.h +++ b/src/math_eigen_impl.h @@ -506,8 +506,7 @@ _Jacobi(int n, Scalar **M, int *max_idx_row) { this->M = M; this->max_idx_row = max_idx_row; //assert(this->max_idx_row); - } - else { + } else { is_preallocated = false; SetSize(n); // allocate the "M" and "max_int_row" arrays } diff --git a/src/min.cpp b/src/min.cpp index 69e24a541f..ab8b1a5235 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -959,20 +959,19 @@ double Min::fnorm_max() double Min::total_torque() { - double fmsq,ftotsqone,ftotsqall; + double ftotsqone,ftotsqall; int nlocal = atom->nlocal; double hbar = force->hplanck/MY_2PI; double tx,ty,tz; double **sp = atom->sp; double **fm = atom->fm; - fmsq = ftotsqone = ftotsqall = 0.0; + ftotsqone = ftotsqall = 0.0; for (int i = 0; i < nlocal; i++) { tx = fm[i][1]*sp[i][2] - fm[i][2]*sp[i][1]; ty = fm[i][2]*sp[i][0] - fm[i][0]*sp[i][2]; tz = fm[i][0]*sp[i][1] - fm[i][1]*sp[i][0]; - fmsq = tx*tx + ty*ty + tz*tz; - ftotsqone += fmsq; + ftotsqone += tx*tx + ty*ty + tz*tz; } // summing all fmsqtot on this replica @@ -1030,7 +1029,7 @@ double Min::max_torque() double **sp = atom->sp; double **fm = atom->fm; - fmsq = fmaxsqone = fmaxsqall = 0.0; + fmaxsqone = fmaxsqall = 0.0; for (int i = 0; i < nlocal; i++) { tx = fm[i][1]*sp[i][2] - fm[i][2]*sp[i][1]; ty = fm[i][2]*sp[i][0] - fm[i][0]*sp[i][2]; diff --git a/src/min_hftn.cpp b/src/min_hftn.cpp index 1c9ff0b237..e743f1e1da 100644 --- a/src/min_hftn.cpp +++ b/src/min_hftn.cpp @@ -893,7 +893,7 @@ bool MinHFTN::compute_inner_cg_step_(const double dTrustRadius, Private method calc_xinf_using_mpi_ ------------------------------------------------------------------------- */ -double MinHFTN::calc_xinf_using_mpi_(void) const +double MinHFTN::calc_xinf_using_mpi_() const { double dXInfLocal = 0.0; for (int i = 0; i < nvec; i++) @@ -1162,7 +1162,7 @@ bool MinHFTN::step_exceeds_TR_(const double dTrustRadius, which calls fix_box_relax->max_alpha ------------------------------------------------------------------------- */ -bool MinHFTN::step_exceeds_DMAX_(void) const +bool MinHFTN::step_exceeds_DMAX_() const { double dAlpha = dmax * sqrt((double) _nNumUnknowns); @@ -1611,7 +1611,7 @@ void MinHFTN::evaluate_dir_der_(const bool bUseForwardDiffs, Private method open_hftn_print_file_ ------------------------------------------------------------------------- */ -void MinHFTN::open_hftn_print_file_(void) +void MinHFTN::open_hftn_print_file_() { int nMyRank; MPI_Comm_rank (world, &nMyRank); @@ -1700,7 +1700,7 @@ void MinHFTN::hftn_print_line_(const bool bIsStepAccepted, Private method close_hftn_print_file_ ------------------------------------------------------------------------- */ -void MinHFTN::close_hftn_print_file_(void) +void MinHFTN::close_hftn_print_file_() { if (_fpPrint != nullptr) fclose (_fpPrint); return; diff --git a/src/modify.cpp b/src/modify.cpp index cac26ffe51..89a26025af 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -13,15 +13,15 @@ ------------------------------------------------------------------------- */ #include "modify.h" -#include "style_compute.h" -#include "style_fix.h" +#include "style_compute.h" // IWYU pragma: keep +#include "style_fix.h" // IWYU pragma: keep #include "atom.h" #include "comm.h" -#include "compute.h" +#include "compute.h" // IWYU pragma: keep #include "domain.h" #include "error.h" -#include "fix.h" +#include "fix.h" // IWYU pragma: keep #include "group.h" #include "input.h" #include "memory.h" @@ -30,7 +30,6 @@ #include "variable.h" #include -#include using namespace LAMMPS_NS; using namespace FixConst; @@ -95,7 +94,7 @@ void _noopt Modify::create_factories() #define FIX_CLASS #define FixStyle(key,Class) \ (*fix_map)[#key] = &fix_creator; -#include "style_fix.h" +#include "style_fix.h" // IWYU pragma: keep #undef FixStyle #undef FIX_CLASS @@ -106,7 +105,7 @@ void _noopt Modify::create_factories() #define COMPUTE_CLASS #define ComputeStyle(key,Class) \ (*compute_map)[#key] = &compute_creator; -#include "style_compute.h" +#include "style_compute.h" // IWYU pragma: keep #undef ComputeStyle #undef COMPUTE_CLASS } @@ -886,8 +885,7 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix) FixCreator &fix_creator = (*fix_map)[estyle]; fix[ifix] = fix_creator(lmp,narg,arg); delete[] fix[ifix]->style; - fix[ifix]->style = new char[estyle.size()+1]; - strcpy(fix[ifix]->style,estyle.c_str()); + fix[ifix]->style = utils::strdup(estyle); } } if (fix[ifix] == nullptr && lmp->suffix2) { @@ -896,8 +894,7 @@ Fix *Modify::add_fix(int narg, char **arg, int trysuffix) FixCreator &fix_creator = (*fix_map)[estyle]; fix[ifix] = fix_creator(lmp,narg,arg); delete[] fix[ifix]->style; - fix[ifix]->style = new char[estyle.size()+1]; - strcpy(fix[ifix]->style,estyle.c_str()); + fix[ifix]->style = utils::strdup(estyle); } } } @@ -1244,8 +1241,7 @@ Compute *Modify::add_compute(int narg, char **arg, int trysuffix) ComputeCreator &compute_creator = (*compute_map)[estyle]; compute[ncompute] = compute_creator(lmp,narg,arg); delete[] compute[ncompute]->style; - compute[ncompute]->style = new char[estyle.size()+1]; - strcpy(compute[ncompute]->style,estyle.c_str()); + compute[ncompute]->style = utils::strdup(estyle); } } if (compute[ncompute] == nullptr && lmp->suffix2) { @@ -1254,8 +1250,7 @@ Compute *Modify::add_compute(int narg, char **arg, int trysuffix) ComputeCreator &compute_creator = (*compute_map)[estyle]; compute[ncompute] = compute_creator(lmp,narg,arg); delete[] compute[ncompute]->style; - compute[ncompute]->style = new char[estyle.size()+1]; - strcpy(compute[ncompute]->style,estyle.c_str()); + compute[ncompute]->style = utils::strdup(estyle); } } } diff --git a/src/molecule.cpp b/src/molecule.cpp index 138b4e0749..1a3acf53ba 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -26,7 +26,6 @@ #include "memory.h" #include "tokenizer.h" -#include #include #include diff --git a/src/molecule.h b/src/molecule.h index c7b54b921a..14db9f3197 100644 --- a/src/molecule.h +++ b/src/molecule.h @@ -16,8 +16,6 @@ #include "pointers.h" -#include - namespace LAMMPS_NS { class Molecule : protected Pointers { diff --git a/src/nbin_multi.cpp b/src/nbin_multi.cpp index c58f2b9a94..f5e79bcda6 100644 --- a/src/nbin_multi.cpp +++ b/src/nbin_multi.cpp @@ -22,6 +22,8 @@ #include "error.h" #include "memory.h" +#include + using namespace LAMMPS_NS; #define SMALL 1.0e-6 diff --git a/src/neighbor.cpp b/src/neighbor.cpp index 6c25332257..d58823063c 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -41,10 +41,10 @@ #include "pair.h" #include "pair_hybrid.h" #include "respa.h" -#include "style_nbin.h" -#include "style_npair.h" -#include "style_nstencil.h" -#include "style_ntopo.h" +#include "style_nbin.h" // IWYU pragma: keep +#include "style_npair.h" // IWYU pragma: keep +#include "style_nstencil.h" // IWYU pragma: keep +#include "style_ntopo.h" // IWYU pragma: keep #include "tokenizer.h" #include "update.h" @@ -681,7 +681,7 @@ void Neighbor::init_styles() #define NBIN_CLASS #define NBinStyle(key,Class,bitmasks) nbclass++; -#include "style_nbin.h" +#include "style_nbin.h" // IWYU pragma: keep #undef NBinStyle #undef NBIN_CLASS @@ -695,7 +695,7 @@ void Neighbor::init_styles() binnames[nbclass] = (char *) #key; \ binclass[nbclass] = &bin_creator; \ binmasks[nbclass++] = bitmasks; -#include "style_nbin.h" +#include "style_nbin.h" // IWYU pragma: keep #undef NBinStyle #undef NBIN_CLASS @@ -705,7 +705,7 @@ void Neighbor::init_styles() #define NSTENCIL_CLASS #define NStencilStyle(key,Class,bitmasks) nsclass++; -#include "style_nstencil.h" +#include "style_nstencil.h" // IWYU pragma: keep #undef NStencilStyle #undef NSTENCIL_CLASS @@ -719,7 +719,7 @@ void Neighbor::init_styles() stencilnames[nsclass] = (char *) #key; \ stencilclass[nsclass] = &stencil_creator; \ stencilmasks[nsclass++] = bitmasks; -#include "style_nstencil.h" +#include "style_nstencil.h" // IWYU pragma: keep #undef NStencilStyle #undef NSTENCIL_CLASS @@ -729,7 +729,7 @@ void Neighbor::init_styles() #define NPAIR_CLASS #define NPairStyle(key,Class,bitmasks) npclass++; -#include "style_npair.h" +#include "style_npair.h" // IWYU pragma: keep #undef NPairStyle #undef NPAIR_CLASS @@ -743,7 +743,7 @@ void Neighbor::init_styles() pairnames[npclass] = (char *) #key; \ pairclass[npclass] = &pair_creator; \ pairmasks[npclass++] = bitmasks; -#include "style_npair.h" +#include "style_npair.h" // IWYU pragma: keep #undef NPairStyle #undef NPAIR_CLASS } @@ -1887,11 +1887,12 @@ int Neighbor::choose_pair(NeighRequest *rq) // convert newton request to newtflag = on or off - int newtflag; - if (rq->newton == 0 && newton_pair) newtflag = 1; - else if (rq->newton == 0 && !newton_pair) newtflag = 0; - else if (rq->newton == 1) newtflag = 1; - else if (rq->newton == 2) newtflag = 0; + bool newtflag; + if (rq->newton == 0 && newton_pair) newtflag = true; + else if (rq->newton == 0 && !newton_pair) newtflag = false; + else if (rq->newton == 1) newtflag = true; + else if (rq->newton == 2) newtflag = false; + else error->all(FLERR,"Illegal 'newton' flag in neighbor list request"); int molecular = atom->molecular; @@ -2565,27 +2566,16 @@ void Neighbor::modify_params(int narg, char **arg) type2collection[i] = -1; // For each custom range, define mapping for types in interval - int nfield; - char *str; for (i = 0; i < ncollections; i++){ - n = strlen(arg[iarg+2+i]) + 1; - str = new char[n]; - strcpy(str,arg[iarg+2+i]); - std::vector words = Tokenizer(str, ",").as_vector(); - nfield = words.size(); - - for (j = 0; j < nfield; j++) { - const char * field = words[j].c_str(); - utils::bounds(FLERR,field,1,ntypes,nlo,nhi,error); - + std::vector words = Tokenizer(arg[iarg+2+i], ",").as_vector(); + for (const auto &word : words) { + utils::bounds(FLERR,word,1,ntypes,nlo,nhi,error); for (k = nlo; k <= nhi; k++) { if (type2collection[k] != -1) error->all(FLERR,"Type specified more than once in collection/type commnd"); type2collection[k] = i; } } - - delete [] str; } // Check for undefined atom type diff --git a/src/npair_half_size_multi_newtoff.cpp b/src/npair_half_size_multi_newtoff.cpp index cb06ddfb6f..4c9d9b3f62 100644 --- a/src/npair_half_size_multi_newtoff.cpp +++ b/src/npair_half_size_multi_newtoff.cpp @@ -12,7 +12,6 @@ es certain rights in this software. This software is distributed under See the README file in the top-level LAMMPS directory. ------------------------------------------------------------------------- */ -#include #include "npair_half_size_multi_newtoff.h" #include "atom.h" diff --git a/src/npair_half_size_multi_old_newtoff.cpp b/src/npair_half_size_multi_old_newtoff.cpp index 26bde10b0e..d98b0a635d 100644 --- a/src/npair_half_size_multi_old_newtoff.cpp +++ b/src/npair_half_size_multi_old_newtoff.cpp @@ -16,7 +16,6 @@ #include "atom.h" #include "error.h" -#include "molecule.h" #include "my_page.h" #include "neigh_list.h" diff --git a/src/npair_half_size_multi_old_newton.cpp b/src/npair_half_size_multi_old_newton.cpp index 7f63679bc1..8ea894db4c 100644 --- a/src/npair_half_size_multi_old_newton.cpp +++ b/src/npair_half_size_multi_old_newton.cpp @@ -16,7 +16,6 @@ #include "atom.h" #include "error.h" -#include "molecule.h" #include "my_page.h" #include "neigh_list.h" diff --git a/src/npair_half_size_multi_old_newton_tri.cpp b/src/npair_half_size_multi_old_newton_tri.cpp index f71a470479..cf7495de1b 100644 --- a/src/npair_half_size_multi_old_newton_tri.cpp +++ b/src/npair_half_size_multi_old_newton_tri.cpp @@ -16,7 +16,6 @@ #include "atom.h" #include "error.h" -#include "molecule.h" #include "my_page.h" #include "neigh_list.h" diff --git a/src/nstencil.cpp b/src/nstencil.cpp index fdd0ddfb1b..944c94f983 100644 --- a/src/nstencil.cpp +++ b/src/nstencil.cpp @@ -21,6 +21,8 @@ #include "domain.h" #include "memory.h" +#include + using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- @@ -346,7 +348,7 @@ void NStencil::create_setup() // Skip all stencils by default, initialize smax for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - flag_skip_multi[i][j] = 1; + flag_skip_multi[i][j] = true; } } diff --git a/src/nstencil_full_multi_2d.cpp b/src/nstencil_full_multi_2d.cpp index 893798ce31..52ae88d09e 100644 --- a/src/nstencil_full_multi_2d.cpp +++ b/src/nstencil_full_multi_2d.cpp @@ -13,12 +13,8 @@ ------------------------------------------------------------------------- */ #include "nstencil_full_multi_2d.h" -#include "neighbor.h" + #include "neigh_list.h" -#include "nbin.h" -#include "memory.h" -#include "atom.h" -#include using namespace LAMMPS_NS; @@ -37,8 +33,8 @@ void NStencilFullMulti2d::set_stencil_properties() for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - flag_half_multi[i][j] = 0; - flag_skip_multi[i][j] = 0; + flag_half_multi[i][j] = false; + flag_skip_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_full_multi_3d.cpp b/src/nstencil_full_multi_3d.cpp index 3265dac884..d48cf0c8d7 100644 --- a/src/nstencil_full_multi_3d.cpp +++ b/src/nstencil_full_multi_3d.cpp @@ -13,12 +13,8 @@ ------------------------------------------------------------------------- */ #include "nstencil_full_multi_3d.h" -#include "neighbor.h" + #include "neigh_list.h" -#include "nbin.h" -#include "memory.h" -#include "atom.h" -#include using namespace LAMMPS_NS; @@ -38,8 +34,8 @@ void NStencilFullMulti3d::set_stencil_properties() for (i = 0; i < n; i++) { for (j = 0; j < n; j++) { - flag_half_multi[i][j] = 0; - flag_skip_multi[i][j] = 0; + flag_half_multi[i][j] = true; + flag_skip_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_half_multi_2d.cpp b/src/nstencil_half_multi_2d.cpp index ebcf26b290..81713e183d 100644 --- a/src/nstencil_half_multi_2d.cpp +++ b/src/nstencil_half_multi_2d.cpp @@ -13,12 +13,8 @@ ------------------------------------------------------------------------- */ #include "nstencil_half_multi_2d.h" -#include "neighbor.h" + #include "neigh_list.h" -#include "nbin.h" -#include "memory.h" -#include "atom.h" -#include using namespace LAMMPS_NS; @@ -43,13 +39,13 @@ void NStencilHalfMulti2d::set_stencil_properties() for (j = 0; j < n; j++) { if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - flag_skip_multi[i][j] = 0; + flag_skip_multi[i][j] = false; if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = 1; + flag_half_multi[i][j] = true; bin_collection_multi[i][j] = i; } else { - flag_half_multi[i][j] = 0; + flag_half_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_half_multi_2d_tri.cpp b/src/nstencil_half_multi_2d_tri.cpp index 621e033fb6..d53c503fad 100644 --- a/src/nstencil_half_multi_2d_tri.cpp +++ b/src/nstencil_half_multi_2d_tri.cpp @@ -13,12 +13,8 @@ ------------------------------------------------------------------------- */ #include "nstencil_half_multi_2d_tri.h" -#include "neighbor.h" + #include "neigh_list.h" -#include "nbin.h" -#include "memory.h" -#include "atom.h" -#include using namespace LAMMPS_NS; @@ -43,13 +39,13 @@ void NStencilHalfMulti2dTri::set_stencil_properties() for (j = 0; j < n; j++) { if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - flag_skip_multi[i][j] = 0; + flag_skip_multi[i][j] = false; if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = 1; + flag_half_multi[i][j] = true; bin_collection_multi[i][j] = i; } else { - flag_half_multi[i][j] = 0; + flag_half_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_half_multi_3d.cpp b/src/nstencil_half_multi_3d.cpp index a3392f164a..ca4b4c4111 100644 --- a/src/nstencil_half_multi_3d.cpp +++ b/src/nstencil_half_multi_3d.cpp @@ -13,12 +13,8 @@ ------------------------------------------------------------------------- */ #include "nstencil_half_multi_3d.h" -#include "neighbor.h" + #include "neigh_list.h" -#include "nbin.h" -#include "memory.h" -#include "atom.h" -#include using namespace LAMMPS_NS; @@ -43,13 +39,13 @@ void NStencilHalfMulti3d::set_stencil_properties() for (j = 0; j < n; j++) { if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - flag_skip_multi[i][j] = 0; + flag_skip_multi[i][j] = false; if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = 1; + flag_half_multi[i][j] = true; bin_collection_multi[i][j] = i; } else { - flag_half_multi[i][j] = 0; + flag_half_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/nstencil_half_multi_3d_tri.cpp b/src/nstencil_half_multi_3d_tri.cpp index 160d04bd61..60df9199a2 100644 --- a/src/nstencil_half_multi_3d_tri.cpp +++ b/src/nstencil_half_multi_3d_tri.cpp @@ -13,12 +13,8 @@ ------------------------------------------------------------------------- */ #include "nstencil_half_multi_3d_tri.h" -#include "neighbor.h" + #include "neigh_list.h" -#include "nbin.h" -#include "memory.h" -#include "atom.h" -#include using namespace LAMMPS_NS; @@ -43,13 +39,13 @@ void NStencilHalfMulti3dTri::set_stencil_properties() for (j = 0; j < n; j++) { if(cutcollectionsq[i][i] > cutcollectionsq[j][j]) continue; - flag_skip_multi[i][j] = 0; + flag_skip_multi[i][j] = false; if(cutcollectionsq[i][i] == cutcollectionsq[j][j]){ - flag_half_multi[i][j] = 1; + flag_half_multi[i][j] = true; bin_collection_multi[i][j] = i; } else { - flag_half_multi[i][j] = 0; + flag_half_multi[i][j] = false; bin_collection_multi[i][j] = j; } } diff --git a/src/output.cpp b/src/output.cpp index 90513619d3..9e29caf118 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -317,7 +317,7 @@ void Output::write(bigint ntimestep) if (next_restart_single == ntimestep) { std::string file = restart1; - std::size_t found = file.find("*"); + std::size_t found = file.find('*'); if (found != std::string::npos) file.replace(found,1,fmt::format("{}",update->ntimestep)); @@ -405,7 +405,7 @@ void Output::write_restart(bigint ntimestep) { if (restart_flag_single) { std::string file = restart1; - std::size_t found = file.find("*"); + std::size_t found = file.find('*'); if (found != std::string::npos) file.replace(found,1,fmt::format("{}",update->ntimestep)); restart->write(file); diff --git a/src/pair.cpp b/src/pair.cpp index 16979f8023..38a21481cd 100644 --- a/src/pair.cpp +++ b/src/pair.cpp @@ -31,13 +31,11 @@ #include "neighbor.h" #include "suffix.h" #include "update.h" -#include "fmt/chrono.h" #include // IWYU pragma: keep #include // IWYU pragma: keep #include #include -#include using namespace LAMMPS_NS; using namespace MathConst; @@ -758,8 +756,7 @@ void Pair::add_tally_callback(Compute *ptr) if (found < 0) { found = num_tally_compute; ++num_tally_compute; - void *p = memory->srealloc((void *)list_tally_compute, - sizeof(Compute *) * num_tally_compute, + void *p = memory->srealloc((void *)list_tally_compute, sizeof(Compute *) * num_tally_compute, "pair:list_tally_compute"); list_tally_compute = (Compute **) p; list_tally_compute[num_tally_compute-1] = ptr; @@ -1816,21 +1813,17 @@ void Pair::write_file(int narg, char **arg) units, update->unit_style); } std::string date = utils::get_potential_date(table_file,"table"); - utils::logmesg(lmp,"Appending to table file {} with DATE: {}\n", - table_file, date); + utils::logmesg(lmp,"Appending to table file {} with DATE: {}\n", table_file, date); fp = fopen(table_file.c_str(),"a"); } else { - time_t tv = time(nullptr); - std::tm current_date = fmt::localtime(tv); - utils::logmesg(lmp,"Creating table file {} with DATE: {:%Y-%m-%d}\n", - table_file, current_date); + utils::logmesg(lmp,"Creating table file {} with DATE: {}\n", + table_file, utils::current_date()); fp = fopen(table_file.c_str(),"w"); - if (fp) fmt::print(fp,"# DATE: {:%Y-%m-%d} UNITS: {} Created by pair_write\n", - current_date, update->unit_style); + if (fp) fmt::print(fp,"# DATE: {} UNITS: {} Created by pair_write\n", + utils::current_date(), update->unit_style); } if (fp == nullptr) - error->one(FLERR,"Cannot open pair_write file {}: {}", - table_file, utils::getsyserror()); + error->one(FLERR,"Cannot open pair_write file {}: {}",table_file, utils::getsyserror()); fprintf(fp,"# Pair potential %s for atom types %d %d: i,r,energy,force\n", force->pair_style,itype,jtype); if (style == RLINEAR) diff --git a/src/pair_buck_coul_cut.cpp b/src/pair_buck_coul_cut.cpp index edcd04df08..95cec11eff 100644 --- a/src/pair_buck_coul_cut.cpp +++ b/src/pair_buck_coul_cut.cpp @@ -18,16 +18,17 @@ #include "pair_buck_coul_cut.h" -#include #include "atom.h" #include "comm.h" +#include "error.h" #include "force.h" -#include "neighbor.h" -#include "neigh_list.h" #include "math_const.h" #include "memory.h" -#include "error.h" +#include "neigh_list.h" +#include "neighbor.h" +#include +#include using namespace LAMMPS_NS; using namespace MathConst; diff --git a/src/pair_hybrid.cpp b/src/pair_hybrid.cpp index 0ba16f29fa..67e0a70249 100644 --- a/src/pair_hybrid.cpp +++ b/src/pair_hybrid.cpp @@ -476,7 +476,7 @@ void PairHybrid::coeff(int narg, char **arg) // 4th arg = pair sub-style index if name used multiple times // allow for "none" as valid sub-style name - int multflag; + int multflag = 0; int m; for (m = 0; m < nstyles; m++) { diff --git a/src/pair_hybrid_overlay.cpp b/src/pair_hybrid_overlay.cpp index 09fd676dd3..db12750f40 100644 --- a/src/pair_hybrid_overlay.cpp +++ b/src/pair_hybrid_overlay.cpp @@ -42,7 +42,7 @@ void PairHybridOverlay::coeff(int narg, char **arg) // 4th arg = pair sub-style index if name used multiple times // allow for "none" as valid sub-style name - int multflag; + int multflag = 0; int m; for (m = 0; m < nstyles; m++) { @@ -128,7 +128,7 @@ void PairHybridOverlay::init_svector() void PairHybridOverlay::copy_svector(int itype, int jtype) { int n=0; - Pair *this_style; + Pair *this_style = nullptr; // fill svector array. // copy data from active styles and use 0.0 for inactive ones diff --git a/src/pair_hybrid_scaled.cpp b/src/pair_hybrid_scaled.cpp index 367afe7809..90e30dd9b2 100644 --- a/src/pair_hybrid_scaled.cpp +++ b/src/pair_hybrid_scaled.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -32,9 +31,8 @@ using namespace LAMMPS_NS; /* ---------------------------------------------------------------------- */ -PairHybridScaled::PairHybridScaled(LAMMPS *lmp) - : PairHybrid(lmp), fsum(nullptr), tsum(nullptr), - scaleval(nullptr), scaleidx(nullptr) +PairHybridScaled::PairHybridScaled(LAMMPS *lmp) : + PairHybrid(lmp), fsum(nullptr), tsum(nullptr), scaleval(nullptr), scaleidx(nullptr) { nmaxfsum = -1; } @@ -63,7 +61,7 @@ PairHybridScaled::~PairHybridScaled() void PairHybridScaled::compute(int eflag, int vflag) { - int i,j,m,n; + int i, j, m, n; // update scale values from variables where needed @@ -73,13 +71,11 @@ void PairHybridScaled::compute(int eflag, int vflag) for (i = 0; i < nvars; ++i) { j = input->variable->find(scalevars[i].c_str()); if (j < 0) - error->all(FLERR,"Variable '{}' not found when updating " - "scale factors",scalevars[i]); + error->all(FLERR, "Variable '{}' not found when updating scale factors", scalevars[i]); vals[i] = input->variable->compute_equal(j); } for (i = 0; i < nstyles; ++i) { - if (scaleidx[i] >= 0) - scaleval[i] = vals[scaleidx[i]]; + if (scaleidx[i] >= 0) scaleval[i] = vals[scaleidx[i]]; } delete[] vals; } @@ -92,7 +88,7 @@ void PairHybridScaled::compute(int eflag, int vflag) if (no_virial_fdotr_compute && (vflag & VIRIAL_FDOTR)) vflag = VIRIAL_PAIR | (vflag & ~VIRIAL_FDOTR); - ev_init(eflag,vflag); + ev_init(eflag, vflag); // grow fsum array if needed, and copy existing forces (usually 0.0) to it. @@ -100,8 +96,8 @@ void PairHybridScaled::compute(int eflag, int vflag) memory->destroy(fsum); if (atom->torque_flag) memory->destroy(tsum); nmaxfsum = atom->nmax; - memory->create(fsum,nmaxfsum,3,"pair:fsum"); - if (atom->torque_flag) memory->create(tsum,nmaxfsum,3,"pair:tsum"); + memory->create(fsum, nmaxfsum, 3, "pair:fsum"); + if (atom->torque_flag) memory->create(tsum, nmaxfsum, 3, "pair:tsum"); } const int nall = atom->nlocal + atom->nghost; auto f = atom->f; @@ -122,8 +118,10 @@ void PairHybridScaled::compute(int eflag, int vflag) // necessary so substyle will not invoke virial_fdotr_compute() int vflag_substyle; - if (vflag & VIRIAL_FDOTR) vflag_substyle = vflag & ~VIRIAL_FDOTR; - else vflag_substyle = vflag; + if (vflag & VIRIAL_FDOTR) + vflag_substyle = vflag & ~VIRIAL_FDOTR; + else + vflag_substyle = vflag; double *saved_special = save_special(); @@ -131,7 +129,7 @@ void PairHybridScaled::compute(int eflag, int vflag) Respa *respa = nullptr; respaflag = 0; - if (utils::strmatch(update->integrate_style,"^respa")) { + if (utils::strmatch(update->integrate_style, "^respa")) { respa = (Respa *) update->integrate; if (respa->nhybrid_styles > 0) respaflag = 1; } @@ -140,8 +138,8 @@ void PairHybridScaled::compute(int eflag, int vflag) // clear forces and torques - memset(&f[0][0],0,nall*3*sizeof(double)); - if (atom->torque_flag) memset(&t[0][0],0,nall*3*sizeof(double)); + memset(&f[0][0], 0, nall * 3 * sizeof(double)); + if (atom->torque_flag) memset(&t[0][0], 0, nall * 3 * sizeof(double)); set_special(m); @@ -152,20 +150,21 @@ void PairHybridScaled::compute(int eflag, int vflag) if (styles[m]->compute_flag == 0) continue; if (outerflag && styles[m]->respa_enable) - styles[m]->compute_outer(eflag,vflag_substyle); - else styles[m]->compute(eflag,vflag_substyle); + styles[m]->compute_outer(eflag, vflag_substyle); + else + styles[m]->compute(eflag, vflag_substyle); } // add scaled forces to global sum const double scale = scaleval[m]; for (i = 0; i < nall; ++i) { - fsum[i][0] += scale*f[i][0]; - fsum[i][1] += scale*f[i][1]; - fsum[i][2] += scale*f[i][2]; + fsum[i][0] += scale * f[i][0]; + fsum[i][1] += scale * f[i][1]; + fsum[i][2] += scale * f[i][2]; if (atom->torque_flag) { - tsum[i][0] += scale*t[i][0]; - tsum[i][1] += scale*t[i][1]; - tsum[i][2] += scale*t[i][2]; + tsum[i][0] += scale * t[i][0]; + tsum[i][1] += scale * t[i][1]; + tsum[i][2] += scale * t[i][2]; } } @@ -176,25 +175,24 @@ void PairHybridScaled::compute(int eflag, int vflag) if (respaflag && !respa->tally_global) continue; if (eflag_global) { - eng_vdwl += scale*styles[m]->eng_vdwl; - eng_coul += scale*styles[m]->eng_coul; + eng_vdwl += scale * styles[m]->eng_vdwl; + eng_coul += scale * styles[m]->eng_coul; } if (vflag_global) { - for (n = 0; n < 6; n++) virial[n] += scale*styles[m]->virial[n]; + for (n = 0; n < 6; n++) virial[n] += scale * styles[m]->virial[n]; } if (eflag_atom) { n = atom->nlocal; if (force->newton_pair) n += atom->nghost; double *eatom_substyle = styles[m]->eatom; - for (i = 0; i < n; i++) eatom[i] += scale*eatom_substyle[i]; + for (i = 0; i < n; i++) eatom[i] += scale * eatom_substyle[i]; } if (vflag_atom) { n = atom->nlocal; if (force->newton_pair) n += atom->nghost; double **vatom_substyle = styles[m]->vatom; for (i = 0; i < n; i++) - for (j = 0; j < 6; j++) - vatom[i][j] += scale*vatom_substyle[i][j]; + for (j = 0; j < 6; j++) vatom[i][j] += scale * vatom_substyle[i][j]; } // substyles may be CENTROID_SAME or CENTROID_AVAIL @@ -205,17 +203,12 @@ void PairHybridScaled::compute(int eflag, int vflag) if (styles[m]->centroidstressflag == CENTROID_AVAIL) { double **cvatom_substyle = styles[m]->cvatom; for (i = 0; i < n; i++) - for (j = 0; j < 9; j++) - cvatom[i][j] += scale*cvatom_substyle[i][j]; + for (j = 0; j < 9; j++) cvatom[i][j] += scale * cvatom_substyle[i][j]; } else { double **vatom_substyle = styles[m]->vatom; for (i = 0; i < n; i++) { - for (j = 0; j < 6; j++) { - cvatom[i][j] += scale*vatom_substyle[i][j]; - } - for (j = 6; j < 9; j++) { - cvatom[i][j] += scale*vatom_substyle[i][j-3]; - } + for (j = 0; j < 6; j++) { cvatom[i][j] += scale * vatom_substyle[i][j]; } + for (j = 6; j < 9; j++) { cvatom[i][j] += scale * vatom_substyle[i][j - 3]; } } } } @@ -233,7 +226,7 @@ void PairHybridScaled::compute(int eflag, int vflag) t[i][2] = tsum[i][2]; } } - delete [] saved_special; + delete[] saved_special; if (vflag_fdotr) virial_fdotr_compute(); } @@ -244,22 +237,21 @@ void PairHybridScaled::compute(int eflag, int vflag) void PairHybridScaled::settings(int narg, char **arg) { - if (narg < 1) error->all(FLERR,"Illegal pair_style command"); - if (lmp->kokkos && !utils::strmatch(force->pair_style,"^hybrid.*/kk$")) - error->all(FLERR,"Must use pair_style {}/kk with Kokkos", - force->pair_style); + if (narg < 1) error->all(FLERR, "Illegal pair_style command"); + if (lmp->kokkos && !utils::strmatch(force->pair_style, "^hybrid.*/kk$")) + error->all(FLERR, "Must use pair_style {}/kk with Kokkos", force->pair_style); if (atom->avec->forceclearflag) - error->all(FLERR,"Atom style is not compatible with pair_style hybrid/scaled"); + error->all(FLERR, "Atom style is not compatible with pair_style hybrid/scaled"); // delete old lists, since cannot just change settings if (nstyles > 0) { for (int m = 0; m < nstyles; m++) { delete styles[m]; - delete [] keywords[m]; - if (special_lj[m]) delete [] special_lj[m]; - if (special_coul[m]) delete [] special_coul[m]; + delete[] keywords[m]; + if (special_lj[m]) delete[] special_lj[m]; + if (special_coul[m]) delete[] special_coul[m]; } delete[] styles; delete[] keywords; @@ -283,12 +275,12 @@ void PairHybridScaled::settings(int narg, char **arg) // allocate list of sub-styles as big as possibly needed if no extra args - styles = new Pair*[narg]; - keywords = new char*[narg]; + styles = new Pair *[narg]; + keywords = new char *[narg]; multiple = new int[narg]; - special_lj = new double*[narg]; - special_coul = new double*[narg]; + special_lj = new double *[narg]; + special_coul = new double *[narg]; compute_tally = new int[narg]; scaleval = new double[narg]; @@ -301,62 +293,63 @@ void PairHybridScaled::settings(int narg, char **arg) // call settings() with set of args that are not pair style names // use force->pair_map to determine which args these are - int iarg,jarg,dummy; + int iarg, jarg, dummy; iarg = 0; nstyles = 0; - while (iarg < narg-1) { + while (iarg < narg - 1) { // first process scale factor or variable // idx < 0 indicates constant value otherwise index in variable name list double val = 0.0; int idx = -1; - if (utils::strmatch(arg[iarg],"^v_")) { - for (std::size_t i=0; i < scalevars.size(); ++i) { - if (scalevars[i] == arg[iarg]+2) { + if (utils::strmatch(arg[iarg], "^v_")) { + for (std::size_t i = 0; i < scalevars.size(); ++i) { + if (scalevars[i] == arg[iarg] + 2) { idx = i; break; } } if (idx < 0) { idx = scalevars.size(); - scalevars.push_back(arg[iarg]+2); + scalevars.emplace_back(arg[iarg] + 2); } } else { - val = utils::numeric(FLERR,arg[iarg],false,lmp); + val = utils::numeric(FLERR, arg[iarg], false, lmp); } scaleval[nstyles] = val; scaleidx[nstyles] = idx; ++iarg; - if (utils::strmatch(arg[iarg],"^hybrid")) - error->all(FLERR,"Pair style hybrid/scaled cannot have hybrid as an argument"); - if (strcmp(arg[iarg],"none") == 0) - error->all(FLERR,"Pair style hybrid/scaled cannot have none as an argument"); + if (utils::strmatch(arg[iarg], "^hybrid")) + error->all(FLERR, "Pair style hybrid/scaled cannot have hybrid as an argument"); + if (strcmp(arg[iarg], "none") == 0) + error->all(FLERR, "Pair style hybrid/scaled cannot have none as an argument"); - styles[nstyles] = force->new_pair(arg[iarg],1,dummy); - force->store_style(keywords[nstyles],arg[iarg],0); + styles[nstyles] = force->new_pair(arg[iarg], 1, dummy); + force->store_style(keywords[nstyles], arg[iarg], 0); special_lj[nstyles] = special_coul[nstyles] = nullptr; compute_tally[nstyles] = 1; - if ((styles[nstyles]->suffix_flag & (Suffix::INTEL|Suffix::GPU|Suffix::OMP)) != 0) - error->all(FLERR,"Pair style hybrid/scaled does not support " + if ((styles[nstyles]->suffix_flag & (Suffix::INTEL | Suffix::GPU | Suffix::OMP)) != 0) + error->all(FLERR, + "Pair style hybrid/scaled does not support " "accelerator styles"); // determine list of arguments for pair style settings // by looking for the next known pair style name. jarg = iarg + 1; - while ((jarg < narg) - && !force->pair_map->count(arg[jarg]) - && !lmp->match_style("pair",arg[jarg])) jarg++; + while ((jarg < narg) && !force->pair_map->count(arg[jarg]) && + !lmp->match_style("pair", arg[jarg])) + jarg++; // decrement to account for scale factor except when last argument if (jarg < narg) --jarg; - styles[nstyles]->settings(jarg-iarg-1,arg+iarg+1); + styles[nstyles]->settings(jarg - iarg - 1, arg + iarg + 1); iarg = jarg; nstyles++; } @@ -366,7 +359,7 @@ void PairHybridScaled::settings(int narg, char **arg) for (int i = 0; i < nstyles; i++) { int count = 0; for (int j = 0; j < nstyles; j++) { - if (strcmp(keywords[j],keywords[i]) == 0) count++; + if (strcmp(keywords[j], keywords[i]) == 0) count++; if (j == i) multiple[i] = count; } if (count == 1) multiple[i] = 0; @@ -383,11 +376,10 @@ void PairHybridScaled::settings(int narg, char **arg) since overlay could have multiple sub-styles, sum results explicitly ------------------------------------------------------------------------- */ -double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, - double factor_coul, double factor_lj, double &fforce) +double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, double factor_coul, + double factor_lj, double &fforce) { - if (nmap[itype][jtype] == 0) - error->one(FLERR,"Invoked pair single on pair style none"); + if (nmap[itype][jtype] == 0) error->one(FLERR, "Invoked pair single on pair style none"); // update scale values from variables where needed @@ -397,13 +389,11 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, for (i = 0; i < nvars; ++i) { j = input->variable->find(scalevars[i].c_str()); if (j < 0) - error->all(FLERR,"Variable '{}' not found when updating " - "scale factors",scalevars[i]); + error->all(FLERR, "Variable '{}' not found when updating scale factors", scalevars[i]); vals[i] = input->variable->compute_equal(j); } for (i = 0; i < nstyles; ++i) { - if (scaleidx[i] >= 0) - scaleval[i] = vals[scaleidx[i]]; + if (scaleidx[i] >= 0) scaleval[i] = vals[scaleidx[i]]; } delete[] vals; } @@ -414,23 +404,22 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, double scale; for (int m = 0; m < nmap[itype][jtype]; m++) { - if (rsq < styles[map[itype][jtype][m]]->cutsq[itype][jtype]) { - if (styles[map[itype][jtype][m]]->single_enable == 0) - error->one(FLERR,"Pair hybrid sub-style does not support single call"); + auto pstyle = styles[map[itype][jtype][m]]; + if (rsq < pstyle->cutsq[itype][jtype]) { + if (pstyle->single_enable == 0) + error->one(FLERR, "Pair hybrid sub-style does not support single call"); if ((special_lj[map[itype][jtype][m]] != nullptr) || (special_coul[map[itype][jtype][m]] != nullptr)) - error->one(FLERR,"Pair hybrid single calls do not support" - " per sub-style special bond values"); + error->one(FLERR, "Pair hybrid single() does not support per sub-style special_bond"); scale = scaleval[map[itype][jtype][m]]; - esum += scale * styles[map[itype][jtype][m]]->single(i,j,itype,jtype,rsq, - factor_coul,factor_lj,fone); + esum += scale * pstyle->single(i, j, itype, jtype, rsq, factor_coul, factor_lj, fone); fforce += scale * fone; } } - if (single_extra) copy_svector(itype,jtype); + if (single_extra) copy_svector(itype, jtype); return esum; } @@ -440,49 +429,54 @@ double PairHybridScaled::single(int i, int j, int itype, int jtype, double rsq, void PairHybridScaled::coeff(int narg, char **arg) { - if (narg < 3) error->all(FLERR,"Incorrect args for pair coefficients"); + if (narg < 3) error->all(FLERR, "Incorrect args for pair coefficients"); if (!allocated) allocate(); - int ilo,ihi,jlo,jhi; - utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error); - utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error); + int ilo, ihi, jlo, jhi; + utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error); + utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error); // 3rd arg = pair sub-style name // 4th arg = pair sub-style index if name used multiple times // allow for "none" as valid sub-style name - int multflag; + int multflag = 0; int m; for (m = 0; m < nstyles; m++) { multflag = 0; - if (strcmp(arg[2],keywords[m]) == 0) { + if (strcmp(arg[2], keywords[m]) == 0) { if (multiple[m]) { multflag = 1; - if (narg < 4) error->all(FLERR,"Incorrect args for pair coefficients"); - int index = utils::inumeric(FLERR,arg[3],false,lmp); - if (index == multiple[m]) break; - else continue; - } else break; + if (narg < 4) error->all(FLERR, "Incorrect args for pair coefficients"); + int index = utils::inumeric(FLERR, arg[3], false, lmp); + if (index == multiple[m]) + break; + else + continue; + } else + break; } } int none = 0; if (m == nstyles) { - if (strcmp(arg[2],"none") == 0) none = 1; - else error->all(FLERR,"Pair coeff for hybrid has invalid style"); + if (strcmp(arg[2], "none") == 0) + none = 1; + else + error->all(FLERR, "Pair coeff for hybrid has invalid style"); } // move 1st/2nd args to 2nd/3rd args // if multflag: move 1st/2nd args to 3rd/4th args // just copy ptrs, since arg[] points into original input line - arg[2+multflag] = arg[1]; - arg[1+multflag] = arg[0]; + arg[2 + multflag] = arg[1]; + arg[1 + multflag] = arg[0]; // invoke sub-style coeff() starting with 1st remaining arg - if (!none) styles[m]->coeff(narg-1-multflag,&arg[1+multflag]); + if (!none) styles[m]->coeff(narg - 1 - multflag, &arg[1 + multflag]); // set setflag and which type pairs map to which sub-style // if sub-style is none: set hybrid subflag, wipe out map @@ -492,7 +486,7 @@ void PairHybridScaled::coeff(int narg, char **arg) int count = 0; for (int i = ilo; i <= ihi; i++) { - for (int j = MAX(jlo,i); j <= jhi; j++) { + for (int j = MAX(jlo, i); j <= jhi; j++) { if (none) { setflag[i][j] = 1; nmap[i][j] = 0; @@ -508,7 +502,7 @@ void PairHybridScaled::coeff(int narg, char **arg) } } - if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients"); + if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients"); } /* ---------------------------------------------------------------------- @@ -519,15 +513,15 @@ void PairHybridScaled::write_restart(FILE *fp) { PairHybrid::write_restart(fp); - fwrite(scaleval,sizeof(double),nstyles,fp); - fwrite(scaleidx,sizeof(int),nstyles,fp); + fwrite(scaleval, sizeof(double), nstyles, fp); + fwrite(scaleidx, sizeof(int), nstyles, fp); int n = scalevars.size(); - fwrite(&n,sizeof(int),1,fp); + fwrite(&n, sizeof(int), 1, fp); for (auto var : scalevars) { n = var.size() + 1; - fwrite(&n,sizeof(int),1,fp); - fwrite(var.c_str(),sizeof(char),n,fp); + fwrite(&n, sizeof(int), 1, fp); + fwrite(var.c_str(), sizeof(char), n, fp); } } @@ -547,23 +541,23 @@ void PairHybridScaled::read_restart(FILE *fp) int n, me = comm->me; if (me == 0) { - utils::sfread(FLERR,scaleval,sizeof(double),nstyles,fp,nullptr,error); - utils::sfread(FLERR,scaleidx,sizeof(int),nstyles,fp,nullptr,error); + utils::sfread(FLERR, scaleval, sizeof(double), nstyles, fp, nullptr, error); + utils::sfread(FLERR, scaleidx, sizeof(int), nstyles, fp, nullptr, error); } - MPI_Bcast(scaleval,nstyles,MPI_DOUBLE,0,world); - MPI_Bcast(scaleidx,nstyles,MPI_INT,0,world); + MPI_Bcast(scaleval, nstyles, MPI_DOUBLE, 0, world); + MPI_Bcast(scaleidx, nstyles, MPI_INT, 0, world); char *tmp; - if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,nullptr,error); - MPI_Bcast(&n,1,MPI_INT,0,world); + if (me == 0) utils::sfread(FLERR, &n, sizeof(int), 1, fp, nullptr, error); + MPI_Bcast(&n, 1, MPI_INT, 0, world); scalevars.resize(n); - for (size_t j=0; j < scalevars.size(); ++j) { - if (me == 0) utils::sfread(FLERR,&n,sizeof(int),1,fp,nullptr,error); - MPI_Bcast(&n,1,MPI_INT,0,world); + for (auto &scale : scalevars) { + if (me == 0) utils::sfread(FLERR, &n, sizeof(int), 1, fp, nullptr, error); + MPI_Bcast(&n, 1, MPI_INT, 0, world); tmp = new char[n]; - if (me == 0) utils::sfread(FLERR,tmp,sizeof(char),n,fp,nullptr,error); - MPI_Bcast(tmp,n,MPI_CHAR,0,world); - scalevars[j] = tmp; + if (me == 0) utils::sfread(FLERR, tmp, sizeof(char), n, fp, nullptr, error); + MPI_Bcast(tmp, n, MPI_CHAR, 0, world); + scale = tmp; delete[] tmp; } } @@ -578,11 +572,10 @@ void PairHybridScaled::init_svector() // allocate svector single_extra = 0; - for (int m = 0; m < nstyles; m++) - single_extra += styles[m]->single_extra; + for (int m = 0; m < nstyles; m++) single_extra += styles[m]->single_extra; if (single_extra) { - delete [] svector; + delete[] svector; svector = new double[single_extra]; } } @@ -593,7 +586,7 @@ void PairHybridScaled::init_svector() void PairHybridScaled::copy_svector(int itype, int jtype) { - int n=0; + int n = 0; Pair *this_style; // fill svector array. diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 82f5c969df..4a7a483cb0 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -285,7 +285,7 @@ bigint ReadDump::seek(bigint nrequest, int exact) ntimestep = -1; if (multiproc) { std::string multiname = files[ifile]; - multiname.replace(multiname.find("%"),1,"0"); + multiname.replace(multiname.find('%'),1,"0"); readers[0]->open_file(multiname.c_str()); } else readers[0]->open_file(files[ifile]); @@ -329,7 +329,7 @@ bigint ReadDump::seek(bigint nrequest, int exact) for (int i = 0; i < nreader; i++) { if (me == 0 && i == 0) continue; // proc 0, reader 0 already found it std::string multiname = files[currentfile]; - multiname.replace(multiname.find("%"),1,fmt::format("{}",firstfile+i)); + multiname.replace(multiname.find('%'),1,fmt::format("{}",firstfile+i)); readers[i]->open_file(multiname.c_str()); bigint step; @@ -377,7 +377,7 @@ bigint ReadDump::next(bigint ncurrent, bigint nlast, int nevery, int nskip) if (ifile != currentfile) { if (multiproc) { std::string multiname = files[ifile]; - multiname.replace(multiname.find("%"),1,"0"); + multiname.replace(multiname.find('%'),1,"0"); readers[0]->open_file(multiname.c_str()); } else readers[0]->open_file(files[ifile]); } @@ -431,7 +431,7 @@ bigint ReadDump::next(bigint ncurrent, bigint nlast, int nevery, int nskip) for (int i = 0; i < nreader; i++) { if (me == 0 && i == 0) continue; std::string multiname = files[currentfile]; - multiname.replace(multiname.find("%"),1,fmt::format("{}",firstfile+i)); + multiname.replace(multiname.find('%'),1,fmt::format("{}",firstfile+i)); readers[i]->open_file(multiname.c_str()); bigint step; diff --git a/src/read_restart.cpp b/src/read_restart.cpp index e42bb59272..bbd3bd3359 100644 --- a/src/read_restart.cpp +++ b/src/read_restart.cpp @@ -32,7 +32,6 @@ #include "mpiio.h" #include "pair.h" #include "special.h" -#include "universe.h" #include "update.h" #include @@ -106,7 +105,7 @@ void ReadRestart::command(int narg, char **arg) utils::logmesg(lmp,"Reading restart file ...\n"); std::string hfile = file; if (multiproc) { - hfile.replace(hfile.find("%"),1,"base"); + hfile.replace(hfile.find('%'),1,"base"); } fp = fopen(hfile.c_str(),"rb"); if (fp == nullptr) @@ -268,7 +267,7 @@ void ReadRestart::command(int narg, char **arg) for (int iproc = me; iproc < multiproc_file; iproc += nprocs) { std::string procfile = file; - procfile.replace(procfile.find("%"),1,fmt::format("{}",iproc)); + procfile.replace(procfile.find('%'),1,fmt::format("{}",iproc)); fp = fopen(procfile.c_str(),"rb"); if (fp == nullptr) error->one(FLERR,"Cannot open restart file {}: {}", @@ -332,7 +331,7 @@ void ReadRestart::command(int narg, char **arg) if (filereader) { std::string procfile = file; - procfile.replace(procfile.find("%"),1,fmt::format("{}",icluster)); + procfile.replace(procfile.find('%'),1,fmt::format("{}",icluster)); fp = fopen(procfile.c_str(),"rb"); if (fp == nullptr) error->one(FLERR,"Cannot open restart file {}: {}", procfile, utils::getsyserror()); diff --git a/src/region.cpp b/src/region.cpp index 750677ad8f..eba9f48510 100644 --- a/src/region.cpp +++ b/src/region.cpp @@ -42,7 +42,7 @@ Region::Region(LAMMPS *lmp, int /*narg*/, char **arg) : dx = dy = dz = 0.0; size_restart = 5; - reset_vel(); + Region::reset_vel(); copymode = 0; list = nullptr; nregion = 1; diff --git a/src/region_cylinder.cpp b/src/region_cylinder.cpp index efa13bd02a..033a2eeae4 100644 --- a/src/region_cylinder.cpp +++ b/src/region_cylinder.cpp @@ -117,7 +117,7 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) : if (varshape) { variable_check(); - shape_update(); + RegCylinder::shape_update(); } if (strcmp(arg[6],"INF") == 0 || strcmp(arg[6],"EDGE") == 0) { diff --git a/src/region_sphere.cpp b/src/region_sphere.cpp index 18493c258a..b2c844c986 100644 --- a/src/region_sphere.cpp +++ b/src/region_sphere.cpp @@ -74,7 +74,7 @@ RegSphere::RegSphere(LAMMPS *lmp, int narg, char **arg) : if (varshape) { variable_check(); - shape_update(); + RegSphere::shape_update(); } // error check diff --git a/src/reset_mol_ids.cpp b/src/reset_mol_ids.cpp index cf5bcdec6e..3ddef738d2 100644 --- a/src/reset_mol_ids.cpp +++ b/src/reset_mol_ids.cpp @@ -89,7 +89,7 @@ void ResetMolIDs::command(int narg, char **arg) iarg += 2; } else if (strcmp(arg[iarg],"offset") == 0) { if (iarg+2 > narg) error->all(FLERR,"Illegal reset_mol_ids command"); - offset = utils::tnumeric(FLERR,arg[iarg+1],1,lmp); + offset = utils::tnumeric(FLERR,arg[iarg+1],true,lmp); if (offset < -1) error->all(FLERR,"Illegal reset_mol_ids command"); iarg += 2; } else error->all(FLERR,"Illegal reset_mol_ids command"); diff --git a/src/table_file_reader.cpp b/src/table_file_reader.cpp index 9ee0c33649..bcd4e91886 100644 --- a/src/table_file_reader.cpp +++ b/src/table_file_reader.cpp @@ -19,7 +19,6 @@ #include "table_file_reader.h" #include "text_file_reader.h" -#include "tokenizer.h" using namespace LAMMPS_NS; diff --git a/src/text_file_reader.h b/src/text_file_reader.h index e1f875a4e6..98657a937e 100644 --- a/src/text_file_reader.h +++ b/src/text_file_reader.h @@ -18,7 +18,7 @@ #ifndef LMP_TEXT_FILE_READER_H #define LMP_TEXT_FILE_READER_H -#include "tokenizer.h" +#include "tokenizer.h" // IWYU pragma: export #include diff --git a/src/tokenizer.h b/src/tokenizer.h index e2a060d218..7f45a512dd 100644 --- a/src/tokenizer.h +++ b/src/tokenizer.h @@ -20,9 +20,9 @@ #include "lmptype.h" -#include // IWYU pragma: export -#include // IWYU pragma: export -#include // IWYU pragma: export +#include +#include +#include namespace LAMMPS_NS { diff --git a/src/universe.cpp b/src/universe.cpp index fc3e79ab83..005a91fc6b 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -174,7 +174,7 @@ void Universe::add_world(char *str) if (part.find_first_not_of("0123456789x") != std::string::npos) valid = false; if (valid) { - std::size_t found = part.find_first_of("x"); + std::size_t found = part.find_first_of('x'); // 'x' may not be the first or last character diff --git a/src/update.cpp b/src/update.cpp index 7f14597e7e..72b60c3d3b 100644 --- a/src/update.cpp +++ b/src/update.cpp @@ -335,8 +335,7 @@ void Update::create_integrate(int narg, char **arg, int trysuffix) if (sflag == 1) estyle += lmp->suffix; else estyle += lmp->suffix2; } - integrate_style = new char[estyle.size()+1]; - strcpy(integrate_style,estyle.c_str()); + integrate_style = utils::strdup(estyle); } /* ---------------------------------------------------------------------- @@ -406,8 +405,7 @@ void Update::create_minimize(int narg, char **arg, int trysuffix) if (sflag == 1) estyle += lmp->suffix; else estyle += lmp->suffix2; } - minimize_style = new char[estyle.size()+1]; - strcpy(minimize_style,estyle.c_str()); + minimize_style = utils::strdup(estyle); } /* ---------------------------------------------------------------------- diff --git a/src/utils.cpp b/src/utils.cpp index 17d544bffa..b2a1e801f7 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -18,6 +18,7 @@ #include "compute.h" #include "error.h" #include "fix.h" +#include "fmt/chrono.h" #include "memory.h" #include "modify.h" #include "text_file_reader.h" @@ -27,6 +28,7 @@ #include #include #include +#include #if defined(__linux__) #include // for readlink @@ -164,7 +166,7 @@ std::string utils::getsyserror() /** On Linux the folder /proc/self/fd holds symbolic links to the actual * pathnames associated with each open file descriptor of the current process. - * On macOS the same kind of information can be obtained using ``fcntl(fd,F_GETPATH,buf)``. + * On MacOS the same kind of information can be obtained using ``fcntl(fd,F_GETPATH,buf)``. * On Windows we use ``GetFinalPathNameByHandleA()`` which is available with * Windows Vista and later. * @@ -502,7 +504,7 @@ void utils::bounds(const char *file, int line, const std::string &str, return; } - found = str.find_first_of("*"); + found = str.find_first_of('*'); if (found == std::string::npos) { // contains no '*' nlo = nhi = strtol(str.c_str(), nullptr, 10); } else if (str.size() == 1) { // is only '*' @@ -583,8 +585,8 @@ int utils::expand_args(const char *file, int line, int narg, char **arg, int mod // split off the compute/fix/property ID, the wildcard and trailing text - size_t first = word.find("["); - size_t second = word.find("]", first + 1); + size_t first = word.find('['); + size_t second = word.find(']', first + 1); if (word[1] == '2') id = word.substr(3, first - 3); else @@ -727,7 +729,7 @@ std::string utils::trim(const std::string &line) std::string utils::trim_comment(const std::string &line) { - auto end = line.find_first_of("#"); + auto end = line.find_first_of('#'); if (end != std::string::npos) { return line.substr(0, end); } return std::string(line); } @@ -1030,7 +1032,7 @@ std::string utils::path_basename(const std::string &path) #if defined(_WIN32) size_t start = path.find_last_of("/\\"); #else - size_t start = path.find_last_of("/"); + size_t start = path.find_last_of('/'); #endif if (start == std::string::npos) { @@ -1051,7 +1053,7 @@ std::string utils::path_dirname(const std::string &path) #if defined(_WIN32) size_t start = path.find_last_of("/\\"); #else - size_t start = path.find_last_of("/"); + size_t start = path.find_last_of('/'); #endif if (start == std::string::npos) return "."; @@ -1316,7 +1318,21 @@ int utils::date2num(const std::string &date) return num; } -/* binary search in vector of ascending doubles */ +/* ---------------------------------------------------------------------- + get formatted string of current date from fmtlib +------------------------------------------------------------------------- */ + +std::string utils::current_date() +{ + time_t tv = time(nullptr); + std::tm today = fmt::localtime(tv); + return fmt::format("{:%Y-%m-%d}", today); +} + +/* ---------------------------------------------------------------------- + binary search in vector of ascending doubles +------------------------------------------------------------------------- */ + int utils::binary_search(const double needle, const int n, const double *haystack) { int lo = 0; diff --git a/src/utils.h b/src/utils.h index f53374144e..37d52f2614 100644 --- a/src/utils.h +++ b/src/utils.h @@ -21,9 +21,7 @@ #include -#include -#include -#include +#include // IWYU pragma: export namespace LAMMPS_NS { @@ -408,7 +406,7 @@ namespace utils { /*! Try to detect pathname from FILE pointer. * - * Currently supported on Linux, macOS, and Windows, otherwise will report "(unknown)". + * Currently supported on Linux, MacOS, and Windows, otherwise will report "(unknown)". * * \param buf storage buffer for pathname. output will be truncated if not large enough * \param len size of storage buffer. output will be truncated to this length - 1 @@ -541,6 +539,14 @@ namespace utils { int date2num(const std::string &date); + /*! Return current date as string + * + * This will generate a string containing the current date in YYYY-MM-DD format. + * + * \return string with current date */ + + std::string current_date(); + /*! Binary search in a vector of ascending doubles of length N * * If the value is smaller than the smallest value in the vector, 0 is returned. diff --git a/src/variable.cpp b/src/variable.cpp index a59a24381f..1981d000c3 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -1294,8 +1294,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = atof(number); - newtree->first = newtree->second = nullptr; - newtree->extra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = atof(number); @@ -1386,8 +1384,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value1; @@ -1415,8 +1411,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value1; @@ -1447,8 +1441,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value1; @@ -1479,9 +1471,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->array = compute->vector; newtree->nvector = compute->size_vector; newtree->nstride = 1; - newtree->selfalloc = 0; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; // c_ID[i] = vector from global array, lowercase or uppercase @@ -1511,9 +1500,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->array = &compute->array[0][index1-1]; newtree->nvector = compute->size_array_rows; newtree->nstride = compute->size_array_cols; - newtree->selfalloc = 0; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; // c_ID[i] = scalar from per-atom vector @@ -1583,9 +1569,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->type = ATOMARRAY; newtree->array = compute->vector_atom; newtree->nstride = 1; - newtree->selfalloc = 0; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; // c_ID[i] = vector from per-atom array @@ -1615,12 +1598,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->type = ATOMARRAY; if (compute->array_atom) newtree->array = &compute->array_atom[0][index1-1]; - else - newtree->array = nullptr; newtree->nstride = compute->size_peratom_cols; - newtree->selfalloc = 0; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else if (nbracket == 1 && compute->local_flag) { @@ -1683,8 +1661,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value1; @@ -1705,8 +1681,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value1; @@ -1730,8 +1704,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value1; @@ -1764,8 +1736,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->nvector = nvec; newtree->nstride = 1; newtree->selfalloc = 1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; // f_ID[i] = vector from global array, lowercase or uppercase @@ -1797,8 +1767,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->nvector = nvec; newtree->nstride = 1; newtree->selfalloc = 1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; // f_ID[i] = scalar from per-atom vector @@ -1853,9 +1821,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->type = ATOMARRAY; newtree->array = fix->vector_atom; newtree->nstride = 1; - newtree->selfalloc = 0; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; // f_ID[i] = vector from per-atom array @@ -1878,12 +1843,7 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->type = ATOMARRAY; if (fix->array_atom) newtree->array = &fix->array_atom[0][index1-1]; - else - newtree->array = nullptr; newtree->nstride = fix->size_peratom_cols; - newtree->selfalloc = 0; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else print_var_error(FLERR,"Mismatched fix in variable formula",ivar); @@ -1926,8 +1886,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value1; @@ -1945,8 +1903,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = atof(var); - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = atof(var); @@ -1981,9 +1937,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->type = ATOMARRAY; newtree->array = reader[ivar]->fixstore->vstore; newtree->nstride = 1; - newtree->selfalloc = 0; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; // v_name = vector from vector-style variable @@ -2006,9 +1959,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->array = vec; newtree->nvector = nvec; newtree->nstride = 1; - newtree->selfalloc = 0; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; // v_name[N] = scalar from atom-style variable @@ -2047,8 +1997,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = vec[m-1]; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = vec[m-1]; @@ -2119,8 +2067,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value1; @@ -2141,8 +2087,6 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value1; } @@ -2221,12 +2165,9 @@ double Variable::evaluate(char *str, Tree **tree, int ivar) newtree->type = opprevious; if ((opprevious == UNARY) || (opprevious == NOT)) { newtree->first = treestack[--ntreestack]; - newtree->second = nullptr; - newtree->nextra = 0; } else { newtree->second = treestack[--ntreestack]; newtree->first = treestack[--ntreestack]; - newtree->nextra = 0; } treestack[ntreestack++] = newtree; @@ -3403,8 +3344,6 @@ int Variable::math_function(char *word, char *contents, Tree **tree, if (tree) { newtree = new Tree(); - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; Tree *argtree = nullptr; evaluate(args[0],&argtree,ivar); newtree->first = argtree; @@ -3836,7 +3775,7 @@ int Variable::group_function(char *word, char *contents, Tree **tree, // match word to group function - double value; + double value = 0.0; if (strcmp(word,"count") == 0) { if (narg == 1) value = group->count(igroup); @@ -4027,8 +3966,6 @@ int Variable::group_function(char *word, char *contents, Tree **tree, Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value; @@ -4318,8 +4255,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value; @@ -4339,8 +4274,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree *newtree = new Tree(); newtree->type = GMASK; newtree->ivalue1 = group->bitmask[igroup]; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else if (strcmp(word,"rmask") == 0) { @@ -4356,8 +4289,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree *newtree = new Tree(); newtree->type = RMASK; newtree->ivalue1 = iregion; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else if (strcmp(word,"grmask") == 0) { @@ -4377,8 +4308,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, newtree->type = GRMASK; newtree->ivalue1 = group->bitmask[igroup]; newtree->ivalue2 = iregion; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; // special function for file-style or atomfile-style variables @@ -4407,8 +4336,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value; @@ -4433,8 +4360,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, newtree->array = result; newtree->nstride = 1; newtree->selfalloc = 1; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else print_var_error(FLERR,"Invalid variable style in " @@ -4454,8 +4379,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value; @@ -4473,8 +4396,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value; @@ -4492,8 +4413,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value; @@ -4512,8 +4431,6 @@ int Variable::special_function(char *word, char *contents, Tree **tree, Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value; } @@ -4597,8 +4514,6 @@ void Variable::peratom2global(int flag, char *word, Tree *newtree = new Tree(); newtree->type = VALUE; newtree->value = value; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; } else argstack[nargstack++] = value; } @@ -4646,9 +4561,6 @@ void Variable::atom_vector(char *word, Tree **tree, Tree *newtree = new Tree(); newtree->type = ATOMARRAY; newtree->nstride = 3; - newtree->selfalloc = 0; - newtree->first = newtree->second = nullptr; - newtree->nextra = 0; treestack[ntreestack++] = newtree; if (strcmp(word,"id") == 0) { diff --git a/src/velocity.cpp b/src/velocity.cpp index fa09f451df..a42c820d8c 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -17,7 +17,6 @@ #include "atom.h" #include "comm.h" #include "compute.h" -#include "compute_temp.h" #include "domain.h" #include "error.h" #include "fix.h" diff --git a/src/version.h b/src/version.h index 366b63f8ea..6b4ecca26b 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define LAMMPS_VERSION "31 Aug 2021" +#define LAMMPS_VERSION "20 Sep 2021" diff --git a/src/write_data.cpp b/src/write_data.cpp index 9016528049..82c237a07e 100644 --- a/src/write_data.cpp +++ b/src/write_data.cpp @@ -61,7 +61,7 @@ void WriteData::command(int narg, char **arg) // if filename contains a "*", replace with current timestep std::string file = arg[0]; - std::size_t found = file.find("*"); + std::size_t found = file.find('*'); if (found != std::string::npos) file.replace(found,1,fmt::format("{}",update->ntimestep)); diff --git a/src/write_dump.cpp b/src/write_dump.cpp index f5b351fae1..89c976fe09 100644 --- a/src/write_dump.cpp +++ b/src/write_dump.cpp @@ -17,7 +17,7 @@ ------------------------------------------------------------------------- */ #include "write_dump.h" -#include "style_dump.h" +#include "style_dump.h" // IWYU pragma: keep #include "comm.h" #include "dump.h" @@ -64,7 +64,7 @@ void WriteDump::command(int narg, char **arg) #define DumpStyle(key,Class) \ } else if (strcmp(arg[1],#key) == 0) { \ dump = new Class(lmp,modindex+2,dumpargs); -#include "style_dump.h" +#include "style_dump.h" // IWYU pragma: keep #undef DUMP_CLASS } else error->all(FLERR,utils::check_packages_for_style("dump",arg[1],lmp)); diff --git a/src/write_restart.cpp b/src/write_restart.cpp index ddae269933..7f73d868ff 100644 --- a/src/write_restart.cpp +++ b/src/write_restart.cpp @@ -65,7 +65,7 @@ void WriteRestart::command(int narg, char **arg) // if filename contains a "*", replace with current timestep std::string file = arg[0]; - std::size_t found = file.find("*"); + std::size_t found = file.find('*'); if (found != std::string::npos) file.replace(found,1,fmt::format("{}",update->ntimestep)); @@ -205,7 +205,7 @@ void WriteRestart::multiproc_options(int multiproc_caller, int mpiioflag_caller, file = final file name to write, except may contain a "%" ------------------------------------------------------------------------- */ -void WriteRestart::write(std::string file) +void WriteRestart::write(const std::string &file) { // special case where reneighboring is not done in integrator // on timestep restart file is written (due to build_once being set) @@ -228,7 +228,7 @@ void WriteRestart::write(std::string file) if (me == 0) { std::string base = file; - if (multiproc) base.replace(base.find("%"),1,"base"); + if (multiproc) base.replace(base.find('%'),1,"base"); fp = fopen(base.c_str(),"wb"); if (fp == nullptr) @@ -290,7 +290,7 @@ void WriteRestart::write(std::string file) } std::string multiname = file; - multiname.replace(multiname.find("%"),1,fmt::format("{}",icluster)); + multiname.replace(multiname.find('%'),1,fmt::format("{}",icluster)); if (filewriter) { fp = fopen(multiname.c_str(),"wb"); diff --git a/src/write_restart.h b/src/write_restart.h index 2e018e1036..54d90405b2 100644 --- a/src/write_restart.h +++ b/src/write_restart.h @@ -29,7 +29,7 @@ class WriteRestart : public Command { WriteRestart(class LAMMPS *); void command(int, char **); void multiproc_options(int, int, int, char **); - void write(std::string); + void write(const std::string &); private: int me, nprocs; diff --git a/tools/binary2txt.cpp b/tools/binary2txt.cpp index 8abaafd093..a7724ffbd2 100644 --- a/tools/binary2txt.cpp +++ b/tools/binary2txt.cpp @@ -29,9 +29,9 @@ // g++ -g -DLAMMPS_BIGBIG binarytxt.o -o binary2txt // again -DLAMMPS_SMALLBIG is the default -#include "stdint.h" +#include #define __STDC_FORMAT_MACROS -#include "inttypes.h" +#include #ifndef PRId64 #define PRId64 "ld" @@ -65,7 +65,7 @@ int main(int narg, char **arg) char boundstr[9]; int maxbuf = 0; - double *buf = NULL; + double *buf = nullptr; if (narg == 1) { printf("Syntax: binary2txt file1 file2 ...\n"); diff --git a/tools/lammps-shell/lammps-shell.cpp b/tools/lammps-shell/lammps-shell.cpp index f77bd5442f..2ee62df920 100644 --- a/tools/lammps-shell/lammps-shell.cpp +++ b/tools/lammps-shell/lammps-shell.cpp @@ -8,11 +8,9 @@ #include "library.h" #include "utils.h" -#include -#include #include -#include #include +#include #include #include diff --git a/unittest/force-styles/test_pair_style.cpp b/unittest/force-styles/test_pair_style.cpp index c4adbe4138..2eda7bea9f 100644 --- a/unittest/force-styles/test_pair_style.cpp +++ b/unittest/force-styles/test_pair_style.cpp @@ -1502,7 +1502,7 @@ TEST(PairStyle, extract) if (!lmp) { std::cerr << "One or more prerequisite styles are not available " "in this LAMMPS configuration:\n"; - for (auto prerequisite : test_config.prerequisites) { + for (const auto &prerequisite : test_config.prerequisites) { std::cerr << prerequisite.first << "_style " << prerequisite.second << "\n"; } GTEST_SKIP(); diff --git a/unittest/utils/test_utils.cpp b/unittest/utils/test_utils.cpp index 5fb45cdf77..e0bc4984cc 100644 --- a/unittest/utils/test_utils.cpp +++ b/unittest/utils/test_utils.cpp @@ -14,8 +14,11 @@ #include "lmptype.h" #include "pointers.h" #include "utils.h" +#include "tokenizer.h" + #include "gmock/gmock.h" #include "gtest/gtest.h" + #include #include #include @@ -875,6 +878,19 @@ TEST(Utils, date2num) ASSERT_EQ(utils::date2num("31December100"), 1001231); } +TEST(Utils, current_date) +{ + auto vals = ValueTokenizer(utils::current_date(),"-"); + int year = vals.next_int(); + int month = vals.next_int(); + int day = vals.next_int(); + ASSERT_GT(year,2020); + ASSERT_GE(month,1); + ASSERT_GE(day,1); + ASSERT_LE(month,12); + ASSERT_LE(day,31); +} + TEST(Utils, binary_search) { double data[] = {-2.0, -1.8, -1.0, -1.0, -1.0, -0.5, -0.2, 0.0, 0.1, 0.1,