diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 00a4596cc8b..c0c3e3f89a8 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -25,7 +25,7 @@ jobs: - name: Cache Coverity id: cache-coverity - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ./download/ key: ${{ runner.os }}-download-${{ hashFiles('**/coverity_tool.*') }} diff --git a/.github/workflows/unittest-macos.yml b/.github/workflows/unittest-macos.yml index 6970faceaab..f9c2a838d6d 100644 --- a/.github/workflows/unittest-macos.yml +++ b/.github/workflows/unittest-macos.yml @@ -32,7 +32,7 @@ jobs: run: mkdir build - name: Set up ccache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ env.CCACHE_DIR }} key: macos-ccache-${{ github.sha }} diff --git a/cmake/Modules/Packages/GPU.cmake b/cmake/Modules/Packages/GPU.cmake index 4c3288df842..6d0ce303a5d 100644 --- a/cmake/Modules/Packages/GPU.cmake +++ b/cmake/Modules/Packages/GPU.cmake @@ -1,3 +1,10 @@ + +# Silence CMake warnings about FindCUDA being obsolete. +# We may need to eventually rewrite this section to use enable_language(CUDA) +if(POLICY CMP0146) + cmake_policy(SET CMP0146 OLD) +endif() + set(GPU_SOURCES_DIR ${LAMMPS_SOURCE_DIR}/GPU) set(GPU_SOURCES ${GPU_SOURCES_DIR}/gpu_extra.h ${GPU_SOURCES_DIR}/fix_gpu.h diff --git a/cmake/Modules/Packages/MDI.cmake b/cmake/Modules/Packages/MDI.cmake index 447b941d990..b21e508b87f 100644 --- a/cmake/Modules/Packages/MDI.cmake +++ b/cmake/Modules/Packages/MDI.cmake @@ -8,8 +8,8 @@ option(DOWNLOAD_MDI "Download and compile the MDI library instead of using an al if(DOWNLOAD_MDI) message(STATUS "MDI download requested - we will build our own") - set(MDI_URL "https://github.com/MolSSI-MDI/MDI_Library/archive/v1.4.16.tar.gz" CACHE STRING "URL for MDI tarball") - set(MDI_MD5 "407db44e2d79447ab5c1233af1965f65" CACHE STRING "MD5 checksum for MDI tarball") + set(MDI_URL "https://github.com/MolSSI-MDI/MDI_Library/archive/v1.4.26.tar.gz" CACHE STRING "URL for MDI tarball") + set(MDI_MD5 "3124bb85259471e2a53a891f04bf697a" CACHE STRING "MD5 checksum for MDI tarball") mark_as_advanced(MDI_URL) mark_as_advanced(MDI_MD5) GetFallbackURL(MDI_URL MDI_FALLBACK) diff --git a/doc/Makefile b/doc/Makefile index b652c515e1f..f9f8336665f 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -100,6 +100,7 @@ html: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX) env LC_ALL=C grep -n ' :[a-z]\+`' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ' `[^`]\+<[a-z][^`]\+`[^_]' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ':\(ref\|doc\):[^`]' $(RSTDIR)/*.rst ;\ + env LC_ALL=C grep -n '\(ref\|doc\)`[^`]' $(RSTDIR)/*.rst ;\ $(PYTHON) $(BUILDDIR)/utils/check-styles.py -s ../src -d src ;\ echo "############################################" ;\ deactivate ;\ @@ -182,6 +183,7 @@ pdf: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) env LC_ALL=C grep -n ' :[a-z]\+`' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ' `[^`]\+<[a-z][^`]\+`[^_]' $(RSTDIR)/*.rst ;\ env LC_ALL=C grep -n ':\(ref\|doc\):[^`]' $(RSTDIR)/*.rst ;\ + env LC_ALL=C grep -n '\(ref\|doc\)`[^`]' $(RSTDIR)/*.rst ;\ $(PYTHON) utils/check-styles.py -s ../src -d src ;\ echo "############################################" ;\ deactivate ;\ @@ -231,6 +233,7 @@ role_check : @( env LC_ALL=C grep -n ' :[a-z]\+`' $(RSTDIR)/*.rst && exit 1 || : ) @( env LC_ALL=C grep -n ' `[^`]\+<[a-z][^`]\+`[^_]' $(RSTDIR)/*.rst && exit 1 || : ) @( env LC_ALL=C grep -n ':\(ref\|doc\):[^`]' $(RSTDIR)/*.rst && exit 1 || : ) + @( env LC_ALL=C grep -n '\(ref\|doc\)`[^`]' $(RSTDIR)/*.rst && exit 1 || : ) link_check : $(VENV) html @(\ diff --git a/doc/src/fix_neb.rst b/doc/src/fix_neb.rst index ccd0f9b83df..51066675b8e 100644 --- a/doc/src/fix_neb.rst +++ b/doc/src/fix_neb.rst @@ -109,7 +109,7 @@ Note that in this case the specified *Kspring* is in force/distance units. With a value of *ideal*, the spring force is computed as suggested in -ref`(WeinanE) ` +:ref:`(WeinanE) ` .. math:: @@ -120,18 +120,18 @@ and :math:`RD_{ideal}` is the ideal *RD* for which all the images are equally spaced. I.e. :math:`RD_{ideal} = (i-1) \cdot meanDist` when the climbing replica is off, where *i* is the replica number). The *meanDist* is the average distance between replicas. Note that in this -case the specified *Kspring* is in force units. When the climbing replica -is on, :math:`RD_{ideal}` and :math:`meanDist` are calculated separately -each side of the climbing image. Note that the *ideal* form of nudging -can often be more effective at keeping the replicas equally spaced before -climbing, then equally spaced either side of the climbing image whilst -climbing. - -With a value of *equal* the spring force is computed as for *ideal* -when the climbing replica is off, promoting equidistance. When the climbing +case the specified *Kspring* is in force units. When the climbing +replica is on, :math:`RD_{ideal}` and :math:`meanDist` are calculated +separately each side of the climbing image. Note that the *ideal* form +of nudging can often be more effective at keeping the replicas equally +spaced before climbing, then equally spaced either side of the climbing +image whilst climbing. + +With a value of *equal* the spring force is computed as for *ideal* when +the climbing replica is off, promoting equidistance. When the climbing replica is on, the spring force is computed to promote equidistant -absolute differences in energy, rather than distance, each side of -the climbing image: +absolute differences in energy, rather than distance, each side of the +climbing image: .. math:: @@ -143,23 +143,22 @@ where *ED* is the cumulative sum of absolute energy differences: ED = \sum_{i`. +*meanEdist* is the average absolute energy difference between replicas +up to the climbing image or from the climbing image to the final image, +for images before or after the climbing image +respectively. :math:`ED_{ideal}` is the corresponding cumulative sum of +average absolute energy differences in each case, in close analogy to +*ideal*. This form of nudging is to aid schemes which integrate forces +along, or near to, NEB pathways such as :doc:`fix_pafi `. ---------- -The keyword *perp* specifies if and how a perpendicular nudging force -is computed. It adds a spring force perpendicular to the path in -order to prevent the path from becoming too strongly kinked. It can +The keyword *perp* specifies if and how a perpendicular nudging force is +computed. It adds a spring force perpendicular to the path in order to +prevent the path from becoming too strongly kinked. It can significantly improve the convergence of the NEB calculation when the -resolution is poor. I.e. when few replicas are used; see -:ref:`(Maras) ` for details. +resolution is poor. I.e. when few replicas are used; see :ref:`(Maras) +` for details. The perpendicular spring force is given by @@ -181,10 +180,10 @@ force is added. By default, no additional forces act on the first and last replicas during the NEB relaxation, so these replicas simply relax toward their -respective local minima. By using the key word *end*, additional -forces can be applied to the first and/or last replicas, to enable -them to relax toward a MEP while constraining their energy E to the -target energy ETarget. +respective local minima. By using the key word *end*, additional forces +can be applied to the first and/or last replicas, to enable them to +relax toward a MEP while constraining their energy E to the target +energy ETarget. If :math:`E_{Target} > E`, the interatomic force :math:`F_i` for the specified replica becomes: @@ -197,33 +196,33 @@ specified replica becomes: The "spring" constant on the difference in energies is the specified *Kspring3* value. -When *estyle* is specified as *first*, the force is applied to the -first replica. When *estyle* is specified as *last*, the force is -applied to the last replica. Note that the *end* keyword can be used -twice to add forces to both the first and last replicas. +When *estyle* is specified as *first*, the force is applied to the first +replica. When *estyle* is specified as *last*, the force is applied to +the last replica. Note that the *end* keyword can be used twice to add +forces to both the first and last replicas. For both these *estyle* settings, the target energy *ETarget* is set to the initial energy of the replica (at the start of the NEB calculation). If the *estyle* is specified as *last/efirst* or *last/efirst/middle*, -force is applied to the last replica, but the target energy *ETarget* -is continuously set to the energy of the first replica, as it evolves +force is applied to the last replica, but the target energy *ETarget* is +continuously set to the energy of the first replica, as it evolves during the NEB relaxation. The difference between these two *estyle* options is as follows. When *estyle* is specified as *last/efirst*, no change is made to the -inter-replica force applied to the intermediate replicas (neither -first or last). If the initial path is too far from the MEP, an -intermediate replica may relax "faster" and reach a lower energy than -the last replica. In this case the intermediate replica will be -relaxing toward its own local minima. This behavior can be prevented -by specifying *estyle* as *last/efirst/middle* which will alter the -inter-replica force applied to intermediate replicas by removing the -contribution of the gradient to the inter-replica force. This will -only be done if a particular intermediate replica has a lower energy -than the first replica. This should effectively prevent the -intermediate replicas from over-relaxing. +inter-replica force applied to the intermediate replicas (neither first +or last). If the initial path is too far from the MEP, an intermediate +replica may relax "faster" and reach a lower energy than the last +replica. In this case the intermediate replica will be relaxing toward +its own local minima. This behavior can be prevented by specifying +*estyle* as *last/efirst/middle* which will alter the inter-replica +force applied to intermediate replicas by removing the contribution of +the gradient to the inter-replica force. This will only be done if a +particular intermediate replica has a lower energy than the first +replica. This should effectively prevent the intermediate replicas from +over-relaxing. After converging a NEB calculation using an *estyle* of *last/efirst/middle*, you should check that all intermediate replicas @@ -237,9 +236,10 @@ target energy. Restart, fix_modify, output, run start/stop, minimize info """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" -No information about this fix is written to :doc:`binary restart files `. None of the :doc:`fix_modify ` options -are relevant to this fix. No global or per-atom quantities are stored -by this fix for access by various :doc:`output commands `. +No information about this fix is written to :doc:`binary restart files +`. None of the :doc:`fix_modify ` options are +relevant to this fix. No global or per-atom quantities are stored by +this fix for access by various :doc:`output commands `. No parameter of this fix can be used with the *start/stop* keywords of the :doc:`run ` command. diff --git a/doc/src/neb.rst b/doc/src/neb.rst index 0bc5de010be..b626796b6bd 100644 --- a/doc/src/neb.rst +++ b/doc/src/neb.rst @@ -10,7 +10,7 @@ Syntax neb etol ftol N1 N2 Nevery file-style arg keyword values -* etol = stopping tolerance for energy (energy units) +* etol = stopping tolerance for energy (dimensionless) * ftol = stopping tolerance for force (force units) * N1 = max # of iterations (timesteps) to run initial NEB * N2 = max # of iterations (timesteps) to run barrier-climbing NEB @@ -89,10 +89,11 @@ potentials, and the starting configuration when the neb command is issued should be the same for every replica. In a NEB calculation each replica is connected to other replicas by -inter-replica nudging forces. These forces are imposed by the :doc:`fix neb ` command, which must be used in conjunction with the -neb command. The group used to define the fix neb command defines the -NEB atoms which are the only ones that inter-replica springs are -applied to. If the group does not include all atoms, then non-NEB +inter-replica nudging forces. These forces are imposed by the +:doc:`fix neb ` command, which must be used in conjunction +with the neb command. The group used to define the fix neb command +defines the NEB atoms which are the only ones that inter-replica springs +are applied to. If the group does not include all atoms, then non-NEB atoms have no inter-replica springs and the forces they feel and their motion is computed in the usual way due only to other atoms within their replica. Conceptually, the non-NEB atoms provide a background @@ -445,7 +446,7 @@ Related commands """""""""""""""" :doc:`prd `, :doc:`temper `, :doc:`fix langevin `, -:doc:`fix viscous ` +:doc:`fix viscous `, :doc:`fix neb ` Default """"""" diff --git a/lib/gpu/Makefile.cuda b/lib/gpu/Makefile.cuda index be8003e02e5..75428c9513f 100644 --- a/lib/gpu/Makefile.cuda +++ b/lib/gpu/Makefile.cuda @@ -134,11 +134,11 @@ $(OBJ_DIR)/scan_app.cu_o: cudpp_mini/scan_app.cu $(GPU_LIB): $(OBJS) $(CUDPP) $(AR) -crusv $(GPU_LIB) $(OBJS) $(CUDPP) @cp $(EXTRAMAKE) Makefile.lammps - + # test app for querying device info $(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H) - $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda + $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda clean: -rm -f $(EXECS) $(GPU_LIB) $(OBJS) $(CUDPP) $(CUHS) *.linkinfo diff --git a/lib/gpu/Makefile.cuda_mps b/lib/gpu/Makefile.cuda_mps index 06d2ef03396..22a34c105c0 100644 --- a/lib/gpu/Makefile.cuda_mps +++ b/lib/gpu/Makefile.cuda_mps @@ -133,11 +133,11 @@ $(OBJ_DIR)/scan_app.cu_o: cudpp_mini/scan_app.cu $(GPU_LIB): $(OBJS) $(CUDPP) $(AR) -crusv $(GPU_LIB) $(OBJS) $(CUDPP) @cp $(EXTRAMAKE) Makefile.lammps - + # test app for querying device info $(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H) - $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda + $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda clean: -rm -f $(EXECS) $(GPU_LIB) $(OBJS) $(CUDPP) $(CUHS) *.linkinfo diff --git a/lib/gpu/Makefile.hip b/lib/gpu/Makefile.hip index f5a0d036081..0350c841c48 100644 --- a/lib/gpu/Makefile.hip +++ b/lib/gpu/Makefile.hip @@ -98,10 +98,10 @@ HIP_GPU_OPTS += $(HIP_OPTS) -I./ ifeq (spirv,$(HIP_PLATFORM)) HIP_HOST_OPTS += -fPIC HIP_GPU_CC = $(HIP_PATH)/bin/hipcc -c - HIP_GPU_OPTS_S = + HIP_GPU_OPTS_S = HIP_GPU_OPTS_E = HIP_KERNEL_SUFFIX = .cpp - HIP_LIBS_TARGET = + HIP_LIBS_TARGET = export HCC_AMDGPU_TARGET := $(HIP_ARCH) else ifeq (clang,$(HIP_COMPILER)) HIP_HOST_OPTS += -fPIC diff --git a/lib/gpu/Makefile.lammps.mac_ocl b/lib/gpu/Makefile.lammps.mac_ocl index 0073efa2ba9..dbbd789464b 100644 --- a/lib/gpu/Makefile.lammps.mac_ocl +++ b/lib/gpu/Makefile.lammps.mac_ocl @@ -2,4 +2,4 @@ gpu_SYSINC = -DFFT_SINGLE gpu_SYSLIB = -framework OpenCL -gpu_SYSPATH = +gpu_SYSPATH = diff --git a/lib/gpu/Makefile.lammps.mingw-cross b/lib/gpu/Makefile.lammps.mingw-cross index 12d833c744b..0b304b0e0c3 100644 --- a/lib/gpu/Makefile.lammps.mingw-cross +++ b/lib/gpu/Makefile.lammps.mingw-cross @@ -2,5 +2,5 @@ # settings for OpenCL builds gpu_SYSINC = gpu_SYSLIB = -Wl,--enable-stdcall-fixup -L../../tools/mingw-cross$(LIBOBJDIR) -Wl,-Bdynamic,-lOpenCL,-Bstatic -gpu_SYSPATH = +gpu_SYSPATH = diff --git a/lib/gpu/Makefile.lammps.opencl b/lib/gpu/Makefile.lammps.opencl index 413ae792109..50f5e63f777 100644 --- a/lib/gpu/Makefile.lammps.opencl +++ b/lib/gpu/Makefile.lammps.opencl @@ -2,4 +2,4 @@ gpu_SYSINC = gpu_SYSLIB = -lOpenCL -gpu_SYSPATH = +gpu_SYSPATH = diff --git a/lib/gpu/Makefile.linux b/lib/gpu/Makefile.linux index 3c37672e011..e02413f3ba7 100644 --- a/lib/gpu/Makefile.linux +++ b/lib/gpu/Makefile.linux @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Linux Makefile for CUDA # - Change CUDA_ARCH for your GPU # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.linux_multi b/lib/gpu/Makefile.linux_multi index 005f6590794..e3a76d99342 100644 --- a/lib/gpu/Makefile.linux_multi +++ b/lib/gpu/Makefile.linux_multi @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Linux Makefile for CUDA complied for multiple compute capabilities # - Add your GPU to CUDA_CODE # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.linux_opencl b/lib/gpu/Makefile.linux_opencl index 43d012dc4ad..b4b25544ee8 100644 --- a/lib/gpu/Makefile.linux_opencl +++ b/lib/gpu/Makefile.linux_opencl @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Linux Makefile for OpenCL - Mixed precision # ------------------------------------------------------------------------- */ @@ -11,7 +11,7 @@ EXTRAMAKE = Makefile.lammps.opencl LMP_INC = -DLAMMPS_SMALLBIG -OCL_INC = +OCL_INC = OCL_CPP = mpic++ -std=c++11 -O3 -DMPICH_IGNORE_CXX_SEEK $(LMP_INC) $(OCL_INC) OCL_LINK = -lOpenCL OCL_PREC = -D_SINGLE_DOUBLE diff --git a/lib/gpu/Makefile.mac_opencl b/lib/gpu/Makefile.mac_opencl index ae7e8ca6fdd..3a9fd39f35e 100644 --- a/lib/gpu/Makefile.mac_opencl +++ b/lib/gpu/Makefile.mac_opencl @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Mac Makefile for OpenCL - Single precision with FFT_SINGLE # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.mac_opencl_mpi b/lib/gpu/Makefile.mac_opencl_mpi index 9be9f07e935..b0c6e39aae7 100644 --- a/lib/gpu/Makefile.mac_opencl_mpi +++ b/lib/gpu/Makefile.mac_opencl_mpi @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Mac Makefile for OpenCL - Single precision with FFT_SINGLE # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.oneapi b/lib/gpu/Makefile.oneapi index 32800676aac..e67f4bb0822 100644 --- a/lib/gpu/Makefile.oneapi +++ b/lib/gpu/Makefile.oneapi @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Linux Makefile for Intel oneAPI - Mixed precision # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.oneapi_prof b/lib/gpu/Makefile.oneapi_prof index 1e215973733..58a03392e28 100644 --- a/lib/gpu/Makefile.oneapi_prof +++ b/lib/gpu/Makefile.oneapi_prof @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Linux Makefile for Intel oneAPI - Mixed precision (with timing enabled) # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Makefile.serial b/lib/gpu/Makefile.serial index 6c94911f327..67d2ce927db 100644 --- a/lib/gpu/Makefile.serial +++ b/lib/gpu/Makefile.serial @@ -1,4 +1,4 @@ -# /* ---------------------------------------------------------------------- +# /* ---------------------------------------------------------------------- # Generic Linux Makefile for CUDA without MPI libraries # - Change CUDA_ARCH for your GPU # ------------------------------------------------------------------------- */ diff --git a/lib/gpu/Nvidia.makefile b/lib/gpu/Nvidia.makefile index 298d4041174..d351b87b372 100644 --- a/lib/gpu/Nvidia.makefile +++ b/lib/gpu/Nvidia.makefile @@ -11,7 +11,7 @@ HOST_H = lal_answer.h lal_atom.h lal_balance.h lal_base_atomic.h lal_base_amoeba lal_base_charge.h lal_base_dipole.h lal_base_dpd.h \ lal_base_ellipsoid.h lal_base_three.h lal_device.h lal_neighbor.h \ lal_neighbor_shared.h lal_pre_ocl_config.h $(NVD_H) - + # Source files SRCS := $(wildcard ./lal_*.cpp) OBJS := $(subst ./,$(OBJ_DIR)/,$(SRCS:%.cpp=%.o)) @@ -127,7 +127,7 @@ $(GPU_LIB): $(OBJS) $(CUDPP) # test app for querying device info $(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H) - $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda + $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda clean: -rm -f $(EXECS) $(GPU_LIB) $(OBJS) $(CUDPP) $(CUHS) *.cubin *.linkinfo diff --git a/lib/gpu/Nvidia.makefile_multi b/lib/gpu/Nvidia.makefile_multi index ddbee4f2a10..c4b27ebbcb5 100644 --- a/lib/gpu/Nvidia.makefile_multi +++ b/lib/gpu/Nvidia.makefile_multi @@ -89,7 +89,7 @@ $(GPU_LIB): $(OBJS) $(CUDPP) # test app for querying device info $(BIN_DIR)/nvc_get_devices: ./geryon/ucl_get_devices.cpp $(NVD_H) - $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda + $(CUDR) -o $@ ./geryon/ucl_get_devices.cpp -DUCL_CUDADR $(CUDA_LIB) -lcuda clean: -rm -f $(EXECS) $(GPU_LIB) $(OBJS) $(CUDPP) $(CUHS) *.linkinfo diff --git a/lib/gpu/geryon/nvd_device.h b/lib/gpu/geryon/nvd_device.h index e63a1f56b2f..e627a7ca607 100644 --- a/lib/gpu/geryon/nvd_device.h +++ b/lib/gpu/geryon/nvd_device.h @@ -138,7 +138,7 @@ class UCL_Device { /** \note You cannot delete the default stream **/ inline void pop_command_queue() { if (_cq.size()<2) return; - CU_SAFE_CALL_NS(cuStreamDestroy(_cq.back())); + cuStreamDestroy(_cq.back()); _cq.pop_back(); } @@ -426,8 +426,8 @@ void UCL_Device::clear() { if (_device>-1) { for (int i=1; i> SBBITS & 3; - int j = sj & NEIGHMASK; + j = sj & NEIGHMASK; tagint jtag = tag[j]; if (!which) { diff --git a/lib/gpu/lal_base_sph.cpp b/lib/gpu/lal_base_sph.cpp index f373c0ebb6b..22ef5964eaa 100644 --- a/lib/gpu/lal_base_sph.cpp +++ b/lib/gpu/lal_base_sph.cpp @@ -195,7 +195,7 @@ void BaseSPHT::compute(const int f_ago, const int inum_full, const int nall, int **firstneigh, const bool eflag_in, const bool vflag_in, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *tag, - double **host_v, const int nlocal) { + double **host_v) { acc_timers(); int eflag, vflag; if (eatom) eflag=2; diff --git a/lib/gpu/lal_base_sph.h b/lib/gpu/lal_base_sph.h index d37e85f1700..46d28790936 100644 --- a/lib/gpu/lal_base_sph.h +++ b/lib/gpu/lal_base_sph.h @@ -132,7 +132,7 @@ class BaseSPH { int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *tag, - double **v, const int nlocal); + double **v); /// Pair loop with device neighboring int** compute(const int ago, const int inum_full, const int nall, diff --git a/lib/gpu/lal_edpd.cu b/lib/gpu/lal_edpd.cu index 9662d15aea3..0982d219ebe 100644 --- a/lib/gpu/lal_edpd.cu +++ b/lib/gpu/lal_edpd.cu @@ -324,8 +324,8 @@ __kernel void k_edpd(const __global numtyp4 *restrict x_, f.z+=delz*force; // heat transfer - - if (r < coeff2w) { + + if (r < coeff2w) { numtyp wrT = (numtyp)1.0 - r/coeff2w; wrT = MAX((numtyp)0.0,MIN((numtyp)1.0,wrT)); wrT = ucl_pow(wrT, (numtyp)0.5*coeff2z); // powerT[itype][jtype] @@ -401,10 +401,8 @@ __kernel void k_edpd_fast(const __global numtyp4 *restrict x_, __local numtyp4 sc[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 kc[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; - __local numtyp sp_sqrt[4]; if (tid<4) { sp_lj[tid]=sp_lj_in[tid]; - sp_sqrt[tid]=sp_sqrt_in[tid]; } if (tid> SBBITS & 3; - int j = sj & NEIGHMASK; + j = sj & NEIGHMASK; tagint jtag = tag[j]; if (!which) { diff --git a/lib/gpu/lal_mdpd.cu b/lib/gpu/lal_mdpd.cu index 6230cb24961..1e0ca8f0526 100644 --- a/lib/gpu/lal_mdpd.cu +++ b/lib/gpu/lal_mdpd.cu @@ -210,13 +210,12 @@ __kernel void k_mdpd(const __global numtyp4 *restrict x_, const numtyp rhoi = extra[i].x; - numtyp factor_dpd, factor_sqrt; + numtyp factor_dpd; for ( ; nbor tag2) { tag1 = jtag; tag2 = itag; @@ -322,10 +320,8 @@ __kernel void k_mdpd_fast(const __global numtyp4 *restrict x_, __local numtyp4 coeff[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp4 coeff2[MAX_SHARED_TYPES*MAX_SHARED_TYPES]; __local numtyp sp_lj[4]; - __local numtyp sp_sqrt[4]; if (tid<4) { sp_lj[tid]=sp_lj_in[tid]; - sp_sqrt[tid]=sp_sqrt_in[tid]; } if (tid tag2) { tag1 = jtag; tag2 = itag; diff --git a/lib/gpu/lal_sph_heatconduction.cu b/lib/gpu/lal_sph_heatconduction.cu index 21c936347a7..e2ba40db0ce 100644 --- a/lib/gpu/lal_sph_heatconduction.cu +++ b/lib/gpu/lal_sph_heatconduction.cu @@ -70,7 +70,9 @@ __kernel void k_sph_heatconduction(const __global numtyp4 *restrict x_, atom_info(t_per_atom,ii,tid,offset); int n_stride; +#if (SHUFFLE_AVAIL == 0) local_allocate_store_pair(); +#endif acctyp dEacc = (acctyp)0; @@ -171,7 +173,9 @@ __kernel void k_sph_heatconduction_fast(const __global numtyp4 *restrict x_, #endif int n_stride; +#if (SHUFFLE_AVAIL == 0) local_allocate_store_pair(); +#endif acctyp dEacc = (acctyp)0; @@ -234,7 +238,7 @@ __kernel void k_sph_heatconduction_fast(const __global numtyp4 *restrict x_, // Lucy Kernel, 2d wfd = (numtyp)-19.098593171027440292 * wfd * wfd * ihsq * ihsq * ihsq; } - + // total thermal energy increment numtyp D = coeffx; // alpha[itype][jtype] diffusion coefficient numtyp deltaE = (numtyp)2.0 * mass_itype * mass_jtype / (mass_itype + mass_jtype); diff --git a/lib/gpu/lal_sph_heatconduction_ext.cpp b/lib/gpu/lal_sph_heatconduction_ext.cpp index 92e0e342d20..645480154c2 100644 --- a/lib/gpu/lal_sph_heatconduction_ext.cpp +++ b/lib/gpu/lal_sph_heatconduction_ext.cpp @@ -110,10 +110,10 @@ void sph_heatconduction_gpu_compute(const int ago, const int inum_full, const in int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal) { + double **host_v) { SPHHeatConductionMF.compute(ago, inum_full, nall, host_x, host_type, ilist, numj, firstneigh, eflag, vflag, eatom, vatom, host_start, cpu_time, success, - host_tag, host_v, nlocal); + host_tag, host_v); } void sph_heatconduction_gpu_get_extra_data(double *host_rho, double *host_esph) { diff --git a/lib/gpu/lal_sph_lj.cu b/lib/gpu/lal_sph_lj.cu index 23863b5e288..f376dfc5335 100644 --- a/lib/gpu/lal_sph_lj.cu +++ b/lib/gpu/lal_sph_lj.cu @@ -362,7 +362,7 @@ __kernel void k_sph_lj_fast(const __global numtyp4 *restrict x_, // Lucy Kernel, 2d wfd = (numtyp)-19.098593171027440292 * wfd * wfd * ihsq * ihsq * ihsq; } - + // function call to LJ EOS numtyp fcj[2]; LJEOS2(rhoj, esphj, cvj, fcj); @@ -404,7 +404,7 @@ __kernel void k_sph_lj_fast(const __global numtyp4 *restrict x_, drhoEacc.y += deltaE; if (EVFLAG && eflag) { - numtyp e = (numtyp)0; + numtyp e = (numtyp)0; energy+=e; } if (EVFLAG && vflag) { diff --git a/lib/gpu/lal_sph_lj_ext.cpp b/lib/gpu/lal_sph_lj_ext.cpp index 55f85c030e2..ba88dc4b191 100644 --- a/lib/gpu/lal_sph_lj_ext.cpp +++ b/lib/gpu/lal_sph_lj_ext.cpp @@ -110,10 +110,10 @@ void sph_lj_gpu_compute(const int ago, const int inum_full, const int nall, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal) { + double **host_v) { SPHLJMF.compute(ago, inum_full, nall, host_x, host_type, ilist, numj, firstneigh, eflag, vflag, eatom, vatom, host_start, cpu_time, success, - host_tag, host_v, nlocal); + host_tag, host_v); } void sph_lj_gpu_get_extra_data(double *host_rho, double *host_esph, double *host_cv) { diff --git a/lib/gpu/lal_sph_taitwater.cu b/lib/gpu/lal_sph_taitwater.cu index 708d3ae43bc..9424d58996b 100644 --- a/lib/gpu/lal_sph_taitwater.cu +++ b/lib/gpu/lal_sph_taitwater.cu @@ -145,9 +145,9 @@ __kernel void k_sph_taitwater(const __global numtyp4 *restrict x_, // Lucy Kernel, 2d wfd = (numtyp)-19.098593171027440292 * wfd * wfd * ihsq * ihsq * ihsq; } - + // compute pressure of atom j with Tait EOS - + numtyp tmp = rhoj / rho0_jtype; numtyp fj = tmp * tmp * tmp; fj = B_jtype * (fj * fj * tmp - (numtyp)1.0); @@ -321,7 +321,7 @@ __kernel void k_sph_taitwater_fast(const __global numtyp4 *restrict x_, wfd = (numtyp)-19.098593171027440292 * wfd * wfd * ihsq * ihsq * ihsq; } - // compute pressure of atom j with Tait EOS + // compute pressure of atom j with Tait EOS numtyp tmp = rhoj / rho0_jtype; numtyp fj = tmp * tmp * tmp; fj = B_jtype * (fj * fj * tmp - (numtyp)1.0); @@ -356,7 +356,7 @@ __kernel void k_sph_taitwater_fast(const __global numtyp4 *restrict x_, drhoEacc.y += deltaE; if (EVFLAG && eflag) { - numtyp e = (numtyp)0; + numtyp e = (numtyp)0; energy+=e; } if (EVFLAG && vflag) { diff --git a/lib/gpu/lal_sph_taitwater_ext.cpp b/lib/gpu/lal_sph_taitwater_ext.cpp index 9d125a63958..8372132213e 100644 --- a/lib/gpu/lal_sph_taitwater_ext.cpp +++ b/lib/gpu/lal_sph_taitwater_ext.cpp @@ -114,10 +114,10 @@ void sph_taitwater_gpu_compute(const int ago, const int inum_full, const int nal int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal) { + double **host_v) { SPHTaitwaterMF.compute(ago, inum_full, nall, host_x, host_type, ilist, numj, firstneigh, eflag, vflag, eatom, vatom, host_start, cpu_time, success, - host_tag, host_v, nlocal); + host_tag, host_v); } void sph_taitwater_gpu_get_extra_data(double *host_rho) { diff --git a/lib/mdi/Install.py b/lib/mdi/Install.py index 316313ded8d..c455f2d0643 100644 --- a/lib/mdi/Install.py +++ b/lib/mdi/Install.py @@ -32,7 +32,7 @@ # settings -version = "1.4.16" +version = "1.4.26" url = "https://github.com/MolSSI-MDI/MDI_Library/archive/v%s.tar.gz" % version # known checksums for different MDI versions. used to validate the download. @@ -41,6 +41,7 @@ '1.4.12' : '7a222353ae8e03961d5365e6cd48baee', \ '1.4.14' : '7a059bb12535360fdcb7de8402f9a0fc', \ '1.4.16' : '407db44e2d79447ab5c1233af1965f65', \ + '1.4.26' : '3124bb85259471e2a53a891f04bf697a', \ } # print error message or help diff --git a/purge-workflows.py b/purge-workflows.py new file mode 100755 index 00000000000..00ebf35fa87 --- /dev/null +++ b/purge-workflows.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 + +from yaml import load +import subprocess +try: + from yaml import CLoader as Loader +except ImportError: + from yaml import Loader + +runs = subprocess.check_output('gh api repos/lammps/lammps/actions/runs',shell=True) +data = load(runs,Loader=Loader) +while data['total_count'] > 3: + print('remaining: ', data['total_count']) + num=1 + for d in data['workflow_runs']: + print(num, d['id'],d['name'],d['run_number']) + num += 1 + if num > 4: + subprocess.call('gh api -X DELETE repos/lammps/lammps/actions/runs/' + str(d['id']), shell=True) + #print('gh api -X DELETE repos/lammps/lammps/actions/runs/' + str(d['id'])) + else: + print('skip') + runs = subprocess.check_output('gh api repos/lammps/lammps/actions/runs',shell=True) + data = load(runs,Loader=Loader) diff --git a/src/ADIOS/reader_adios.cpp b/src/ADIOS/reader_adios.cpp index ec87bc26ccb..0fe82dd49fa 100644 --- a/src/ADIOS/reader_adios.cpp +++ b/src/ADIOS/reader_adios.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; -#define SMALL 1.0e-6 +static constexpr double SMALL = 1.0e-6; namespace LAMMPS_NS { class ReadADIOSInternal { diff --git a/src/AMOEBA/amoeba_convolution.cpp b/src/AMOEBA/amoeba_convolution.cpp index ae3dbf16c4a..262ce3a9c32 100644 --- a/src/AMOEBA/amoeba_convolution.cpp +++ b/src/AMOEBA/amoeba_convolution.cpp @@ -47,13 +47,8 @@ enum{MPOLE_GRID,POLAR_GRID,POLAR_GRIDC,DISP_GRID,INDUCE_GRID,INDUCE_GRIDC}; //#define SCALE 1 #define SCALE 0 -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- partition an FFT grid across processors diff --git a/src/AMOEBA/amoeba_file.cpp b/src/AMOEBA/amoeba_file.cpp index 6bf961cdab5..a48af86ffe2 100644 --- a/src/AMOEBA/amoeba_file.cpp +++ b/src/AMOEBA/amoeba_file.cpp @@ -25,23 +25,23 @@ using namespace LAMMPS_NS; -enum{UNKNOWN,FFIELD,LITERATURE,ATOMTYPE,VDWL,VDWLPAIR,BSTRETCH,SBEND,ABEND, - PAULI,DISPERSION,UB,OUTPLANE,TORSION,PITORSION,ATOMMULT, - QPENETRATION,DIPPOLAR,QTRANSFER,END_OF_FILE}; -enum{ALLINGER,BUFFERED_14_7}; -enum{ARITHMETIC,GEOMETRIC,CUBIC_MEAN,R_MIN,SIGMA,DIAMETER,HARMONIC,HHG,W_H}; -enum{MUTUAL,OPT,TCG,DIRECT}; -enum{NOFRAME,ZONLY,ZTHENX,BISECTOR,ZBISECT,THREEFOLD}; -enum{GEAR,ASPC,LSQR}; +enum { UNKNOWN, FFIELD, LITERATURE, ATOMTYPE, VDWL, VDWLPAIR, BSTRETCH, SBEND, ABEND, + PAULI, DISPERSION, UB, OUTPLANE, TORSION, PITORSION, ATOMMULT, QPENETRATION, DIPPOLAR, + QTRANSFER, END_OF_FILE }; +enum { ALLINGER, BUFFERED_14_7 }; +enum { ARITHMETIC, GEOMETRIC, CUBIC_MEAN, R_MIN, SIGMA, DIAMETER, HARMONIC, HHG, W_H }; +enum { MUTUAL, OPT, TCG, DIRECT }; +enum { NOFRAME, ZONLY, ZTHENX, BISECTOR, ZBISECT, THREEFOLD }; +enum { GEAR, ASPC, LSQR }; -#define MAXLINE 65536 // crazy big for TORSION-TORSION section -#define MAX_TYPE_PER_GROUP 6 // max types per AMOEBA group -#define MAX_FRAME_PER_TYPE 32 // max multipole frames for any AMOEBA type +static constexpr int MAXLINE = 65536; // crazy big for TORSION-TORSION section +static constexpr int MAX_TYPE_PER_GROUP = 6; // max types per AMOEBA group +static constexpr int MAX_FRAME_PER_TYPE = 32; // max multipole frames for any AMOEBA type -#define DELTA_TYPE_CLASS 32 -#define DELTA_VDWL_PAIR 16 +static constexpr int DELTA_TYPE_CLASS = 32; +static constexpr int DELTA_VDWL_PAIR = 16; -#define BOHR 0.52917721067 // Bohr in Angstroms +static constexpr double BOHR = 0.52917721067; // Bohr in Angstroms // methods to read, parse, and store info from force field file @@ -79,7 +79,7 @@ void PairAmoeba::read_prmfile(char *filename) int me = comm->me; FILE *fptr; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; if (me == 0) { fptr = utils::open_potential(filename, lmp, nullptr); @@ -179,8 +179,7 @@ void PairAmoeba::read_prmfile(char *filename) for (int i = 1; i <= n_amtype; i++) nmultiframe[i] = 0; } - char next[MAXLINE]; - next[0] = '\0'; + char next[MAXLINE] = {'\0'}; bool has_next = false; int n; while (true) { @@ -381,7 +380,7 @@ void PairAmoeba::read_keyfile(char *filename) int me = comm->me; FILE *fptr; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; if (me == 0) { fptr = utils::open_potential(filename, lmp, nullptr); if (fptr == nullptr) diff --git a/src/AMOEBA/amoeba_induce.cpp b/src/AMOEBA/amoeba_induce.cpp index 6017b775caa..278a00316d5 100644 --- a/src/AMOEBA/amoeba_induce.cpp +++ b/src/AMOEBA/amoeba_induce.cpp @@ -41,7 +41,7 @@ enum{GEAR,ASPC,LSQR}; enum{BUILD,APPLY}; enum{GORDON1,GORDON2}; -#define DEBYE 4.80321 // conversion factor from q-Angs (real units) to Debye +static constexpr double DEBYE = 4.80321; // conversion factor from q-Angs (real units) to Debye /* ---------------------------------------------------------------------- induce = induced dipole moments via pre-conditioned CG solver diff --git a/src/AMOEBA/amoeba_multipole.cpp b/src/AMOEBA/amoeba_multipole.cpp index d0ae03401a6..81e7763fe77 100644 --- a/src/AMOEBA/amoeba_multipole.cpp +++ b/src/AMOEBA/amoeba_multipole.cpp @@ -35,11 +35,11 @@ enum{FIELD,ZRSD,TORQUE,UFLD}; // reverse comm enum{VDWL,REPULSE,QFER,DISP,MPOLE,POLAR,USOLV,DISP_LONG,MPOLE_LONG,POLAR_LONG}; #ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f +static constexpr FFT_SCALAR ZEROF = 0.0f; +static constexpr FFT_SCALAR ONEF = 1.0f; #else -#define ZEROF 0.0 -#define ONEF 1.0 +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; #endif /* ---------------------------------------------------------------------- diff --git a/src/AMOEBA/angle_amoeba.cpp b/src/AMOEBA/angle_amoeba.cpp index e6ee7b579ef..54fc3e9f9ac 100644 --- a/src/AMOEBA/angle_amoeba.cpp +++ b/src/AMOEBA/angle_amoeba.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/AMOEBA/fix_amoeba_bitorsion.cpp b/src/AMOEBA/fix_amoeba_bitorsion.cpp index cb8c62819d9..f814f4109a7 100644 --- a/src/AMOEBA/fix_amoeba_bitorsion.cpp +++ b/src/AMOEBA/fix_amoeba_bitorsion.cpp @@ -32,10 +32,10 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define BITORSIONMAX 6 // max # of BiTorsion terms stored by one atom -#define LISTDELTA 10000 -#define LB_FACTOR 1.5 -#define MAXLINE 1024 +static constexpr int BITORSIONMAX = 6; // max # of BiTorsion terms stored by one atom +static constexpr int LISTDELTA = 10000; +static constexpr double LB_FACTOR = 1.5; +static constexpr int MAXLINE = 1024; // spline weighting factors @@ -724,7 +724,7 @@ double FixAmoebaBiTorsion::compute_scalar() void FixAmoebaBiTorsion::read_grid_data(char *bitorsion_file) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; char *eof; FILE *fp = nullptr; diff --git a/src/AMOEBA/fix_amoeba_pitorsion.cpp b/src/AMOEBA/fix_amoeba_pitorsion.cpp index 445845c075d..33af4a3c31a 100644 --- a/src/AMOEBA/fix_amoeba_pitorsion.cpp +++ b/src/AMOEBA/fix_amoeba_pitorsion.cpp @@ -32,9 +32,9 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define PITORSIONMAX 6 // max # of PiTorsion terms stored by one atom -#define LISTDELTA 8196 -#define LB_FACTOR 1.5 +static constexpr int PITORSIONMAX = 6; // max # of PiTorsion terms stored by one atom +static constexpr int LISTDELTA = 8196; +static constexpr double LB_FACTOR = 1.5; /* ---------------------------------------------------------------------- */ diff --git a/src/AMOEBA/improper_amoeba.cpp b/src/AMOEBA/improper_amoeba.cpp index 32c31b0af98..46c2585d1f4 100644 --- a/src/AMOEBA/improper_amoeba.cpp +++ b/src/AMOEBA/improper_amoeba.cpp @@ -28,8 +28,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/AMOEBA/pair_amoeba.cpp b/src/AMOEBA/pair_amoeba.cpp index cad9e2b6289..de505f4a4e9 100644 --- a/src/AMOEBA/pair_amoeba.cpp +++ b/src/AMOEBA/pair_amoeba.cpp @@ -47,7 +47,7 @@ enum{MPOLE_GRID,POLAR_GRID,POLAR_GRIDC,DISP_GRID,INDUCE_GRID,INDUCE_GRIDC}; enum{MUTUAL,OPT,TCG,DIRECT}; enum{GEAR,ASPC,LSQR}; -#define DELTASTACK 16 +static constexpr int DELTASTACK = 16; #define DEBUG_AMOEBA 0 /* ---------------------------------------------------------------------- */ diff --git a/src/ASPHERE/compute_temp_asphere.cpp b/src/ASPHERE/compute_temp_asphere.cpp index 707938b2b94..7d5d6adce51 100644 --- a/src/ASPHERE/compute_temp_asphere.cpp +++ b/src/ASPHERE/compute_temp_asphere.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; enum{ROTATE,ALL}; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/ASPHERE/fix_nve_asphere.cpp b/src/ASPHERE/fix_nve_asphere.cpp index f4080493c8f..a5655b875cc 100644 --- a/src/ASPHERE/fix_nve_asphere.cpp +++ b/src/ASPHERE/fix_nve_asphere.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/ASPHERE/fix_nve_line.cpp b/src/ASPHERE/fix_nve_line.cpp index d7adf0a963f..4d7a691bdda 100644 --- a/src/ASPHERE/fix_nve_line.cpp +++ b/src/ASPHERE/fix_nve_line.cpp @@ -23,7 +23,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define INERTIA (1.0/12.0) // moment of inertia prefactor for line segment +static constexpr double INERTIA = (1.0/12.0); // moment of inertia prefactor for line segment /* ---------------------------------------------------------------------- */ diff --git a/src/ASPHERE/pair_line_lj.cpp b/src/ASPHERE/pair_line_lj.cpp index 2d6dc557f3c..3bfc10758cd 100644 --- a/src/ASPHERE/pair_line_lj.cpp +++ b/src/ASPHERE/pair_line_lj.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ASPHERE/pair_tri_lj.cpp b/src/ASPHERE/pair_tri_lj.cpp index 4fe999f0394..b9cb2528cac 100644 --- a/src/ASPHERE/pair_tri_lj.cpp +++ b/src/ASPHERE/pair_tri_lj.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define DELTA 20 +static constexpr int DELTA = 20; /* ---------------------------------------------------------------------- */ diff --git a/src/BOCS/fix_bocs.cpp b/src/BOCS/fix_bocs.cpp index 4918f8d8791..33f4f072e7b 100644 --- a/src/BOCS/fix_bocs.cpp +++ b/src/BOCS/fix_bocs.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -42,31 +41,30 @@ using namespace LAMMPS_NS; using namespace FixConst; static const char cite_user_bocs_package[] = - "BOCS package: doi:10.1021/acs.jpcb.7b09993\n\n" - "@Article{Dunn2018,\n" - " author = {N. J. H. Dunn and K. M. Lebold and M. R. {DeLyser} and\n" - " J. F. Rudzinski and W. G. Noid},\n" - " title = {{BOCS}: Bottom-Up Open-Source Coarse-Graining Software},\n" - " journal = {J.~Phys.\\ Chem.~B},\n" - " year = 2018,\n" - " volume = 122,\n" - " number = 13,\n" - " pages = {3363--3377}\n" - "}\n\n"; - - -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 - -enum{NOBIAS,BIAS}; -enum{NONE,XYZ,XY,YZ,XZ}; -enum{ISO,ANISO,TRICLINIC}; - -const int NUM_INPUT_DATA_COLUMNS = 2; // columns in the pressure correction file + "BOCS package: doi:10.1021/acs.jpcb.7b09993\n\n" + "@Article{Dunn2018,\n" + " author = {N. J. H. Dunn and K. M. Lebold and M. R. {DeLyser} and\n" + " J. F. Rudzinski and W. G. Noid},\n" + " title = {{BOCS}: Bottom-Up Open-Source Coarse-Graining Software},\n" + " journal = {J.~Phys.\\ Chem.~B},\n" + " year = 2018,\n" + " volume = 122,\n" + " number = 13,\n" + " pages = {3363--3377}\n" + "}\n\n"; + +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; +static constexpr int NUM_INPUT_DATA_COLUMNS = 2; // columns in the pressure correction file + +enum { NOBIAS, BIAS }; +enum { NONE, XYZ, XY, YZ, XZ }; +enum { ISO, ANISO, TRICLINIC }; /* ---------------------------------------------------------------------- NVT,NPH,NPT integrators for improved Nose-Hoover equations of motion ---------------------------------------------------------------------- */ +// clang-format off FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), id_dilate(nullptr), irregular(nullptr), id_temp(nullptr), @@ -75,7 +73,7 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : { if (lmp->citeme) lmp->citeme->add(cite_user_bocs_package); - if (narg < 4) error->all(FLERR,"Illegal fix bocs command"); + if (narg < 4) utils::missing_cmd_args(FLERR,"fix bocs",error); restart_global = 1; dynamic_group_allow = 1; @@ -102,8 +100,6 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : omega_mass_flag = 0; etap_mass_flag = 0; flipflag = 1; - dipole_flag = 0; - dlm_flag = 0; tcomputeflag = 0; pcomputeflag = 0; @@ -266,13 +262,6 @@ FixBocs::FixBocs(LAMMPS *lmp, int narg, char **arg) : if (p_flag[2] && domain->zperiodic == 0) error->all(FLERR,"Cannot use fix bocs on a non-periodic dimension"); - if (dipole_flag) { - if (!atom->sphere_flag) - error->all(FLERR,"Using update dipole flag requires atom style sphere"); - if (!atom->mu_flag) - error->all(FLERR,"Using update dipole flag requires atom attribute mu"); - } - if ((tstat_flag && t_period <= 0.0) || (p_flag[0] && p_period[0] <= 0.0) || (p_flag[1] && p_period[1] <= 0.0) || @@ -616,8 +605,8 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) // Data file lines hold two floating point numbers. // Line length we allocate should be long enough without being too long. // 128 seems safe for a line we expect to be < 30 chars. - const int MAX_F_TABLE_LINE_LENGTH = 128; - char line[MAX_F_TABLE_LINE_LENGTH]; + constexpr int MAX_F_TABLE_LINE_LENGTH = 128; + char line[MAX_F_TABLE_LINE_LENGTH] = {'\0'}; std::vector inputLines; while (fgets(line, MAX_F_TABLE_LINE_LENGTH, fpi)) { inputLines.emplace_back(line); @@ -649,17 +638,13 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) for (int i = 0; i < (int)inputLines.size(); ++i) { lineNum++; // count each line processed now so lineNum messages can be 1-based test_sscanf = sscanf(inputLines.at(i).c_str()," %f , %f ",&f1, &f2); - if (test_sscanf == 2) - { + if (test_sscanf == 2) { data[VOLUME][i] = (double)f1; data[PRESSURE_CORRECTION][i] = (double)f2; - if (i == 1) - { + if (i == 1) { // second entry is used to compute the validation interval used below stdVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1]; - } - else if (i > 1) - { + } else if (i > 1) { // after second entry, all intervals are validated currVolumeInterval = data[VOLUME][i] - data[VOLUME][i-1]; if (fabs(currVolumeInterval - stdVolumeInterval) > volumeIntervalTolerance) { @@ -673,17 +658,14 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) } // no concluding else is intentional: i = 0, first line, no interval to validate } - } - else - { + } else { if (comm->me == 0) error->warning(FLERR,"Bad input format: did not find 2 comma separated numeric" " values in line {} of file {}\nWARNING:\tline: {}", lineNum, filename, inputLines.at(i)); badInput = true; } - if (badInput) - { + if (badInput) { numBadVolumeIntervals++; } } @@ -700,18 +682,13 @@ int FixBocs::read_F_table( char *filename, int p_basis_type ) error->warning(FLERR,"Bad volume / pressure-correction data: {}\nSee details above", filename); } - if (p_basis_type == BASIS_LINEAR_SPLINE) - { + if (p_basis_type == BASIS_LINEAR_SPLINE) { spline_length = numEntries; numEntries = build_linear_splines(data); - } - else if (p_basis_type == BASIS_CUBIC_SPLINE) - { + } else if (p_basis_type == BASIS_CUBIC_SPLINE) { spline_length = numEntries; numEntries = build_cubic_splines(data); - } - else - { + } else { error->all(FLERR,"ERROR: invalid p_basis_type value of {} in read_F_table", p_basis_type); } @@ -724,8 +701,7 @@ int FixBocs::build_linear_splines(double **data) { splines[VOLUME] = (double *) calloc(spline_length,sizeof(double)); splines[PRESSURE_CORRECTION] = (double *) calloc(spline_length,sizeof(double)); - for (int i = 0; i < spline_length; ++i) - { + for (int i = 0; i < spline_length; ++i) { splines[VOLUME][i] = data[VOLUME][i]; splines[PRESSURE_CORRECTION][i] = data[PRESSURE_CORRECTION][i]; } @@ -758,18 +734,15 @@ int FixBocs::build_cubic_splines(double **data) memory->create(mu, n, "mu"); memory->create(z, n, "z"); - for (int i=0; i1 && i<(n-1)) - { + if (i>1 && i<(n-1)) { alpha_i = (3.0 / h[i]) * ( data[1][i+1] - data[1][i]) - (3.0 / h[i-1] ) * ( data[1][i] - data[1][i-1] ); alpha[i-1] = alpha_i; @@ -779,8 +752,7 @@ int FixBocs::build_cubic_splines(double **data) mu[0] = 0.0; z[0] = 0.0; - for (int i=1; i=0; j--) - { + for (int j=n-1; j>=0; j--) { c[j] = z[j] - mu[j]*c[j+1]; - b[j] = (a[j+1]-a[j])/h[j] - h[j]*(c[j+1] + 2.0 * c[j])/3.0; - d[j] = (c[j+1]-c[j])/(3.0 * h[j]); } int numSplines = n - 1; memory->create(splines, NUM_CUBIC_SPLINE_COLUMNS, numSplines, "splines"); - for (int idx = 0; idx < numSplines; ++idx) - { + for (int idx = 0; idx < numSplines; ++idx) { splines[0][idx] = data[0][idx]; splines[1][idx] = a[idx]; splines[2][idx] = b[idx]; diff --git a/src/BOCS/fix_bocs.h b/src/BOCS/fix_bocs.h index 71fbc273d86..af221fedb36 100644 --- a/src/BOCS/fix_bocs.h +++ b/src/BOCS/fix_bocs.h @@ -129,8 +129,6 @@ class FixBocs : public Fix { int eta_mass_flag; // 1 if eta_mass updated, 0 if not. int omega_mass_flag; // 1 if omega_mass updated, 0 if not. int etap_mass_flag; // 1 if etap_mass updated, 0 if not. - int dipole_flag; // 1 if dipole is updated, 0 if not. - int dlm_flag; // 1 if using the DLM rotational integrator, 0 if not int scaleyz; // 1 if yz scaled with lz int scalexz; // 1 if xz scaled with lz diff --git a/src/BODY/body_nparticle.cpp b/src/BODY/body_nparticle.cpp index 62e6ee802ae..7a1dbaa0f08 100644 --- a/src/BODY/body_nparticle.cpp +++ b/src/BODY/body_nparticle.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-7 +static constexpr double EPSILON = 1.0e-7; enum{SPHERE,LINE,TRI}; // also in DumpImage /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/body_rounded_polygon.cpp b/src/BODY/body_rounded_polygon.cpp index 2fb2a991f1b..6a94f68a8e7 100644 --- a/src/BODY/body_rounded_polygon.cpp +++ b/src/BODY/body_rounded_polygon.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-7 +static constexpr double EPSILON = 1.0e-7; enum{SPHERE,LINE}; // also in DumpImage /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/body_rounded_polyhedron.cpp b/src/BODY/body_rounded_polyhedron.cpp index 1d11644618e..bcc3495644d 100644 --- a/src/BODY/body_rounded_polyhedron.cpp +++ b/src/BODY/body_rounded_polyhedron.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-7 +static constexpr double EPSILON = 1.0e-7; #define MAX_FACE_SIZE 4 // maximum number of vertices per face (for now) enum{SPHERE,LINE}; // also in DumpImage diff --git a/src/BODY/compute_body_local.cpp b/src/BODY/compute_body_local.cpp index 42afa135144..4a4a36bfae7 100644 --- a/src/BODY/compute_body_local.cpp +++ b/src/BODY/compute_body_local.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; enum{ID,TYPE,INDEX}; diff --git a/src/BODY/fix_wall_body_polygon.cpp b/src/BODY/fix_wall_body_polygon.cpp index 6f0622cbf6b..0920145eb25 100644 --- a/src/BODY/fix_wall_body_polygon.cpp +++ b/src/BODY/fix_wall_body_polygon.cpp @@ -43,9 +43,9 @@ enum {INVALID=0,NONE=1,VERTEX=2}; enum {FAR=0,XLO,XHI,YLO,YHI}; //#define _POLYGON_DEBUG -#define DELTA 10000 -#define EPSILON 1e-2 // dimensionless threshold (dot products, end point checks, contact checks) -#define BIG 1.0e20 +static constexpr int DELTA = 10000; +static constexpr double EPSILON = 1e-2; // dimensionless threshold (dot products, end point checks, contact checks) +static constexpr double BIG = 1.0e20; #define MAX_CONTACTS 4 // maximum number of contacts for 2D models #define EFF_CONTACTS 2 // effective contacts for 2D models diff --git a/src/BODY/fix_wall_body_polyhedron.cpp b/src/BODY/fix_wall_body_polyhedron.cpp index 4b28f6af726..035e814692c 100644 --- a/src/BODY/fix_wall_body_polyhedron.cpp +++ b/src/BODY/fix_wall_body_polyhedron.cpp @@ -43,9 +43,9 @@ enum {INVALID=0,NONE=1,VERTEX=2}; enum {FAR=0,XLO,XHI,YLO,YHI,ZLO,ZHI}; //#define _POLYHEDRON_DEBUG -#define DELTA 10000 -#define EPSILON 1e-3 // dimensionless threshold (dot products, end point checks) -#define BIG 1.0e20 +static constexpr int DELTA = 10000; +static constexpr double EPSILON = 1e-3; // dimensionless threshold (dot products, end point checks) +static constexpr double BIG = 1.0e20; #define MAX_CONTACTS 4 // maximum number of contacts for 2D models #define EFF_CONTACTS 2 // effective contacts for 2D models diff --git a/src/BODY/pair_body_nparticle.cpp b/src/BODY/pair_body_nparticle.cpp index 9e1e640015b..29ee06dbefd 100644 --- a/src/BODY/pair_body_nparticle.cpp +++ b/src/BODY/pair_body_nparticle.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/BODY/pair_body_rounded_polygon.cpp b/src/BODY/pair_body_rounded_polygon.cpp index 24f38a6a0a1..4b5a3c4f649 100644 --- a/src/BODY/pair_body_rounded_polygon.cpp +++ b/src/BODY/pair_body_rounded_polygon.cpp @@ -39,8 +39,8 @@ using namespace LAMMPS_NS; -#define DELTA 10000 -#define EPSILON 1e-3 // dimensionless threshold (dot products, end point checks, contact checks) +static constexpr int DELTA = 10000; +static constexpr double EPSILON = 1e-3; // dimensionless threshold (dot products, end point checks, contact checks) #define MAX_CONTACTS 4 // maximum number of contacts for 2D models #define EFF_CONTACTS 2 // effective contacts for 2D models diff --git a/src/BODY/pair_body_rounded_polyhedron.cpp b/src/BODY/pair_body_rounded_polyhedron.cpp index e261ff14d39..9eaed320fef 100644 --- a/src/BODY/pair_body_rounded_polyhedron.cpp +++ b/src/BODY/pair_body_rounded_polyhedron.cpp @@ -43,8 +43,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 -#define EPSILON 1e-3 // dimensionless threshold (dot products, end point checks, contact checks) +static constexpr int DELTA = 10000; +static constexpr double EPSILON = 1e-3; // dimensionless threshold (dot products, end point checks, contact checks) #define MAX_FACE_SIZE 4 // maximum number of vertices per face (same as BodyRoundedPolyhedron) #define MAX_CONTACTS 32 // for 3D models (including duplicated counts) diff --git a/src/BPM/bond_bpm_rotational.cpp b/src/BPM/bond_bpm_rotational.cpp index ffb0d9521d0..85570385b48 100644 --- a/src/BPM/bond_bpm_rotational.cpp +++ b/src/BPM/bond_bpm_rotational.cpp @@ -28,7 +28,7 @@ #include #include -#define EPSILON 1e-10 +static constexpr double EPSILON = 1e-10; using namespace LAMMPS_NS; using MathConst::MY_SQRT2; diff --git a/src/BPM/bond_bpm_spring.cpp b/src/BPM/bond_bpm_spring.cpp index 37b79f93fba..28d17b408a2 100644 --- a/src/BPM/bond_bpm_spring.cpp +++ b/src/BPM/bond_bpm_spring.cpp @@ -26,7 +26,7 @@ #include #include -#define EPSILON 1e-10 +static constexpr double EPSILON = 1e-10; using namespace LAMMPS_NS; diff --git a/src/BPM/fix_nve_bpm_sphere.cpp b/src/BPM/fix_nve_bpm_sphere.cpp index ceab07822e1..98595c6ebc4 100644 --- a/src/BPM/fix_nve_bpm_sphere.cpp +++ b/src/BPM/fix_nve_bpm_sphere.cpp @@ -28,7 +28,7 @@ using namespace MathExtra; FixNVEBPMSphere::FixNVEBPMSphere(LAMMPS *_lmp, int narg, char **arg) : FixNVE(_lmp, narg, arg) { - if (narg < 3) error->all(FLERR, "Illegal fix nve/bpm/sphere command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "fix nve/bpm/sphere", error); time_integrate = 1; @@ -45,7 +45,7 @@ FixNVEBPMSphere::FixNVEBPMSphere(LAMMPS *_lmp, int narg, char **arg) : FixNVE(_l error->all(FLERR, "Fix nve/bpm/sphere disc requires 2d simulation"); iarg++; } else - error->all(FLERR, "Illegal fix nve/bpm/sphere command"); + error->all(FLERR, "Illegal fix nve/bpm/sphere keyword {}", arg[iarg]); } inv_inertia = 1.0 / inertia; diff --git a/src/BPM/fix_update_special_bonds.cpp b/src/BPM/fix_update_special_bonds.cpp index b6bf8b433fd..54523660906 100644 --- a/src/BPM/fix_update_special_bonds.cpp +++ b/src/BPM/fix_update_special_bonds.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/BROWNIAN/fix_brownian_base.cpp b/src/BROWNIAN/fix_brownian_base.cpp index b2e89a096a4..508ce4d1c6f 100644 --- a/src/BROWNIAN/fix_brownian_base.cpp +++ b/src/BROWNIAN/fix_brownian_base.cpp @@ -204,7 +204,7 @@ FixBrownianBase::~FixBrownianBase() delete[] gamma_r_invsqrt; } - if (dipole_flag) { delete[] dipole_body; } + if (dipole_flag) delete[] dipole_body; delete rng; } diff --git a/src/BROWNIAN/fix_brownian_sphere.cpp b/src/BROWNIAN/fix_brownian_sphere.cpp index 220a3b9735a..8bfeb76adc6 100644 --- a/src/BROWNIAN/fix_brownian_sphere.cpp +++ b/src/BROWNIAN/fix_brownian_sphere.cpp @@ -36,10 +36,10 @@ FixBrownianSphere::FixBrownianSphere(LAMMPS *lmp, int narg, char **arg) : FixBrownianBase(lmp, narg, arg) { if (gamma_t_eigen_flag || gamma_r_eigen_flag) { - error->all(FLERR, "Illegal fix brownian command."); + error->all(FLERR, "Illegal fix brownian/sphere command."); } - if (!gamma_t_flag || !gamma_r_flag) { error->all(FLERR, "Illegal fix brownian command."); } + if (!gamma_t_flag || !gamma_r_flag) error->all(FLERR, "Illegal fix brownian/sphere command."); if (!atom->mu_flag) error->all(FLERR, "Fix brownian/sphere requires atom attribute mu"); if (!atom->sphere_flag) error->all(FLERR, "Fix brownian/sphere requires atom style sphere"); } diff --git a/src/BROWNIAN/fix_propel_self.cpp b/src/BROWNIAN/fix_propel_self.cpp index 8d97b828a90..e98f461b805 100644 --- a/src/BROWNIAN/fix_propel_self.cpp +++ b/src/BROWNIAN/fix_propel_self.cpp @@ -35,7 +35,7 @@ using namespace FixConst; enum { DIPOLE, VELOCITY, QUAT }; -#define TOL 1e-14 +static constexpr double TOL = 1e-14; /* ---------------------------------------------------------------------- */ diff --git a/src/CG-DNA/fix_nve_dot.cpp b/src/CG-DNA/fix_nve_dot.cpp index a9d288eb16e..4fbf9bb9be4 100644 --- a/src/CG-DNA/fix_nve_dot.cpp +++ b/src/CG-DNA/fix_nve_dot.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathExtra; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/CG-DNA/fix_nve_dotc_langevin.cpp b/src/CG-DNA/fix_nve_dotc_langevin.cpp index 56436a3a983..8151cbe4fea 100644 --- a/src/CG-DNA/fix_nve_dotc_langevin.cpp +++ b/src/CG-DNA/fix_nve_dotc_langevin.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathExtra; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/CG-SPICA/angle_spica.cpp b/src/CG-SPICA/angle_spica.cpp index 3f8a506ed26..45b28d812a3 100644 --- a/src/CG-SPICA/angle_spica.cpp +++ b/src/CG-SPICA/angle_spica.cpp @@ -39,7 +39,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace LJSPICAParms; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/CLASS2/angle_class2.cpp b/src/CLASS2/angle_class2.cpp index c731a4d5c9a..1dbaaf05684 100644 --- a/src/CLASS2/angle_class2.cpp +++ b/src/CLASS2/angle_class2.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/CLASS2/dihedral_class2.cpp b/src/CLASS2/dihedral_class2.cpp index d49d50f0e6a..288fac2e923 100644 --- a/src/CLASS2/dihedral_class2.cpp +++ b/src/CLASS2/dihedral_class2.cpp @@ -32,8 +32,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.0000001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.0000001; /* ---------------------------------------------------------------------- */ diff --git a/src/CLASS2/improper_class2.cpp b/src/CLASS2/improper_class2.cpp index 1e172757b0b..e2f5ffe01b6 100644 --- a/src/CLASS2/improper_class2.cpp +++ b/src/CLASS2/improper_class2.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/COLLOID/pair_brownian.cpp b/src/COLLOID/pair_brownian.cpp index 82be043df02..46892da1aad 100644 --- a/src/COLLOID/pair_brownian.cpp +++ b/src/COLLOID/pair_brownian.cpp @@ -42,10 +42,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -// same as fix_wall.cpp - -enum { EDGE, CONSTANT, VARIABLE }; - /* ---------------------------------------------------------------------- */ PairBrownian::PairBrownian(LAMMPS *lmp) : Pair(lmp) @@ -110,7 +106,7 @@ void PairBrownian::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -506,7 +502,7 @@ void PairBrownian::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_brownian_poly.cpp b/src/COLLOID/pair_brownian_poly.cpp index 1e04b8dc2ad..95db05544a8 100644 --- a/src/COLLOID/pair_brownian_poly.cpp +++ b/src/COLLOID/pair_brownian_poly.cpp @@ -42,10 +42,6 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairBrownianPoly::PairBrownianPoly(LAMMPS *lmp) : PairBrownian(lmp) @@ -95,7 +91,7 @@ void PairBrownianPoly::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -376,7 +372,7 @@ void PairBrownianPoly::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); // Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricate.cpp b/src/COLLOID/pair_lubricate.cpp index 6f07d63bfb6..067158b4bc7 100644 --- a/src/COLLOID/pair_lubricate.cpp +++ b/src/COLLOID/pair_lubricate.cpp @@ -41,10 +41,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{NONE=0,EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricate::PairLubricate(LAMMPS *lmp) : Pair(lmp) @@ -169,7 +165,7 @@ void PairLubricate::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -593,7 +589,7 @@ void PairLubricate::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU.cpp b/src/COLLOID/pair_lubricateU.cpp index ac1e62c2a25..218d1042f72 100644 --- a/src/COLLOID/pair_lubricateU.cpp +++ b/src/COLLOID/pair_lubricateU.cpp @@ -40,11 +40,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOL 1E-4 // tolerance for conjugate gradient - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; +static constexpr double TOL = 1e-4; // tolerance for conjugate gradient /* ---------------------------------------------------------------------- */ @@ -595,7 +591,7 @@ void PairLubricateU::compute_Fh(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -827,7 +823,7 @@ void PairLubricateU::compute_RU() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1098,7 +1094,7 @@ void PairLubricateU::compute_RU(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1819,7 +1815,7 @@ void PairLubricateU::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLLOID/pair_lubricateU_poly.cpp b/src/COLLOID/pair_lubricateU_poly.cpp index 297c4e1924b..af7e4d1de33 100644 --- a/src/COLLOID/pair_lubricateU_poly.cpp +++ b/src/COLLOID/pair_lubricateU_poly.cpp @@ -41,12 +41,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOL 1E-3 // tolerance for conjugate gradient - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - +static constexpr double TOL = 1e-3; // tolerance for conjugate gradient /* ---------------------------------------------------------------------- */ @@ -365,7 +360,7 @@ void PairLubricateUPoly::compute_Fh(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -640,7 +635,7 @@ void PairLubricateUPoly::compute_RU(double **x) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -1161,9 +1156,7 @@ void PairLubricateUPoly::init_style() flagdeform = 1; else if (strstr(modify->fix[i]->style,"wall") != nullptr) { if (flagwall) - error->all(FLERR, - "Cannot use multiple fix wall commands with " - "pair lubricateU"); + error->all(FLERR, "Cannot use multiple fix wall commands with pair lubricateU/poly"); flagwall = 1; // Walls exist wallfix = dynamic_cast(modify->fix[i]); if (wallfix->xflag) flagwall = 2; // Moving walls exist @@ -1184,7 +1177,7 @@ void PairLubricateUPoly::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); @@ -1214,14 +1207,8 @@ void PairLubricateUPoly::init_style() if (!flagVF) vol_f = 0; - if (!comm->me) { - if (logfile) - fprintf(logfile, "lubricateU: vol_f = %g, vol_p = %g, vol_T = %g\n", - vol_f,vol_P,vol_T); - if (screen) - fprintf(screen, "lubricateU: vol_f = %g, vol_p = %g, vol_T = %g\n", - vol_f,vol_P,vol_T); - } + if (comm->me == 0) + utils::logmesg(lmp, "lubricateU: vol_f = {}, vol_p = {}, vol_T = {}\n", vol_f, vol_P, vol_T); // Set the isotropic constant diff --git a/src/COLLOID/pair_lubricate_poly.cpp b/src/COLLOID/pair_lubricate_poly.cpp index e6a0606e87c..b989a8f04ba 100644 --- a/src/COLLOID/pair_lubricate_poly.cpp +++ b/src/COLLOID/pair_lubricate_poly.cpp @@ -41,10 +41,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricatePoly::PairLubricatePoly(LAMMPS *lmp) : PairLubricate(lmp) @@ -151,7 +147,7 @@ void PairLubricatePoly::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; @@ -498,7 +494,7 @@ void PairLubricatePoly::init_style() for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallfix->xindex[m] = input->variable->find(wallfix->xstr[m]); //Since fix->wall->init happens after pair->init_style wallcoord = input->variable->compute_equal(wallfix->xindex[m]); diff --git a/src/COLVARS/ndx_group.cpp b/src/COLVARS/ndx_group.cpp index 1d24db3900a..062f17619a6 100644 --- a/src/COLVARS/ndx_group.cpp +++ b/src/COLVARS/ndx_group.cpp @@ -26,8 +26,8 @@ #include "tokenizer.h" using namespace LAMMPS_NS; -#define BUFLEN 4096 -#define DELTA 16384 +static constexpr int BUFLEN = 4096; +static constexpr int DELTA = 16384; // read file until next section "name" or any next section if name == "" diff --git a/src/COMPRESS/dump_cfg_gz.cpp b/src/COMPRESS/dump_cfg_gz.cpp index 259056c0133..e4d5ae76cca 100644 --- a/src/COMPRESS/dump_cfg_gz.cpp +++ b/src/COMPRESS/dump_cfg_gz.cpp @@ -22,7 +22,7 @@ #include using namespace LAMMPS_NS; -#define UNWRAPEXPAND 10.0 +static constexpr double UNWRAPEXPAND = 10.0; DumpCFGGZ::DumpCFGGZ(LAMMPS *lmp, int narg, char **arg) : DumpCFG(lmp, narg, arg) { diff --git a/src/COMPRESS/dump_cfg_zstd.cpp b/src/COMPRESS/dump_cfg_zstd.cpp index e3f9a7c1f9e..c52f9e0942e 100644 --- a/src/COMPRESS/dump_cfg_zstd.cpp +++ b/src/COMPRESS/dump_cfg_zstd.cpp @@ -28,7 +28,7 @@ #include using namespace LAMMPS_NS; -#define UNWRAPEXPAND 10.0 +static constexpr double UNWRAPEXPAND = 10.0; DumpCFGZstd::DumpCFGZstd(LAMMPS *lmp, int narg, char **arg) : DumpCFG(lmp, narg, arg) { diff --git a/src/CORESHELL/pair_born_coul_dsf_cs.cpp b/src/CORESHELL/pair_born_coul_dsf_cs.cpp index 9e0ac11c788..9edcf2755d5 100644 --- a/src/CORESHELL/pair_born_coul_dsf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_dsf_cs.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_born_coul_long_cs.cpp b/src/CORESHELL/pair_born_coul_long_cs.cpp index 3a3dc39d692..c29bd5c31dc 100644 --- a/src/CORESHELL/pair_born_coul_long_cs.cpp +++ b/src/CORESHELL/pair_born_coul_long_cs.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; #define B4 -5.80844129e-3 #define B5 1.14652755e-1 -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; #define EPS_EWALD 1.0e-6 #define EPS_EWALD_SQR 1.0e-12 diff --git a/src/CORESHELL/pair_born_coul_wolf_cs.cpp b/src/CORESHELL/pair_born_coul_wolf_cs.cpp index 4765e1575ca..47241c0bebe 100644 --- a/src/CORESHELL/pair_born_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_born_coul_wolf_cs.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_buck_coul_long_cs.cpp b/src/CORESHELL/pair_buck_coul_long_cs.cpp index 6b15e8dfe53..96203deae1c 100644 --- a/src/CORESHELL/pair_buck_coul_long_cs.cpp +++ b/src/CORESHELL/pair_buck_coul_long_cs.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; #define B4 -5.80844129e-3 #define B5 1.14652755e-1 -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; #define EPS_EWALD 1.0e-6 #define EPS_EWALD_SQR 1.0e-12 diff --git a/src/CORESHELL/pair_coul_long_cs.cpp b/src/CORESHELL/pair_coul_long_cs.cpp index 5148ffda2d7..6af9a306396 100644 --- a/src/CORESHELL/pair_coul_long_cs.cpp +++ b/src/CORESHELL/pair_coul_long_cs.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; #define B4 -5.80844129e-3 #define B5 1.14652755e-1 -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; #define EPS_EWALD 1.0e-6 #define EPS_EWALD_SQR 1.0e-12 diff --git a/src/CORESHELL/pair_coul_wolf_cs.cpp b/src/CORESHELL/pair_coul_wolf_cs.cpp index 5e15493aade..6deb66735b7 100644 --- a/src/CORESHELL/pair_coul_wolf_cs.cpp +++ b/src/CORESHELL/pair_coul_wolf_cs.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; /* ---------------------------------------------------------------------- */ diff --git a/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp b/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp index 1cbddf06143..577bc2e6dfe 100644 --- a/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp +++ b/src/CORESHELL/pair_lj_class2_coul_long_cs.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; #define B4 -5.80844129e-3 #define B5 1.14652755e-1 -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; #define EPS_EWALD 1.0e-6 #define EPS_EWALD_SQR 1.0e-12 diff --git a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp index 253ae440b0a..d5fd66e3820 100644 --- a/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp +++ b/src/CORESHELL/pair_lj_cut_coul_long_cs.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; #define B4 -5.80844129e-3 #define B5 1.14652755e-1 -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; #define EPS_EWALD 1.0e-6 #define EPS_EWALD_SQR 1.0e-12 diff --git a/src/DIELECTRIC/pppm_dielectric.cpp b/src/DIELECTRIC/pppm_dielectric.cpp index e308cb0826a..dac24a98383 100644 --- a/src/DIELECTRIC/pppm_dielectric.cpp +++ b/src/DIELECTRIC/pppm_dielectric.cpp @@ -36,18 +36,13 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; enum {REVERSE_RHO}; enum {FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ diff --git a/src/DIELECTRIC/pppm_disp_dielectric.cpp b/src/DIELECTRIC/pppm_disp_dielectric.cpp index 2c4de6ada15..baa9478a459 100644 --- a/src/DIELECTRIC/pppm_disp_dielectric.cpp +++ b/src/DIELECTRIC/pppm_disp_dielectric.cpp @@ -33,11 +33,11 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXORDER 7 -#define OFFSET 16384 -#define SMALL 0.00001 -#define LARGE 10000.0 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double SMALL = 0.00001; +static constexpr double LARGE = 10000.0; +static constexpr double EPS_HOC = 1.0e-7; enum{REVERSE_RHO,REVERSE_RHO_GEOM,REVERSE_RHO_ARITH,REVERSE_RHO_NONE}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, @@ -48,13 +48,8 @@ enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, FORWARD_IK_NONE,FORWARD_AD_NONE,FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-BASIC/pair_dpd.cpp b/src/DPD-BASIC/pair_dpd.cpp index 5771831e022..1f600742804 100644 --- a/src/DPD-BASIC/pair_dpd.cpp +++ b/src/DPD-BASIC/pair_dpd.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-BASIC/pair_dpd_ext.cpp b/src/DPD-BASIC/pair_dpd_ext.cpp index 623b16774cc..da08e53a4a7 100644 --- a/src/DPD-BASIC/pair_dpd_ext.cpp +++ b/src/DPD-BASIC/pair_dpd_ext.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-BASIC/pair_dpd_ext_tstat.cpp b/src/DPD-BASIC/pair_dpd_ext_tstat.cpp index 433bc54063c..fe881d7bc53 100644 --- a/src/DPD-BASIC/pair_dpd_ext_tstat.cpp +++ b/src/DPD-BASIC/pair_dpd_ext_tstat.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-BASIC/pair_dpd_tstat.cpp b/src/DPD-BASIC/pair_dpd_tstat.cpp index ed659e7cc3c..108177ed69c 100644 --- a/src/DPD-BASIC/pair_dpd_tstat.cpp +++ b/src/DPD-BASIC/pair_dpd_tstat.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-MESO/pair_edpd.cpp b/src/DPD-MESO/pair_edpd.cpp index ed99a5eac1d..b575956f71e 100644 --- a/src/DPD-MESO/pair_edpd.cpp +++ b/src/DPD-MESO/pair_edpd.cpp @@ -38,7 +38,7 @@ using namespace LAMMPS_NS; #define MIN(A,B) ((A) < (B) ? (A) : (B)) #define MAX(A,B) ((A) > (B) ? (A) : (B)) -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; static const char cite_pair_edpd[] = "pair edpd command: doi:10.1016/j.jcp.2014.02.003\n\n" diff --git a/src/DPD-MESO/pair_mdpd.cpp b/src/DPD-MESO/pair_mdpd.cpp index 767fddd7acd..de148189e01 100644 --- a/src/DPD-MESO/pair_mdpd.cpp +++ b/src/DPD-MESO/pair_mdpd.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; static const char cite_pair_mdpd[] = "pair mdpd command: doi:10.1063/1.4812366\n\n" diff --git a/src/DPD-MESO/pair_tdpd.cpp b/src/DPD-MESO/pair_tdpd.cpp index eac5bd1318e..038b3c3cdcb 100644 --- a/src/DPD-MESO/pair_tdpd.cpp +++ b/src/DPD-MESO/pair_tdpd.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; #define MIN(A,B) ((A) < (B) ? (A) : (B)) #define MAX(A,B) ((A) > (B) ? (A) : (B)) -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; static const char cite_pair_tdpd[] = "pair tdpd command: doi:10.1063/1.4923254\n\n" diff --git a/src/DPD-REACT/fix_eos_table.cpp b/src/DPD-REACT/fix_eos_table.cpp index 36bbe4d478b..42567119dfc 100644 --- a/src/DPD-REACT/fix_eos_table.cpp +++ b/src/DPD-REACT/fix_eos_table.cpp @@ -24,7 +24,7 @@ #include -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; using namespace LAMMPS_NS; using namespace FixConst; @@ -194,7 +194,7 @@ void FixEOStable::free_table(Table *tb) void FixEOStable::read_table(Table *tb, Table *tb2, char *file, char *keyword) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file diff --git a/src/DPD-REACT/fix_eos_table_rx.cpp b/src/DPD-REACT/fix_eos_table_rx.cpp index f7afddc64f5..bf71b502f05 100644 --- a/src/DPD-REACT/fix_eos_table_rx.cpp +++ b/src/DPD-REACT/fix_eos_table_rx.cpp @@ -28,12 +28,12 @@ #include #include -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; #ifdef DBL_EPSILON - #define MY_EPSILON (10.0*DBL_EPSILON) +static constexpr double MY_EPSILON = 10.0*DBL_EPSILON; #else - #define MY_EPSILON (10.0*2.220446049250313e-16) +static constexpr double MY_EPSILON = 10.0*2.220446049250313e-16; #endif using namespace LAMMPS_NS; @@ -318,7 +318,8 @@ void FixEOStableRX::read_file(char *file) // one set of params can span multiple lines int n,nwords,ispecies; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { @@ -414,7 +415,7 @@ void FixEOStableRX::free_table(Table *tb) void FixEOStableRX::read_table(Table *tb, Table *tb2, char *file, char *keyword) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file diff --git a/src/DPD-REACT/fix_rx.cpp b/src/DPD-REACT/fix_rx.cpp index cce88cf4652..69eab4dbee4 100644 --- a/src/DPD-REACT/fix_rx.cpp +++ b/src/DPD-REACT/fix_rx.cpp @@ -38,16 +38,16 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathSpecial; -enum{NONE,HARMONIC}; -enum{LUCY}; +enum { NONE, HARMONIC }; +enum { LUCY }; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; #ifdef DBL_EPSILON - #define MY_EPSILON (10.0*DBL_EPSILON) +static constexpr double MY_EPSILON = 10.0*DBL_EPSILON; #else - #define MY_EPSILON (10.0*2.220446049250313e-16) +static constexpr double MY_EPSILON = 10.0*2.220446049250313e-16; #endif #define SparseKinetics_enableIntegralReactions (true) @@ -250,7 +250,8 @@ void FixRX::post_constructor() // Assign species names to tmpspecies array and determine the number of unique species int n; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; char * word; @@ -784,7 +785,8 @@ void FixRX::read_file(char *file) // Count the number of reactions from kinetics file int n,ispecies; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { diff --git a/src/DPD-REACT/fix_shardlow.cpp b/src/DPD-REACT/fix_shardlow.cpp index 19f2c08a5fd..747d2725b83 100644 --- a/src/DPD-REACT/fix_shardlow.cpp +++ b/src/DPD-REACT/fix_shardlow.cpp @@ -59,7 +59,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace random_external_state; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; #define EPSILON_SQUARED ((EPSILON) * (EPSILON)) static const char cite_fix_shardlow[] = diff --git a/src/DPD-REACT/pair_dpd_fdt.cpp b/src/DPD-REACT/pair_dpd_fdt.cpp index e6cab0e9964..44920a6bdac 100644 --- a/src/DPD-REACT/pair_dpd_fdt.cpp +++ b/src/DPD-REACT/pair_dpd_fdt.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-REACT/pair_dpd_fdt_energy.cpp b/src/DPD-REACT/pair_dpd_fdt_energy.cpp index d3371f465a6..12d6dc5fb76 100644 --- a/src/DPD-REACT/pair_dpd_fdt_energy.cpp +++ b/src/DPD-REACT/pair_dpd_fdt_energy.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/DPD-REACT/pair_exp6_rx.cpp b/src/DPD-REACT/pair_exp6_rx.cpp index c6b831f84b4..e0ac9c0b27e 100644 --- a/src/DPD-REACT/pair_exp6_rx.cpp +++ b/src/DPD-REACT/pair_exp6_rx.cpp @@ -31,13 +31,13 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; #ifdef DBL_EPSILON - #define MY_EPSILON (10.0*DBL_EPSILON) +static constexpr double MY_EPSILON = 10.0*DBL_EPSILON; #else - #define MY_EPSILON (10.0*2.220446049250313e-16) +static constexpr double MY_EPSILON = 10.0*2.220446049250313e-16; #endif #define oneFluidApproxParameter (-1) @@ -728,7 +728,8 @@ void PairExp6rx::read_file(char *file) // one set of params can span multiple lines int n,nwords,ispecies; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { @@ -835,7 +836,8 @@ void PairExp6rx::read_file2(char *file) // one set of params can span multiple lines int n,nwords; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { diff --git a/src/DPD-REACT/pair_multi_lucy.cpp b/src/DPD-REACT/pair_multi_lucy.cpp index 89263dd445e..918246dcde0 100644 --- a/src/DPD-REACT/pair_multi_lucy.cpp +++ b/src/DPD-REACT/pair_multi_lucy.cpp @@ -39,9 +39,8 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -enum{NONE,RLINEAR,RSQ}; - -#define MAXLINE 1024 +enum { NONE, RLINEAR, RSQ }; +static constexpr int MAXLINE = 1024; static const char cite_pair_multi_lucy[] = "pair_style multi/lucy command: doi:10.1063/1.4942520\n\n" @@ -344,7 +343,7 @@ double PairMultiLucy::init_one(int i, int j) void PairMultiLucy::read_table(Table *tb, char *file, char *keyword) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file diff --git a/src/DPD-REACT/pair_multi_lucy_rx.cpp b/src/DPD-REACT/pair_multi_lucy_rx.cpp index 96209085310..5ff03de6e73 100644 --- a/src/DPD-REACT/pair_multi_lucy_rx.cpp +++ b/src/DPD-REACT/pair_multi_lucy_rx.cpp @@ -41,14 +41,14 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -enum{NONE,RLINEAR,RSQ}; +enum{ NONE, RLINEAR, RSQ }; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; #ifdef DBL_EPSILON - #define MY_EPSILON (10.0*DBL_EPSILON) +static constexpr double MY_EPSILON = 10.0*DBL_EPSILON; #else - #define MY_EPSILON (10.0*2.220446049250313e-16) +static constexpr double MY_EPSILON = 10.0*2.220446049250313e-16; #endif #define oneFluidParameter (-1) @@ -483,16 +483,13 @@ double PairMultiLucyRX::init_one(int i, int j) void PairMultiLucyRX::read_table(Table *tb, char *file, char *keyword) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file FILE *fp = utils::open_potential(file,lmp,nullptr); - if (fp == nullptr) { - char str[128]; - snprintf(str,128,"Cannot open file %s",file); - error->one(FLERR,str); - } + if (fp == nullptr) + error->one(FLERR, "Cannot open file {}: {}",file,utils::getsyserror()); // loop until section found with matching keyword diff --git a/src/DRUDE/fix_tgnh_drude.cpp b/src/DRUDE/fix_tgnh_drude.cpp index b23acd349be..c067bf7adfa 100644 --- a/src/DRUDE/fix_tgnh_drude.cpp +++ b/src/DRUDE/fix_tgnh_drude.cpp @@ -40,8 +40,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{NONE,XYZ,XY,YZ,XZ}; diff --git a/src/DRUDE/pair_lj_cut_thole_long.cpp b/src/DRUDE/pair_lj_cut_thole_long.cpp index cfdf631eb99..a11fc691b1c 100644 --- a/src/DRUDE/pair_lj_cut_thole_long.cpp +++ b/src/DRUDE/pair_lj_cut_thole_long.cpp @@ -46,7 +46,7 @@ using namespace MathConst; #define B4 -5.80844129e-3 #define B5 1.14652755e-1 -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; #define EPS_EWALD 1.0e-6 #define EPS_EWALD_SQR 1.0e-12 diff --git a/src/EFF/fix_langevin_eff.cpp b/src/EFF/fix_langevin_eff.cpp index a25b6ac8374..72c368b6124 100644 --- a/src/EFF/fix_langevin_eff.cpp +++ b/src/EFF/fix_langevin_eff.cpp @@ -37,8 +37,8 @@ using namespace FixConst; enum{NOBIAS,BIAS}; enum{CONSTANT,EQUAL,ATOM}; -#define SINERTIA 0.4 // moment of inertia prefactor for sphere -#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double SINERTIA = 0.4; // moment of inertia prefactor for sphere +static constexpr double EINERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/ELECTRODE/ewald_electrode.cpp b/src/ELECTRODE/ewald_electrode.cpp index 99266ed4505..122708b97d1 100644 --- a/src/ELECTRODE/ewald_electrode.cpp +++ b/src/ELECTRODE/ewald_electrode.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/ELECTRODE/fix_electrode_conp.cpp b/src/ELECTRODE/fix_electrode_conp.cpp index 1b6c0a37d4c..9e2599ca8ad 100644 --- a/src/ELECTRODE/fix_electrode_conp.cpp +++ b/src/ELECTRODE/fix_electrode_conp.cpp @@ -48,7 +48,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 1e-16 +static constexpr double SMALL = 1e-16; extern "C" { void dgetrf_(const int *M, const int *N, double *A, const int *lda, int *ipiv, int *info); diff --git a/src/ELECTRODE/fix_electrode_thermo.cpp b/src/ELECTRODE/fix_electrode_thermo.cpp index 52c0a3ce4cf..f95aeac6150 100644 --- a/src/ELECTRODE/fix_electrode_thermo.cpp +++ b/src/ELECTRODE/fix_electrode_thermo.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; #define NUM_GROUPS 2 -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ----------------------------------------------------------------------- */ diff --git a/src/ELECTRODE/pppm_electrode.cpp b/src/ELECTRODE/pppm_electrode.cpp index 0ae3da68633..b9024cd69a3 100644 --- a/src/ELECTRODE/pppm_electrode.cpp +++ b/src/ELECTRODE/pppm_electrode.cpp @@ -45,22 +45,17 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double LARGE = 10000.0; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; enum { REVERSE_RHO }; enum { FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM }; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; static const char cite_pppm_electrode[] = "kspace_style pppm/electrode command:\n\n" diff --git a/src/ELECTRODE/slab_dipole.cpp b/src/ELECTRODE/slab_dipole.cpp index d5f3eae7aa4..27ec42a8b55 100644 --- a/src/ELECTRODE/slab_dipole.cpp +++ b/src/ELECTRODE/slab_dipole.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- Slab-geometry correction term to dampen inter-slab interactions between diff --git a/src/EXTRA-COMPUTE/compute_born_matrix.cpp b/src/EXTRA-COMPUTE/compute_born_matrix.cpp index 4eecbbfa14c..2e674409d15 100644 --- a/src/EXTRA-COMPUTE/compute_born_matrix.cpp +++ b/src/EXTRA-COMPUTE/compute_born_matrix.cpp @@ -42,8 +42,7 @@ using namespace LAMMPS_NS; -#define BIG 1000000000 -#define SMALL 1e-16 +static constexpr double SMALL = 1e-16; // this table is used to pick the 3d rij vector indices used to // compute the 6 indices long Voigt stress vector diff --git a/src/EXTRA-COMPUTE/compute_cnp_atom.cpp b/src/EXTRA-COMPUTE/compute_cnp_atom.cpp index 526874d7a44..f42d896f6bd 100644 --- a/src/EXTRA-COMPUTE/compute_cnp_atom.cpp +++ b/src/EXTRA-COMPUTE/compute_cnp_atom.cpp @@ -41,8 +41,8 @@ using namespace LAMMPS_NS; //define maximum values -#define MAXNEAR 24 -#define MAXCOMMON 12 +static constexpr int MAXNEAR = 24; +static constexpr int MAXCOMMON = 12; enum{NCOMMON}; diff --git a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp index e1bc6bcd915..622ea839bec 100644 --- a/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_cartesian.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; -#define SMALL 1.0e-10 +static constexpr double SMALL = 1.0e-10; /*----------------------------------------------------------------------------------- Contributing author: Olav Galteland (Norwegian University of Science and Technology) olav.galteland@ntnu.no diff --git a/src/EXTRA-COMPUTE/compute_stress_mop.cpp b/src/EXTRA-COMPUTE/compute_stress_mop.cpp index 6c35b4ba075..ee8f5e554a2 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop.cpp @@ -39,7 +39,7 @@ using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; enum { X, Y, Z }; enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE, DIHEDRAL }; @@ -773,7 +773,7 @@ void ComputeStressMop::compute_angles() // only left bond crossing the plane - if (!right_cross && left_cross) { + else if (!right_cross && left_cross) { double sgn = copysign(1.0, x_angle_left[dir] - pos); dcos_theta[0] = -sgn * (dx_left[0] * cos_theta / r1 + dx_right[0] / r2) / r1; dcos_theta[1] = -sgn * (dx_left[1] * cos_theta / r1 + dx_right[1] / r2) / r1; @@ -782,7 +782,7 @@ void ComputeStressMop::compute_angles() // both bonds crossing the plane - if (right_cross && left_cross) { + else if (right_cross && left_cross) { // due to right bond @@ -1042,9 +1042,12 @@ void ComputeStressMop::compute_dihedrals() f3[1] = sy2 - f4[1]; f3[2] = sz2 - f4[2]; - // only right bond crossing the plane - if (right_cross && !middle_cross && !left_cross) - { + // no bonds crossing the plane + + if (!right_cross && !middle_cross && !left_cross) continue; + + // onPly right bond crossing the plane + if (right_cross && !middle_cross && !left_cross) { double sgn = copysign(1.0, x_atom_1[dir] - pos); df[0] = sgn * f1[0]; df[1] = sgn * f1[1]; @@ -1052,8 +1055,7 @@ void ComputeStressMop::compute_dihedrals() } // only middle bond crossing the plane - if (!right_cross && middle_cross && !left_cross) - { + else if (!right_cross && middle_cross && !left_cross) { double sgn = copysign(1.0, x_atom_2[dir] - pos); df[0] = sgn * (f2[0] + f1[0]); df[1] = sgn * (f2[1] + f1[1]); @@ -1061,8 +1063,7 @@ void ComputeStressMop::compute_dihedrals() } // only left bond crossing the plane - if (!right_cross && !middle_cross && left_cross) - { + else if (!right_cross && !middle_cross && left_cross) { double sgn = copysign(1.0, x_atom_4[dir] - pos); df[0] = sgn * f4[0]; df[1] = sgn * f4[1]; @@ -1070,8 +1071,7 @@ void ComputeStressMop::compute_dihedrals() } // only right & middle bonds crossing the plane - if (right_cross && middle_cross && !left_cross) - { + else if (right_cross && middle_cross && !left_cross) { double sgn = copysign(1.0, x_atom_2[dir] - pos); df[0] = sgn * f2[0]; df[1] = sgn * f2[1]; @@ -1079,8 +1079,7 @@ void ComputeStressMop::compute_dihedrals() } // only right & left bonds crossing the plane - if (right_cross && !middle_cross && left_cross) - { + else if (right_cross && !middle_cross && left_cross) { double sgn = copysign(1.0, x_atom_1[dir] - pos); df[0] = sgn * (f1[0] + f4[0]); df[1] = sgn * (f1[1] + f4[1]); @@ -1088,8 +1087,7 @@ void ComputeStressMop::compute_dihedrals() } // only middle & left bonds crossing the plane - if (!right_cross && middle_cross && left_cross) - { + else if (!right_cross && middle_cross && left_cross) { double sgn = copysign(1.0, x_atom_3[dir] - pos); df[0] = sgn * f3[0]; df[1] = sgn * f3[1]; @@ -1097,14 +1095,12 @@ void ComputeStressMop::compute_dihedrals() } // all three bonds crossing the plane - if (right_cross && middle_cross && left_cross) - { + else if (right_cross && middle_cross && left_cross) { double sgn = copysign(1.0, x_atom_1[dir] - pos); df[0] = sgn * (f1[0] + f3[0]); df[1] = sgn * (f1[1] + f3[1]); df[2] = sgn * (f1[2] + f3[2]); } - local_contribution[0] += df[0]/area*nktv2p; local_contribution[1] += df[1]/area*nktv2p; local_contribution[2] += df[2]/area*nktv2p; diff --git a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp index 41b5f64a675..676b0f5796c 100644 --- a/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_mop_profile.cpp @@ -39,7 +39,7 @@ using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; enum { X, Y, Z }; enum { TOTAL, CONF, KIN, PAIR, BOND, ANGLE, DIHEDRAL }; diff --git a/src/EXTRA-COMPUTE/compute_stress_spherical.cpp b/src/EXTRA-COMPUTE/compute_stress_spherical.cpp index db20ab67068..983d31559d1 100644 --- a/src/EXTRA-COMPUTE/compute_stress_spherical.cpp +++ b/src/EXTRA-COMPUTE/compute_stress_spherical.cpp @@ -34,7 +34,7 @@ using namespace MathConst; using MathSpecial::cube; using MathSpecial::square; -#define SMALL 1.0e-10 +static constexpr double SMALL = 1.0e-10; /*----------------------------------------------------------------------------------- Contributing author: Olav Galteland (Norwegian University of Science and Technology) diff --git a/src/EXTRA-FIX/fix_ffl.cpp b/src/EXTRA-FIX/fix_ffl.cpp index 0a06707fbd3..3039d338fc3 100644 --- a/src/EXTRA-FIX/fix_ffl.cpp +++ b/src/EXTRA-FIX/fix_ffl.cpp @@ -43,7 +43,7 @@ enum {CONSTANT,EQUAL,ATOM}; enum {NO_FLIP, FLIP_RESCALE, FLIP_HARD, FLIP_SOFT}; //#define FFL_DEBUG 1 -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* syntax for fix_ffl: * fix nfix id-group ffl tau Tstart Tstop seed [flip_type] diff --git a/src/EXTRA-FIX/fix_filter_corotate.cpp b/src/EXTRA-FIX/fix_filter_corotate.cpp index c88969344a0..74d1d184865 100644 --- a/src/EXTRA-FIX/fix_filter_corotate.cpp +++ b/src/EXTRA-FIX/fix_filter_corotate.cpp @@ -42,8 +42,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace FixConst; -#define BIG 1.0e20 -#define MASSDELTA 0.1 +static constexpr double BIG = 1.0e20; +static constexpr double MASSDELTA = 0.1; static const char cite_filter_corotate[] = "Mollified Impulse Method with Corotational Filter: doi:10.1016/j.jcp.2016.12.024\n\n" diff --git a/src/EXTRA-FIX/fix_gle.cpp b/src/EXTRA-FIX/fix_gle.cpp index c5a6c974f6b..a65b60377e6 100644 --- a/src/EXTRA-FIX/fix_gle.cpp +++ b/src/EXTRA-FIX/fix_gle.cpp @@ -41,7 +41,7 @@ enum{CONSTANT,EQUAL,ATOM}; //#define GLE_DEBUG 1 -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* syntax for fix_gle: * fix nfix id-group gle ns Tstart Tstop seed amatrix [noneq cmatrix] [every nmts] diff --git a/src/EXTRA-FIX/fix_npt_cauchy.cpp b/src/EXTRA-FIX/fix_npt_cauchy.cpp index f3dfd1af367..8eb6a80b6de 100644 --- a/src/EXTRA-FIX/fix_npt_cauchy.cpp +++ b/src/EXTRA-FIX/fix_npt_cauchy.cpp @@ -42,8 +42,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{NONE,XYZ,XY,YZ,XZ}; @@ -91,8 +91,6 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : omega_mass_flag = 0; etap_mass_flag = 0; flipflag = 1; - dipole_flag = 0; - dlm_flag = 0; tcomputeflag = 0; pcomputeflag = 0; @@ -327,14 +325,6 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); flipflag = utils::logical(FLERR,arg[iarg+1],false,lmp); iarg += 2; - } else if (strcmp(arg[iarg],"update") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix npt/cauchy command"); - if (strcmp(arg[iarg+1],"dipole") == 0) dipole_flag = 1; - else if (strcmp(arg[iarg+1],"dipole/dlm") == 0) { - dipole_flag = 1; - dlm_flag = 1; - } else error->all(FLERR,"Illegal fix npt/cauchy command"); - iarg += 2; } else if (strcmp(arg[iarg],"alpha") == 0) { alpha = utils::numeric(FLERR,arg[iarg+1],false,lmp); iarg += 2; @@ -349,20 +339,6 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : fixedpoint[2] = utils::numeric(FLERR,arg[iarg+3],false,lmp); iarg += 4; - // disc keyword is also parsed in fix/nh/sphere - - } else if (strcmp(arg[iarg],"disc") == 0) { - iarg++; - - // keywords erate, strain, and ext are also parsed in fix/nh/uef - - } else if (strcmp(arg[iarg],"erate") == 0) { - iarg += 3; - } else if (strcmp(arg[iarg],"strain") == 0) { - iarg += 3; - } else if (strcmp(arg[iarg],"ext") == 0) { - iarg += 2; - } else error->all(FLERR,"Illegal fix npt/cauchy command"); } @@ -453,13 +429,6 @@ FixNPTCauchy::FixNPTCauchy(LAMMPS *lmp, int narg, char **arg) : p_period[0] != p_period[2])) error->all(FLERR,"Invalid fix npt/cauchy pressure settings"); - if (dipole_flag) { - if (!atom->sphere_flag) - error->all(FLERR,"Using update dipole flag requires atom style sphere"); - if (!atom->mu_flag) - error->all(FLERR,"Using update dipole flag requires atom attribute mu"); - } - if ((tstat_flag && t_period <= 0.0) || (p_flag[0] && p_period[0] <= 0.0) || (p_flag[1] && p_period[1] <= 0.0) || diff --git a/src/EXTRA-FIX/fix_npt_cauchy.h b/src/EXTRA-FIX/fix_npt_cauchy.h index 43a944acb4d..4a738e48abf 100644 --- a/src/EXTRA-FIX/fix_npt_cauchy.h +++ b/src/EXTRA-FIX/fix_npt_cauchy.h @@ -117,8 +117,6 @@ class FixNPTCauchy : public Fix { int eta_mass_flag; // 1 if eta_mass updated, 0 if not. int omega_mass_flag; // 1 if omega_mass updated, 0 if not. int etap_mass_flag; // 1 if etap_mass updated, 0 if not. - int dipole_flag; // 1 if dipole is updated, 0 if not. - int dlm_flag; // 1 if using the DLM rotational integrator, 0 if not int scaleyz; // 1 if yz scaled with lz int scalexz; // 1 if xz scaled with lz diff --git a/src/EXTRA-FIX/fix_smd.cpp b/src/EXTRA-FIX/fix_smd.cpp index e19a605e71e..a9dbfcc2d10 100644 --- a/src/EXTRA-FIX/fix_smd.cpp +++ b/src/EXTRA-FIX/fix_smd.cpp @@ -38,7 +38,7 @@ enum { SMD_NONE=0, SMD_CVEL=1<<2, SMD_CFOR=1<<3, SMD_AUTOX=1<<4, SMD_AUTOY=1<<5, SMD_AUTOZ=1<<6}; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-FIX/fix_tmd.cpp b/src/EXTRA-FIX/fix_tmd.cpp index e88007a29d7..401ed415730 100644 --- a/src/EXTRA-FIX/fix_tmd.cpp +++ b/src/EXTRA-FIX/fix_tmd.cpp @@ -36,8 +36,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define CHUNK 1000 -#define MAXLINE 256 +static constexpr int CHUNK = 1000; +static constexpr int MAXLINE = 256; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-FIX/fix_viscosity.cpp b/src/EXTRA-FIX/fix_viscosity.cpp index a44050636d2..715c30afddf 100644 --- a/src/EXTRA-FIX/fix_viscosity.cpp +++ b/src/EXTRA-FIX/fix_viscosity.cpp @@ -32,7 +32,7 @@ using namespace FixConst; // needs to be big, but not so big that lose precision when subtract velocity -#define BIG 1.0e10 +static constexpr double BIG = 1.0e10; /* ---------------------------------------------------------------------- */ @@ -120,14 +120,14 @@ int FixViscosity::setmask() void FixViscosity::init() { - // warn if any fix ave/spatial comes after this fix + // warn if any fix ave/chunk comes after this fix // can cause glitch in averaging since ave will happen after swap int foundme = 0; - for (int i = 0; i < modify->nfix; i++) { - if (modify->fix[i] == this) foundme = 1; - if (foundme && strcmp(modify->fix[i]->style,"ave/spatial") == 0 && me == 0) - error->warning(FLERR,"Fix viscosity comes before fix ave/spatial"); + for (const auto &ifix : modify->get_fix_list()) { + if (ifix == this) foundme = 1; + if (foundme && utils::strmatch(ifix->style,"^ave/chunk") && (me == 0)) + error->warning(FLERR,"Fix viscosity comes before fix ave/chunk"); } // set bounds of 2 slabs in pdim diff --git a/src/EXTRA-MOLECULE/angle_cosine_delta.cpp b/src/EXTRA-MOLECULE/angle_cosine_delta.cpp index 71acca6001e..51a53e1a964 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_delta.cpp +++ b/src/EXTRA-MOLECULE/angle_cosine_delta.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp b/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp index 245a7b8d584..0b2a6d336d0 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp +++ b/src/EXTRA-MOLECULE/angle_cosine_periodic.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_cosine_shift.cpp b/src/EXTRA-MOLECULE/angle_cosine_shift.cpp index ce9b4c4133c..53ecb35eaf6 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_shift.cpp +++ b/src/EXTRA-MOLECULE/angle_cosine_shift.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_cosine_shift_exp.cpp b/src/EXTRA-MOLECULE/angle_cosine_shift_exp.cpp index a411ea31999..acca92c48e6 100644 --- a/src/EXTRA-MOLECULE/angle_cosine_shift_exp.cpp +++ b/src/EXTRA-MOLECULE/angle_cosine_shift_exp.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_fourier.cpp b/src/EXTRA-MOLECULE/angle_fourier.cpp index c7eb3d4fe48..2c458c07cc1 100644 --- a/src/EXTRA-MOLECULE/angle_fourier.cpp +++ b/src/EXTRA-MOLECULE/angle_fourier.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_fourier_simple.cpp b/src/EXTRA-MOLECULE/angle_fourier_simple.cpp index 0ba890b273e..6de7956ffa7 100644 --- a/src/EXTRA-MOLECULE/angle_fourier_simple.cpp +++ b/src/EXTRA-MOLECULE/angle_fourier_simple.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.0001 +static constexpr double SMALL = 0.0001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/angle_quartic.cpp b/src/EXTRA-MOLECULE/angle_quartic.cpp index eaccdbe6083..aade6b4534d 100644 --- a/src/EXTRA-MOLECULE/angle_quartic.cpp +++ b/src/EXTRA-MOLECULE/angle_quartic.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp b/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp index 7165cde1fdd..36874ee9341 100644 --- a/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp +++ b/src/EXTRA-MOLECULE/dihedral_cosine_shift_exp.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_fourier.cpp b/src/EXTRA-MOLECULE/dihedral_fourier.cpp index f9b4a0d13e5..37e1ae83283 100644 --- a/src/EXTRA-MOLECULE/dihedral_fourier.cpp +++ b/src/EXTRA-MOLECULE/dihedral_fourier.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_helix.cpp b/src/EXTRA-MOLECULE/dihedral_helix.cpp index 1d99de6ba90..0111da9f995 100644 --- a/src/EXTRA-MOLECULE/dihedral_helix.cpp +++ b/src/EXTRA-MOLECULE/dihedral_helix.cpp @@ -32,9 +32,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp b/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp index 206ad4f3ad7..4c3cd3be2c1 100644 --- a/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp +++ b/src/EXTRA-MOLECULE/dihedral_nharmonic.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp index a7c0dc3eb10..1bef5956fa0 100644 --- a/src/EXTRA-MOLECULE/dihedral_quadratic.cpp +++ b/src/EXTRA-MOLECULE/dihedral_quadratic.cpp @@ -32,9 +32,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/dihedral_table_cut.cpp b/src/EXTRA-MOLECULE/dihedral_table_cut.cpp index ce0d431e7c0..a06df279f36 100644 --- a/src/EXTRA-MOLECULE/dihedral_table_cut.cpp +++ b/src/EXTRA-MOLECULE/dihedral_table_cut.cpp @@ -47,8 +47,8 @@ static const char cite_dihedral_tablecut[] = /* ---------------------------------------------------------------------- */ -#define TOLERANCE 0.05 -#define SMALL 0.0000001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.0000001; // ------------------------------------------------------------------------ // The following auxiliary functions were left out of the diff --git a/src/EXTRA-MOLECULE/improper_cossq.cpp b/src/EXTRA-MOLECULE/improper_cossq.cpp index bd21fa12e78..864ec289272 100644 --- a/src/EXTRA-MOLECULE/improper_cossq.cpp +++ b/src/EXTRA-MOLECULE/improper_cossq.cpp @@ -32,8 +32,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/improper_distance.cpp b/src/EXTRA-MOLECULE/improper_distance.cpp index 18f6dd9a3f7..acb962c4f02 100644 --- a/src/EXTRA-MOLECULE/improper_distance.cpp +++ b/src/EXTRA-MOLECULE/improper_distance.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/improper_fourier.cpp b/src/EXTRA-MOLECULE/improper_fourier.cpp index 295657b1b63..1db8b3697cb 100644 --- a/src/EXTRA-MOLECULE/improper_fourier.cpp +++ b/src/EXTRA-MOLECULE/improper_fourier.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/EXTRA-MOLECULE/improper_ring.cpp b/src/EXTRA-MOLECULE/improper_ring.cpp index 36d6277e465..8c570550e4f 100644 --- a/src/EXTRA-MOLECULE/improper_ring.cpp +++ b/src/EXTRA-MOLECULE/improper_ring.cpp @@ -54,8 +54,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/fix_nh_gpu.cpp b/src/GPU/fix_nh_gpu.cpp index 00df278ea81..d15f6c6a7e1 100644 --- a/src/GPU/fix_nh_gpu.cpp +++ b/src/GPU/fix_nh_gpu.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define TILTMAX 1.5 +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{ISO,ANISO,TRICLINIC}; diff --git a/src/GPU/fix_nve_asphere_gpu.cpp b/src/GPU/fix_nve_asphere_gpu.cpp index 481f44bb630..9b75964c791 100644 --- a/src/GPU/fix_nve_asphere_gpu.cpp +++ b/src/GPU/fix_nve_asphere_gpu.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid #define ME_qnormalize(q) \ { \ diff --git a/src/GPU/pair_amoeba_gpu.cpp b/src/GPU/pair_amoeba_gpu.cpp index 1621e1f5b66..569dc125f0e 100644 --- a/src/GPU/pair_amoeba_gpu.cpp +++ b/src/GPU/pair_amoeba_gpu.cpp @@ -51,7 +51,7 @@ enum{GORDON1,GORDON2}; // same as in pair_amoeba.cpp enum{MPOLE_GRID,POLAR_GRID,POLAR_GRIDC,DISP_GRID,INDUCE_GRID,INDUCE_GRIDC}; -#define DEBYE 4.80321 // conversion factor from q-Angs (real units) to Debye +static constexpr double DEBYE = 4.80321; // conversion factor from q-Angs (real units) to Debye // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_born_coul_long_cs_gpu.cpp b/src/GPU/pair_born_coul_long_cs_gpu.cpp index 798caeb97a2..d37f0c53e29 100644 --- a/src/GPU/pair_born_coul_long_cs_gpu.cpp +++ b/src/GPU/pair_born_coul_long_cs_gpu.cpp @@ -42,7 +42,7 @@ using namespace MathConst; #define B4 -5.80844129e-3 #define B5 1.14652755e-1 -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; #define EPS_EWALD 1.0e-6 #define EPS_EWALD_SQR 1.0e-12 diff --git a/src/GPU/pair_born_coul_wolf_cs_gpu.cpp b/src/GPU/pair_born_coul_wolf_cs_gpu.cpp index 98580156225..128863527c2 100644 --- a/src/GPU/pair_born_coul_wolf_cs_gpu.cpp +++ b/src/GPU/pair_born_coul_wolf_cs_gpu.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_coul_long_cs_gpu.cpp b/src/GPU/pair_coul_long_cs_gpu.cpp index 79c4c4ab7ce..bbe50e43514 100644 --- a/src/GPU/pair_coul_long_cs_gpu.cpp +++ b/src/GPU/pair_coul_long_cs_gpu.cpp @@ -40,7 +40,7 @@ using namespace LAMMPS_NS; #define B4 -5.80844129e-3 #define B5 1.14652755e-1 -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; #define EPS_EWALD 1.0e-6 #define EPS_EWALD_SQR 1.0e-12 diff --git a/src/GPU/pair_dpd_gpu.cpp b/src/GPU/pair_dpd_gpu.cpp index e4657cf2ebe..afbdedcd11e 100644 --- a/src/GPU/pair_dpd_gpu.cpp +++ b/src/GPU/pair_dpd_gpu.cpp @@ -53,7 +53,7 @@ void dpd_gpu_compute(const int ago, const int inum_full, const int nall, double double *boxlo, double *prd); double dpd_gpu_bytes(); -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; //#define _USE_UNIFORM_SARU_LCG //#define _USE_UNIFORM_SARU_TEA8 diff --git a/src/GPU/pair_dpd_tstat_gpu.cpp b/src/GPU/pair_dpd_tstat_gpu.cpp index 4a7b05fd2cd..6889a0e0b8e 100644 --- a/src/GPU/pair_dpd_tstat_gpu.cpp +++ b/src/GPU/pair_dpd_tstat_gpu.cpp @@ -55,7 +55,7 @@ void dpd_tstat_gpu_update_coeff(int ntypes, double **host_a0, double **host_gamm double **host_sigma, double **host_cut); double dpd_tstat_gpu_bytes(); -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; //#define _USE_UNIFORM_SARU_LCG //#define _USE_UNIFORM_SARU_TEA8 diff --git a/src/GPU/pair_eam_gpu.cpp b/src/GPU/pair_eam_gpu.cpp index 155da437682..563b3f8284c 100644 --- a/src/GPU/pair_eam_gpu.cpp +++ b/src/GPU/pair_eam_gpu.cpp @@ -29,7 +29,7 @@ #include -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; using namespace LAMMPS_NS; diff --git a/src/GPU/pair_edpd_gpu.cpp b/src/GPU/pair_edpd_gpu.cpp index 5bee0cadb81..b6ea6d9098c 100644 --- a/src/GPU/pair_edpd_gpu.cpp +++ b/src/GPU/pair_edpd_gpu.cpp @@ -58,7 +58,7 @@ void edpd_gpu_get_extra_data(double *host_T, double *host_cv); void edpd_gpu_update_flux(void **flux_ptr); double edpd_gpu_bytes(); -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pair_hippo_gpu.cpp b/src/GPU/pair_hippo_gpu.cpp index 59a95619d7c..7346ffda8c1 100644 --- a/src/GPU/pair_hippo_gpu.cpp +++ b/src/GPU/pair_hippo_gpu.cpp @@ -50,7 +50,7 @@ enum{GORDON1,GORDON2}; // same as in pair_amoeba.cpp enum{MPOLE_GRID,POLAR_GRID,POLAR_GRIDC,DISP_GRID,INDUCE_GRID,INDUCE_GRIDC}; -#define DEBYE 4.80321 // conversion factor from q-Angs (real units) to Debye +static constexpr double DEBYE = 4.80321; // conversion factor from q-Angs (real units) to Debye // External functions from cuda library for atom decomposition diff --git a/src/GPU/pair_mdpd_gpu.cpp b/src/GPU/pair_mdpd_gpu.cpp index bebe1e97360..78861504ee6 100644 --- a/src/GPU/pair_mdpd_gpu.cpp +++ b/src/GPU/pair_mdpd_gpu.cpp @@ -55,7 +55,7 @@ void mdpd_gpu_compute(const int ago, const int inum_full, const int nall, double void mdpd_gpu_get_extra_data(double *host_rho); double mdpd_gpu_bytes(); -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pair_sph_heatconduction_gpu.cpp b/src/GPU/pair_sph_heatconduction_gpu.cpp index 0f0aa079c8b..a81de53c914 100644 --- a/src/GPU/pair_sph_heatconduction_gpu.cpp +++ b/src/GPU/pair_sph_heatconduction_gpu.cpp @@ -53,7 +53,7 @@ void sph_heatconduction_gpu_compute(const int ago, const int inum_full, const in int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal); + double **host_v); void sph_heatconduction_gpu_get_extra_data(double *host_rho, double *host_esph); void sph_heatconduction_gpu_update_dE(void **dE_ptr); double sph_heatconduction_gpu_bytes(); @@ -122,7 +122,7 @@ void PairSPHHeatConductionGPU::compute(int eflag, int vflag) sph_heatconduction_gpu_compute(neighbor->ago, inum, nall, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success, - atom->tag, atom->v, atom->nlocal); + atom->tag, atom->v); } if (!success) error->one(FLERR, "Insufficient memory on accelerator"); diff --git a/src/GPU/pair_sph_lj_gpu.cpp b/src/GPU/pair_sph_lj_gpu.cpp index 942a3c33bd4..46d7b380731 100644 --- a/src/GPU/pair_sph_lj_gpu.cpp +++ b/src/GPU/pair_sph_lj_gpu.cpp @@ -53,7 +53,7 @@ void sph_lj_gpu_compute(const int ago, const int inum_full, const int nall, int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *host_tag, - double **host_v, const int nlocal); + double **host_v); void sph_lj_gpu_get_extra_data(double *host_rho, double *host_esph, double *host_cv); void sph_lj_gpu_update_drhoE(void **drhoE_ptr); @@ -123,7 +123,7 @@ void PairSPHLJGPU::compute(int eflag, int vflag) sph_lj_gpu_compute(neighbor->ago, inum, nall, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success, - atom->tag, atom->v, atom->nlocal); + atom->tag, atom->v); } if (!success) error->one(FLERR, "Insufficient memory on accelerator"); diff --git a/src/GPU/pair_sph_taitwater_gpu.cpp b/src/GPU/pair_sph_taitwater_gpu.cpp index 37a1b0feb5b..6f2762c1441 100644 --- a/src/GPU/pair_sph_taitwater_gpu.cpp +++ b/src/GPU/pair_sph_taitwater_gpu.cpp @@ -53,7 +53,7 @@ void sph_taitwater_gpu_compute(const int ago, const int inum_full, const int nal int **firstneigh, const bool eflag, const bool vflag, const bool eatom, const bool vatom, int &host_start, const double cpu_time, bool &success, tagint *tag, - double **host_v, const int nlocal); + double **host_v); void sph_taitwater_gpu_get_extra_data(double *host_rho); void sph_taitwater_gpu_update_drhoE(void **drhoE_ptr); double sph_taitwater_gpu_bytes(); @@ -118,7 +118,7 @@ void PairSPHTaitwaterGPU::compute(int eflag, int vflag) firstneigh = list->firstneigh; sph_taitwater_gpu_compute(neighbor->ago, inum, nall, atom->x, atom->type, ilist, numneigh, firstneigh, eflag, vflag, eflag_atom, vflag_atom, host_start, cpu_time, success, - atom->tag, atom->v, atom->nlocal); + atom->tag, atom->v); } if (!success) error->one(FLERR, "Insufficient memory on accelerator"); diff --git a/src/GPU/pair_sw_gpu.cpp b/src/GPU/pair_sw_gpu.cpp index 7645218a859..ac604f3a74b 100644 --- a/src/GPU/pair_sw_gpu.cpp +++ b/src/GPU/pair_sw_gpu.cpp @@ -49,8 +49,8 @@ void sw_gpu_compute(const int ago, const int nloc, const int nall, const int ln, const double cpu_time, bool &success); double sw_gpu_bytes(); -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pair_tersoff_gpu.cpp b/src/GPU/pair_tersoff_gpu.cpp index 8610a3880c0..c3c9e6cfab5 100644 --- a/src/GPU/pair_tersoff_gpu.cpp +++ b/src/GPU/pair_tersoff_gpu.cpp @@ -54,8 +54,8 @@ void tersoff_gpu_compute(const int ago, const int nlocal, const int nall, const int &host_start, const double cpu_time, bool &success); double tersoff_gpu_bytes(); -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/GPU/pppm_gpu.cpp b/src/GPU/pppm_gpu.cpp index 1959f00865f..2c092f6a8e5 100644 --- a/src/GPU/pppm_gpu.cpp +++ b/src/GPU/pppm_gpu.cpp @@ -40,22 +40,17 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXORDER 7 -#define OFFSET 16384 -#define SMALL 0.00001 -#define LARGE 10000.0 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double SMALL = 0.00001; +static constexpr double LARGE = 10000.0; +static constexpr double EPS_HOC = 1.0e-7; enum{REVERSE_RHO_GPU,REVERSE_RHO}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; // external functions from cuda library for atom decomposition diff --git a/src/GRANULAR/compute_contact_atom.cpp b/src/GRANULAR/compute_contact_atom.cpp index 310fdb5a418..35bd6fb3e0b 100644 --- a/src/GRANULAR/compute_contact_atom.cpp +++ b/src/GRANULAR/compute_contact_atom.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -67,10 +66,10 @@ ComputeContactAtom::~ComputeContactAtom() void ComputeContactAtom::init() { if (force->pair == nullptr) - error->all(FLERR,"Compute contact/atom requires a pair style be defined"); + error->all(FLERR, "Compute contact/atom requires a pair style be defined"); if (modify->get_compute_by_style("contact/atom").size() > 1 && comm->me == 0) - error->warning(FLERR,"More than one compute contact/atom"); + error->warning(FLERR, "More than one compute contact/atom"); // need an occasional neighbor list @@ -88,10 +87,10 @@ void ComputeContactAtom::init_list(int /*id*/, NeighList *ptr) void ComputeContactAtom::compute_peratom() { - int i,j,ii,jj,inum,jnum; - double xtmp,ytmp,ztmp,delx,dely,delz,rsq; - double radi,radsum,radsumsq; - int *ilist,*jlist,*numneigh,**firstneigh; + int i, j, ii, jj, inum, jnum; + double xtmp, ytmp, ztmp, delx, dely, delz, rsq; + double radi, radsum, radsumsq; + int *ilist, *jlist, *numneigh, **firstneigh; invoked_peratom = update->ntimestep; @@ -100,7 +99,7 @@ void ComputeContactAtom::compute_peratom() if (atom->nmax > nmax) { memory->destroy(contact); nmax = atom->nmax; - memory->create(contact,nmax,"contact/atom:contact"); + memory->create(contact, nmax, "contact/atom:contact"); vector_atom = contact; } @@ -130,7 +129,7 @@ void ComputeContactAtom::compute_peratom() i = ilist[ii]; // Only proceed if i is either part of the compute group or will contribute to contacts - if (! (mask[i] & groupbit) && ! (mask[i] & jgroupbit)) continue; + if (!(mask[i] & groupbit) && !(mask[i] & jgroupbit)) continue; xtmp = x[i][0]; ytmp = x[i][1]; @@ -146,7 +145,7 @@ void ComputeContactAtom::compute_peratom() // Only tally for atoms in compute group (groupbit) if neighbor is in group2 (jgroupbit) update_i_flag = (mask[i] & groupbit) && (mask[j] & jgroupbit); update_j_flag = (mask[j] & groupbit) && (mask[i] & jgroupbit); - if (! update_i_flag && ! update_j_flag) continue; + if (!update_i_flag && !update_j_flag) continue; delx = xtmp - x[j][0]; dely = ytmp - x[j][1]; @@ -170,12 +169,11 @@ void ComputeContactAtom::compute_peratom() int ComputeContactAtom::pack_reverse_comm(int n, int first, double *buf) { - int i,m,last; + int i, m, last; m = 0; last = first + n; - for (i = first; i < last; i++) - buf[m++] = contact[i]; + for (i = first; i < last; i++) buf[m++] = contact[i]; return m; } @@ -183,7 +181,7 @@ int ComputeContactAtom::pack_reverse_comm(int n, int first, double *buf) void ComputeContactAtom::unpack_reverse_comm(int n, int *list, double *buf) { - int i,j,m; + int i, j, m; m = 0; for (i = 0; i < n; i++) { @@ -198,6 +196,6 @@ void ComputeContactAtom::unpack_reverse_comm(int n, int *list, double *buf) double ComputeContactAtom::memory_usage() { - double bytes = (double)nmax * sizeof(double); + double bytes = (double) nmax * sizeof(double); return bytes; } diff --git a/src/GRANULAR/fix_damping_cundall.cpp b/src/GRANULAR/fix_damping_cundall.cpp index cf17e91050a..1b12ad59e54 100644 --- a/src/GRANULAR/fix_damping_cundall.cpp +++ b/src/GRANULAR/fix_damping_cundall.cpp @@ -42,7 +42,7 @@ FixDampingCundall::FixDampingCundall(LAMMPS *_lmp, int narg, char **arg) : if (!atom->sphere_flag) error->all(FLERR, "Fix damping/cundall requires atom style sphere"); - if (narg < 5) error->all(FLERR, "Illegal fix damping/cundall command"); + if (narg < 5) utils::missing_cmd_args(FLERR, "fix damping/cundall", error); gamma_lin = utils::numeric(FLERR, arg[3], false, lmp); gamma_ang = utils::numeric(FLERR, arg[4], false, lmp); diff --git a/src/GRANULAR/fix_wall_gran.cpp b/src/GRANULAR/fix_wall_gran.cpp index 550d2e17dbf..ced30035081 100644 --- a/src/GRANULAR/fix_wall_gran.cpp +++ b/src/GRANULAR/fix_wall_gran.cpp @@ -42,7 +42,7 @@ using namespace FixConst; using namespace MathConst; using namespace MathExtra; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; // XYZ PLANE need to be 0,1,2 @@ -55,7 +55,7 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), idregion(nullptr), tstr(nullptr), history_one(nullptr), fix_rigid(nullptr), mass_rigid(nullptr) { - if (narg < 4) error->all(FLERR,"Illegal fix wall/gran command"); + if (narg < 4) utils::missing_cmd_args(FLERR,"fix wall/gran", error); if (!atom->sphere_flag) error->all(FLERR,"Fix wall/gran requires atom style sphere"); @@ -110,7 +110,7 @@ FixWallGran::FixWallGran(LAMMPS *lmp, int narg, char **arg) : model->limit_damping = 1; iarg += 1; } else { - error->all(FLERR, "Illegal fix wall/gran command"); + error->all(FLERR, "Unknown fix wall/gran keyword {}", arg[iarg]); } } } @@ -281,8 +281,8 @@ FixWallGran::~FixWallGran() // delete local storage delete model; - delete [] tstr; - delete [] idregion; + delete[] tstr; + delete[] idregion; memory->destroy(history_one); memory->destroy(mass_rigid); } diff --git a/src/INTEL/fix_nh_intel.cpp b/src/INTEL/fix_nh_intel.cpp index 688101ab131..5455576a1cd 100644 --- a/src/INTEL/fix_nh_intel.cpp +++ b/src/INTEL/fix_nh_intel.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define TILTMAX 1.5 +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{ISO,ANISO,TRICLINIC}; diff --git a/src/INTEL/fix_nve_asphere_intel.cpp b/src/INTEL/fix_nve_asphere_intel.cpp index 7e429901a41..848afa20cca 100644 --- a/src/INTEL/fix_nve_asphere_intel.cpp +++ b/src/INTEL/fix_nve_asphere_intel.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/INTEL/pair_airebo_intel.cpp b/src/INTEL/pair_airebo_intel.cpp index 7bc2b3edb87..8d2475604b6 100644 --- a/src/INTEL/pair_airebo_intel.cpp +++ b/src/INTEL/pair_airebo_intel.cpp @@ -633,9 +633,8 @@ namespace overloaded { compared to original code. ---------------------------------------------------------------------- */ -#define CARBON 0 -#define HYDROGEN 1 -#define TOL 1.0e-9 +enum { CARBON, HYDROGEN }; +static constexpr double TOL = 1.0e-9; template inline T fmin_nonan(T a, T b) { diff --git a/src/INTEL/pair_eam_intel.cpp b/src/INTEL/pair_eam_intel.cpp index 9c5d6da5e54..03e268bb682 100644 --- a/src/INTEL/pair_eam_intel.cpp +++ b/src/INTEL/pair_eam_intel.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; #define FC_PACKED1_T typename ForceConst::fc_packed1 #define FC_PACKED2_T typename ForceConst::fc_packed2 diff --git a/src/INTEL/pair_snap_intel.cpp b/src/INTEL/pair_snap_intel.cpp index d91f0adc36b..c9a4ed3d5a0 100644 --- a/src/INTEL/pair_snap_intel.cpp +++ b/src/INTEL/pair_snap_intel.cpp @@ -34,8 +34,8 @@ using namespace LAMMPS_NS; using namespace ip_simd; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; +static constexpr int MAXWORD = 3; /* ---------------------------------------------------------------------- */ @@ -445,7 +445,8 @@ void PairSNAPIntel::read_files(char *coefffilename, char *paramfilename) coefffilename, utils::getsyserror()); } - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int nwords = 0; while (nwords == 0) { diff --git a/src/INTEL/pair_sw_intel.cpp b/src/INTEL/pair_sw_intel.cpp index fa62f499de3..61c25692e9e 100644 --- a/src/INTEL/pair_sw_intel.cpp +++ b/src/INTEL/pair_sw_intel.cpp @@ -52,8 +52,8 @@ using namespace LAMMPS_NS; #define FC_PACKED2_T typename ForceConst::fc_packed2 #define FC_PACKED3_T typename ForceConst::fc_packed3 -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/INTEL/pppm_disp_intel.cpp b/src/INTEL/pppm_disp_intel.cpp index 6dac9fad99a..01981f31527 100644 --- a/src/INTEL/pppm_disp_intel.cpp +++ b/src/INTEL/pppm_disp_intel.cpp @@ -39,11 +39,11 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define SMALL 0.00001 -#define LARGE 10000.0 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double SMALL = 0.00001; +static constexpr double LARGE = 10000.0; +static constexpr double EPS_HOC = 1.0e-7; enum{GEOMETRIC,ARITHMETIC,SIXTHPOWER}; enum{REVERSE_RHO, REVERSE_RHO_G, REVERSE_RHO_A, REVERSE_RHO_NONE}; @@ -53,13 +53,8 @@ enum{FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM, FORWARD_IK_NONE, FORWARD_AD_NONE, FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ @@ -268,23 +263,23 @@ void PPPMDispIntel::compute(int eflag, int vflag) //perform calculations for coulomb interactions only if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - particle_map(delxinv, delyinv, delzinv, shift, part2grid, - nupper, nlower, nxlo_out, nylo_out, nzlo_out, - nxhi_out, nyhi_out, nzhi_out, - fix->get_mixed_buffers()); - make_rho_c(fix->get_mixed_buffers()); + particle_map_intel(delxinv, delyinv, delzinv, shift, part2grid, + nupper, nlower, nxlo_out, nylo_out, nzlo_out, + nxhi_out, nyhi_out, nzhi_out, + fix->get_mixed_buffers()); + make_rho_c_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - particle_map(delxinv, delyinv, delzinv, shift, part2grid, - nupper, nlower, nxlo_out, nylo_out, - nzlo_out, nxhi_out, nyhi_out, nzhi_out, - fix->get_double_buffers()); - make_rho_c(fix->get_double_buffers()); + particle_map_intel(delxinv, delyinv, delzinv, shift, part2grid, + nupper, nlower, nxlo_out, nylo_out, + nzlo_out, nxhi_out, nyhi_out, nzhi_out, + fix->get_double_buffers()); + make_rho_c_intel(fix->get_double_buffers()); } else { - particle_map(delxinv, delyinv, delzinv, shift, part2grid, - nupper, nlower, nxlo_out, nylo_out, nzlo_out, - nxhi_out, nyhi_out, nzhi_out, - fix->get_single_buffers()); - make_rho_c(fix->get_single_buffers()); + particle_map_intel(delxinv, delyinv, delzinv, shift, part2grid, + nupper, nlower, nxlo_out, nylo_out, nzlo_out, + nxhi_out, nyhi_out, nzhi_out, + fix->get_single_buffers()); + make_rho_c_intel(fix->get_single_buffers()); } gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO,1,sizeof(FFT_SCALAR), @@ -305,11 +300,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc_buf1,gc_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_c_ad(fix->get_mixed_buffers()); + fieldforce_c_ad_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_c_ad(fix->get_double_buffers()); + fieldforce_c_ad_intel(fix->get_double_buffers()); } else { - fieldforce_c_ad(fix->get_single_buffers()); + fieldforce_c_ad_intel(fix->get_single_buffers()); } if (vflag_atom) @@ -330,11 +325,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc_buf1,gc_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_c_ik(fix->get_mixed_buffers()); + fieldforce_c_ik_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_c_ik(fix->get_double_buffers()); + fieldforce_c_ik_intel(fix->get_double_buffers()); } else { - fieldforce_c_ik(fix->get_single_buffers()); + fieldforce_c_ik_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -349,26 +344,26 @@ void PPPMDispIntel::compute(int eflag, int vflag) //perform calculations for geometric mixing if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_mixed_buffers()); - make_rho_g(fix->get_mixed_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_mixed_buffers()); + make_rho_g_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_double_buffers()); - make_rho_g(fix->get_double_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_double_buffers()); + make_rho_g_intel(fix->get_double_buffers()); } else { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_single_buffers()); - make_rho_g(fix->get_single_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_single_buffers()); + make_rho_g_intel(fix->get_single_buffers()); } gc6->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO_G,1,sizeof(FFT_SCALAR), @@ -390,11 +385,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_g_ad(fix->get_mixed_buffers()); + fieldforce_g_ad_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_g_ad(fix->get_double_buffers()); + fieldforce_g_ad_intel(fix->get_double_buffers()); } else { - fieldforce_g_ad(fix->get_single_buffers()); + fieldforce_g_ad_intel(fix->get_single_buffers()); } if (vflag_atom) @@ -415,11 +410,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_g_ik(fix->get_mixed_buffers()); + fieldforce_g_ik_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_g_ik(fix->get_double_buffers()); + fieldforce_g_ik_intel(fix->get_double_buffers()); } else { - fieldforce_g_ik(fix->get_single_buffers()); + fieldforce_g_ik_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -434,26 +429,26 @@ void PPPMDispIntel::compute(int eflag, int vflag) //perform calculations for arithmetic mixing if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, - nxlo_out_6, nylo_out_6, nzlo_out_6, - nxhi_out_6, nyhi_out_6, nzhi_out_6, - fix->get_mixed_buffers()); - make_rho_a(fix->get_mixed_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, + nxlo_out_6, nylo_out_6, nzlo_out_6, + nxhi_out_6, nyhi_out_6, nzhi_out_6, + fix->get_mixed_buffers()); + make_rho_a_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_double_buffers()); - make_rho_a(fix->get_double_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_double_buffers()); + make_rho_a_intel(fix->get_double_buffers()); } else { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_single_buffers()); - make_rho_a(fix->get_single_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_single_buffers()); + make_rho_a_intel(fix->get_single_buffers()); } gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO_A,7,sizeof(FFT_SCALAR), @@ -486,11 +481,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_a_ad(fix->get_mixed_buffers()); + fieldforce_a_ad_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_a_ad(fix->get_double_buffers()); + fieldforce_a_ad_intel(fix->get_double_buffers()); } else { - fieldforce_a_ad(fix->get_single_buffers()); + fieldforce_a_ad_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -529,11 +524,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_a_ik(fix->get_mixed_buffers()); + fieldforce_a_ik_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_a_ik(fix->get_double_buffers()); + fieldforce_a_ik_intel(fix->get_double_buffers()); } else { - fieldforce_a_ik(fix->get_single_buffers()); + fieldforce_a_ik_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -549,26 +544,26 @@ void PPPMDispIntel::compute(int eflag, int vflag) // perform calculations if no mixing rule applies if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_mixed_buffers()); - make_rho_none(fix->get_mixed_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_mixed_buffers()); + make_rho_none_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_double_buffers()); - make_rho_none(fix->get_double_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_double_buffers()); + make_rho_none_intel(fix->get_double_buffers()); } else { - particle_map(delxinv_6, delyinv_6, delzinv_6, shift_6, - part2grid_6, nupper_6, nlower_6, nxlo_out_6, - nylo_out_6, nzlo_out_6, nxhi_out_6, - nyhi_out_6, nzhi_out_6, - fix->get_single_buffers()); - make_rho_none(fix->get_single_buffers()); + particle_map_intel(delxinv_6, delyinv_6, delzinv_6, shift_6, + part2grid_6, nupper_6, nlower_6, nxlo_out_6, + nylo_out_6, nzlo_out_6, nxhi_out_6, + nyhi_out_6, nzhi_out_6, + fix->get_single_buffers()); + make_rho_none_intel(fix->get_single_buffers()); } gc->reverse_comm(Grid3d::KSPACE,this,REVERSE_RHO_NONE,1,sizeof(FFT_SCALAR), @@ -591,11 +586,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_none_ad(fix->get_mixed_buffers()); + fieldforce_none_ad_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_none_ad(fix->get_double_buffers()); + fieldforce_none_ad_intel(fix->get_double_buffers()); } else { - fieldforce_none_ad(fix->get_single_buffers()); + fieldforce_none_ad_intel(fix->get_single_buffers()); } if (vflag_atom) @@ -620,11 +615,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) gc6_buf1,gc6_buf2,MPI_FFT_SCALAR); if (fix->precision() == FixIntel::PREC_MODE_MIXED) { - fieldforce_none_ik(fix->get_mixed_buffers()); + fieldforce_none_ik_intel(fix->get_mixed_buffers()); } else if (fix->precision() == FixIntel::PREC_MODE_DOUBLE) { - fieldforce_none_ik(fix->get_double_buffers()); + fieldforce_none_ik_intel(fix->get_double_buffers()); } else { - fieldforce_none_ik(fix->get_single_buffers()); + fieldforce_none_ik_intel(fix->get_single_buffers()); } if (evflag_atom) @@ -730,11 +725,11 @@ void PPPMDispIntel::compute(int eflag, int vflag) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::particle_map(double delx, double dely, double delz, - double sft, int** p2g, int nup, int nlow, - int nxlo, int nylo, int nzlo, - int nxhi, int nyhi, int nzhi, - IntelBuffers * /*buffers*/) +void PPPMDispIntel::particle_map_intel(double delx, double dely, double delz, + double sft, int** p2g, int nup, int nlow, + int nxlo, int nylo, int nzlo, + int nxhi, int nyhi, int nzhi, + IntelBuffers * /*buffers*/) { int nlocal = atom->nlocal; int nthr = comm->nthreads; @@ -805,7 +800,7 @@ void PPPMDispIntel::particle_map(double delx, double dely, double delz, ------------------------------------------------------------------------- */ template -void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) +void PPPMDispIntel::make_rho_c_intel(IntelBuffers * /*buffers*/) { // clear 3d density array @@ -968,7 +963,7 @@ void PPPMDispIntel::make_rho_c(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) +void PPPMDispIntel::make_rho_g_intel(IntelBuffers * /*buffers*/) { // clear 3d density array @@ -1134,7 +1129,7 @@ void PPPMDispIntel::make_rho_g(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::make_rho_a(IntelBuffers * /*buffers*/) +void PPPMDispIntel::make_rho_a_intel(IntelBuffers * /*buffers*/) { // clear 3d density array @@ -1268,7 +1263,7 @@ void PPPMDispIntel::make_rho_a(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) +void PPPMDispIntel::make_rho_none_intel(IntelBuffers * /*buffers*/) { FFT_SCALAR * _noalias global_density = &(density_brick_none[0][nzlo_out_6][nylo_out_6][nxlo_out_6]); @@ -1428,7 +1423,7 @@ void PPPMDispIntel::make_rho_none(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_c_ik(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_c_ik_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -1587,7 +1582,7 @@ void PPPMDispIntel::fieldforce_c_ik(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_c_ad_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -1808,7 +1803,7 @@ void PPPMDispIntel::fieldforce_c_ad(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_g_ik(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_g_ik_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -1964,7 +1959,7 @@ void PPPMDispIntel::fieldforce_g_ik(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_g_ad_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -2180,7 +2175,7 @@ void PPPMDispIntel::fieldforce_g_ad(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_a_ik(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_a_ik_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -2405,7 +2400,7 @@ void PPPMDispIntel::fieldforce_a_ik(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_a_ad_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -2733,7 +2728,7 @@ void PPPMDispIntel::fieldforce_a_ad(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_none_ik(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_none_ik_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points @@ -2906,7 +2901,7 @@ void PPPMDispIntel::fieldforce_none_ik(IntelBuffers * /*buffers*/) ------------------------------------------------------------------------- */ template -void PPPMDispIntel::fieldforce_none_ad(IntelBuffers * /*buffers*/) +void PPPMDispIntel::fieldforce_none_ad_intel(IntelBuffers * /*buffers*/) { // loop over my charges, interpolate electric field from nearby grid points // (nx,ny,nz) = global coords of grid pt to "lower left" of charge diff --git a/src/INTEL/pppm_disp_intel.h b/src/INTEL/pppm_disp_intel.h index 20c59c00e8f..11fdd056381 100644 --- a/src/INTEL/pppm_disp_intel.h +++ b/src/INTEL/pppm_disp_intel.h @@ -86,137 +86,137 @@ class PPPMDispIntel : public PPPMDisp { #endif template - void particle_map(double, double, double, double, int **, int, int, int, int, int, int, int, int, - IntelBuffers *buffers); + void particle_map_intel(double, double, double, double, int **, int, int, int, int, int, int, int, int, + IntelBuffers *buffers); template - void make_rho_c(IntelBuffers *buffers); - template void make_rho_c(IntelBuffers *buffers) + void make_rho_c_intel(IntelBuffers *buffers); + template void make_rho_c_intel(IntelBuffers *buffers) { if (_use_table == 1) { - make_rho_c(buffers); + make_rho_c_intel(buffers); } else { - make_rho_c(buffers); + make_rho_c_intel(buffers); } } template - void make_rho_g(IntelBuffers *buffers); - template void make_rho_g(IntelBuffers *buffers) + void make_rho_g_intel(IntelBuffers *buffers); + template void make_rho_g_intel(IntelBuffers *buffers) { if (_use_table == 1) { - make_rho_g(buffers); + make_rho_g_intel(buffers); } else { - make_rho_g(buffers); + make_rho_g_intel(buffers); } } template - void make_rho_a(IntelBuffers *buffers); - template void make_rho_a(IntelBuffers *buffers) + void make_rho_a_intel(IntelBuffers *buffers); + template void make_rho_a_intel(IntelBuffers *buffers) { if (_use_table == 1) { - make_rho_a(buffers); + make_rho_a_intel(buffers); } else { - make_rho_a(buffers); + make_rho_a_intel(buffers); } } template - void make_rho_none(IntelBuffers *buffers); - template void make_rho_none(IntelBuffers *buffers) + void make_rho_none_intel(IntelBuffers *buffers); + template void make_rho_none_intel(IntelBuffers *buffers) { if (_use_table == 1) { - make_rho_none(buffers); + make_rho_none_intel(buffers); } else { - make_rho_none(buffers); + make_rho_none_intel(buffers); } } template - void fieldforce_c_ik(IntelBuffers *buffers); - template void fieldforce_c_ik(IntelBuffers *buffers) + void fieldforce_c_ik_intel(IntelBuffers *buffers); + template void fieldforce_c_ik_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_c_ik(buffers); + fieldforce_c_ik_intel(buffers); } else { - fieldforce_c_ik(buffers); + fieldforce_c_ik_intel(buffers); } } template - void fieldforce_c_ad(IntelBuffers *buffers); - template void fieldforce_c_ad(IntelBuffers *buffers) + void fieldforce_c_ad_intel(IntelBuffers *buffers); + template void fieldforce_c_ad_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_c_ad(buffers); + fieldforce_c_ad_intel(buffers); } else { - fieldforce_c_ad(buffers); + fieldforce_c_ad_intel(buffers); } } template - void fieldforce_g_ik(IntelBuffers *buffers); - template void fieldforce_g_ik(IntelBuffers *buffers) + void fieldforce_g_ik_intel(IntelBuffers *buffers); + template void fieldforce_g_ik_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_g_ik(buffers); + fieldforce_g_ik_intel(buffers); } else { - fieldforce_g_ik(buffers); + fieldforce_g_ik_intel(buffers); } } template - void fieldforce_g_ad(IntelBuffers *buffers); - template void fieldforce_g_ad(IntelBuffers *buffers) + void fieldforce_g_ad_intel(IntelBuffers *buffers); + template void fieldforce_g_ad_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_g_ad(buffers); + fieldforce_g_ad_intel(buffers); } else { - fieldforce_g_ad(buffers); + fieldforce_g_ad_intel(buffers); } } template - void fieldforce_a_ik(IntelBuffers *buffers); - template void fieldforce_a_ik(IntelBuffers *buffers) + void fieldforce_a_ik_intel(IntelBuffers *buffers); + template void fieldforce_a_ik_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_a_ik(buffers); + fieldforce_a_ik_intel(buffers); } else { - fieldforce_a_ik(buffers); + fieldforce_a_ik_intel(buffers); } } template - void fieldforce_a_ad(IntelBuffers *buffers); - template void fieldforce_a_ad(IntelBuffers *buffers) + void fieldforce_a_ad_intel(IntelBuffers *buffers); + template void fieldforce_a_ad_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_a_ad(buffers); + fieldforce_a_ad_intel(buffers); } else { - fieldforce_a_ad(buffers); + fieldforce_a_ad_intel(buffers); } } template - void fieldforce_none_ik(IntelBuffers *buffers); - template void fieldforce_none_ik(IntelBuffers *buffers) + void fieldforce_none_ik_intel(IntelBuffers *buffers); + template void fieldforce_none_ik_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_none_ik(buffers); + fieldforce_none_ik_intel(buffers); } else { - fieldforce_none_ik(buffers); + fieldforce_none_ik_intel(buffers); } } template - void fieldforce_none_ad(IntelBuffers *buffers); - template void fieldforce_none_ad(IntelBuffers *buffers) + void fieldforce_none_ad_intel(IntelBuffers *buffers); + template void fieldforce_none_ad_intel(IntelBuffers *buffers) { if (_use_table == 1) { - fieldforce_none_ad(buffers); + fieldforce_none_ad_intel(buffers); } else { - fieldforce_none_ad(buffers); + fieldforce_none_ad_intel(buffers); } } diff --git a/src/INTEL/pppm_electrode_intel.cpp b/src/INTEL/pppm_electrode_intel.cpp index 4d8a0331b8b..9f3c57b50e3 100644 --- a/src/INTEL/pppm_electrode_intel.cpp +++ b/src/INTEL/pppm_electrode_intel.cpp @@ -48,23 +48,18 @@ using namespace LAMMPS_NS; using namespace std; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double LARGE = 10000.0; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; enum { REVERSE_RHO }; enum { FORWARD_IK, FORWARD_AD, FORWARD_IK_PERATOM, FORWARD_AD_PERATOM }; enum : bool { ELECTRODE = true, ELECTROLYTE = false }; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; static const char cite_pppm_electrode[] = "kspace_style pppm/electrode command:\n\n" diff --git a/src/INTEL/pppm_intel.cpp b/src/INTEL/pppm_intel.cpp index f67b3a89b39..b72a7efd115 100644 --- a/src/INTEL/pppm_intel.cpp +++ b/src/INTEL/pppm_intel.cpp @@ -41,22 +41,17 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double LARGE = 10000.0; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; enum{REVERSE_RHO}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ @@ -156,8 +151,6 @@ void PPPMIntel::compute(int eflag, int vflag) void PPPMIntel::compute_first(int eflag, int vflag) { - int i,j; - // set energy/virial flags // invoke allocate_peratom() if needed for first time @@ -465,7 +458,6 @@ void PPPMIntel::make_rho(IntelBuffers *buffers) const flt_t xi = delxinv; const flt_t yi = delyinv; const flt_t zi = delzinv; - const flt_t fshift = shift; const flt_t fshiftone = shiftone; const flt_t fdelvolinv = delvolinv; diff --git a/src/INTERLAYER/pair_aip_water_2dm.cpp b/src/INTERLAYER/pair_aip_water_2dm.cpp index 6e2bf7228d1..655fc9f6953 100644 --- a/src/INTERLAYER/pair_aip_water_2dm.cpp +++ b/src/INTERLAYER/pair_aip_water_2dm.cpp @@ -29,9 +29,9 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 -#define PGDELTA 1 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; static const char cite_aip_water[] = "aip/water/2dm potential doi/10.1021/acs.jpcc.2c08464\n" diff --git a/src/INTERLAYER/pair_drip.cpp b/src/INTERLAYER/pair_drip.cpp index 90773b40342..e9a820d5dbc 100644 --- a/src/INTERLAYER/pair_drip.cpp +++ b/src/INTERLAYER/pair_drip.cpp @@ -36,9 +36,9 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 -#define HALF 0.5 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; +static constexpr double HALF = 0.5; // inline functions static inline double dot(double const *x, double const *y) diff --git a/src/INTERLAYER/pair_ilp_graphene_hbn.cpp b/src/INTERLAYER/pair_ilp_graphene_hbn.cpp index 69896d7c0b9..a3e3a833c3f 100644 --- a/src/INTERLAYER/pair_ilp_graphene_hbn.cpp +++ b/src/INTERLAYER/pair_ilp_graphene_hbn.cpp @@ -39,8 +39,8 @@ using namespace LAMMPS_NS; using namespace InterLayer; -#define DELTA 4 -#define PGDELTA 1 +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; static const char cite_ilp[] = "ilp/graphene/hbn potential doi:10.1021/acs.nanolett.8b02848\n" diff --git a/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp b/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp index ad42ba1922d..64e71f22fcb 100644 --- a/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp +++ b/src/INTERLAYER/pair_kolmogorov_crespi_full.cpp @@ -40,9 +40,9 @@ using namespace LAMMPS_NS; using namespace InterLayer; -#define MAXLINE 1024 -#define DELTA 4 -#define PGDELTA 1 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; static const char cite_kc[] = "kolmogorov/crespi/full potential doi:10.1021/acs.nanolett.8b02848\n" diff --git a/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp b/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp index d8f0d798e43..4ccbd28c026 100644 --- a/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp +++ b/src/INTERLAYER/pair_kolmogorov_crespi_z.cpp @@ -37,8 +37,8 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/INTERLAYER/pair_lebedeva_z.cpp b/src/INTERLAYER/pair_lebedeva_z.cpp index b38900ad14f..d7b13ef8215 100644 --- a/src/INTERLAYER/pair_lebedeva_z.cpp +++ b/src/INTERLAYER/pair_lebedeva_z.cpp @@ -39,8 +39,8 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/INTERLAYER/pair_saip_metal.cpp b/src/INTERLAYER/pair_saip_metal.cpp index bd327391a42..c6c107c9803 100644 --- a/src/INTERLAYER/pair_saip_metal.cpp +++ b/src/INTERLAYER/pair_saip_metal.cpp @@ -33,9 +33,9 @@ using namespace LAMMPS_NS; using namespace InterLayer; -#define MAXLINE 1024 -#define DELTA 4 -#define PGDELTA 1 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; static const char cite_saip[] = "saip/metal potential: doi:10.1021/acs.jctc.1c00622\n\n" diff --git a/src/KIM/kim_interactions.cpp b/src/KIM/kim_interactions.cpp index ce550bf5da6..c0ec0ee28e0 100644 --- a/src/KIM/kim_interactions.cpp +++ b/src/KIM/kim_interactions.cpp @@ -81,7 +81,7 @@ extern "C" { using namespace LAMMPS_NS; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ @@ -281,7 +281,8 @@ void KimInteractions::KIM_SET_TYPE_PARAMETERS(const std::string &input_line) con if (fp == nullptr) error->one(FLERR, "Parameter file {} not found", filename); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int n, eof = 0; while (true) { diff --git a/src/KOKKOS/angle_charmm_kokkos.cpp b/src/KOKKOS/angle_charmm_kokkos.cpp index 8b41a934514..666002686cf 100644 --- a/src/KOKKOS/angle_charmm_kokkos.cpp +++ b/src/KOKKOS/angle_charmm_kokkos.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/angle_class2_kokkos.cpp b/src/KOKKOS/angle_class2_kokkos.cpp index 8f77ab4c94b..e831ae22834 100644 --- a/src/KOKKOS/angle_class2_kokkos.cpp +++ b/src/KOKKOS/angle_class2_kokkos.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/angle_cosine_kokkos.cpp b/src/KOKKOS/angle_cosine_kokkos.cpp index 189a1568662..ec20c8fbdad 100644 --- a/src/KOKKOS/angle_cosine_kokkos.cpp +++ b/src/KOKKOS/angle_cosine_kokkos.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/angle_harmonic_kokkos.cpp b/src/KOKKOS/angle_harmonic_kokkos.cpp index 1d8ada4bd98..d7be418326c 100644 --- a/src/KOKKOS/angle_harmonic_kokkos.cpp +++ b/src/KOKKOS/angle_harmonic_kokkos.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/atom_map_kokkos.cpp b/src/KOKKOS/atom_map_kokkos.cpp index 4f46c33dbe5..828eb7edeae 100644 --- a/src/KOKKOS/atom_map_kokkos.cpp +++ b/src/KOKKOS/atom_map_kokkos.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- allocate and initialize array or hash table for global -> local map diff --git a/src/KOKKOS/atom_vec_spin_kokkos.cpp b/src/KOKKOS/atom_vec_spin_kokkos.cpp index 72d38a731ea..c6ee7c1d3b4 100644 --- a/src/KOKKOS/atom_vec_spin_kokkos.cpp +++ b/src/KOKKOS/atom_vec_spin_kokkos.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; -#define DELTA 10 +static constexpr int DELTA = 10; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/comm_kokkos.cpp b/src/KOKKOS/comm_kokkos.cpp index 2f1818e47fd..4d527cc16b5 100644 --- a/src/KOKKOS/comm_kokkos.cpp +++ b/src/KOKKOS/comm_kokkos.cpp @@ -36,9 +36,9 @@ using namespace LAMMPS_NS; -#define BUFFACTOR 1.5 -#define BUFMIN 10000 -#define BUFEXTRA 1000 +static constexpr double BUFFACTOR = 1.5; +static constexpr int BUFMIN = 10000; +static constexpr int BUFEXTRA = 1000; /* ---------------------------------------------------------------------- setup MPI and allocate buffer space diff --git a/src/KOKKOS/comm_tiled_kokkos.cpp b/src/KOKKOS/comm_tiled_kokkos.cpp index e3286a73f50..4549f53f706 100644 --- a/src/KOKKOS/comm_tiled_kokkos.cpp +++ b/src/KOKKOS/comm_tiled_kokkos.cpp @@ -20,11 +20,10 @@ using namespace LAMMPS_NS; -#define BUFFACTOR 1.5 -#define BUFFACTOR 1.5 -#define BUFMIN 1000 -#define BUFEXTRA 1000 -#define EPSILON 1.0e-6 +static constexpr double BUFFACTOR = 1.5; +static constexpr int BUFMIN = 1000; +static constexpr int BUFEXTRA = 1000; +static constexpr double EPSILON = 1.0e-6; #define DELTA_PROCS 16 diff --git a/src/KOKKOS/dihedral_charmm_kokkos.cpp b/src/KOKKOS/dihedral_charmm_kokkos.cpp index 70a74a48468..b385ec7f010 100644 --- a/src/KOKKOS/dihedral_charmm_kokkos.cpp +++ b/src/KOKKOS/dihedral_charmm_kokkos.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/dihedral_charmmfsw_kokkos.cpp b/src/KOKKOS/dihedral_charmmfsw_kokkos.cpp index 1caea90a74c..aeb9b022a7b 100644 --- a/src/KOKKOS/dihedral_charmmfsw_kokkos.cpp +++ b/src/KOKKOS/dihedral_charmmfsw_kokkos.cpp @@ -40,7 +40,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/dihedral_class2_kokkos.cpp b/src/KOKKOS/dihedral_class2_kokkos.cpp index 2d6032600b2..59f5c18ee7b 100644 --- a/src/KOKKOS/dihedral_class2_kokkos.cpp +++ b/src/KOKKOS/dihedral_class2_kokkos.cpp @@ -30,9 +30,9 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/dihedral_harmonic_kokkos.cpp b/src/KOKKOS/dihedral_harmonic_kokkos.cpp index 8ca0b368dfd..87e83a17fcf 100644 --- a/src/KOKKOS/dihedral_harmonic_kokkos.cpp +++ b/src/KOKKOS/dihedral_harmonic_kokkos.cpp @@ -30,9 +30,9 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/dihedral_opls_kokkos.cpp b/src/KOKKOS/dihedral_opls_kokkos.cpp index 670faa9e84d..ce7502b25a8 100644 --- a/src/KOKKOS/dihedral_opls_kokkos.cpp +++ b/src/KOKKOS/dihedral_opls_kokkos.cpp @@ -30,9 +30,9 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/domain_kokkos.cpp b/src/KOKKOS/domain_kokkos.cpp index 6311d45a3f2..d0af281a14f 100644 --- a/src/KOKKOS/domain_kokkos.cpp +++ b/src/KOKKOS/domain_kokkos.cpp @@ -22,8 +22,8 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 -#define SMALL 1.0e-4 +static constexpr double BIG = 1.0e20; +static constexpr double SMALL = 1.0e-4; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp b/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp index 9c34908d08c..5256b7f4a49 100644 --- a/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_acks2_reaxff_kokkos.cpp @@ -38,7 +38,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define SMALL 0.0001 +static constexpr double SMALL = 0.0001; #define EV_TO_KCAL_PER_MOL 14.4 /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_dt_reset_kokkos.cpp b/src/KOKKOS/fix_dt_reset_kokkos.cpp index 6e7709ace15..83cdc5f26fd 100644 --- a/src/KOKKOS/fix_dt_reset_kokkos.cpp +++ b/src/KOKKOS/fix_dt_reset_kokkos.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_enforce2d_kokkos.cpp b/src/KOKKOS/fix_enforce2d_kokkos.cpp index 24cf3078277..567c6ad1600 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.cpp +++ b/src/KOKKOS/fix_enforce2d_kokkos.cpp @@ -122,7 +122,7 @@ void FixEnforce2DKokkos::post_force(int /*vflag*/) template -template +template KOKKOS_INLINE_FUNCTION void FixEnforce2DKokkos::post_force_item( int i ) const { @@ -130,17 +130,17 @@ void FixEnforce2DKokkos::post_force_item( int i ) const v(i,2) = 0.0; f(i,2) = 0.0; - if (omega_flag) { + if (OMEGA_FLAG) { omega(i,0) = 0.0; omega(i,1) = 0.0; } - if (angmom_flag) { + if (ANGMOM_FLAG) { angmom(i,0) = 0.0; angmom(i,1) = 0.0; } - if (torque_flag) { + if (TORQUE_FLAG) { torque(i,0) = 0.0; torque(i,1) = 0.0; } diff --git a/src/KOKKOS/fix_enforce2d_kokkos.h b/src/KOKKOS/fix_enforce2d_kokkos.h index cd6903f6c91..1c7a33f3b82 100644 --- a/src/KOKKOS/fix_enforce2d_kokkos.h +++ b/src/KOKKOS/fix_enforce2d_kokkos.h @@ -36,7 +36,7 @@ class FixEnforce2DKokkos : public FixEnforce2D { void setup(int) override; void post_force(int) override; - template + template KOKKOS_INLINE_FUNCTION void post_force_item(const int i) const; diff --git a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp index 309eaeeebfe..9b8ac915699 100644 --- a/src/KOKKOS/fix_eos_table_rx_kokkos.cpp +++ b/src/KOKKOS/fix_eos_table_rx_kokkos.cpp @@ -25,7 +25,7 @@ #include #include "atom_masks.h" -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; #ifdef DBL_EPSILON #define MY_EPSILON (10.0*DBL_EPSILON) diff --git a/src/KOKKOS/fix_langevin_kokkos.cpp b/src/KOKKOS/fix_langevin_kokkos.cpp index 437dd9daeff..89cf91130ff 100644 --- a/src/KOKKOS/fix_langevin_kokkos.cpp +++ b/src/KOKKOS/fix_langevin_kokkos.cpp @@ -34,8 +34,8 @@ using namespace FixConst; enum{NOBIAS,BIAS}; enum{CONSTANT,EQUAL,ATOM}; -#define SINERTIA 0.4 // moment of inertia prefactor for sphere -#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double SINERTIA = 0.4; // moment of inertia prefactor for sphere +static constexpr double EINERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_nh_kokkos.cpp b/src/KOKKOS/fix_nh_kokkos.cpp index 3d2d3ebb716..d0380933178 100644 --- a/src/KOKKOS/fix_nh_kokkos.cpp +++ b/src/KOKKOS/fix_nh_kokkos.cpp @@ -39,8 +39,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; enum{NOBIAS,BIAS}; enum{NONE,XYZ,XY,YZ,XZ}; diff --git a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp index 18d7af75a74..06485eb1ccd 100644 --- a/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp +++ b/src/KOKKOS/fix_qeq_reaxff_kokkos.cpp @@ -46,7 +46,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define SMALL 0.0001 +static constexpr double SMALL = 0.0001; #define EV_TO_KCAL_PER_MOL 14.4 /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_shake_kokkos.cpp b/src/KOKKOS/fix_shake_kokkos.cpp index 39f4f4d4fe4..81489142db9 100644 --- a/src/KOKKOS/fix_shake_kokkos.cpp +++ b/src/KOKKOS/fix_shake_kokkos.cpp @@ -41,10 +41,10 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define RVOUS 1 // 0 for irregular, 1 for all2all +static constexpr int RVOUS = 1; // 0 for irregular, 1 for all2all -#define BIG 1.0e20 -#define MASSDELTA 0.1 +static constexpr double BIG = 1.0e20; +static constexpr double MASSDELTA = 0.1; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_shardlow_kokkos.cpp b/src/KOKKOS/fix_shardlow_kokkos.cpp index 37ffd15cdf2..cb35a63fcbc 100644 --- a/src/KOKKOS/fix_shardlow_kokkos.cpp +++ b/src/KOKKOS/fix_shardlow_kokkos.cpp @@ -57,7 +57,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace random_external_state; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; #define EPSILON_SQUARED ((EPSILON) * (EPSILON)) /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/fix_wall_gran_old.cpp b/src/KOKKOS/fix_wall_gran_old.cpp index 8c02e6146dc..c6d82a8b520 100644 --- a/src/KOKKOS/fix_wall_gran_old.cpp +++ b/src/KOKKOS/fix_wall_gran_old.cpp @@ -45,8 +45,8 @@ using namespace MathConst; #define THREEQUARTERS 0.75 // 3/4 #define TWOPI 6.28318530717959 // 2*PI -#define BIG 1.0e20 -#define EPSILON 1e-10 +static constexpr double BIG = 1.0e20; +static constexpr double EPSILON = 1e-10; // XYZ PLANE need to be 0,1,2 @@ -81,7 +81,7 @@ FixWallGranOld::FixWallGranOld(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[3],"hooke/history") == 0) pairstyle = HOOKE_HISTORY; else if (strcmp(arg[3],"hertz/history") == 0) pairstyle = HERTZ_HISTORY; else if (strcmp(arg[3],"granular") == 0) pairstyle = GRANULAR; - else error->all(FLERR,"Invalid fix wall/gran interaction style"); + else error->all(FLERR,"Invalid fix {} interaction style: {}", style, arg[3]); use_history = restart_peratom = 1; if (pairstyle == HOOKE) use_history = restart_peratom = 0; diff --git a/src/KOKKOS/grid3d_kokkos.cpp b/src/KOKKOS/grid3d_kokkos.cpp index 87f2baff84f..26882f20ca9 100644 --- a/src/KOKKOS/grid3d_kokkos.cpp +++ b/src/KOKKOS/grid3d_kokkos.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 16 +static constexpr int DELTA = 16; /* ---------------------------------------------------------------------- NOTES: diff --git a/src/KOKKOS/improper_class2_kokkos.cpp b/src/KOKKOS/improper_class2_kokkos.cpp index f1ed6fdbc0f..4b9a009df20 100644 --- a/src/KOKKOS/improper_class2_kokkos.cpp +++ b/src/KOKKOS/improper_class2_kokkos.cpp @@ -27,8 +27,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/improper_harmonic_kokkos.cpp b/src/KOKKOS/improper_harmonic_kokkos.cpp index 1d217461d05..a075238f226 100644 --- a/src/KOKKOS/improper_harmonic_kokkos.cpp +++ b/src/KOKKOS/improper_harmonic_kokkos.cpp @@ -28,8 +28,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/min_linesearch_kokkos.cpp b/src/KOKKOS/min_linesearch_kokkos.cpp index 2d424957c50..601d5e7d570 100644 --- a/src/KOKKOS/min_linesearch_kokkos.cpp +++ b/src/KOKKOS/min_linesearch_kokkos.cpp @@ -43,7 +43,7 @@ using namespace LAMMPS_NS; #define BACKTRACK_SLOPE 0.4 #define QUADRATIC_TOL 0.1 //#define EMACH 1.0e-8 -#define EMACH 1.0e-8 +static constexpr double EMACH = 1.0e-8; #define EPS_QUAD 1.0e-28 /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/mliap_descriptor_so3_kokkos.cpp b/src/KOKKOS/mliap_descriptor_so3_kokkos.cpp index ff9e5d2aa68..b079b734e0e 100644 --- a/src/KOKKOS/mliap_descriptor_so3_kokkos.cpp +++ b/src/KOKKOS/mliap_descriptor_so3_kokkos.cpp @@ -31,8 +31,8 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; +static constexpr int MAXWORD = 3; /* ---------------------------------------------------------------------- */ template diff --git a/src/KOKKOS/mliap_so3_kokkos.cpp b/src/KOKKOS/mliap_so3_kokkos.cpp index 1fb5ffb52ec..3f6370a6fc5 100644 --- a/src/KOKKOS/mliap_so3_kokkos.cpp +++ b/src/KOKKOS/mliap_so3_kokkos.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecialKokkos; -#define SMALL 1.0e-8 +static constexpr double SMALL = 1.0e-8; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/modify_kokkos.cpp b/src/KOKKOS/modify_kokkos.cpp index 8d8ffca6714..26ee88ff513 100644 --- a/src/KOKKOS/modify_kokkos.cpp +++ b/src/KOKKOS/modify_kokkos.cpp @@ -21,7 +21,7 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/nbin_kokkos.cpp b/src/KOKKOS/nbin_kokkos.cpp index e65cf4ecb71..fd8cf5771b0 100644 --- a/src/KOKKOS/nbin_kokkos.cpp +++ b/src/KOKKOS/nbin_kokkos.cpp @@ -22,7 +22,7 @@ using namespace LAMMPS_NS; -#define SMALL 1.0e-6 +static constexpr double SMALL = 1.0e-6; #define CUT2BIN_RATIO 100 /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/neigh_bond_kokkos.cpp b/src/KOKKOS/neigh_bond_kokkos.cpp index b7495907797..85ca6c916e3 100644 --- a/src/KOKKOS/neigh_bond_kokkos.cpp +++ b/src/KOKKOS/neigh_bond_kokkos.cpp @@ -35,8 +35,8 @@ #include using namespace LAMMPS_NS; -#define BONDDELTA 10000 -#define LB_FACTOR 1.5 +static constexpr int BONDDELTA = 10000; +static constexpr double LB_FACTOR = 1.5; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_dpd_ext_kokkos.cpp b/src/KOKKOS/pair_dpd_ext_kokkos.cpp index 7264877d70f..3624208c6b4 100644 --- a/src/KOKKOS/pair_dpd_ext_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_ext_kokkos.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; template diff --git a/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp b/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp index dcf88d1763a..9808c53856e 100644 --- a/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_ext_tstat_kokkos.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; template diff --git a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp index a0ee204aeb3..dd1591bf4b1 100644 --- a/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_fdt_energy_kokkos.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_dpd_kokkos.cpp b/src/KOKKOS/pair_dpd_kokkos.cpp index 3db8a06f6d4..5dca219cdf1 100644 --- a/src/KOKKOS/pair_dpd_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_kokkos.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; template diff --git a/src/KOKKOS/pair_dpd_tstat_kokkos.cpp b/src/KOKKOS/pair_dpd_tstat_kokkos.cpp index 9058c236282..78cc862ac03 100644 --- a/src/KOKKOS/pair_dpd_tstat_kokkos.cpp +++ b/src/KOKKOS/pair_dpd_tstat_kokkos.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; template diff --git a/src/KOKKOS/pair_exp6_rx_kokkos.cpp b/src/KOKKOS/pair_exp6_rx_kokkos.cpp index b4576db89a3..dad74136697 100644 --- a/src/KOKKOS/pair_exp6_rx_kokkos.cpp +++ b/src/KOKKOS/pair_exp6_rx_kokkos.cpp @@ -42,8 +42,8 @@ using namespace LAMMPS_NS; using namespace MathSpecialKokkos; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; #ifdef DBL_EPSILON #define MY_EPSILON (10.0*DBL_EPSILON) @@ -1702,7 +1702,8 @@ void PairExp6rxKokkos::read_file(char *file) // one set of params can span multiple lines int n,nwords,ispecies; - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { diff --git a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp index f487b0c84ef..9f0b1dd747e 100644 --- a/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp +++ b/src/KOKKOS/pair_multi_lucy_rx_kokkos.cpp @@ -43,7 +43,7 @@ using MathConst::MY_PI; enum{NONE,RLINEAR,RSQ}; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; #ifdef DBL_EPSILON #define MY_EPSILON (10.0*DBL_EPSILON) diff --git a/src/KOKKOS/pair_sw_kokkos.cpp b/src/KOKKOS/pair_sw_kokkos.cpp index 93b39197953..294b451e7ec 100644 --- a/src/KOKKOS/pair_sw_kokkos.cpp +++ b/src/KOKKOS/pair_sw_kokkos.cpp @@ -37,8 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pair_vashishta_kokkos.cpp b/src/KOKKOS/pair_vashishta_kokkos.cpp index 8400807ec6e..d2eb3036d69 100644 --- a/src/KOKKOS/pair_vashishta_kokkos.cpp +++ b/src/KOKKOS/pair_vashishta_kokkos.cpp @@ -36,8 +36,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/pppm_kokkos.cpp b/src/KOKKOS/pppm_kokkos.cpp index baa85dc585c..4a253c5779c 100644 --- a/src/KOKKOS/pppm_kokkos.cpp +++ b/src/KOKKOS/pppm_kokkos.cpp @@ -39,22 +39,17 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecialKokkos; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double LARGE = 10000.0; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; enum{REVERSE_RHO}; enum{FORWARD_IK,FORWARD_IK_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ diff --git a/src/KOKKOS/region_block_kokkos.cpp b/src/KOKKOS/region_block_kokkos.cpp index c53fae7b039..6d53514d193 100644 --- a/src/KOKKOS/region_block_kokkos.cpp +++ b/src/KOKKOS/region_block_kokkos.cpp @@ -18,7 +18,7 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/ewald.cpp b/src/KSPACE/ewald.cpp index 93470c60ac0..930cc68ba97 100644 --- a/src/KSPACE/ewald.cpp +++ b/src/KSPACE/ewald.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/ewald_dipole.cpp b/src/KSPACE/ewald_dipole.cpp index 7a3a1da8ffd..e4982b1d566 100644 --- a/src/KSPACE/ewald_dipole.cpp +++ b/src/KSPACE/ewald_dipole.cpp @@ -36,7 +36,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/ewald_dipole_spin.cpp b/src/KSPACE/ewald_dipole_spin.cpp index c679e164f73..93821db9ba6 100644 --- a/src/KSPACE/ewald_dipole_spin.cpp +++ b/src/KSPACE/ewald_dipole_spin.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/ewald_disp.cpp b/src/KSPACE/ewald_disp.cpp index 31149134ad6..9c81b214485 100644 --- a/src/KSPACE/ewald_disp.cpp +++ b/src/KSPACE/ewald_disp.cpp @@ -38,7 +38,7 @@ using namespace MathConst; using namespace MathSpecial; using namespace MathExtra; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; //#define DEBUG diff --git a/src/KSPACE/msm.cpp b/src/KSPACE/msm.cpp index 041a5d52420..8f79ab408c4 100644 --- a/src/KSPACE/msm.cpp +++ b/src/KSPACE/msm.cpp @@ -37,8 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; #define MAX_LEVELS 10 -#define OFFSET 16384 -#define SMALL 0.00001 +static constexpr int OFFSET = 16384; +static constexpr double SMALL = 0.00001; enum{REVERSE_RHO,REVERSE_AD,REVERSE_AD_PERATOM}; enum{FORWARD_RHO,FORWARD_AD,FORWARD_AD_PERATOM}; diff --git a/src/KSPACE/msm_cg.cpp b/src/KSPACE/msm_cg.cpp index 4a8daedf10f..e680c05cb21 100644 --- a/src/KSPACE/msm_cg.cpp +++ b/src/KSPACE/msm_cg.cpp @@ -31,8 +31,8 @@ using namespace LAMMPS_NS; -#define OFFSET 16384 -#define SMALLQ 0.00001 +static constexpr int OFFSET = 16384; +static constexpr double SMALLQ = 0.00001; enum{REVERSE_RHO,REVERSE_AD,REVERSE_AD_PERATOM}; enum{FORWARD_RHO,FORWARD_AD,FORWARD_AD_PERATOM}; diff --git a/src/KSPACE/pair_coul_streitz.cpp b/src/KSPACE/pair_coul_streitz.cpp index bd7fd206565..9e3811c0274 100644 --- a/src/KSPACE/pair_coul_streitz.cpp +++ b/src/KSPACE/pair_coul_streitz.cpp @@ -35,9 +35,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 4 -#define PGDELTA 1 -#define MAXNEIGH 24 +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; +static constexpr int MAXNEIGH = 24; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm.cpp b/src/KSPACE/pppm.cpp index ac516ff18cc..0ac83c01fb8 100644 --- a/src/KSPACE/pppm.cpp +++ b/src/KSPACE/pppm.cpp @@ -45,22 +45,17 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double LARGE = 10000.0; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; enum{REVERSE_RHO}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_cg.cpp b/src/KSPACE/pppm_cg.cpp index 845abe0078c..e5ae0b05c89 100644 --- a/src/KSPACE/pppm_cg.cpp +++ b/src/KSPACE/pppm_cg.cpp @@ -34,17 +34,13 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define OFFSET 16384 -#define SMALLQ 0.00001 +static constexpr int OFFSET = 16384; +static constexpr double SMALLQ = 0.00001; enum{REVERSE_RHO}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#else -#define ZEROF 0.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_dipole.cpp b/src/KSPACE/pppm_dipole.cpp index e0d13f2b9a9..da64f85f9e9 100644 --- a/src/KSPACE/pppm_dipole.cpp +++ b/src/KSPACE/pppm_dipole.cpp @@ -40,22 +40,17 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double LARGE = 10000.0; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; enum{REVERSE_MU}; enum{FORWARD_MU,FORWARD_MU_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_dipole_spin.cpp b/src/KSPACE/pppm_dipole_spin.cpp index e96378180a5..16b9e459e6b 100644 --- a/src/KSPACE/pppm_dipole_spin.cpp +++ b/src/KSPACE/pppm_dipole_spin.cpp @@ -35,22 +35,17 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXORDER 7 -#define OFFSET 16384 -#define LARGE 10000.0 -#define SMALL 0.00001 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double LARGE = 10000.0; +static constexpr double SMALL = 0.00001; +static constexpr double EPS_HOC = 1.0e-7; enum{REVERSE_MU}; enum{FORWARD_MU,FORWARD_MU_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_disp.cpp b/src/KSPACE/pppm_disp.cpp index a738db98d23..58c91ce3bef 100644 --- a/src/KSPACE/pppm_disp.cpp +++ b/src/KSPACE/pppm_disp.cpp @@ -40,11 +40,11 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXORDER 7 -#define OFFSET 16384 -#define SMALL 0.00001 -#define LARGE 10000.0 -#define EPS_HOC 1.0e-7 +static constexpr int MAXORDER = 7; +static constexpr int OFFSET = 16384; +static constexpr double SMALL = 0.00001; +static constexpr double LARGE = 10000.0; +static constexpr double EPS_HOC = 1.0e-7; enum{REVERSE_RHO,REVERSE_RHO_GEOM,REVERSE_RHO_ARITH,REVERSE_RHO_NONE}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, @@ -55,13 +55,8 @@ enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM, FORWARD_IK_NONE,FORWARD_AD_NONE,FORWARD_IK_PERATOM_NONE, FORWARD_AD_PERATOM_NONE}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_disp.h b/src/KSPACE/pppm_disp.h index a222e041d96..1a271e59d2a 100644 --- a/src/KSPACE/pppm_disp.h +++ b/src/KSPACE/pppm_disp.h @@ -25,8 +25,8 @@ KSpaceStyle(pppm/disp,PPPMDisp); namespace LAMMPS_NS { -#define EWALD_MAXORDER 6 -#define EWALD_FUNCS 4 +static constexpr int EWALD_MAXORDER = 6; +static constexpr int EWALD_FUNCS = 4; class PPPMDisp : public KSpace { public: diff --git a/src/KSPACE/pppm_disp_tip4p.cpp b/src/KSPACE/pppm_disp_tip4p.cpp index c5ed2f26d6c..6161ebbe092 100644 --- a/src/KSPACE/pppm_disp_tip4p.cpp +++ b/src/KSPACE/pppm_disp_tip4p.cpp @@ -29,15 +29,10 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define OFFSET 16384 +static constexpr int OFFSET = 16384; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ @@ -490,7 +485,7 @@ void PPPMDispTIP4P::fieldforce_c_peratom() Fix handling of TIP4P dipole compared to PPPMDisp::slabcorr ------------------------------------------------------------------------- */ -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; void PPPMDispTIP4P::slabcorr(int /*eflag*/) { diff --git a/src/KSPACE/pppm_stagger.cpp b/src/KSPACE/pppm_stagger.cpp index d44f2428c88..a14d7a68d68 100644 --- a/src/KSPACE/pppm_stagger.cpp +++ b/src/KSPACE/pppm_stagger.cpp @@ -33,19 +33,14 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define OFFSET 16384 -#define EPS_HOC 1.0e-7 +static constexpr int OFFSET = 16384; +static constexpr double EPS_HOC = 1.0e-7; enum{REVERSE_RHO}; enum{FORWARD_IK,FORWARD_AD,FORWARD_IK_PERATOM,FORWARD_AD_PERATOM}; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; /* ---------------------------------------------------------------------- */ diff --git a/src/KSPACE/pppm_tip4p.cpp b/src/KSPACE/pppm_tip4p.cpp index 730b604d7a5..7237bc24f2e 100644 --- a/src/KSPACE/pppm_tip4p.cpp +++ b/src/KSPACE/pppm_tip4p.cpp @@ -29,15 +29,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define OFFSET 16384 - -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; +static constexpr int OFFSET = 16384; /* ---------------------------------------------------------------------- */ @@ -483,7 +477,7 @@ void PPPMTIP4P::fieldforce_peratom() Fix handling of TIP4P dipole compared to PPPMDisp::slabcorr ------------------------------------------------------------------------- */ -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; void PPPMTIP4P::slabcorr() { diff --git a/src/MACHDYN/fix_smd_adjust_dt.cpp b/src/MACHDYN/fix_smd_adjust_dt.cpp index d2728f10424..30006ec7cc8 100644 --- a/src/MACHDYN/fix_smd_adjust_dt.cpp +++ b/src/MACHDYN/fix_smd_adjust_dt.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/MACHDYN/fix_smd_tlsph_reference_configuration.cpp b/src/MACHDYN/fix_smd_tlsph_reference_configuration.cpp index b236952e603..72ad76eccdf 100644 --- a/src/MACHDYN/fix_smd_tlsph_reference_configuration.cpp +++ b/src/MACHDYN/fix_smd_tlsph_reference_configuration.cpp @@ -48,7 +48,7 @@ using namespace FixConst; using namespace SMD_Kernels; using namespace SMD_Math; -#define DELTA 16384 +static constexpr int DELTA = 16384; #define INSERT_PREDEFINED_CRACKS false diff --git a/src/MACHDYN/fix_smd_wall_surface.cpp b/src/MACHDYN/fix_smd_wall_surface.cpp index facc03d471a..3753b64f52a 100644 --- a/src/MACHDYN/fix_smd_wall_surface.cpp +++ b/src/MACHDYN/fix_smd_wall_surface.cpp @@ -32,8 +32,8 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace Eigen; using namespace std; -#define DELTA 16384 -#define EPSILON 1.0e-6 +static constexpr int DELTA = 16384; +static constexpr double EPSILON = 1.0e-6; /* ---------------------------------------------------------------------- */ diff --git a/src/MACHDYN/pair_smd_tlsph.cpp b/src/MACHDYN/pair_smd_tlsph.cpp index 845fed33524..6b2320219f4 100644 --- a/src/MACHDYN/pair_smd_tlsph.cpp +++ b/src/MACHDYN/pair_smd_tlsph.cpp @@ -54,8 +54,6 @@ using namespace SMD_Math; #define JAUMANN false #define DETF_MIN 0.2 // maximum compression deformation allow #define DETF_MAX 2.0 // maximum tension deformation allowed -#define TLSPH_DEBUG 0 -#define PLASTIC_STRAIN_AVERAGE_WINDOW 100.0 /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_airebo.cpp b/src/MANYBODY/pair_airebo.cpp index 129b9d2218c..13d2b97433f 100644 --- a/src/MANYBODY/pair_airebo.cpp +++ b/src/MANYBODY/pair_airebo.cpp @@ -41,8 +41,8 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define TOL 1.0e-9 -#define PGDELTA 1 +static constexpr double TOL = 1.0e-9; +static constexpr int PGDELTA = 1; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_comb.cpp b/src/MANYBODY/pair_comb.cpp index 126544ddc5f..37e3bb404fc 100644 --- a/src/MANYBODY/pair_comb.cpp +++ b/src/MANYBODY/pair_comb.cpp @@ -43,9 +43,9 @@ using namespace MathConst; using namespace MathExtra; using namespace MathSpecial; -#define DELTA 4 -#define PGDELTA 1 -#define MAXNEIGH 24 +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; +static constexpr int MAXNEIGH = 24; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_comb3.cpp b/src/MANYBODY/pair_comb3.cpp index a6a6ed37fd6..5ae599ea31d 100644 --- a/src/MANYBODY/pair_comb3.cpp +++ b/src/MANYBODY/pair_comb3.cpp @@ -43,9 +43,9 @@ using namespace MathConst; using namespace MathExtra; using namespace MathSpecial; -#define DELTA 4 -#define PGDELTA 1 -#define MAXNEIGH 24 +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; +static constexpr int MAXNEIGH = 24; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_eam.cpp b/src/MANYBODY/pair_eam.cpp index a3d4257cc2c..a2fff8fb55d 100644 --- a/src/MANYBODY/pair_eam.cpp +++ b/src/MANYBODY/pair_eam.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_eam_cd.cpp b/src/MANYBODY/pair_eam_cd.cpp index 1746435fad4..798292eb1de 100644 --- a/src/MANYBODY/pair_eam_cd.cpp +++ b/src/MANYBODY/pair_eam_cd.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 // This sets the maximum line length in EAM input files. +static constexpr int MAXLINE = 1024; // This sets the maximum line length in EAM input files. PairEAMCD::PairEAMCD(LAMMPS *lmp, int _cdeamVersion) : PairEAM(lmp), PairEAMAlloy(lmp), cdeamVersion(_cdeamVersion) diff --git a/src/MANYBODY/pair_edip.cpp b/src/MANYBODY/pair_edip.cpp index 974dc9ab84d..0098bb32e54 100644 --- a/src/MANYBODY/pair_edip.cpp +++ b/src/MANYBODY/pair_edip.cpp @@ -39,11 +39,11 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; -#define GRIDDENSITY 8000 -#define GRIDSTART 0.1 +static constexpr int GRIDDENSITY = 8000; +static constexpr double GRIDSTART = 0.1; // max number of interaction per atom for f(Z) environment potential diff --git a/src/MANYBODY/pair_edip_multi.cpp b/src/MANYBODY/pair_edip_multi.cpp index 00be0ad8290..2f8e9ca9c83 100644 --- a/src/MANYBODY/pair_edip_multi.cpp +++ b/src/MANYBODY/pair_edip_multi.cpp @@ -38,8 +38,8 @@ using namespace LAMMPS_NS; using namespace MathExtra; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; static const char cite_pair_edip[] = "pair edip/multi: doi:10.1103/PhysRevB.86.144118, doi:10.1088/0953-8984/22/3/035802\n\n" diff --git a/src/MANYBODY/pair_extep.cpp b/src/MANYBODY/pair_extep.cpp index 755b4d01323..bcebbd3e729 100644 --- a/src/MANYBODY/pair_extep.cpp +++ b/src/MANYBODY/pair_extep.cpp @@ -37,9 +37,9 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathExtra; -#define MAXLINE 1024 -#define DELTA 4 -#define PGDELTA 1 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_gw.cpp b/src/MANYBODY/pair_gw.cpp index 1fd98b80f01..471896851af 100644 --- a/src/MANYBODY/pair_gw.cpp +++ b/src/MANYBODY/pair_gw.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathExtra; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_gw_zbl.cpp b/src/MANYBODY/pair_gw_zbl.cpp index 5e61778c687..da1ff557ad2 100644 --- a/src/MANYBODY/pair_gw_zbl.cpp +++ b/src/MANYBODY/pair_gw_zbl.cpp @@ -32,8 +32,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_lcbop.cpp b/src/MANYBODY/pair_lcbop.cpp index ed085c4b986..1e193632129 100644 --- a/src/MANYBODY/pair_lcbop.cpp +++ b/src/MANYBODY/pair_lcbop.cpp @@ -33,9 +33,9 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define TOL 1.0e-9 -#define PGDELTA 1 +static constexpr int MAXLINE = 1024; +static constexpr double TOL = 1.0e-9; +static constexpr int PGDELTA = 1; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_local_density.cpp b/src/MANYBODY/pair_local_density.cpp index 71a7e658d2a..444f56f2919 100644 --- a/src/MANYBODY/pair_local_density.cpp +++ b/src/MANYBODY/pair_local_density.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; static const char cite_pair_local_density[] = "pair_style local/density command: doi:10.1063/1.4958629, doi:10.1021/acs.jpcb.7b12446\n\n" diff --git a/src/MANYBODY/pair_meam_spline.cpp b/src/MANYBODY/pair_meam_spline.cpp index 1c17f434f21..b952330c044 100644 --- a/src/MANYBODY/pair_meam_spline.cpp +++ b/src/MANYBODY/pair_meam_spline.cpp @@ -440,7 +440,7 @@ void PairMEAMSpline::coeff(int narg, char **arg) } } -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; void PairMEAMSpline::read_file(const char* filename) { diff --git a/src/MANYBODY/pair_meam_sw_spline.cpp b/src/MANYBODY/pair_meam_sw_spline.cpp index 3e3e813c5b2..e02625c598a 100644 --- a/src/MANYBODY/pair_meam_sw_spline.cpp +++ b/src/MANYBODY/pair_meam_sw_spline.cpp @@ -384,7 +384,7 @@ void PairMEAMSWSpline::coeff(int narg, char **arg) set coeffs for one or more type pairs ------------------------------------------------------------------------- */ -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; void PairMEAMSWSpline::read_file(const char* filename) { diff --git a/src/MANYBODY/pair_nb3b_harmonic.cpp b/src/MANYBODY/pair_nb3b_harmonic.cpp index 5bc930c1860..51e554694cd 100644 --- a/src/MANYBODY/pair_nb3b_harmonic.cpp +++ b/src/MANYBODY/pair_nb3b_harmonic.cpp @@ -34,8 +34,8 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -#define DELTA 4 -#define SMALL 0.001 +static constexpr int DELTA = 4; +static constexpr double SMALL = 0.001; static const char *substyle[] = {"nb3n/harmonic", "nb3b/screened"}; diff --git a/src/MANYBODY/pair_nb3b_screened.cpp b/src/MANYBODY/pair_nb3b_screened.cpp index d66945d563d..9480ae9f15e 100644 --- a/src/MANYBODY/pair_nb3b_screened.cpp +++ b/src/MANYBODY/pair_nb3b_screened.cpp @@ -20,7 +20,7 @@ #include -#define SMALL 0.001 +static constexpr double SMALL = 0.001; using namespace LAMMPS_NS; diff --git a/src/MANYBODY/pair_polymorphic.cpp b/src/MANYBODY/pair_polymorphic.cpp index 03ef6cb49f2..cc0b225a782 100644 --- a/src/MANYBODY/pair_polymorphic.cpp +++ b/src/MANYBODY/pair_polymorphic.cpp @@ -38,8 +38,8 @@ using namespace LAMMPS_NS; using namespace MathExtra; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_sw.cpp b/src/MANYBODY/pair_sw.cpp index 540fd8772c2..18b642967cb 100644 --- a/src/MANYBODY/pair_sw.cpp +++ b/src/MANYBODY/pair_sw.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_sw_angle_table.cpp b/src/MANYBODY/pair_sw_angle_table.cpp index 21f1967c0d8..8e605caebdc 100644 --- a/src/MANYBODY/pair_sw_angle_table.cpp +++ b/src/MANYBODY/pair_sw_angle_table.cpp @@ -39,7 +39,7 @@ using MathConst::DEG2RAD; using MathConst::MY_PI; using MathConst::RAD2DEG; -#define DELTA 4 +static constexpr int DELTA = 4; enum { LINEAR, SPLINE }; diff --git a/src/MANYBODY/pair_tersoff.cpp b/src/MANYBODY/pair_tersoff.cpp index c7c45bc8657..e3c8c834167 100644 --- a/src/MANYBODY/pair_tersoff.cpp +++ b/src/MANYBODY/pair_tersoff.cpp @@ -40,7 +40,7 @@ using namespace MathConst; using namespace MathSpecial; using namespace MathExtra; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_mod.cpp b/src/MANYBODY/pair_tersoff_mod.cpp index 010ff8df876..f4ae623baeb 100644 --- a/src/MANYBODY/pair_tersoff_mod.cpp +++ b/src/MANYBODY/pair_tersoff_mod.cpp @@ -35,7 +35,7 @@ using namespace MathConst; using namespace MathExtra; using namespace MathSpecial; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_mod_c.cpp b/src/MANYBODY/pair_tersoff_mod_c.cpp index bdec854c413..e7fef3ccfa4 100644 --- a/src/MANYBODY/pair_tersoff_mod_c.cpp +++ b/src/MANYBODY/pair_tersoff_mod_c.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_tersoff_table.cpp b/src/MANYBODY/pair_tersoff_table.cpp index 325542f97ee..34c3573d0ce 100644 --- a/src/MANYBODY/pair_tersoff_table.cpp +++ b/src/MANYBODY/pair_tersoff_table.cpp @@ -39,10 +39,10 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -#define MAXLINE 1024 -#define DELTA 4 +static constexpr int MAXLINE = 1024; +static constexpr int DELTA = 4; -#define GRIDSTART 0.1 +static constexpr double GRIDSTART = 0.1; #define GRIDDENSITY_FCUTOFF 5000 #define GRIDDENSITY_EXP 12000 #define GRIDDENSITY_GTETA 12000 diff --git a/src/MANYBODY/pair_tersoff_zbl.cpp b/src/MANYBODY/pair_tersoff_zbl.cpp index daf2718cb1a..9c4dabc219c 100644 --- a/src/MANYBODY/pair_tersoff_zbl.cpp +++ b/src/MANYBODY/pair_tersoff_zbl.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_threebody_table.cpp b/src/MANYBODY/pair_threebody_table.cpp index 57f7021816c..20b26edbfab 100644 --- a/src/MANYBODY/pair_threebody_table.cpp +++ b/src/MANYBODY/pair_threebody_table.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using MathConst::MY_PI; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MANYBODY/pair_vashishta.cpp b/src/MANYBODY/pair_vashishta.cpp index 531f15d2638..79df1f36d7e 100644 --- a/src/MANYBODY/pair_vashishta.cpp +++ b/src/MANYBODY/pair_vashishta.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_bond_break.cpp b/src/MC/fix_bond_break.cpp index 6589f93e239..bb3e725c961 100644 --- a/src/MC/fix_bond_break.cpp +++ b/src/MC/fix_bond_break.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTA 16 +static constexpr int DELTA = 16; /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_bond_create.cpp b/src/MC/fix_bond_create.cpp index adecc9f2521..8922bde55fb 100644 --- a/src/MC/fix_bond_create.cpp +++ b/src/MC/fix_bond_create.cpp @@ -34,8 +34,8 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define BIG 1.0e20 -#define DELTA 16 +static constexpr double BIG = 1.0e20; +static constexpr int DELTA = 16; /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_charge_regulation.cpp b/src/MC/fix_charge_regulation.cpp index a828f276ead..2fade2be79a 100644 --- a/src/MC/fix_charge_regulation.cpp +++ b/src/MC/fix_charge_regulation.cpp @@ -66,9 +66,9 @@ static const char cite_fix_charge_regulation[] = enum{CONSTANT,EQUAL}; // parsing input variables // large energy value used to signal overlap -#define MAXENERGYSIGNAL 1.0e100 -#define MAXENERGYTEST 1.0e50 -#define SMALL 0.0000001 +static constexpr double MAXENERGYSIGNAL = 1.0e100; +static constexpr double MAXENERGYTEST = 1.0e50; +static constexpr double SMALL = 0.0000001; #define NA_RHO0 0.602214 // Avogadro's constant times reference concentration (N_A * mol / liter) [nm^-3] /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_gcmc.cpp b/src/MC/fix_gcmc.cpp index 2e29b403fd1..b3d000e8b11 100644 --- a/src/MC/fix_gcmc.cpp +++ b/src/MC/fix_gcmc.cpp @@ -52,14 +52,14 @@ using namespace MathConst; // large energy value used to signal overlap -#define MAXENERGYSIGNAL 1.0e100 +static constexpr double MAXENERGYSIGNAL = 1.0e100; // this must be lower than MAXENERGYSIGNAL // by a large amount, so that it is still // less than total energy when negative // energy contributions are added to MAXENERGYSIGNAL -#define MAXENERGYTEST 1.0e50 +static constexpr double MAXENERGYTEST = 1.0e50; enum { EXCHATOM, EXCHMOL }; // exchmode enum { NONE, MOVEATOM, MOVEMOL }; // movemode diff --git a/src/MC/fix_mol_swap.cpp b/src/MC/fix_mol_swap.cpp index a47cf039d16..f496d4a9c5d 100644 --- a/src/MC/fix_mol_swap.cpp +++ b/src/MC/fix_mol_swap.cpp @@ -38,7 +38,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/MC/fix_widom.cpp b/src/MC/fix_widom.cpp index 7869b213a06..c0a5501a228 100644 --- a/src/MC/fix_widom.cpp +++ b/src/MC/fix_widom.cpp @@ -50,7 +50,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using MathConst::MY_2PI; -#define MAXENERGYTEST 1.0e50 +static constexpr double MAXENERGYTEST = 1.0e50; enum { EXCHATOM, EXCHMOL }; // exchmode /* ---------------------------------------------------------------------- */ diff --git a/src/MDI/fix_mdi_qm.cpp b/src/MDI/fix_mdi_qm.cpp index ff2c667f1ce..86dc87fd356 100644 --- a/src/MDI/fix_mdi_qm.cpp +++ b/src/MDI/fix_mdi_qm.cpp @@ -27,7 +27,7 @@ using namespace FixConst; enum { NATIVE, REAL, METAL }; // LAMMPS units which MDI supports -#define MAXELEMENT 118 +static constexpr int MAXELEMENT = 118; // prototype for non-class compare function for sorting QM IDs diff --git a/src/MDI/fix_mdi_qmmm.cpp b/src/MDI/fix_mdi_qmmm.cpp index 958b5ec3121..c6df52333d7 100644 --- a/src/MDI/fix_mdi_qmmm.cpp +++ b/src/MDI/fix_mdi_qmmm.cpp @@ -31,7 +31,7 @@ using namespace FixConst; enum { NATIVE, REAL, METAL }; // LAMMPS units which MDI supports enum { DIRECT, POTENTIAL }; // mode of QMMM coupling -#define MAXELEMENT 118 +static constexpr int MAXELEMENT = 118; // prototype for non-class compare function for sorting QM IDs diff --git a/src/MDI/mdi_engine.cpp b/src/MDI/mdi_engine.cpp index f7025549cdb..9c58de7560a 100644 --- a/src/MDI/mdi_engine.cpp +++ b/src/MDI/mdi_engine.cpp @@ -54,7 +54,7 @@ enum { DEFAULT, MD, OPT }; // top-level MDI engine modes enum { TYPE, CHARGE, MASS, COORD, VELOCITY, FORCE, ADDFORCE }; -#define MAXELEMENT 118 +static constexpr int MAXELEMENT = 118; /* ---------------------------------------------------------------------- trigger LAMMPS to start acting as an MDI engine diff --git a/src/MEAM/pair_meam.cpp b/src/MEAM/pair_meam.cpp index 2f095754af3..c8932d9a319 100644 --- a/src/MEAM/pair_meam.cpp +++ b/src/MEAM/pair_meam.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; static const int nkeywords = 22; static const char *keywords[] = { diff --git a/src/MESONT/pair_mesocnt.cpp b/src/MESONT/pair_mesocnt.cpp index 521c8c5f60b..eae638bde87 100644 --- a/src/MESONT/pair_mesocnt.cpp +++ b/src/MESONT/pair_mesocnt.cpp @@ -43,11 +43,11 @@ using namespace MathExtra; using MathConst::MY_2PI; using MathConst::MY_PI; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; #define SELF_CUTOFF 3 -#define SMALL 1.0e-6 -#define SWITCH 1.0e-4 -#define RHOMIN 10.0 +static constexpr double SMALL = 1.0e-6; +static constexpr double SWITCH = 1.0e-4; +static constexpr double RHOMIN = 10.0; #define QUAD_FINF 129 #define QUAD_FSEMI 10 diff --git a/src/MESONT/pair_mesocnt_viscous.cpp b/src/MESONT/pair_mesocnt_viscous.cpp index be3715be25f..df159db92a7 100644 --- a/src/MESONT/pair_mesocnt_viscous.cpp +++ b/src/MESONT/pair_mesocnt_viscous.cpp @@ -36,7 +36,7 @@ using namespace MathExtra; using MathConst::MY_PI; #define SELF_CUTOFF 3 -#define RHOMIN 10.0 +static constexpr double RHOMIN = 10.0; #define QUAD_FINF 129 #define QUAD_FSEMI 10 diff --git a/src/MISC/pair_agni.cpp b/src/MISC/pair_agni.cpp index 8597e5db934..92b358316fe 100644 --- a/src/MISC/pair_agni.cpp +++ b/src/MISC/pair_agni.cpp @@ -47,8 +47,8 @@ static const char cite_pair_agni[] = " year = {2019},\n" "}\n\n"; -#define MAXLINE 10240 -#define MAXWORD 40 +static constexpr int MAXLINE = 10240; +static constexpr int MAXWORD = 40; /* ---------------------------------------------------------------------- */ diff --git a/src/MISC/pair_srp.cpp b/src/MISC/pair_srp.cpp index ddcfb92e9ca..31f5b85760d 100644 --- a/src/MISC/pair_srp.cpp +++ b/src/MISC/pair_srp.cpp @@ -47,8 +47,8 @@ Please contact Timothy Sirk for questions (tim.sirk@us.army.mil). using namespace LAMMPS_NS; -#define SMALL 1.0e-10 -#define BIG 1e10 +static constexpr double SMALL = 1.0e-10; +static constexpr double BIG = 1e10; #define ONETWOBIT 0x40000000 static const char cite_srp[] = diff --git a/src/ML-IAP/mliap_descriptor_snap.cpp b/src/ML-IAP/mliap_descriptor_snap.cpp index cec03fca767..892dc8a0049 100644 --- a/src/ML-IAP/mliap_descriptor_snap.cpp +++ b/src/ML-IAP/mliap_descriptor_snap.cpp @@ -31,8 +31,8 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; +static constexpr int MAXWORD = 3; /* ---------------------------------------------------------------------- */ @@ -380,7 +380,8 @@ void MLIAPDescriptorSNAP::read_paramfile(char *paramfilename) utils::getsyserror()); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int n; diff --git a/src/ML-IAP/mliap_descriptor_so3.cpp b/src/ML-IAP/mliap_descriptor_so3.cpp index 4f976f06bec..23089619139 100644 --- a/src/ML-IAP/mliap_descriptor_so3.cpp +++ b/src/ML-IAP/mliap_descriptor_so3.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; +static constexpr int MAXWORD = 3; /* ---------------------------------------------------------------------- */ @@ -90,7 +90,8 @@ void MLIAPDescriptorSO3::read_paramfile(char *paramfilename) utils::getsyserror()); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int n, nwords; diff --git a/src/ML-IAP/mliap_model.cpp b/src/ML-IAP/mliap_model.cpp index a93090d3644..c6df037c047 100644 --- a/src/ML-IAP/mliap_model.cpp +++ b/src/ML-IAP/mliap_model.cpp @@ -26,8 +26,8 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; +static constexpr int MAXWORD = 3; /* ---------------------------------------------------------------------- */ @@ -93,7 +93,8 @@ void MLIAPModelSimple::read_coeffs(char *coefffilename) utils::getsyserror()); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int n; diff --git a/src/ML-IAP/mliap_model_nn.cpp b/src/ML-IAP/mliap_model_nn.cpp index 6c039f9a07e..6695109f918 100644 --- a/src/ML-IAP/mliap_model_nn.cpp +++ b/src/ML-IAP/mliap_model_nn.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ @@ -75,7 +75,8 @@ void MLIAPModelNN::read_coeffs(char *coefffilename) utils::getsyserror()); } - char line[MAXLINE], *ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int n, eof = 0, nwords = 0; while (nwords == 0) { if (comm->me == 0) { diff --git a/src/ML-IAP/mliap_so3.cpp b/src/ML-IAP/mliap_so3.cpp index 72ca466ab38..bfdde4b9684 100644 --- a/src/ML-IAP/mliap_so3.cpp +++ b/src/ML-IAP/mliap_so3.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 1.0e-8 +static constexpr double SMALL = 1.0e-8; /* ---------------------------------------------------------------------- */ diff --git a/src/ML-POD/fitpod_command.cpp b/src/ML-POD/fitpod_command.cpp index 87de65c3e23..ef39962e0bf 100644 --- a/src/ML-POD/fitpod_command.cpp +++ b/src/ML-POD/fitpod_command.cpp @@ -33,8 +33,7 @@ using namespace LAMMPS_NS; using MathSpecial::powint; -#define MAXLINE 1024 - +static constexpr int MAXLINE = 1024; static constexpr double SMALL = 1.0e-10; FitPOD::FitPOD(LAMMPS *_lmp) : Command(_lmp), podptr(nullptr) @@ -151,7 +150,8 @@ int FitPOD::read_data_file(double *fitting_weights, std::string &file_format, // loop through lines of training data file and parse keywords - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { if (comm->me == 0) { @@ -252,7 +252,8 @@ int FitPOD::get_number_atom_exyz(std::vector& num_atom, int& num_atom_sum, error->one(FLERR,"Cannot open POD coefficient file {}: ", filename, utils::getsyserror()); } - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int num_configs = 0; num_atom_sum = 0; @@ -324,7 +325,8 @@ void FitPOD::read_exyz_file(double *lattice, double *stress, double *energy, dou error->one(FLERR,"Cannot open POD coefficient file {}: ", filename, utils::getsyserror()); } - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int cfi = 0; int nat = 0; diff --git a/src/ML-POD/mlpod.cpp b/src/ML-POD/mlpod.cpp index f20498b50b3..088b9abadc1 100644 --- a/src/ML-POD/mlpod.cpp +++ b/src/ML-POD/mlpod.cpp @@ -35,7 +35,7 @@ using MathConst::MY_PI; using MathSpecial::cube; using MathSpecial::powint; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; MLPOD::podstruct::podstruct() : twobody{4, 8, 6}, threebody{4, 8, 5, 4}, fourbody{0, 0, 0, 0}, pbc(nullptr), @@ -302,7 +302,8 @@ void MLPOD::read_pod(const std::string &pod_file) // loop through lines of POD file and parse keywords - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; while (true) { if (comm->me == 0) { @@ -639,7 +640,8 @@ void MLPOD::read_coeff_file(const std::string &coeff_file) // check format for first line of file - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int nwords = 0; while (nwords == 0) { diff --git a/src/ML-RANN/pair_rann.cpp b/src/ML-RANN/pair_rann.cpp index f2948cbb43c..4ec1f45703d 100644 --- a/src/ML-RANN/pair_rann.cpp +++ b/src/ML-RANN/pair_rann.cpp @@ -55,7 +55,7 @@ DISTRIBUTION A. Approved for public release; distribution unlimited. OPSEC#4918 #include "rann_fingerprint_radialscreenedspin.h" #include "rann_fingerprint_radialspin.h" -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; using namespace LAMMPS_NS; @@ -616,7 +616,8 @@ void PairRANN::read_weight(std::vector line,std::vector line,std::vector line1,FILE* fp,char *filename,int *linenum) { int i,j,l; - char linetemp[MAXLINE],*ptr; + char linetemp[MAXLINE] = {'\0'}; + char *ptr; for (l=0;lone(filename,*linenum-1,"networklayers must be defined before biases."); diff --git a/src/ML-SNAP/pair_snap.cpp b/src/ML-SNAP/pair_snap.cpp index 3029e9212df..f0fcd5c4e7a 100644 --- a/src/ML-SNAP/pair_snap.cpp +++ b/src/ML-SNAP/pair_snap.cpp @@ -29,8 +29,8 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 -#define MAXWORD 3 +static constexpr int MAXLINE = 1024; +static constexpr int MAXWORD = 3; /* ---------------------------------------------------------------------- */ @@ -475,7 +475,8 @@ void PairSNAP::read_files(char *coefffilename, char *paramfilename) coefffilename, utils::getsyserror()); } - char line[MAXLINE],*ptr; + char line[MAXLINE] = {'\0'}; + char *ptr; int eof = 0; int nwords = 0; while (nwords == 0) { diff --git a/src/MOFFF/angle_class2_p6.cpp b/src/MOFFF/angle_class2_p6.cpp index bfa6a068f56..39dec0d9d6f 100644 --- a/src/MOFFF/angle_class2_p6.cpp +++ b/src/MOFFF/angle_class2_p6.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/MOFFF/angle_cosine_buck6d.cpp b/src/MOFFF/angle_cosine_buck6d.cpp index dbdf39292e2..0ab9cbbf1f4 100644 --- a/src/MOFFF/angle_cosine_buck6d.cpp +++ b/src/MOFFF/angle_cosine_buck6d.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/MOFFF/improper_inversion_harmonic.cpp b/src/MOFFF/improper_inversion_harmonic.cpp index 817b35332a7..cc9bd8ad944 100644 --- a/src/MOFFF/improper_inversion_harmonic.cpp +++ b/src/MOFFF/improper_inversion_harmonic.cpp @@ -35,8 +35,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/angle_table.cpp b/src/MOLECULE/angle_table.cpp index c5e65be4023..b1984a69185 100644 --- a/src/MOLECULE/angle_table.cpp +++ b/src/MOLECULE/angle_table.cpp @@ -38,8 +38,8 @@ using MathConst::RAD2DEG; enum { LINEAR, SPLINE }; -#define SMALL 0.001 -#define TINY 1.E-10 +static constexpr double SMALL = 0.001; +static constexpr double TINY = 1.E-10; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/bond_table.cpp b/src/MOLECULE/bond_table.cpp index 4068e98e8d9..67cd3769ca5 100644 --- a/src/MOLECULE/bond_table.cpp +++ b/src/MOLECULE/bond_table.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; enum { NONE, LINEAR, SPLINE }; -#define BIGNUM 1.0e300 +static constexpr double BIGNUM = 1.0e300; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/pair_hbond_dreiding_lj.cpp b/src/MOLECULE/pair_hbond_dreiding_lj.cpp index 496e368452a..dbd7db7780d 100644 --- a/src/MOLECULE/pair_hbond_dreiding_lj.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_lj.cpp @@ -37,8 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 -#define CHUNK 8 +static constexpr double SMALL = 0.001; +static constexpr int CHUNK = 8; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLECULE/pair_hbond_dreiding_morse.cpp b/src/MOLECULE/pair_hbond_dreiding_morse.cpp index 7ec2db073d4..5cc45ea2348 100644 --- a/src/MOLECULE/pair_hbond_dreiding_morse.cpp +++ b/src/MOLECULE/pair_hbond_dreiding_morse.cpp @@ -37,8 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 -#define CHUNK 8 +static constexpr double SMALL = 0.001; +static constexpr int CHUNK = 8; /* ---------------------------------------------------------------------- */ diff --git a/src/MOLFILE/reader_molfile.cpp b/src/MOLFILE/reader_molfile.cpp index 441a152ad92..43154d658b8 100644 --- a/src/MOLFILE/reader_molfile.cpp +++ b/src/MOLFILE/reader_molfile.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; typedef MolfileInterface MFI; using namespace MathConst; -#define SMALL 1.0e-6 +static constexpr double SMALL = 1.0e-6; // true if the difference between two floats is "small". // cannot use fabsf() since it is not fully portable. diff --git a/src/OPENMP/angle_charmm_omp.cpp b/src/OPENMP/angle_charmm_omp.cpp index 9eb91bcb27c..bb5dcca0daf 100644 --- a/src/OPENMP/angle_charmm_omp.cpp +++ b/src/OPENMP/angle_charmm_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_class2_omp.cpp b/src/OPENMP/angle_class2_omp.cpp index 300f8f2b3c4..9480d2ebfbe 100644 --- a/src/OPENMP/angle_class2_omp.cpp +++ b/src/OPENMP/angle_class2_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_delta_omp.cpp b/src/OPENMP/angle_cosine_delta_omp.cpp index 98b6a7ac56d..cc8370d0531 100644 --- a/src/OPENMP/angle_cosine_delta_omp.cpp +++ b/src/OPENMP/angle_cosine_delta_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_omp.cpp b/src/OPENMP/angle_cosine_omp.cpp index 1985633c387..e4e32bd769b 100644 --- a/src/OPENMP/angle_cosine_omp.cpp +++ b/src/OPENMP/angle_cosine_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_periodic_omp.cpp b/src/OPENMP/angle_cosine_periodic_omp.cpp index 48532c8f6c4..4abe7bd6923 100644 --- a/src/OPENMP/angle_cosine_periodic_omp.cpp +++ b/src/OPENMP/angle_cosine_periodic_omp.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_shift_exp_omp.cpp b/src/OPENMP/angle_cosine_shift_exp_omp.cpp index 5831f59fab2..c131efd8397 100644 --- a/src/OPENMP/angle_cosine_shift_exp_omp.cpp +++ b/src/OPENMP/angle_cosine_shift_exp_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_shift_omp.cpp b/src/OPENMP/angle_cosine_shift_omp.cpp index 020f7583ff4..47fed634aa3 100644 --- a/src/OPENMP/angle_cosine_shift_omp.cpp +++ b/src/OPENMP/angle_cosine_shift_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_cosine_squared_omp.cpp b/src/OPENMP/angle_cosine_squared_omp.cpp index 9d98455fe48..f14af0b3e4a 100644 --- a/src/OPENMP/angle_cosine_squared_omp.cpp +++ b/src/OPENMP/angle_cosine_squared_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_dipole_omp.cpp b/src/OPENMP/angle_dipole_omp.cpp index 3a8099ac73f..338c63e42ee 100644 --- a/src/OPENMP/angle_dipole_omp.cpp +++ b/src/OPENMP/angle_dipole_omp.cpp @@ -29,7 +29,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_fourier_omp.cpp b/src/OPENMP/angle_fourier_omp.cpp index 0c85264342d..27d5f62595d 100644 --- a/src/OPENMP/angle_fourier_omp.cpp +++ b/src/OPENMP/angle_fourier_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_fourier_simple_omp.cpp b/src/OPENMP/angle_fourier_simple_omp.cpp index a8f234918b4..ad63fa08622 100644 --- a/src/OPENMP/angle_fourier_simple_omp.cpp +++ b/src/OPENMP/angle_fourier_simple_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.0001 +static constexpr double SMALL = 0.0001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_harmonic_omp.cpp b/src/OPENMP/angle_harmonic_omp.cpp index e83146a3ad7..5d779fbe216 100644 --- a/src/OPENMP/angle_harmonic_omp.cpp +++ b/src/OPENMP/angle_harmonic_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_quartic_omp.cpp b/src/OPENMP/angle_quartic_omp.cpp index bb9a9837d2f..7c1d1b4a17c 100644 --- a/src/OPENMP/angle_quartic_omp.cpp +++ b/src/OPENMP/angle_quartic_omp.cpp @@ -28,7 +28,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_spica_omp.cpp b/src/OPENMP/angle_spica_omp.cpp index 728e2ff4356..f1dd7d40b50 100644 --- a/src/OPENMP/angle_spica_omp.cpp +++ b/src/OPENMP/angle_spica_omp.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace LJSPICAParms; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/angle_table_omp.cpp b/src/OPENMP/angle_table_omp.cpp index d75bd8a6945..11436723b1a 100644 --- a/src/OPENMP/angle_table_omp.cpp +++ b/src/OPENMP/angle_table_omp.cpp @@ -29,7 +29,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_charmm_omp.cpp b/src/OPENMP/dihedral_charmm_omp.cpp index e78a3e89192..42fbea419fc 100644 --- a/src/OPENMP/dihedral_charmm_omp.cpp +++ b/src/OPENMP/dihedral_charmm_omp.cpp @@ -30,8 +30,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_class2_omp.cpp b/src/OPENMP/dihedral_class2_omp.cpp index 8ec39ceee82..ffcdf4fa1ad 100644 --- a/src/OPENMP/dihedral_class2_omp.cpp +++ b/src/OPENMP/dihedral_class2_omp.cpp @@ -29,8 +29,8 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.0000001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.0000001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp b/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp index 106db995c41..4032f9a13d4 100644 --- a/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp +++ b/src/OPENMP/dihedral_cosine_shift_exp_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_fourier_omp.cpp b/src/OPENMP/dihedral_fourier_omp.cpp index aae1eec5592..34a145a06d9 100644 --- a/src/OPENMP/dihedral_fourier_omp.cpp +++ b/src/OPENMP/dihedral_fourier_omp.cpp @@ -29,7 +29,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 +static constexpr double TOLERANCE = 0.05; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_harmonic_omp.cpp b/src/OPENMP/dihedral_harmonic_omp.cpp index 8737c61cdd1..f8df7dd41e4 100644 --- a/src/OPENMP/dihedral_harmonic_omp.cpp +++ b/src/OPENMP/dihedral_harmonic_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_helix_omp.cpp b/src/OPENMP/dihedral_helix_omp.cpp index d7782859746..64ba0b9af51 100644 --- a/src/OPENMP/dihedral_helix_omp.cpp +++ b/src/OPENMP/dihedral_helix_omp.cpp @@ -31,9 +31,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_multi_harmonic_omp.cpp b/src/OPENMP/dihedral_multi_harmonic_omp.cpp index d3f4447d08a..57c4b775656 100644 --- a/src/OPENMP/dihedral_multi_harmonic_omp.cpp +++ b/src/OPENMP/dihedral_multi_harmonic_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_nharmonic_omp.cpp b/src/OPENMP/dihedral_nharmonic_omp.cpp index f9a3f1328da..34e54f6c7c1 100644 --- a/src/OPENMP/dihedral_nharmonic_omp.cpp +++ b/src/OPENMP/dihedral_nharmonic_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_opls_omp.cpp b/src/OPENMP/dihedral_opls_omp.cpp index fbdc408c4d7..ccfd2ea42c8 100644 --- a/src/OPENMP/dihedral_opls_omp.cpp +++ b/src/OPENMP/dihedral_opls_omp.cpp @@ -29,9 +29,9 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_quadratic_omp.cpp b/src/OPENMP/dihedral_quadratic_omp.cpp index 43d97da5f22..52b7c331fd7 100644 --- a/src/OPENMP/dihedral_quadratic_omp.cpp +++ b/src/OPENMP/dihedral_quadratic_omp.cpp @@ -31,9 +31,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define SMALLER 0.00001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr double SMALLER = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/dihedral_table_omp.cpp b/src/OPENMP/dihedral_table_omp.cpp index 7405ae4a131..db90e32e6b5 100644 --- a/src/OPENMP/dihedral_table_omp.cpp +++ b/src/OPENMP/dihedral_table_omp.cpp @@ -34,8 +34,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathExtra; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; // -------------------------------------------- // ------- Calculate the dihedral angle ------- diff --git a/src/OPENMP/ewald_omp.cpp b/src/OPENMP/ewald_omp.cpp index ee2963659ab..fc32efd3c02 100644 --- a/src/OPENMP/ewald_omp.cpp +++ b/src/OPENMP/ewald_omp.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/fix_nh_omp.cpp b/src/OPENMP/fix_nh_omp.cpp index a7fe2738ca8..d3565c4994e 100644 --- a/src/OPENMP/fix_nh_omp.cpp +++ b/src/OPENMP/fix_nh_omp.cpp @@ -33,7 +33,7 @@ using namespace FixConst; enum{NOBIAS,BIAS}; enum{ISO,ANISO,TRICLINIC}; -#define TILTMAX 1.5 +static constexpr double TILTMAX = 1.5; typedef struct { double x,y,z; } dbl3_t; diff --git a/src/OPENMP/fix_nh_sphere_omp.cpp b/src/OPENMP/fix_nh_sphere_omp.cpp index 93a674cbce7..e5c1c247832 100644 --- a/src/OPENMP/fix_nh_sphere_omp.cpp +++ b/src/OPENMP/fix_nh_sphere_omp.cpp @@ -28,7 +28,7 @@ using namespace FixConst; enum{NOBIAS,BIAS}; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere typedef struct { double x,y,z; } dbl3_t; diff --git a/src/OPENMP/fix_nve_sphere_omp.cpp b/src/OPENMP/fix_nve_sphere_omp.cpp index be3fc8d147f..8c65a0df6a4 100644 --- a/src/OPENMP/fix_nve_sphere_omp.cpp +++ b/src/OPENMP/fix_nve_sphere_omp.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathExtra; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere enum{NONE,DIPOLE}; enum{NODLM,DLM}; diff --git a/src/OPENMP/improper_class2_omp.cpp b/src/OPENMP/improper_class2_omp.cpp index b7387ea75a1..38a2f12f5ee 100644 --- a/src/OPENMP/improper_class2_omp.cpp +++ b/src/OPENMP/improper_class2_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_cossq_omp.cpp b/src/OPENMP/improper_cossq_omp.cpp index 3bfc86bcaba..4ccc0d730a0 100644 --- a/src/OPENMP/improper_cossq_omp.cpp +++ b/src/OPENMP/improper_cossq_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_cvff_omp.cpp b/src/OPENMP/improper_cvff_omp.cpp index 310806d872c..b7fe9ffb03c 100644 --- a/src/OPENMP/improper_cvff_omp.cpp +++ b/src/OPENMP/improper_cvff_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_fourier_omp.cpp b/src/OPENMP/improper_fourier_omp.cpp index b70e3fb0ac9..000bc020664 100644 --- a/src/OPENMP/improper_fourier_omp.cpp +++ b/src/OPENMP/improper_fourier_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_harmonic_omp.cpp b/src/OPENMP/improper_harmonic_omp.cpp index d17fe9407d7..12c26996637 100644 --- a/src/OPENMP/improper_harmonic_omp.cpp +++ b/src/OPENMP/improper_harmonic_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_ring_omp.cpp b/src/OPENMP/improper_ring_omp.cpp index 899727c685c..366d03e02d3 100644 --- a/src/OPENMP/improper_ring_omp.cpp +++ b/src/OPENMP/improper_ring_omp.cpp @@ -31,8 +31,8 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/improper_umbrella_omp.cpp b/src/OPENMP/improper_umbrella_omp.cpp index e5d03863df2..50c1ce46764 100644 --- a/src/OPENMP/improper_umbrella_omp.cpp +++ b/src/OPENMP/improper_umbrella_omp.cpp @@ -29,8 +29,8 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/msm_cg_omp.cpp b/src/OPENMP/msm_cg_omp.cpp index 6904830fedc..00230c9eced 100644 --- a/src/OPENMP/msm_cg_omp.cpp +++ b/src/OPENMP/msm_cg_omp.cpp @@ -38,8 +38,8 @@ using namespace LAMMPS_NS; -#define OFFSET 16384 -#define SMALLQ 0.00001 +static constexpr int OFFSET = 16384; +static constexpr double SMALLQ = 0.00001; enum{REVERSE_RHO,REVERSE_AD,REVERSE_AD_PERATOM}; enum{FORWARD_RHO,FORWARD_AD,FORWARD_AD_PERATOM}; diff --git a/src/OPENMP/pair_airebo_omp.cpp b/src/OPENMP/pair_airebo_omp.cpp index 0872678518b..9f992aefdaa 100644 --- a/src/OPENMP/pair_airebo_omp.cpp +++ b/src/OPENMP/pair_airebo_omp.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathSpecial; -#define TOL 1.0e-9 +static constexpr double TOL = 1.0e-9; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_brownian_omp.cpp b/src/OPENMP/pair_brownian_omp.cpp index 45288f13dd7..1506f1f35ae 100644 --- a/src/OPENMP/pair_brownian_omp.cpp +++ b/src/OPENMP/pair_brownian_omp.cpp @@ -36,11 +36,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define EPSILON 1.0e-10 - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ @@ -93,7 +89,7 @@ void PairBrownianOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_brownian_poly_omp.cpp b/src/OPENMP/pair_brownian_poly_omp.cpp index 91a496979d0..ddd1af2c015 100644 --- a/src/OPENMP/pair_brownian_poly_omp.cpp +++ b/src/OPENMP/pair_brownian_poly_omp.cpp @@ -36,11 +36,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define EPSILON 1.0e-10 - -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ @@ -93,7 +89,7 @@ void PairBrownianPolyOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_comb_omp.cpp b/src/OPENMP/pair_comb_omp.cpp index aceff6e111a..87d467a8468 100644 --- a/src/OPENMP/pair_comb_omp.cpp +++ b/src/OPENMP/pair_comb_omp.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using MathExtra::dot3; -#define MAXNEIGH 24 +static constexpr int MAXNEIGH = 24; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_dpd_ext_omp.cpp b/src/OPENMP/pair_dpd_ext_omp.cpp index f900512e26a..9c53984b68b 100644 --- a/src/OPENMP/pair_dpd_ext_omp.cpp +++ b/src/OPENMP/pair_dpd_ext_omp.cpp @@ -28,7 +28,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_dpd_ext_tstat_omp.cpp b/src/OPENMP/pair_dpd_ext_tstat_omp.cpp index b55a9d39c62..41234dbcc99 100644 --- a/src/OPENMP/pair_dpd_ext_tstat_omp.cpp +++ b/src/OPENMP/pair_dpd_ext_tstat_omp.cpp @@ -28,7 +28,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_dpd_omp.cpp b/src/OPENMP/pair_dpd_omp.cpp index f267bde1b01..c4226b5f9d6 100644 --- a/src/OPENMP/pair_dpd_omp.cpp +++ b/src/OPENMP/pair_dpd_omp.cpp @@ -27,7 +27,7 @@ #include "suffix.h" using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_dpd_tstat_omp.cpp b/src/OPENMP/pair_dpd_tstat_omp.cpp index 2396bf57561..86ecd86528b 100644 --- a/src/OPENMP/pair_dpd_tstat_omp.cpp +++ b/src/OPENMP/pair_dpd_tstat_omp.cpp @@ -28,7 +28,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define EPSILON 1.0e-10 +static constexpr double EPSILON = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_edip_omp.cpp b/src/OPENMP/pair_edip_omp.cpp index 7c31f0db780..a96f276916f 100644 --- a/src/OPENMP/pair_edip_omp.cpp +++ b/src/OPENMP/pair_edip_omp.cpp @@ -28,8 +28,8 @@ using namespace LAMMPS_NS; static constexpr int leadDimInteractionList = 64; -#define GRIDDENSITY 8000 -#define GRIDSTART 0.1 +static constexpr int GRIDDENSITY = 8000; +static constexpr double GRIDSTART = 0.1; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_hbond_dreiding_lj_omp.cpp b/src/OPENMP/pair_hbond_dreiding_lj_omp.cpp index e7ba4d72c6a..b0f6dcfb5b9 100644 --- a/src/OPENMP/pair_hbond_dreiding_lj_omp.cpp +++ b/src/OPENMP/pair_hbond_dreiding_lj_omp.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_hbond_dreiding_morse_omp.cpp b/src/OPENMP/pair_hbond_dreiding_morse_omp.cpp index 99e2d2c5b1d..0e43e2a037a 100644 --- a/src/OPENMP/pair_hbond_dreiding_morse_omp.cpp +++ b/src/OPENMP/pair_hbond_dreiding_morse_omp.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_lj_cut_thole_long_omp.cpp b/src/OPENMP/pair_lj_cut_thole_long_omp.cpp index 1ad97a44161..8fdea2ce6d0 100644 --- a/src/OPENMP/pair_lj_cut_thole_long_omp.cpp +++ b/src/OPENMP/pair_lj_cut_thole_long_omp.cpp @@ -43,7 +43,7 @@ using namespace MathConst; #define B4 -5.80844129e-3 #define B5 1.14652755e-1 -#define EPSILON 1.0e-20 +static constexpr double EPSILON = 1.0e-20; #define EPS_EWALD 1.0e-6 #define EPS_EWALD_SQR 1.0e-12 diff --git a/src/OPENMP/pair_lubricate_omp.cpp b/src/OPENMP/pair_lubricate_omp.cpp index 2145744a5ba..5ba66ff266f 100644 --- a/src/OPENMP/pair_lubricate_omp.cpp +++ b/src/OPENMP/pair_lubricate_omp.cpp @@ -32,10 +32,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricateOMP::PairLubricateOMP(LAMMPS *lmp) : @@ -74,7 +70,7 @@ void PairLubricateOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_lubricate_poly_omp.cpp b/src/OPENMP/pair_lubricate_poly_omp.cpp index 5b98ec7b144..ebb2d65496b 100644 --- a/src/OPENMP/pair_lubricate_poly_omp.cpp +++ b/src/OPENMP/pair_lubricate_poly_omp.cpp @@ -32,10 +32,6 @@ using namespace LAMMPS_NS; using namespace MathConst; -// same as fix_wall.cpp - -enum{EDGE,CONSTANT,VARIABLE}; - /* ---------------------------------------------------------------------- */ PairLubricatePolyOMP::PairLubricatePolyOMP(LAMMPS *_lmp) : @@ -74,7 +70,7 @@ void PairLubricatePolyOMP::compute(int eflag, int vflag) for (int m = 0; m < wallfix->nwall; m++) { int dim = wallfix->wallwhich[m] / 2; int side = wallfix->wallwhich[m] % 2; - if (wallfix->xstyle[m] == VARIABLE) { + if (wallfix->xstyle[m] == FixWall::VARIABLE) { wallcoord = input->variable->compute_equal(wallfix->xindex[m]); } else wallcoord = wallfix->coord0[m]; diff --git a/src/OPENMP/pair_soft_omp.cpp b/src/OPENMP/pair_soft_omp.cpp index 0be8c80dcfa..309d11a6f9c 100644 --- a/src/OPENMP/pair_soft_omp.cpp +++ b/src/OPENMP/pair_soft_omp.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 1.0e-4 +static constexpr double SMALL = 1.0e-4; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pair_tersoff_table_omp.cpp b/src/OPENMP/pair_tersoff_table_omp.cpp index 5c44aa33294..ec97df26f62 100644 --- a/src/OPENMP/pair_tersoff_table_omp.cpp +++ b/src/OPENMP/pair_tersoff_table_omp.cpp @@ -26,7 +26,7 @@ #include "omp_compat.h" using namespace LAMMPS_NS; -#define GRIDSTART 0.1 +static constexpr double GRIDSTART = 0.1; #define GRIDDENSITY_FCUTOFF 5000 #define GRIDDENSITY_EXP 12000 #define GRIDDENSITY_GTETA 12000 diff --git a/src/OPENMP/pair_tersoff_zbl_omp.cpp b/src/OPENMP/pair_tersoff_zbl_omp.cpp index cefa89665a1..524d7fe509f 100644 --- a/src/OPENMP/pair_tersoff_zbl_omp.cpp +++ b/src/OPENMP/pair_tersoff_zbl_omp.cpp @@ -34,7 +34,7 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#define DELTA 4 +static constexpr int DELTA = 4; /* ---------------------------------------------------------------------- Fermi-like smoothing function diff --git a/src/OPENMP/pppm_cg_omp.cpp b/src/OPENMP/pppm_cg_omp.cpp index 4c751a16f72..0eff5c93636 100644 --- a/src/OPENMP/pppm_cg_omp.cpp +++ b/src/OPENMP/pppm_cg_omp.cpp @@ -38,15 +38,10 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; -#define EPS_HOC 1.0e-7 +static constexpr double EPS_HOC = 1.0e-7; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pppm_disp_omp.cpp b/src/OPENMP/pppm_disp_omp.cpp index 24bf2d95648..b610b1711e1 100644 --- a/src/OPENMP/pppm_disp_omp.cpp +++ b/src/OPENMP/pppm_disp_omp.cpp @@ -38,15 +38,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#define ONEF 1.0f -#else -#define ZEROF 0.0 -#define ONEF 1.0 -#endif - -#define OFFSET 16384 +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr FFT_SCALAR ONEF = 1.0; +static constexpr int OFFSET = 16384; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pppm_disp_tip4p_omp.cpp b/src/OPENMP/pppm_disp_tip4p_omp.cpp index ab6342a047e..bcc083e809b 100644 --- a/src/OPENMP/pppm_disp_tip4p_omp.cpp +++ b/src/OPENMP/pppm_disp_tip4p_omp.cpp @@ -37,13 +37,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#else -#define ZEROF 0.0 -#endif - -#define OFFSET 16384 +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr int OFFSET = 16384; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pppm_omp.cpp b/src/OPENMP/pppm_omp.cpp index 86e65da1010..a178483b8a5 100644 --- a/src/OPENMP/pppm_omp.cpp +++ b/src/OPENMP/pppm_omp.cpp @@ -38,13 +38,8 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#else -#define ZEROF 0.0 -#endif - -#define EPS_HOC 1.0e-7 +static constexpr FFT_SCALAR ZEROF = 0.0; +static constexpr double EPS_HOC = 1.0e-7; /* ---------------------------------------------------------------------- */ diff --git a/src/OPENMP/pppm_tip4p_omp.cpp b/src/OPENMP/pppm_tip4p_omp.cpp index 66ce44b5ef4..420a1168161 100644 --- a/src/OPENMP/pppm_tip4p_omp.cpp +++ b/src/OPENMP/pppm_tip4p_omp.cpp @@ -39,14 +39,10 @@ using namespace LAMMPS_NS; using namespace MathConst; using namespace MathSpecial; -#ifdef FFT_SINGLE -#define ZEROF 0.0f -#else -#define ZEROF 0.0 -#endif +static constexpr FFT_SCALAR ZEROF = 0.0; -#define EPS_HOC 1.0e-7 -#define OFFSET 16384 +static constexpr double EPS_HOC = 1.0e-7; +static constexpr int OFFSET = 16384; /* ---------------------------------------------------------------------- */ diff --git a/src/ORIENT/fix_orient_bcc.cpp b/src/ORIENT/fix_orient_bcc.cpp index 2d801b0bdc7..25fec2e606a 100644 --- a/src/ORIENT/fix_orient_bcc.cpp +++ b/src/ORIENT/fix_orient_bcc.cpp @@ -38,7 +38,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define BIG 1000000000 +static constexpr int BIG = 1000000000; static const char cite_fix_orient_bcc[] = "fix orient/bcc command: doi:10.1016/j.commatsci.2016.02.016\n\n" diff --git a/src/ORIENT/fix_orient_fcc.cpp b/src/ORIENT/fix_orient_fcc.cpp index cdb3fd689d9..78a84852787 100644 --- a/src/ORIENT/fix_orient_fcc.cpp +++ b/src/ORIENT/fix_orient_fcc.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define BIG 1000000000 +static constexpr int BIG = 1000000000; static const char cite_fix_orient_fcc[] = "fix orient/fcc command: doi:10.1038/nmat1559\n\n" diff --git a/src/PHONON/fix_phonon.cpp b/src/PHONON/fix_phonon.cpp index 6b5294d3087..786931a549c 100644 --- a/src/PHONON/fix_phonon.cpp +++ b/src/PHONON/fix_phonon.cpp @@ -45,9 +45,9 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define MAXLINE 512 +static constexpr int MAXLINE = 512; -enum{FORWARD=-1,BACKWARD=1}; +enum{ FORWARD=-1, BACKWARD=1 }; static const char cite_fix_phonon[] = "fix phonon command: doi:10.1016/j.cpc.2011.04.019\n\n" @@ -555,7 +555,7 @@ void FixPhonon::readmap() } // read from map file for others - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; FILE *fp = fopen(mapfile, "r"); if (fp == nullptr) error->all(FLERR,"Cannot open input map file {}: {}", mapfile, utils::getsyserror()); diff --git a/src/POEMS/fix_poems.cpp b/src/POEMS/fix_poems.cpp index 55199a71912..6ae21f652cd 100644 --- a/src/POEMS/fix_poems.cpp +++ b/src/POEMS/fix_poems.cpp @@ -42,9 +42,9 @@ using namespace LAMMPS_NS; using namespace FixConst; #define MAXBODY 2 // currently 2 since only linear chains allowed -#define DELTA 128 -#define TOLERANCE 1.0e-6 -#define EPSILON 1.0e-7 +static constexpr int DELTA = 128; +static constexpr double TOLERANCE = 1.0e-6; +static constexpr double EPSILON = 1.0e-7; static const char cite_fix_poems[] = "fix poems command: doi:10.1016/j.ijnonlinmec.2008.04.003\n\n" diff --git a/src/PTM/ptm_convex_hull_incremental.cpp b/src/PTM/ptm_convex_hull_incremental.cpp index 25ff54c7879..abae00778cf 100644 --- a/src/PTM/ptm_convex_hull_incremental.cpp +++ b/src/PTM/ptm_convex_hull_incremental.cpp @@ -17,10 +17,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI namespace ptm { -#define VISIBLE 1 -#define INVISIBLE 2 -#define BOTH 3 -#define TOLERANCE 1E-8 +enum { VISIBLE=1, INVISIBLE, BOTH }; +static constexpr double TOLERANCE = 1E-8; static double norm_squared(double *p) { diff --git a/src/QEQ/fix_qeq_fire.cpp b/src/QEQ/fix_qeq_fire.cpp index 34ef51d9475..f8eb667f2ab 100644 --- a/src/QEQ/fix_qeq_fire.cpp +++ b/src/QEQ/fix_qeq_fire.cpp @@ -34,12 +34,12 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELAYSTEP 0 +static constexpr int DELAYSTEP = 0; #define DT_GROW 1.1 #define DT_SHRINK 0.5 #define ALPHA0 0.8 #define ALPHA_SHRINK 0.10 -#define TMAX 10.0 +static constexpr double TMAX = 10.0; /* ---------------------------------------------------------------------- */ diff --git a/src/REACTION/fix_bond_react.cpp b/src/REACTION/fix_bond_react.cpp index 786f5bfe6e7..d8561b39594 100644 --- a/src/REACTION/fix_bond_react.cpp +++ b/src/REACTION/fix_bond_react.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -58,30 +57,31 @@ using namespace FixConst; using namespace MathConst; static const char cite_fix_bond_react[] = - "fix bond/react: reacter.org doi:10.1016/j.polymer.2017.09.038, doi:10.1021/acs.macromol.0c02012\n\n" - "@Article{Gissinger17,\n" - " author = {J. R. Gissinger and B. D. Jensen and K. E. Wise},\n" - " title = {Modeling Chemical Reactions in Classical Molecular Dynamics Simulations},\n" - " journal = {Polymer},\n" - " year = 2017,\n" - " volume = 128,\n" - " pages = {211--217}\n" - "}\n\n" - "@Article{Gissinger20,\n" - " author = {J. R. Gissinger, B. D. Jensen, K. E. Wise},\n" - " title = {{REACTER}: A Heuristic Method for Reactive Molecular Dynamics},\n" - " journal = {Macromolecules},\n" - " year = 2020,\n" - " volume = 53,\n" - " number = 22,\n" - " pages = {9953--9961}\n" - "}\n\n"; - -#define BIG 1.0e20 -#define DELTA 16 -#define MAXGUESS 20 // max # of guesses allowed by superimpose algorithm -#define MAXCONARGS 14 // max # of arguments for any type of constraint + rxnID -#define NUMVARVALS 5 // max # of keyword values that have variables as input + "fix bond/react: reacter.org doi:10.1016/j.polymer.2017.09.038, " + "doi:10.1021/acs.macromol.0c02012\n\n" + "@Article{Gissinger17,\n" + " author = {J. R. Gissinger and B. D. Jensen and K. E. Wise},\n" + " title = {Modeling Chemical Reactions in Classical Molecular Dynamics Simulations},\n" + " journal = {Polymer},\n" + " year = 2017,\n" + " volume = 128,\n" + " pages = {211--217}\n" + "}\n\n" + "@Article{Gissinger20,\n" + " author = {J. R. Gissinger, B. D. Jensen, K. E. Wise},\n" + " title = {{REACTER}: A Heuristic Method for Reactive Molecular Dynamics},\n" + " journal = {Macromolecules},\n" + " year = 2020,\n" + " volume = 53,\n" + " number = 22,\n" + " pages = {9953--9961}\n" + "}\n\n"; + +static constexpr double BIG = 1.0e20; +static constexpr int DELTA = 16; +static constexpr int MAXGUESS = 20; // max # of guesses allowed by superimpose algorithm +static constexpr int MAXCONARGS = 14; // max # of arguments for any type of constraint + rxnID +static constexpr int NUMVARVALS = 5; // max # of keyword values that have variables as input // various statuses of superimpose algorithm: // ACCEPT: site successfully matched to pre-reacted template @@ -90,24 +90,25 @@ static const char cite_fix_bond_react[] = // CONTINUE: a neighbor has been assigned, skip to next neighbor // GUESSFAIL: a guess has failed (if no more restore points, status = 'REJECT') // RESTORE: restore mode, load most recent restore point -enum{ACCEPT,REJECT,PROCEED,CONTINUE,GUESSFAIL,RESTORE}; +enum { ACCEPT, REJECT, PROCEED, CONTINUE, GUESSFAIL, RESTORE }; // types of available reaction constraints -enum{DISTANCE,ANGLE,DIHEDRAL,ARRHENIUS,RMSD,CUSTOM}; +enum { DISTANCE, ANGLE, DIHEDRAL, ARRHENIUS, RMSD, CUSTOM }; // ID type used by constraint -enum{ATOM,FRAG}; +enum { ATOM, FRAG }; // keyword values that accept variables as input -enum{NEVERY,RMIN,RMAX,PROB,NRATE}; +enum { NEVERY, RMIN, RMAX, PROB, NRATE }; // flag for one-proc vs shared reaction sites -enum{LOCAL,GLOBAL}; +enum { LOCAL, GLOBAL }; // values for molecule_keyword -enum{OFF,INTER,INTRA}; +enum { OFF, INTER, INTRA }; /* ---------------------------------------------------------------------- */ +// clang-format off FixBondReact::FixBondReact(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg) @@ -3921,7 +3922,8 @@ read map file void FixBondReact::read_map_file(int myrxn) { int rv; - char line[MAXLINE],keyword[MAXLINE]; + char line[MAXLINE] = {'\0'}; + char keyword[MAXLINE] = {'\0'}; char *eof,*ptr; // skip 1st line of file diff --git a/src/REPLICA/fix_hyper_global.cpp b/src/REPLICA/fix_hyper_global.cpp index d262c49fda7..79d901893e5 100644 --- a/src/REPLICA/fix_hyper_global.cpp +++ b/src/REPLICA/fix_hyper_global.cpp @@ -32,8 +32,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTABOND 16384 -#define VECLEN 5 +static constexpr int DELTABOND = 16384; +static constexpr int VECLEN = 5; // possible enhancements // should there be a virial contribution from boosted bond? diff --git a/src/REPLICA/fix_hyper_local.cpp b/src/REPLICA/fix_hyper_local.cpp index d0cfc4bb013..dde49404036 100644 --- a/src/REPLICA/fix_hyper_local.cpp +++ b/src/REPLICA/fix_hyper_local.cpp @@ -35,11 +35,11 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTABOND 16384 -#define DELTABIAS 16 -#define COEFFINIT 1.0 -#define FCCBONDS 12 -#define BIG 1.0e20 +static constexpr int DELTABOND = 16384; +static constexpr int DELTABIAS = 16; +static constexpr double COEFFINIT = 1.0; +static constexpr int FCCBONDS = 12; +static constexpr double BIG = 1.0e20; enum{STRAIN,STRAINDOMAIN,BIASFLAG,BIASCOEFF}; enum{IGNORE,WARN,ERROR}; diff --git a/src/REPLICA/fix_neb.cpp b/src/REPLICA/fix_neb.cpp index f2962d9b9da..9c920f26dc9 100644 --- a/src/REPLICA/fix_neb.cpp +++ b/src/REPLICA/fix_neb.cpp @@ -40,7 +40,7 @@ using namespace MathConst; enum { SINGLE_PROC_DIRECT, SINGLE_PROC_MAP, MULTI_PROC }; enum { NEIGHBOR, IDEAL, EQUAL }; -#define BUFSIZE 8 +static constexpr int BUFSIZE = 8; /* ---------------------------------------------------------------------- */ @@ -139,7 +139,15 @@ FixNEB::FixNEB(LAMMPS *lmp, int narg, char **arg) : uworld = universe->uworld; - if ((neb_mode == IDEAL) || (neb_mode == EQUAL)) { + // set comm mode for inter-replica exchange of coords + // may change from SINGLE_PROC_MAP to SINGLE_PROC_DIRECT only in Fix::init() + + if (nreplica == nprocs_universe) + cmode = SINGLE_PROC_MAP; + else + cmode = MULTI_PROC; + + if (cmode == MULTI_PROC) { int *iroots = new int[nreplica]; MPI_Group uworldgroup, rootgroup; @@ -150,7 +158,7 @@ FixNEB::FixNEB(LAMMPS *lmp, int narg, char **arg) : if (rootgroup != MPI_GROUP_NULL) MPI_Group_free(&rootgroup); if (uworldgroup != MPI_GROUP_NULL) MPI_Group_free(&uworldgroup); delete[] iroots; - } + } else rootworld = MPI_COMM_NULL; // create a new compute pe style // id = fix-ID + pe, compute group = all @@ -193,8 +201,10 @@ FixNEB::~FixNEB() memory->destroy(counts); memory->destroy(displacements); - if ((neb_mode == IDEAL) || (neb_mode == EQUAL)) { + if (cmode == MULTI_PROC) if (rootworld != MPI_COMM_NULL) MPI_Comm_free(&rootworld); + + if ((neb_mode == IDEAL) || (neb_mode == EQUAL)) { memory->destroy(nlenall); } if (neb_mode == EQUAL) memory->destroy(vengall); @@ -227,14 +237,10 @@ void FixNEB::init() if (count > MAXSMALLINT) error->all(FLERR, "Too many active NEB atoms"); nebatoms = count; - // comm mode for inter-replica exchange of coords + // change comm mode for inter-replica exchange of coords to direct if possible - if (nreplica == nprocs_universe && nebatoms == atom->natoms && atom->sortfreq == 0) + if ((cmode == SINGLE_PROC_MAP) && (nebatoms == atom->natoms) && (atom->sortfreq == 0)) cmode = SINGLE_PROC_DIRECT; - else if (nreplica == nprocs_universe) - cmode = SINGLE_PROC_MAP; - else - cmode = MULTI_PROC; // ntotal = total # of atoms in system, NEB atoms or not @@ -298,9 +304,8 @@ void FixNEB::min_post_force(int /*vflag*/) int procFirst; procFirst = universe->root_proc[0]; MPI_Bcast(&vIni, 1, MPI_DOUBLE, procFirst, uworld); - } else { + } else { // cmode == MULTI_PROC if (me == 0) MPI_Bcast(&vIni, 1, MPI_DOUBLE, 0, rootworld); - MPI_Bcast(&vIni, 1, MPI_DOUBLE, 0, world); } } @@ -812,7 +817,7 @@ void FixNEB::calculate_ideal_positions() if ((neb_mode == EQUAL) && (rclimber > 0.0)) { if ((cmode == SINGLE_PROC_DIRECT) || (cmode == SINGLE_PROC_MAP)) { MPI_Allgather(&veng, 1, MPI_DOUBLE, &vengall[0], 1, MPI_DOUBLE, uworld); - } else { + } else { // cmode == MULTI_PROC if (me == 0) MPI_Allgather(&veng, 1, MPI_DOUBLE, &vengall[0], 1, MPI_DOUBLE, rootworld); MPI_Bcast(vengall, nreplica, MPI_DOUBLE, 0, world); } @@ -823,7 +828,7 @@ void FixNEB::calculate_ideal_positions() } else if ((neb_mode == IDEAL) || (neb_mode == EQUAL)) { if ((cmode == SINGLE_PROC_DIRECT) || (cmode == SINGLE_PROC_MAP)) { MPI_Allgather(&nlen, 1, MPI_DOUBLE, &nlenall[0], 1, MPI_DOUBLE, uworld); - } else { + } else { // cmode == MULTI_PROC if (me == 0) MPI_Allgather(&nlen, 1, MPI_DOUBLE, &nlenall[0], 1, MPI_DOUBLE, rootworld); MPI_Bcast(nlenall, nreplica, MPI_DOUBLE, 0, world); } diff --git a/src/REPLICA/neb.cpp b/src/REPLICA/neb.cpp index 11933164eb6..d9144a9489b 100644 --- a/src/REPLICA/neb.cpp +++ b/src/REPLICA/neb.cpp @@ -36,15 +36,26 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define MAXLINE 256 -#define CHUNK 1024 -#define ATTRIBUTE_PERLINE 4 +static constexpr int MAXLINE = 256; +static constexpr int CHUNK = 1024; +static constexpr int ATTRIBUTE_PERLINE = 4; enum { DEFAULT, TERSE, VERBOSE }; /* ---------------------------------------------------------------------- */ -NEB::NEB(LAMMPS *lmp) : Command(lmp), fp(nullptr), all(nullptr), rdist(nullptr) {} +NEB::NEB(LAMMPS *lmp) : Command(lmp), fp(nullptr), all(nullptr), rdist(nullptr) +{ + print_mode = DEFAULT; + + // replica info + + nreplica = universe->nworlds; + ireplica = universe->iworld; + me_universe = universe->me; + uworld = universe->uworld; + MPI_Comm_rank(world, &me); +} /* ---------------------------------------------------------------------- internal NEB constructor, called from TAD @@ -52,8 +63,7 @@ NEB::NEB(LAMMPS *lmp) : Command(lmp), fp(nullptr), all(nullptr), rdist(nullptr) NEB::NEB(LAMMPS *lmp, double etol_in, double ftol_in, int n1steps_in, int n2steps_in, int nevery_in, double *buf_init, double *buf_final) : - Command(lmp), - fp(nullptr), all(nullptr), rdist(nullptr) + NEB(lmp) { double delx, dely, delz; @@ -62,17 +72,8 @@ NEB::NEB(LAMMPS *lmp, double etol_in, double ftol_in, int n1steps_in, int n2step n1steps = n1steps_in; n2steps = n2steps_in; nevery = nevery_in; - print_mode = DEFAULT; - - // replica info - nreplica = universe->nworlds; - ireplica = universe->iworld; - me_universe = universe->me; - uworld = universe->uworld; - MPI_Comm_rank(world, &me); - - // generate linear interpolate replica + // generate linear interpolated replica double fraction = ireplica / (nreplica - 1.0); double **x = atom->x; int nlocal = atom->nlocal; @@ -129,19 +130,11 @@ void NEB::command(int narg, char **arg) if (nevery <= 0) error->universe_all(FLERR, fmt::format("Illegal NEB command every parameter: {}", nevery)); if (n1steps % nevery) - error->universe_all(FLERR, fmt::format("NEB N1 value {} incompatible with every {}", - n1steps, nevery)); + error->universe_all(FLERR, + fmt::format("NEB N1 value {} incompatible with every {}", n1steps, nevery)); if (n2steps % nevery) - error->universe_all(FLERR, fmt::format("NEB N2 value {} incompatible with every {}", - n2steps, nevery)); - - // replica info - - nreplica = universe->nworlds; - ireplica = universe->iworld; - me_universe = universe->me; - uworld = universe->uworld; - MPI_Comm_rank(world, &me); + error->universe_all(FLERR, + fmt::format("NEB N2 value {} incompatible with every {}", n2steps, nevery)); // error checks @@ -437,7 +430,7 @@ void NEB::readfile(char *file, int flag) int i, nchunk, eofflag, nlines; tagint tag; char *eof, *start, *next, *buf; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; double delx, dely, delz; if (me_universe == 0 && universe->uscreen) diff --git a/src/RIGID/compute_rigid_local.cpp b/src/RIGID/compute_rigid_local.cpp index bd0db29d206..ea45389e7b9 100644 --- a/src/RIGID/compute_rigid_local.cpp +++ b/src/RIGID/compute_rigid_local.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; enum{ID,MOL,MASS,X,Y,Z,XU,YU,ZU,VX,VY,VZ,FX,FY,FZ,IX,IY,IZ, TQX,TQY,TQZ,OMEGAX,OMEGAY,OMEGAZ,ANGMOMX,ANGMOMY,ANGMOMZ, diff --git a/src/RIGID/fix_rigid.cpp b/src/RIGID/fix_rigid.cpp index bd3c53e3ec3..7a63c52220c 100644 --- a/src/RIGID/fix_rigid.cpp +++ b/src/RIGID/fix_rigid.cpp @@ -2300,7 +2300,7 @@ void FixRigid::readfile(int which, double *vec, double **array1, double **array2 int nlines; FILE *fp; char *eof,*start,*next,*buf; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // open file and read and parse first non-empty, non-comment line containing the number of bodies if (comm->me == 0) { diff --git a/src/RIGID/fix_rigid_small.cpp b/src/RIGID/fix_rigid_small.cpp index 5905e445950..9e185a4de28 100644 --- a/src/RIGID/fix_rigid_small.cpp +++ b/src/RIGID/fix_rigid_small.cpp @@ -49,7 +49,7 @@ using namespace FixConst; using namespace MathConst; using namespace RigidConst; -#define RVOUS 1 // 0 for irregular, 1 for all2all +static constexpr int RVOUS = 1; // 0 for irregular, 1 for all2all /* ---------------------------------------------------------------------- */ @@ -2470,7 +2470,7 @@ void FixRigidSmall::readfile(int which, double **array, int *inbody) int nchunk,eofflag,nlines,xbox,ybox,zbox; FILE *fp; char *eof,*start,*next,*buf; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; // create local hash with key/value pairs // key = mol ID of bodies my atoms own diff --git a/src/RIGID/fix_shake.cpp b/src/RIGID/fix_shake.cpp index 15bd5d207fe..73c29d86bdf 100644 --- a/src/RIGID/fix_shake.cpp +++ b/src/RIGID/fix_shake.cpp @@ -39,7 +39,7 @@ using namespace LAMMPS_NS; using namespace FixConst; using namespace MathConst; -#define RVOUS 1 // 0 for irregular, 1 for all2all +static constexpr int RVOUS = 1; // 0 for irregular, 1 for all2all static constexpr double BIG = 1.0e20; static constexpr double MASSDELTA = 0.1; diff --git a/src/SHOCK/fix_append_atoms.cpp b/src/SHOCK/fix_append_atoms.cpp index 9ab788b352a..677b3b55fd0 100644 --- a/src/SHOCK/fix_append_atoms.cpp +++ b/src/SHOCK/fix_append_atoms.cpp @@ -14,8 +14,6 @@ #include "fix_append_atoms.h" -#include -#include #include "atom.h" #include "atom_vec.h" #include "comm.h" @@ -27,11 +25,13 @@ #include "error.h" #include "force.h" +#include +#include + using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e30 -#define EPSILON 1.0e-6 +static constexpr double BIG = 1.0e30; /* ---------------------------------------------------------------------- */ @@ -43,7 +43,7 @@ FixAppendAtoms::FixAppendAtoms(LAMMPS *lmp, int narg, char **arg) : next_reneighbor = -1; time_depend = 1; - if (narg < 4) error->all(FLERR,"Illegal fix append/atoms command"); + if (narg < 4) utils::missing_cmd_args(FLERR,"fix append/atoms", error); // default settings @@ -121,8 +121,7 @@ FixAppendAtoms::FixAppendAtoms(LAMMPS *lmp, int narg, char **arg) : } else if (strcmp(arg[iarg],"spatial") == 0) { if (iarg+3 > narg) error->all(FLERR,"Illegal fix append/atoms command"); if (strcmp(arg[iarg+1],"f_") == 0) - error->all(FLERR, - "Bad fix ID in fix append/atoms command"); + error->all(FLERR, "Bad fix ID in fix append/atoms command"); spatflag = 1; spatialid = utils::strdup(arg[iarg+1]+2); spatlead = utils::numeric(FLERR,arg[iarg+2],false,lmp); @@ -208,14 +207,14 @@ FixAppendAtoms::FixAppendAtoms(LAMMPS *lmp, int narg, char **arg) : FixAppendAtoms::~FixAppendAtoms() { - delete [] basistype; + delete[] basistype; if (ranflag) delete randomx; if (spatflag) delete[] spatialid; if (tempflag) { delete randomt; - delete [] gfactor1; - delete [] gfactor2; + delete[] gfactor1; + delete[] gfactor2; } } @@ -239,22 +238,30 @@ void FixAppendAtoms::initial_integrate(int /*vflag*/) /* ---------------------------------------------------------------------- */ +void FixAppendAtoms::init() +{ + if (spatflag) { + Fix *ifix = modify->get_fix_by_id(spatialid); + if (!ifix) error->all(FLERR,"Fix ID {} for fix ave/chunk does not exist", spatialid); + if (!utils::strmatch(ifix->style, "^ave/chunk")) + error->all(FLERR,"Fix {} for spatial keyword is not fix style ave/chunk", spatialid);} +} + +/* ---------------------------------------------------------------------- */ + void FixAppendAtoms::setup(int vflag) { /*** CALL TO CREATE GROUP? SEE POST_FORCE ***/ post_force(vflag); } - /* ---------------------------------------------------------------------- */ int FixAppendAtoms::get_spatial() { if (update->ntimestep % freq == 0) { - int ifix = modify->find_fix(spatialid); - if (ifix < 0) - error->all(FLERR,"Fix ID for fix ave/spatial does not exist"); - Fix *fix = modify->fix[ifix]; + Fix *fix = modify->get_fix_by_id(spatialid); + if (!fix) error->all(FLERR,"Fix ID {} for fix ave/chunk does not exist", spatialid); int failed = 0; int count = 0; @@ -319,8 +326,8 @@ int FixAppendAtoms::get_spatial() if (domain->boxhi[2] - shockfront_loc < spatlead) advance = 1; - delete [] pos; - delete [] val; + delete[] pos; + delete[] val; } advance_sum = 0; @@ -433,22 +440,14 @@ void FixAppendAtoms::pre_exchange() xmin = ymin = zmin = BIG; xmax = ymax = zmax = -BIG; - domain->lattice->bbox(1,bboxlo[0],bboxlo[1],bboxlo[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxhi[0],bboxlo[1],bboxlo[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxlo[0],bboxhi[1],bboxlo[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxhi[0],bboxhi[1],bboxlo[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxlo[0],bboxlo[1],bboxhi[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxhi[0],bboxlo[1],bboxhi[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxlo[0],bboxhi[1],bboxhi[2], - xmin,ymin,zmin,xmax,ymax,zmax); - domain->lattice->bbox(1,bboxhi[0],bboxhi[1],bboxhi[2], - xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxlo[0],bboxlo[1],bboxlo[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxhi[0],bboxlo[1],bboxlo[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxlo[0],bboxhi[1],bboxlo[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxhi[0],bboxhi[1],bboxlo[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxlo[0],bboxlo[1],bboxhi[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxhi[0],bboxlo[1],bboxhi[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxlo[0],bboxhi[1],bboxhi[2],xmin,ymin,zmin,xmax,ymax,zmax); + domain->lattice->bbox(1,bboxhi[0],bboxhi[1],bboxhi[2],xmin,ymin,zmin,xmax,ymax,zmax); int ilo,ihi,jlo,jhi,klo,khi; ilo = static_cast (xmin); diff --git a/src/SHOCK/fix_append_atoms.h b/src/SHOCK/fix_append_atoms.h index 5fbe9e904b1..a7e89a39768 100644 --- a/src/SHOCK/fix_append_atoms.h +++ b/src/SHOCK/fix_append_atoms.h @@ -29,6 +29,7 @@ class FixAppendAtoms : public Fix { FixAppendAtoms(class LAMMPS *, int, char **); ~FixAppendAtoms() override; int setmask() override; + void init() override; void setup(int) override; void pre_exchange() override; void initial_integrate(int) override; diff --git a/src/SMTBQ/pair_smtbq.cpp b/src/SMTBQ/pair_smtbq.cpp index 4f924a6fcad..d262491912b 100644 --- a/src/SMTBQ/pair_smtbq.cpp +++ b/src/SMTBQ/pair_smtbq.cpp @@ -70,11 +70,11 @@ using namespace MathConst; using namespace MathExtra; using namespace MathSpecial; -#define MAXLINE 2048 -#define MAXTOKENS 2048 -#define DELTA 4 -#define PGDELTA 1 -#define MAXNEIGH 24 +static constexpr int MAXLINE = 2048; +static constexpr int MAXTOKENS = 2048; +static constexpr int DELTA = 4; +static constexpr int PGDELTA = 1; +static constexpr int MAXNEIGH = 24; static constexpr char SMTBQ_SEPARATORS[] = "' \t\n\r"; diff --git a/src/SPIN/fix_neb_spin.cpp b/src/SPIN/fix_neb_spin.cpp index ea8ce9c1fc0..0d7703d06f1 100644 --- a/src/SPIN/fix_neb_spin.cpp +++ b/src/SPIN/fix_neb_spin.cpp @@ -42,7 +42,7 @@ using namespace FixConst; enum{SINGLE_PROC_DIRECT,SINGLE_PROC_MAP,MULTI_PROC}; -#define BUFSIZE 8 +static constexpr int BUFSIZE = 8; /* ---------------------------------------------------------------------- */ diff --git a/src/SPIN/min_spin.cpp b/src/SPIN/min_spin.cpp index a2202cba325..99b3bd71450 100644 --- a/src/SPIN/min_spin.cpp +++ b/src/SPIN/min_spin.cpp @@ -38,7 +38,7 @@ using namespace MathConst; #define EPS_ENERGY 1.0e-8 -#define DELAYSTEP 5 +static constexpr int DELAYSTEP = 5; /* ---------------------------------------------------------------------- */ diff --git a/src/SPIN/min_spin_cg.cpp b/src/SPIN/min_spin_cg.cpp index ee72609ed94..25ea83d6dea 100644 --- a/src/SPIN/min_spin_cg.cpp +++ b/src/SPIN/min_spin_cg.cpp @@ -56,7 +56,7 @@ static const char cite_minstyle_spin_cg[] = #define EPS_ENERGY 1.0e-8 -#define DELAYSTEP 5 +static constexpr int DELAYSTEP = 5; /* ---------------------------------------------------------------------- */ diff --git a/src/SPIN/min_spin_lbfgs.cpp b/src/SPIN/min_spin_lbfgs.cpp index ae9d33a7057..357d8364e1a 100644 --- a/src/SPIN/min_spin_lbfgs.cpp +++ b/src/SPIN/min_spin_lbfgs.cpp @@ -56,7 +56,7 @@ static const char cite_minstyle_spin_lbfgs[] = #define EPS_ENERGY 1.0e-8 -#define DELAYSTEP 5 +static constexpr int DELAYSTEP = 5; /* ---------------------------------------------------------------------- */ diff --git a/src/SPIN/neb_spin.cpp b/src/SPIN/neb_spin.cpp index e7ef9ff7ea9..ac54f069a97 100644 --- a/src/SPIN/neb_spin.cpp +++ b/src/SPIN/neb_spin.cpp @@ -62,10 +62,11 @@ static const char cite_neb_spin[] = "doi={10.1016/j.cpc.2015.07.001}\n" "}\n\n"; -#define MAXLINE 256 -#define CHUNK 1024 +static constexpr int MAXLINE = 256; +static constexpr int CHUNK = 1024; + // 8 attributes: tag, spin norm, position (3), spin direction (3) -#define ATTRIBUTE_PERLINE 8 +static constexpr int ATTRIBUTE_PERLINE = 8; /* ---------------------------------------------------------------------- */ @@ -374,7 +375,7 @@ void NEBSpin::readfile(char *file, int flag) int i,nchunk,eofflag,nlines; tagint tag; char *eof,*start,*next,*buf; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; double musp,xx,yy,zz,spx,spy,spz; if (me_universe == 0 && universe->uscreen) diff --git a/src/SRD/fix_srd.cpp b/src/SRD/fix_srd.cpp index e96321a7a3c..9b153a1c28c 100644 --- a/src/SRD/fix_srd.cpp +++ b/src/SRD/fix_srd.cpp @@ -52,13 +52,13 @@ enum { BIG_MOVE, SRD_MOVE, SRD_ROTATE }; enum { CUBIC_ERROR, CUBIC_WARN }; enum { SHIFT_NO, SHIFT_YES, SHIFT_POSSIBLE }; -#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double EINERTIA = 0.2; // moment of inertia prefactor for ellipsoid -#define ATOMPERBIN 30 -#define BIG 1.0e20 -#define VBINSIZE 5 -#define TOLERANCE 0.00001 -#define MAXITER 20 +static constexpr int ATOMPERBIN = 30; +static constexpr double BIG = 1.0e20; +static constexpr int VBINSIZE = 5; +static constexpr double TOLERANCE = 0.00001; +static constexpr int MAXITER = 20; static const char cite_fix_srd[] = "fix srd command: doi:10.1063/1.3419070\n\n" diff --git a/src/UEF/dump_cfg_uef.cpp b/src/UEF/dump_cfg_uef.cpp index d72225b2381..34ef655af94 100644 --- a/src/UEF/dump_cfg_uef.cpp +++ b/src/UEF/dump_cfg_uef.cpp @@ -26,9 +26,9 @@ using namespace LAMMPS_NS; -#define UNWRAPEXPAND 10.0 -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr double UNWRAPEXPAND = 10.0; +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- * base method is mostly fine, just need to find the FixNHUef diff --git a/src/VORONOI/compute_voronoi_atom.cpp b/src/VORONOI/compute_voronoi_atom.cpp index b4f1aa30551..ca4ad4a85cf 100644 --- a/src/VORONOI/compute_voronoi_atom.cpp +++ b/src/VORONOI/compute_voronoi_atom.cpp @@ -35,7 +35,7 @@ using namespace LAMMPS_NS; using namespace voro; -#define FACESDELTA 10000 +static constexpr int FACESDELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/VTK/dump_vtk.cpp b/src/VTK/dump_vtk.cpp index 172a0926297..12fc4ad1eaa 100644 --- a/src/VTK/dump_vtk.cpp +++ b/src/VTK/dump_vtk.cpp @@ -93,8 +93,8 @@ enum{X,Y,Z, // required for vtk, must come first enum{LT,LE,GT,GE,EQ,NEQ,XOR}; enum{VTK,VTP,VTU,PVTP,PVTU}; // file formats -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; #if (VTK_MAJOR_VERSION < 5) || (VTK_MAJOR_VERSION > 9) #error This code has only been tested with VTK 5, 6, 7, 8, and 9 @@ -2096,7 +2096,7 @@ int DumpVTK::modify_param(int narg, char **arg) if (refreshflag) error->all(FLERR,"Dump_modify can only have one refresh"); refreshflag = 1; - refresh = argi.copy_name(); + idrefresh = argi.copy_name(); return 2; } diff --git a/src/YAFF/angle_cross.cpp b/src/YAFF/angle_cross.cpp index 46833b7f74d..d3e127e935a 100644 --- a/src/YAFF/angle_cross.cpp +++ b/src/YAFF/angle_cross.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/YAFF/angle_mm3.cpp b/src/YAFF/angle_mm3.cpp index af199f6fe98..3ff7df1653b 100644 --- a/src/YAFF/angle_mm3.cpp +++ b/src/YAFF/angle_mm3.cpp @@ -32,7 +32,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/YAFF/improper_distharm.cpp b/src/YAFF/improper_distharm.cpp index 27516fa4167..53658a13776 100644 --- a/src/YAFF/improper_distharm.cpp +++ b/src/YAFF/improper_distharm.cpp @@ -31,8 +31,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/YAFF/improper_sqdistharm.cpp b/src/YAFF/improper_sqdistharm.cpp index 1cd8515d9a2..e85f8e4c25c 100644 --- a/src/YAFF/improper_sqdistharm.cpp +++ b/src/YAFF/improper_sqdistharm.cpp @@ -31,8 +31,8 @@ using namespace LAMMPS_NS; -#define TOLERANCE 0.05 -#define SMALL 0.001 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/angle.cpp b/src/angle.cpp index 93d217237e5..79893cc52fb 100644 --- a/src/angle.cpp +++ b/src/angle.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define FOURTH 0.25 +static constexpr double FOURTH = 0.25; /* ---------------------------------------------------------------------- */ diff --git a/src/angle_hybrid.cpp b/src/angle_hybrid.cpp index 7419139942f..e79776b0d28 100644 --- a/src/angle_hybrid.cpp +++ b/src/angle_hybrid.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- */ diff --git a/src/angle_write.cpp b/src/angle_write.cpp index fb0e65ccf5f..0a0c4570004 100644 --- a/src/angle_write.cpp +++ b/src/angle_write.cpp @@ -35,7 +35,7 @@ using MathConst::DEG2RAD; using MathConst::RAD2DEG; static constexpr double epsilon = 6.5e-6; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ void AngleWrite::command(int narg, char **arg) @@ -147,7 +147,7 @@ void AngleWrite::command(int narg, char **arg) writer->input->one("mass * 1.0"); writer->input->one(fmt::format("angle_style {}", force->angle_style)); FILE *coeffs; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; coeffs = fopen(coeffs_file.c_str(), "r"); for (int i = 0; i < atom->nangletypes; ++i) { fgets(line, MAXLINE, coeffs); diff --git a/src/atom.cpp b/src/atom.cpp index c08df166147..75d3a645ad8 100644 --- a/src/atom.cpp +++ b/src/atom.cpp @@ -48,9 +48,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 1 -#define EPSILON 1.0e-6 -#define MAXLINE 256 +static constexpr int DELTA = 1; +static constexpr double EPSILON = 1.0e-6; +static constexpr int MAXLINE = 256; /* ---------------------------------------------------------------------- one instance per AtomVec style in style_atom.h diff --git a/src/atom_map.cpp b/src/atom_map.cpp index c28b886335a..37b46182c14 100644 --- a/src/atom_map.cpp +++ b/src/atom_map.cpp @@ -22,7 +22,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- allocate and initialize array or hash table for global -> local map diff --git a/src/atom_vec_sphere.cpp b/src/atom_vec_sphere.cpp index 8769c316d99..35fe1dccc96 100644 --- a/src/atom_vec_sphere.cpp +++ b/src/atom_vec_sphere.cpp @@ -60,13 +60,10 @@ AtomVecSphere::AtomVecSphere(LAMMPS *lmp) : AtomVec(lmp) void AtomVecSphere::process_args(int narg, char **arg) { - if (narg != 0 && narg != 1) error->all(FLERR, "Illegal atom_style sphere command"); + if (narg > 1) error->all(FLERR, "Illegal atom_style sphere command"); radvary = 0; - if (narg == 1) { - radvary = utils::numeric(FLERR, arg[0], true, lmp); - if (radvary < 0 || radvary > 1) error->all(FLERR, "Illegal atom_style sphere command"); - } + if (narg == 1) radvary = utils::logical(FLERR, arg[0], true, lmp); // dynamic particle radius and mass must be communicated every step diff --git a/src/bond_hybrid.cpp b/src/bond_hybrid.cpp index 4e477ab3a65..401358dda04 100644 --- a/src/bond_hybrid.cpp +++ b/src/bond_hybrid.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- */ diff --git a/src/comm.cpp b/src/comm.cpp index a6ac1c4bc81..1293dd3d6df 100644 --- a/src/comm.cpp +++ b/src/comm.cpp @@ -42,7 +42,7 @@ using namespace LAMMPS_NS; -#define BUFEXTRA 1024 +static constexpr int BUFEXTRA = 1024; enum{ONELEVEL,TWOLEVEL,NUMA,CUSTOM}; enum{CART,CARTREORDER,XYZ}; diff --git a/src/comm_brick.cpp b/src/comm_brick.cpp index 08d372187e7..cf38271029d 100644 --- a/src/comm_brick.cpp +++ b/src/comm_brick.cpp @@ -35,9 +35,9 @@ using namespace LAMMPS_NS; -#define BUFFACTOR 1.5 -#define BUFMIN 1024 -#define BIG 1.0e20 +static constexpr double BUFFACTOR = 1.5; +static constexpr int BUFMIN = 1024; +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/comm_tiled.cpp b/src/comm_tiled.cpp index f2d91c07faf..6c44af686f5 100644 --- a/src/comm_tiled.cpp +++ b/src/comm_tiled.cpp @@ -36,10 +36,9 @@ using namespace LAMMPS_NS; -#define BUFFACTOR 1.5 -#define BUFFACTOR 1.5 -#define BUFMIN 1024 -#define EPSILON 1.0e-6 +static constexpr double BUFFACTOR = 1.5; +static constexpr int BUFMIN = 1024; +static constexpr double EPSILON = 1.0e-6; #define DELTA_PROCS 16 diff --git a/src/compute.cpp b/src/compute.cpp index d47d1d5292e..d6ac382151b 100644 --- a/src/compute.cpp +++ b/src/compute.cpp @@ -26,8 +26,8 @@ using namespace LAMMPS_NS; -#define DELTA 4 -#define BIG MAXTAGINT +static constexpr int DELTA = 4; +static constexpr double BIG = MAXTAGINT; // allocate space for static class instance variable and initialize it diff --git a/src/compute_angle_local.cpp b/src/compute_angle_local.cpp index 3600562664e..3e8b15fd64b 100644 --- a/src/compute_angle_local.cpp +++ b/src/compute_angle_local.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 +static constexpr int DELTA = 10000; enum{THETA,ENG,VARIABLE}; diff --git a/src/compute_bond_local.cpp b/src/compute_bond_local.cpp index f2603e8cdd3..143539d435a 100644 --- a/src/compute_bond_local.cpp +++ b/src/compute_bond_local.cpp @@ -31,8 +31,8 @@ using namespace LAMMPS_NS; -#define DELTA 10000 -#define EPSILON 1.0e-12 +static constexpr int DELTA = 10000; +static constexpr double EPSILON = 1.0e-12; enum{DIST,DX,DY,DZ,VELVIB,OMEGA,ENGTRANS,ENGVIB,ENGROT,ENGPOT,FORCE,FX,FY,FZ,VARIABLE,BN}; diff --git a/src/compute_centroid_stress_atom.cpp b/src/compute_centroid_stress_atom.cpp index 5226af19985..c6854737a8a 100644 --- a/src/compute_centroid_stress_atom.cpp +++ b/src/compute_centroid_stress_atom.cpp @@ -303,8 +303,8 @@ void ComputeCentroidStressAtom::compute_peratom() // add in per-atom contributions from relevant fixes // skip if vatom = nullptr // possible during setup phase if fix has not initialized its vatom yet - // e.g. fix ave/spatial defined before fix shake, - // and fix ave/spatial uses a per-atom stress from this compute as input + // e.g. fix ave/chunk defined before fix shake, + // and fix ave/chunk uses a per-atom stress from this compute as input // fix styles are CENTROID_SAME, CENTROID_AVAIL or CENTROID_NOTAVAIL if (fixflag) { diff --git a/src/compute_chunk_atom.cpp b/src/compute_chunk_atom.cpp index fc70a3246f3..a1d595a086c 100644 --- a/src/compute_chunk_atom.cpp +++ b/src/compute_chunk_atom.cpp @@ -46,7 +46,7 @@ enum { NODISCARD, MIXED, YESDISCARD }; enum { ONCE, NFREQ, EVERY }; // used in several files enum { LIMITMAX, LIMITEXACT }; -#define IDMAX (1024 * 1024) +static constexpr int IDMAX = (1024 * 1024); /* ---------------------------------------------------------------------- */ diff --git a/src/compute_dihedral_local.cpp b/src/compute_dihedral_local.cpp index a6bcbccf00d..6543c06d200 100644 --- a/src/compute_dihedral_local.cpp +++ b/src/compute_dihedral_local.cpp @@ -30,8 +30,8 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 -#define SMALL 0.001 +static constexpr int DELTA = 10000; +static constexpr double SMALL = 0.001; enum{PHI,VARIABLE}; diff --git a/src/compute_erotate_sphere.cpp b/src/compute_erotate_sphere.cpp index b020fc4e0e0..d2f907fc554 100644 --- a/src/compute_erotate_sphere.cpp +++ b/src/compute_erotate_sphere.cpp @@ -20,7 +20,7 @@ using namespace LAMMPS_NS; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere /* ---------------------------------------------------------------------- */ diff --git a/src/compute_erotate_sphere_atom.cpp b/src/compute_erotate_sphere_atom.cpp index 3ec0f402a87..41819143b45 100644 --- a/src/compute_erotate_sphere_atom.cpp +++ b/src/compute_erotate_sphere_atom.cpp @@ -23,7 +23,7 @@ using namespace LAMMPS_NS; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere /* ---------------------------------------------------------------------- */ diff --git a/src/compute_group_group.cpp b/src/compute_group_group.cpp index 31bbc815970..afc825ac3c9 100644 --- a/src/compute_group_group.cpp +++ b/src/compute_group_group.cpp @@ -37,7 +37,7 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; enum { OFF, INTER, INTRA }; diff --git a/src/compute_heat_flux.cpp b/src/compute_heat_flux.cpp index 55fa27cafed..1b6fd270863 100644 --- a/src/compute_heat_flux.cpp +++ b/src/compute_heat_flux.cpp @@ -28,7 +28,6 @@ using namespace LAMMPS_NS; - /* ---------------------------------------------------------------------- */ ComputeHeatFlux::ComputeHeatFlux(LAMMPS *lmp, int narg, char **arg) : @@ -45,22 +44,24 @@ ComputeHeatFlux::ComputeHeatFlux(LAMMPS *lmp, int narg, char **arg) : // ensure they are valid for these computations id_ke = utils::strdup(arg[3]); + auto ike = modify->get_compute_by_id(id_ke); + if (!ike) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_ke); + if (!utils::strmatch(ike->style,"^ke/atom")) + error->all(FLERR,"Compute heat/flux compute ID {} does not compute ke/atom", id_ke); + id_pe = utils::strdup(arg[4]); - id_stress = utils::strdup(arg[5]); + auto ipe = modify->get_compute_by_id(id_pe); + if (!ipe) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_pe); + if (ipe->peatomflag == 0) + error->all(FLERR,"Compute heat/flux compute ID {} does not compute pe/atom", id_pe); - int ike = modify->find_compute(id_ke); - int ipe = modify->find_compute(id_pe); - int istress = modify->find_compute(id_stress); - if (ike < 0 || ipe < 0 || istress < 0) - error->all(FLERR,"Could not find compute heat/flux compute ID"); - if (strcmp(modify->compute[ike]->style,"ke/atom") != 0) - error->all(FLERR,"Compute heat/flux compute ID does not compute ke/atom"); - if (modify->compute[ipe]->peatomflag == 0) - error->all(FLERR,"Compute heat/flux compute ID does not compute pe/atom"); - if (modify->compute[istress]->pressatomflag != 1 - && modify->compute[istress]->pressatomflag != 2) + id_stress = utils::strdup(arg[5]); + auto istress = modify->get_compute_by_id(id_stress); + if (!istress) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_stress); + if ((istress->pressatomflag != 1) && (istress->pressatomflag != 2)) error->all(FLERR, - "Compute heat/flux compute ID does not compute stress/atom or centroid/stress/atom"); + "Compute heat/flux compute ID {} does not compute stress/atom or " + "centroid/stress/atom", id_stress); vector = new double[size_vector]; } @@ -69,10 +70,10 @@ ComputeHeatFlux::ComputeHeatFlux(LAMMPS *lmp, int narg, char **arg) : ComputeHeatFlux::~ComputeHeatFlux() { - delete [] id_ke; - delete [] id_pe; - delete [] id_stress; - delete [] vector; + delete[] id_ke; + delete[] id_pe; + delete[] id_stress; + delete[] vector; } /* ---------------------------------------------------------------------- */ @@ -81,15 +82,12 @@ void ComputeHeatFlux::init() { // error checks - int ike = modify->find_compute(id_ke); - int ipe = modify->find_compute(id_pe); - int istress = modify->find_compute(id_stress); - if (ike < 0 || ipe < 0 || istress < 0) - error->all(FLERR,"Could not find compute heat/flux compute ID"); - - c_ke = modify->compute[ike]; - c_pe = modify->compute[ipe]; - c_stress = modify->compute[istress]; + c_ke = modify->get_compute_by_id(id_ke); + if (!c_ke) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_ke); + c_pe = modify->get_compute_by_id(id_pe); + if (!c_pe) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_pe); + c_stress = modify->get_compute_by_id(id_stress); + if (!c_stress) error->all(FLERR,"Could not find compute heat/flux compute ID {}", id_stress); } /* ---------------------------------------------------------------------- */ diff --git a/src/compute_improper_local.cpp b/src/compute_improper_local.cpp index 48070a4f7cc..a58f4f4d0d8 100644 --- a/src/compute_improper_local.cpp +++ b/src/compute_improper_local.cpp @@ -28,9 +28,9 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define DELTA 10000 +static constexpr int DELTA = 10000; -#define SMALL 0.001 +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_omega_chunk.cpp b/src/compute_omega_chunk.cpp index 3c345ab7a40..1a8852b1442 100644 --- a/src/compute_omega_chunk.cpp +++ b/src/compute_omega_chunk.cpp @@ -23,7 +23,7 @@ using namespace LAMMPS_NS; -#define EPSILON 1.0e-6 +static constexpr double EPSILON = 1.0e-6; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_pair_local.cpp b/src/compute_pair_local.cpp index 5dad405bc36..88991f74819 100644 --- a/src/compute_pair_local.cpp +++ b/src/compute_pair_local.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; enum { DIST, ENG, FORCE, FX, FY, FZ, PN, DX, DY, DZ }; enum { TYPE, RADIUS }; diff --git a/src/compute_property_grid.cpp b/src/compute_property_grid.cpp index 17f9689bf6a..6e316de3f83 100644 --- a/src/compute_property_grid.cpp +++ b/src/compute_property_grid.cpp @@ -28,7 +28,7 @@ using namespace LAMMPS_NS; enum { LOW, CTR }; enum { UNSCALED, SCALED }; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_property_local.cpp b/src/compute_property_local.cpp index 87517a3e057..64f38591173 100644 --- a/src/compute_property_local.cpp +++ b/src/compute_property_local.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; enum { NONE, NEIGH, PAIR, BOND, ANGLE, DIHEDRAL, IMPROPER }; enum { TYPE, RADIUS }; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_reduce.cpp b/src/compute_reduce.cpp index b2968042482..ee94c2d9a7a 100644 --- a/src/compute_reduce.cpp +++ b/src/compute_reduce.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; //---------------------------------------------------------------- diff --git a/src/compute_reduce_chunk.cpp b/src/compute_reduce_chunk.cpp index 51781eac7b1..9ba0e30a8d3 100644 --- a/src/compute_reduce_chunk.cpp +++ b/src/compute_reduce_chunk.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; enum { SUM, MINN, MAXX }; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/compute_stress_atom.cpp b/src/compute_stress_atom.cpp index 55824b1ce55..3560570163e 100644 --- a/src/compute_stress_atom.cpp +++ b/src/compute_stress_atom.cpp @@ -54,11 +54,11 @@ ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) : id_temp = nullptr; else { id_temp = utils::strdup(arg[3]); - - int icompute = modify->find_compute(id_temp); - if (icompute < 0) error->all(FLERR, "Could not find compute stress/atom temperature ID"); - if (modify->compute[icompute]->tempflag == 0) - error->all(FLERR, "Compute stress/atom temperature ID does not compute temperature"); + auto icompute = modify->get_compute_by_id(id_temp); + if (!icompute) + error->all(FLERR, "Could not find compute stress/atom temperature compute {}", id_temp); + if (icompute->tempflag == 0) + error->all(FLERR, "Compute stress/atom compute {} does not compute temperature", id_temp); } // process optional args @@ -122,9 +122,9 @@ void ComputeStressAtom::init() // fixes could have changed or compute_modify could have changed it if (id_temp) { - int icompute = modify->find_compute(id_temp); - if (icompute < 0) error->all(FLERR, "Could not find compute stress/atom temperature ID"); - temperature = modify->compute[icompute]; + temperature = modify->get_compute_by_id(id_temp); + if (!temperature) + error->all(FLERR, "Could not find compute stress/atom temperature compute {}", id_temp); if (temperature->tempbias) biasflag = BIAS; else @@ -216,8 +216,8 @@ void ComputeStressAtom::compute_peratom() // add in per-atom contributions from relevant fixes // skip if vatom = nullptr // possible during setup phase if fix has not initialized its vatom yet - // e.g. fix ave/spatial defined before fix shake, - // and fix ave/spatial uses a per-atom stress from this compute as input + // e.g. fix ave/chunk defined before fix shake, + // and fix ave/chunk uses a per-atom stress from this compute as input if (fixflag) { for (auto &ifix : modify->get_fix_list()) diff --git a/src/compute_temp_sphere.cpp b/src/compute_temp_sphere.cpp index 0cfc9a93bad..4c9ad1bd288 100644 --- a/src/compute_temp_sphere.cpp +++ b/src/compute_temp_sphere.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -14,28 +13,28 @@ #include "compute_temp_sphere.h" -#include #include "atom.h" -#include "update.h" -#include "force.h" #include "domain.h" -#include "modify.h" -#include "group.h" #include "error.h" +#include "force.h" +#include "group.h" +#include "modify.h" +#include "update.h" + +#include using namespace LAMMPS_NS; -enum{ROTATE,ALL}; +enum { ROTATE, ALL }; -#define INERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double INERTIA = 0.4; // moment of inertia prefactor for sphere /* ---------------------------------------------------------------------- */ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) : - Compute(lmp, narg, arg), - id_bias(nullptr) + Compute(lmp, narg, arg), id_bias(nullptr) { - if (narg < 3) error->all(FLERR,"Illegal compute temp/sphere command"); + if (narg < 3) utils::missing_cmd_args(FLERR, "compute temp/sphere", error); scalar_flag = vector_flag = 1; size_vector = 6; @@ -48,20 +47,22 @@ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) : int iarg = 3; while (iarg < narg) { - if (strcmp(arg[iarg],"bias") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/sphere command"); + if (strcmp(arg[iarg], "bias") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute temp/sphere bias", error); tempbias = 1; - id_bias = utils::strdup(arg[iarg+1]); + id_bias = utils::strdup(arg[iarg + 1]); iarg += 2; - } else if (strcmp(arg[iarg],"dof") == 0) { - if (iarg+2 > narg) - error->all(FLERR,"Illegal compute temp/sphere command"); - if (strcmp(arg[iarg+1],"rotate") == 0) mode = ROTATE; - else if (strcmp(arg[iarg+1],"all") == 0) mode = ALL; - else error->all(FLERR,"Illegal compute temp/sphere command"); + } else if (strcmp(arg[iarg], "dof") == 0) { + if (iarg + 2 > narg) utils::missing_cmd_args(FLERR, "compute temp/sphere dof", error); + if (strcmp(arg[iarg + 1], "rotate") == 0) + mode = ROTATE; + else if (strcmp(arg[iarg + 1], "all") == 0) + mode = ALL; + else + error->all(FLERR, "Unknown compute temp/sphere dof keyword {}", arg[iarg + 1]); iarg += 2; - } else error->all(FLERR,"Illegal compute temp/sphere command"); + } else + error->all(FLERR, "Unknown compute temp/sphere keyword {}", arg[iarg]); } // when computing only the rotational temperature, @@ -73,16 +74,15 @@ ComputeTempSphere::ComputeTempSphere(LAMMPS *lmp, int narg, char **arg) : // error checks - if (!atom->sphere_flag) - error->all(FLERR,"Compute temp/sphere requires atom style sphere"); + if (!atom->sphere_flag) error->all(FLERR, "Compute temp/sphere requires atom style sphere"); } /* ---------------------------------------------------------------------- */ ComputeTempSphere::~ComputeTempSphere() { - delete [] id_bias; - delete [] vector; + delete[] id_bias; + delete[] vector; } /* ---------------------------------------------------------------------- */ @@ -90,18 +90,16 @@ ComputeTempSphere::~ComputeTempSphere() void ComputeTempSphere::init() { if (tempbias) { - int i = modify->find_compute(id_bias); - if (i < 0) - error->all(FLERR,"Could not find compute ID for temperature bias"); - tbias = modify->compute[i]; - if (tbias->tempflag == 0) - error->all(FLERR,"Bias compute does not calculate temperature"); - if (tbias->tempbias == 0) - error->all(FLERR,"Bias compute does not calculate a velocity bias"); + tbias = modify->get_compute_by_id(id_bias); + if (!tbias) error->all(FLERR, "Could not find compute {} for temperature bias", id_bias); + if (tbias->tempflag == 0) error->all(FLERR, "Bias compute does not calculate temperature"); + if (tbias->tempbias == 0) error->all(FLERR, "Bias compute does not calculate a velocity bias"); if (tbias->igroup != igroup) - error->all(FLERR,"Bias compute group does not match compute group"); - if (strcmp(tbias->style,"temp/region") == 0) tempbias = 2; - else tempbias = 1; + error->all(FLERR, "Bias compute group does not match compute group"); + if (strcmp(tbias->style, "temp/region") == 0) + tempbias = 2; + else + tempbias = 1; // init and setup bias compute because // this compute's setup()->dof_compute() may be called first @@ -124,7 +122,7 @@ void ComputeTempSphere::setup() void ComputeTempSphere::dof_compute() { - int count,count_all; + int count, count_all; adjust_dof_fix(); natoms_temp = group->count(igroup); @@ -146,8 +144,10 @@ void ComputeTempSphere::dof_compute() if (radius[i] == 0.0) { if (mode == ALL) count += 3; } else { - if (mode == ALL) count += 6; - else count += 3; + if (mode == ALL) + count += 6; + else + count += 3; } } } else { @@ -156,13 +156,15 @@ void ComputeTempSphere::dof_compute() if (radius[i] == 0.0) { if (mode == ALL) count += 2; } else { - if (mode == ALL) count += 3; - else count += 1; + if (mode == ALL) + count += 3; + else + count += 1; } } } - MPI_Allreduce(&count,&count_all,1,MPI_INT,MPI_SUM,world); + MPI_Allreduce(&count, &count_all, 1, MPI_INT, MPI_SUM, world); dof = count_all; // additional adjustments to dof @@ -181,8 +183,10 @@ void ComputeTempSphere::dof_compute() if (radius[i] == 0.0) { if (mode == ALL) count += 3; } else { - if (mode == ALL) count += 6; - else count += 3; + if (mode == ALL) + count += 6; + else + count += 3; } } } @@ -193,20 +197,24 @@ void ComputeTempSphere::dof_compute() if (radius[i] == 0.0) { if (mode == ALL) count += 2; } else { - if (mode == ALL) count += 3; - else count += 1; + if (mode == ALL) + count += 3; + else + count += 1; } } } } - MPI_Allreduce(&count,&count_all,1,MPI_INT,MPI_SUM,world); + MPI_Allreduce(&count, &count_all, 1, MPI_INT, MPI_SUM, world); dof -= count_all; } dof -= extra_dof + fix_dof; - if (dof > 0) tfactor = force->mvv2e / (dof * force->boltz); - else tfactor = 0.0; + if (dof > 0) + tfactor = force->mvv2e / (dof * force->boltz); + else + tfactor = 0.0; } /* ---------------------------------------------------------------------- */ @@ -231,6 +239,8 @@ double ComputeTempSphere::compute_scalar() double t = 0.0; + // clang-format off + if (mode == ALL) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { @@ -244,13 +254,14 @@ double ComputeTempSphere::compute_scalar() t += (omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] + omega[i][2]*omega[i][2]) * INERTIA*rmass[i]*radius[i]*radius[i]; } + // clang-format on if (tempbias) tbias->restore_bias_all(); - MPI_Allreduce(&t,&scalar,1,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(&t, &scalar, 1, MPI_DOUBLE, MPI_SUM, world); if (dynamic || tempbias == 2) dof_compute(); if (dof < 0.0 && natoms_temp > 0.0) - error->all(FLERR,"Temperature compute degrees of freedom < 0"); + error->all(FLERR, "Temperature compute degrees of freedom < 0"); scalar *= tfactor; return scalar; } @@ -275,44 +286,44 @@ void ComputeTempSphere::compute_vector() // point particles will not contribute rotation due to radius = 0 - double massone,inertiaone,t[6]; + double massone, inertiaone, t[6]; for (auto &ti : t) ti = 0.0; if (mode == ALL) { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { massone = rmass[i]; - t[0] += massone * v[i][0]*v[i][0]; - t[1] += massone * v[i][1]*v[i][1]; - t[2] += massone * v[i][2]*v[i][2]; - t[3] += massone * v[i][0]*v[i][1]; - t[4] += massone * v[i][0]*v[i][2]; - t[5] += massone * v[i][1]*v[i][2]; - - inertiaone = INERTIA*rmass[i]*radius[i]*radius[i]; - t[0] += inertiaone * omega[i][0]*omega[i][0]; - t[1] += inertiaone * omega[i][1]*omega[i][1]; - t[2] += inertiaone * omega[i][2]*omega[i][2]; - t[3] += inertiaone * omega[i][0]*omega[i][1]; - t[4] += inertiaone * omega[i][0]*omega[i][2]; - t[5] += inertiaone * omega[i][1]*omega[i][2]; + t[0] += massone * v[i][0] * v[i][0]; + t[1] += massone * v[i][1] * v[i][1]; + t[2] += massone * v[i][2] * v[i][2]; + t[3] += massone * v[i][0] * v[i][1]; + t[4] += massone * v[i][0] * v[i][2]; + t[5] += massone * v[i][1] * v[i][2]; + + inertiaone = INERTIA * rmass[i] * radius[i] * radius[i]; + t[0] += inertiaone * omega[i][0] * omega[i][0]; + t[1] += inertiaone * omega[i][1] * omega[i][1]; + t[2] += inertiaone * omega[i][2] * omega[i][2]; + t[3] += inertiaone * omega[i][0] * omega[i][1]; + t[4] += inertiaone * omega[i][0] * omega[i][2]; + t[5] += inertiaone * omega[i][1] * omega[i][2]; } } else { for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) { - inertiaone = INERTIA*rmass[i]*radius[i]*radius[i]; - t[0] += inertiaone * omega[i][0]*omega[i][0]; - t[1] += inertiaone * omega[i][1]*omega[i][1]; - t[2] += inertiaone * omega[i][2]*omega[i][2]; - t[3] += inertiaone * omega[i][0]*omega[i][1]; - t[4] += inertiaone * omega[i][0]*omega[i][2]; - t[5] += inertiaone * omega[i][1]*omega[i][2]; + inertiaone = INERTIA * rmass[i] * radius[i] * radius[i]; + t[0] += inertiaone * omega[i][0] * omega[i][0]; + t[1] += inertiaone * omega[i][1] * omega[i][1]; + t[2] += inertiaone * omega[i][2] * omega[i][2]; + t[3] += inertiaone * omega[i][0] * omega[i][1]; + t[4] += inertiaone * omega[i][0] * omega[i][2]; + t[5] += inertiaone * omega[i][1] * omega[i][2]; } } if (tempbias) tbias->restore_bias_all(); - MPI_Allreduce(t,vector,6,MPI_DOUBLE,MPI_SUM,world); + MPI_Allreduce(t, vector, 6, MPI_DOUBLE, MPI_SUM, world); for (int i = 0; i < 6; i++) vector[i] *= force->mvv2e; } @@ -322,7 +333,7 @@ void ComputeTempSphere::compute_vector() void ComputeTempSphere::remove_bias(int i, double *v) { - tbias->remove_bias(i,v); + tbias->remove_bias(i, v); } /* ---------------------------------------------------------------------- @@ -331,7 +342,7 @@ void ComputeTempSphere::remove_bias(int i, double *v) void ComputeTempSphere::remove_bias_thr(int i, double *v, double *b) { - tbias->remove_bias_thr(i,v,b); + tbias->remove_bias_thr(i, v, b); } /* ---------------------------------------------------------------------- @@ -341,7 +352,7 @@ void ComputeTempSphere::remove_bias_thr(int i, double *v, double *b) void ComputeTempSphere::restore_bias(int i, double *v) { - tbias->restore_bias(i,v); + tbias->restore_bias(i, v); } /* ---------------------------------------------------------------------- @@ -351,5 +362,5 @@ void ComputeTempSphere::restore_bias(int i, double *v) void ComputeTempSphere::restore_bias_thr(int i, double *v, double *b) { - tbias->restore_bias_thr(i,v,b); + tbias->restore_bias_thr(i, v, b); } diff --git a/src/dihedral_hybrid.cpp b/src/dihedral_hybrid.cpp index d38ccf5d52f..9da4df1f684 100644 --- a/src/dihedral_hybrid.cpp +++ b/src/dihedral_hybrid.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- */ diff --git a/src/dihedral_write.cpp b/src/dihedral_write.cpp index 3d87591bccd..375373523b8 100644 --- a/src/dihedral_write.cpp +++ b/src/dihedral_write.cpp @@ -35,7 +35,7 @@ using MathConst::DEG2RAD; using MathConst::RAD2DEG; static constexpr double epsilon = 6.5e-6; -#define MAXLINE 1024 +static constexpr int MAXLINE = 1024; /* ---------------------------------------------------------------------- */ void DihedralWrite::command(int narg, char **arg) @@ -148,7 +148,7 @@ void DihedralWrite::command(int narg, char **arg) writer->input->one("mass * 1.0"); writer->input->one(fmt::format("dihedral_style {}", force->dihedral_style)); FILE *coeffs; - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; coeffs = fopen(coeffs_file.c_str(), "r"); for (int i = 0; i < atom->ndihedraltypes; ++i) { fgets(line, MAXLINE, coeffs); diff --git a/src/domain.cpp b/src/domain.cpp index 3627af26cfe..7513d384e28 100644 --- a/src/domain.cpp +++ b/src/domain.cpp @@ -42,10 +42,9 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 -#define SMALL 1.0e-4 -#define DELTAREGION 4 -#define BONDSTRETCH 1.1 +static constexpr double BIG = 1.0e20; +static constexpr double SMALL = 1.0e-4; +static constexpr double BONDSTRETCH = 1.1; /* ---------------------------------------------------------------------- one instance per region style in style_region.h diff --git a/src/dump.cpp b/src/dump.cpp index a231b367d56..c735a4a60d1 100644 --- a/src/dump.cpp +++ b/src/dump.cpp @@ -1,4 +1,3 @@ -// clang-format off /* ---------------------------------------------------------------------- LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator https://www.lammps.org/, Sandia National Laboratories @@ -38,16 +37,16 @@ using namespace LAMMPS_NS; Dump *Dump::dumpptr; #endif -#define BIG 1.0e20 -#define EPSILON 1.0e-6 +static constexpr double BIG = 1.0e20; +static constexpr double EPSILON = 1.0e-6; enum { ASCEND, DESCEND }; /* ---------------------------------------------------------------------- */ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : - Pointers(lmp), multiname(nullptr), refresh(nullptr), skipvar(nullptr), format(nullptr), - format_default(nullptr), format_line_user(nullptr), format_float_user(nullptr), + Pointers(lmp), multiname(nullptr), idrefresh(nullptr), irefresh(nullptr), skipvar(nullptr), + format(nullptr), format_default(nullptr), format_line_user(nullptr), format_float_user(nullptr), format_int_user(nullptr), format_bigint_user(nullptr), format_column_user(nullptr), fp(nullptr), nameslist(nullptr), buf(nullptr), sbuf(nullptr), ids(nullptr), bufsort(nullptr), idsort(nullptr), index(nullptr), proclist(nullptr), xpbc(nullptr), vpbc(nullptr), @@ -119,21 +118,21 @@ Dump::Dump(LAMMPS *lmp, int /*narg*/, char **arg) : fileproc = 0; char *ptr; - if ((ptr = strchr(filename,'%'))) { + if ((ptr = strchr(filename, '%'))) { multiproc = 1; nclusterprocs = 1; filewriter = 1; fileproc = me; - MPI_Comm_split(world,me,0,&clustercomm); + MPI_Comm_split(world, me, 0, &clustercomm); *ptr = '\0'; - multiname = utils::strdup(fmt::format("{}{}{}", filename, me, ptr+1)); + multiname = utils::strdup(fmt::format("{}{}{}", filename, me, ptr + 1)); *ptr = '%'; } - if (strchr(filename,'*')) multifile = 1; + if (strchr(filename, '*')) multifile = 1; - if (utils::strmatch(filename, "\\.bin$") - || utils::strmatch(filename, "\\.lammpsbin$")) binary = 1; + if (utils::strmatch(filename, "\\.bin$") || utils::strmatch(filename, "\\.lammpsbin$")) + binary = 1; if (platform::has_compress_extension(filename)) compressed = 1; } @@ -153,7 +152,7 @@ Dump::~Dump() delete[] format_int_user; delete[] format_bigint_user; - delete[] refresh; + delete[] idrefresh; delete[] skipvar; // format_column_user is deallocated by child classes that use it @@ -179,8 +178,7 @@ Dump::~Dump() // delete storage for caching file names if (maxfiles > 0) { - for (int idx=0; idx < numfiles; ++idx) - delete[] nameslist[idx]; + for (int idx = 0; idx < numfiles; ++idx) delete[] nameslist[idx]; delete[] nameslist; } @@ -196,6 +194,8 @@ Dump::~Dump() } } +// clang-format off + /* ---------------------------------------------------------------------- */ void Dump::init() @@ -216,21 +216,21 @@ void Dump::init() index = proclist = nullptr; irregular = nullptr; if ((has_id == 0) && (me == 0)) - error->warning(FLERR,"Dump {} includes no atom IDs and is not sorted by ID. This may complicate " - "post-processing tasks or visualization", id); + error->warning(FLERR,"Dump {} includes no atom IDs and is not sorted by ID. " + "This may complicate post-processing tasks or visualization", id); } if (sort_flag) { if (multiproc > 1) error->all(FLERR, - "Cannot sort dump when 'nfile' or 'fileper' keywords are set to non-default values"); + "Cannot sort dump when 'nfile' or 'fileper' keywords have non-default values"); if (sortcol == 0 && atom->tag_enable == 0) error->all(FLERR,"Cannot sort dump on atom IDs with no atom IDs defined"); if (sortcol && sortcol > size_one) - error->all(FLERR,"Dump sort column is invalid"); + error->all(FLERR,"Dump sort column index {} is invalid", sortcol); if ((sortcol != 0) && (has_id == 0) && (me == 0)) - error->warning(FLERR,"Dump {} includes no atom IDs and is not sorted by ID. This may complicate " - "post-processing tasks or visualization", id); + error->warning(FLERR,"Dump {} includes no atom IDs and is not sorted by ID. " + "This may complicate post-processing tasks or visualization", id); if (nprocs > 1 && irregular == nullptr) irregular = new Irregular(lmp); @@ -288,11 +288,8 @@ void Dump::init() // search for refresh compute specified by dump_modify refresh if (refreshflag) { - int icompute; - for (icompute = 0; icompute < modify->ncompute; icompute++) - if (strcmp(refresh,modify->compute[icompute]->id) == 0) break; - if (icompute < modify->ncompute) irefresh = icompute; - else error->all(FLERR,"Dump could not find refresh compute ID"); + irefresh = modify->get_compute_by_id(idrefresh); + if (!irefresh) error->all(FLERR,"Dump could not find refresh compute ID {}", idrefresh); } // if skipflag, check skip variable @@ -531,7 +528,7 @@ void Dump::write() // trigger post-dump refresh by specified compute // currently used for incremental dump files - if (refreshflag) modify->compute[irefresh]->refresh(); + if (refreshflag) irefresh->refresh(); if (filewriter && fp != nullptr) write_footer(); diff --git a/src/dump.h b/src/dump.h index bae7dbd8c87..43baf96ccff 100644 --- a/src/dump.h +++ b/src/dump.h @@ -19,6 +19,7 @@ #include namespace LAMMPS_NS { +class Compute; class Dump : protected Pointers { friend class Output; @@ -45,15 +46,9 @@ class Dump : protected Pointers { void init(); virtual void write(); - virtual int pack_forward_comm(int, int *, double *, int, int *) - { - return 0; - } + virtual int pack_forward_comm(int, int *, double *, int, int *) { return 0; } virtual void unpack_forward_comm(int, int, double *) {} - virtual int pack_reverse_comm(int, int, double *) - { - return 0; - } + virtual int pack_reverse_comm(int, int, double *) { return 0; } virtual void unpack_reverse_comm(int, int *, double *) {} void modify_params(int, char **); @@ -94,9 +89,9 @@ class Dump : protected Pointers { bigint delaystep; - int refreshflag; // 1 if dump_modify refresh specified - char *refresh; // compute ID to invoke refresh() on - int irefresh; // index of compute + int refreshflag; // 1 if dump_modify refresh specified + char *idrefresh; // compute ID to invoke refresh() on + Compute *irefresh; // index of compute int skipflag; // 1 if skip condition defined char *skipvar; // name of variable to check for skip condition @@ -158,17 +153,11 @@ class Dump : protected Pointers { virtual void init_style() = 0; virtual void openfile(); - virtual int modify_param(int, char **) - { - return 0; - } + virtual int modify_param(int, char **) { return 0; } virtual void write_header(bigint) = 0; virtual int count(); virtual void pack(tagint *) = 0; - virtual int convert_string(int, double *) - { - return 0; - } + virtual int convert_string(int, double *) { return 0; } virtual void write_data(int, double *) = 0; virtual void write_footer() {} diff --git a/src/dump_atom.cpp b/src/dump_atom.cpp index 2d047dc0a05..fb3f58042c3 100644 --- a/src/dump_atom.cpp +++ b/src/dump_atom.cpp @@ -24,8 +24,8 @@ using namespace LAMMPS_NS; -#define ONELINE 256 -#define DELTA 1048576 +static constexpr int ONELINE = 256; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/dump_cfg.cpp b/src/dump_cfg.cpp index a64507dc162..e5af83a3c62 100644 --- a/src/dump_cfg.cpp +++ b/src/dump_cfg.cpp @@ -29,9 +29,9 @@ using namespace LAMMPS_NS; -#define UNWRAPEXPAND 10.0 -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr double UNWRAPEXPAND = 10.0; +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/dump_custom.cpp b/src/dump_custom.cpp index 1e60295bbe2..ed70c7413d1 100644 --- a/src/dump_custom.cpp +++ b/src/dump_custom.cpp @@ -47,8 +47,8 @@ enum{ID,MOL,PROC,PROCP1,TYPE,ELEMENT,MASS, COMPUTE,FIX,VARIABLE,IVEC,DVEC,IARRAY,DARRAY}; enum{LT,LE,GT,GE,EQ,NEQ,XOR}; -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ @@ -1768,7 +1768,7 @@ int DumpCustom::modify_param(int narg, char **arg) if (refreshflag) error->all(FLERR,"Dump_modify can only have one refresh"); refreshflag = 1; - refresh = argi.copy_name(); + idrefresh = argi.copy_name(); return 2; } diff --git a/src/dump_grid.cpp b/src/dump_grid.cpp index 8e3a2977cf2..4c89b057390 100644 --- a/src/dump_grid.cpp +++ b/src/dump_grid.cpp @@ -35,8 +35,8 @@ using namespace LAMMPS_NS; enum {COMPUTE,FIX}; -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/dump_image.cpp b/src/dump_image.cpp index ba7e36eb0b8..ed4fc8dff4e 100644 --- a/src/dump_image.cpp +++ b/src/dump_image.cpp @@ -49,7 +49,7 @@ using namespace LAMMPS_NS; using MathConst::DEG2RAD; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; enum{NUMERIC,ATOM,TYPE,ELEMENT,ATTRIBUTE}; enum{SPHERE,LINE,TRI}; // also in some Body and Fix child classes diff --git a/src/dump_local.cpp b/src/dump_local.cpp index 9695e152b24..8d546634b6f 100644 --- a/src/dump_local.cpp +++ b/src/dump_local.cpp @@ -27,8 +27,8 @@ using namespace LAMMPS_NS; -#define ONEFIELD 32 -#define DELTA 1048576 +static constexpr int ONEFIELD = 32; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/dump_xyz.cpp b/src/dump_xyz.cpp index 241ec1c0591..f7ab77b2bf1 100644 --- a/src/dump_xyz.cpp +++ b/src/dump_xyz.cpp @@ -23,8 +23,8 @@ using namespace LAMMPS_NS; -#define ONELINE 128 -#define DELTA 1048576 +static constexpr int ONELINE = 128; +static constexpr int DELTA = 1048576; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_ave_chunk.cpp b/src/fix_ave_chunk.cpp index 7c37bbaaffc..8ed518efc2d 100644 --- a/src/fix_ave_chunk.cpp +++ b/src/fix_ave_chunk.cpp @@ -485,7 +485,7 @@ void FixAveChunk::init() /* ---------------------------------------------------------------------- only does averaging if nvalid = current timestep - do not call setup_chunks(), even though fix ave/spatial called setup_bins() + do not call setup_chunks(), even though fix ave/chunk called setup_bins() b/c could cause nchunk to change if Nfreq epoch crosses 2 runs does mean that if change_box is used between runs to change box size, that nchunk may not track it diff --git a/src/fix_ave_histo.cpp b/src/fix_ave_histo.cpp index 4503ad56f4e..a92efcdacd2 100644 --- a/src/fix_ave_histo.cpp +++ b/src/fix_ave_histo.cpp @@ -35,7 +35,7 @@ enum { SCALAR, VECTOR, WINDOW }; enum { DEFAULT, GLOBAL, PERATOM, LOCAL }; enum { IGNORE, END, EXTRA }; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ FixAveHisto::FixAveHisto(LAMMPS *lmp, int narg, char **arg) : diff --git a/src/fix_ave_histo_weight.cpp b/src/fix_ave_histo_weight.cpp index 181aa2a79d1..7a5458bd3d3 100644 --- a/src/fix_ave_histo_weight.cpp +++ b/src/fix_ave_histo_weight.cpp @@ -38,7 +38,7 @@ enum { DEFAULT, GLOBAL, PERATOM, LOCAL }; enum { IGNORE, END, EXTRA }; enum { SINGLE, VALUE }; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_ave_time.cpp b/src/fix_ave_time.cpp index 833d5f42072..f6ba0ad0e6e 100644 --- a/src/fix_ave_time.cpp +++ b/src/fix_ave_time.cpp @@ -1081,17 +1081,17 @@ void FixAveTime::options(int iarg, int narg, char **arg) format = format_user; iarg += 2; } else if (strcmp(arg[iarg],"title1") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command"); 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/spatial command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command"); delete[] title2; title2 = utils::strdup(arg[iarg+1]); iarg += 2; } else if (strcmp(arg[iarg],"title3") == 0) { - if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/spatial command"); + if (iarg+2 > narg) error->all(FLERR,"Illegal fix ave/time command"); delete[] title3; title3 = utils::strdup(arg[iarg+1]); iarg += 2; diff --git a/src/fix_bond_history.cpp b/src/fix_bond_history.cpp index cae9dc744d3..2d344e24fca 100644 --- a/src/fix_bond_history.cpp +++ b/src/fix_bond_history.cpp @@ -27,8 +27,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define LB_FACTOR 1.5 -#define DELTA 8192 +static constexpr double LB_FACTOR = 1.5; +static constexpr int DELTA = 8192; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_deposit.cpp b/src/fix_deposit.cpp index 4a9c5aa9da2..d8ea665149c 100644 --- a/src/fix_deposit.cpp +++ b/src/fix_deposit.cpp @@ -42,7 +42,7 @@ using namespace MathConst; enum{ATOM,MOLECULE}; enum{DIST_UNIFORM,DIST_GAUSSIAN}; -#define EPSILON 1.0e6 +static constexpr double EPSILON = 1.0e6; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_dt_reset.cpp b/src/fix_dt_reset.cpp index ba69d177183..ea364657c6a 100644 --- a/src/fix_dt_reset.cpp +++ b/src/fix_dt_reset.cpp @@ -31,7 +31,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_langevin.cpp b/src/fix_langevin.cpp index 35bffb24fa8..073c2fd5199 100644 --- a/src/fix_langevin.cpp +++ b/src/fix_langevin.cpp @@ -46,8 +46,8 @@ using namespace FixConst; enum { NOBIAS, BIAS }; enum { CONSTANT, EQUAL, ATOM }; -#define SINERTIA 0.4 // moment of inertia prefactor for sphere -#define EINERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double SINERTIA = 0.4; // moment of inertia prefactor for sphere +static constexpr double EINERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ @@ -789,7 +789,7 @@ void FixLangevin::compute_target() if (tstyle == EQUAL) { t_target = input->variable->compute_equal(tvar); if (t_target < 0.0) - error->one(FLERR,"Fix langevin variable returned negative temperature"); + error->one(FLERR, "Fix langevin variable returned negative temperature"); tsqrt = sqrt(t_target); } else { if (atom->nmax > maxatom2) { @@ -801,8 +801,7 @@ void FixLangevin::compute_target() for (int i = 0; i < nlocal; i++) if (mask[i] & groupbit) if (tforce[i] < 0.0) - error->one(FLERR, - "Fix langevin variable returned negative temperature"); + error->one(FLERR, "Fix langevin variable returned negative temperature"); } modify->addstep_compute(update->ntimestep + 1); } diff --git a/src/fix_move.cpp b/src/fix_move.cpp index 53009495b17..80e10c4d3d4 100644 --- a/src/fix_move.cpp +++ b/src/fix_move.cpp @@ -42,7 +42,7 @@ using namespace MathConst; enum { LINEAR, WIGGLE, ROTATE, VARIABLE, TRANSROT }; enum { EQUAL, ATOM }; -#define INERTIA 0.2 // moment of inertia prefactor for ellipsoid +static constexpr double INERTIA = 0.2; // moment of inertia prefactor for ellipsoid /* ---------------------------------------------------------------------- */ diff --git a/src/fix_nh.cpp b/src/fix_nh.cpp index 562ca51c293..e46fca001ec 100644 --- a/src/fix_nh.cpp +++ b/src/fix_nh.cpp @@ -40,9 +40,9 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 -#define EPSILON 1.0e-6 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; +static constexpr double EPSILON = 1.0e-6; enum{NOBIAS,BIAS}; enum{NONE,XYZ,XY,YZ,XZ}; diff --git a/src/fix_press_langevin.cpp b/src/fix_press_langevin.cpp index 752f826dfee..d8d2a3b04ae 100644 --- a/src/fix_press_langevin.cpp +++ b/src/fix_press_langevin.cpp @@ -37,8 +37,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTAFLIP 0.1 -#define TILTMAX 1.5 +static constexpr double DELTAFLIP = 0.1; +static constexpr double TILTMAX = 1.5; enum { NONE, XYZ, XY, YZ, XZ }; enum { ISO, ANISO, TRICLINIC }; diff --git a/src/fix_recenter.cpp b/src/fix_recenter.cpp index bee7f55823c..4da8c4787bd 100644 --- a/src/fix_recenter.cpp +++ b/src/fix_recenter.cpp @@ -125,13 +125,12 @@ void FixRecenter::init() int after = 0; int flag = 0; - for (int i = 0; i < modify->nfix; i++) { - if (strcmp(id,modify->fix[i]->id) == 0) after = 1; - else if ((modify->fmask[i] & INITIAL_INTEGRATE) && after) flag = 1; + for (const auto &ifix : modify->get_fix_list()) { + if (strcmp(id, ifix->id) == 0) after = 1; + else if ((modify->get_fix_mask(ifix) & INITIAL_INTEGRATE) && after) flag = 1; } if (flag && comm->me == 0) - error->warning(FLERR,"Fix recenter should come after all other " - "integration fixes"); + error->warning(FLERR,"Fix recenter should come after all other integration fixes"); masstotal = group->mass(igroup); diff --git a/src/fix_restrain.cpp b/src/fix_restrain.cpp index f252134aa98..cc95fc93f35 100644 --- a/src/fix_restrain.cpp +++ b/src/fix_restrain.cpp @@ -38,9 +38,9 @@ using MathConst::DEG2RAD; enum{BOND,LBOUND,ANGLE,DIHEDRAL}; -#define TOLERANCE 0.05 -#define SMALL 0.001 -#define DELTA 1 +static constexpr double TOLERANCE = 0.05; +static constexpr double SMALL = 0.001; +static constexpr int DELTA = 1; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_spring.cpp b/src/fix_spring.cpp index 3a14ec8de1e..93c1f7867d7 100644 --- a/src/fix_spring.cpp +++ b/src/fix_spring.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define SMALL 1.0e-10 +static constexpr double SMALL = 1.0e-10; enum{TETHER,COUPLE}; diff --git a/src/fix_spring_chunk.cpp b/src/fix_spring_chunk.cpp index 3deedcffacc..f42572b1907 100644 --- a/src/fix_spring_chunk.cpp +++ b/src/fix_spring_chunk.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define SMALL 1.0e-10 +static constexpr double SMALL = 1.0e-10; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_store_local.cpp b/src/fix_store_local.cpp index d32f0e81788..8deac03d795 100644 --- a/src/fix_store_local.cpp +++ b/src/fix_store_local.cpp @@ -21,7 +21,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTA 1024 +static constexpr int DELTA = 1024; /* ---------------------------------------------------------------------- */ diff --git a/src/fix_thermal_conductivity.cpp b/src/fix_thermal_conductivity.cpp index 5fcb59d276a..dd674a0506e 100644 --- a/src/fix_thermal_conductivity.cpp +++ b/src/fix_thermal_conductivity.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define BIG 1.0e10 +static constexpr double BIG = 1.0e10; /* ---------------------------------------------------------------------- */ @@ -108,15 +108,14 @@ int FixThermalConductivity::setmask() void FixThermalConductivity::init() { - // warn if any fix ave/spatial comes after this fix + // warn if any fix ave/chunk comes after this fix // can cause glitch in averaging since ave will happen after swap int foundme = 0; - for (int i = 0; i < modify->nfix; i++) { - if (modify->fix[i] == this) foundme = 1; - if (foundme && strcmp(modify->fix[i]->style,"ave/spatial") == 0 && me == 0) - error->warning(FLERR, - "Fix thermal/conductivity comes before fix ave/spatial"); + for (const auto &ifix : modify->get_fix_list()) { + if (ifix == this) foundme = 1; + if (foundme && utils::strmatch(ifix->style,"^ave/chunk") && (me == 0)) + error->warning(FLERR, "Fix thermal/conductivity comes before fix ave/chunk"); } // set bounds of 2 slabs in edim diff --git a/src/fix_wall.cpp b/src/fix_wall.cpp index c4f32196225..50289d0f69a 100644 --- a/src/fix_wall.cpp +++ b/src/fix_wall.cpp @@ -28,7 +28,6 @@ using namespace LAMMPS_NS; using namespace FixConst; enum { XLO = 0, XHI = 1, YLO = 2, YHI = 3, ZLO = 4, ZHI = 5 }; -enum { NONE = 0, EDGE, CONSTANT, VARIABLE }; static const char *wallpos[] = {"xlo", "xhi", "ylo", "yhi", "zlo", "zhi"}; diff --git a/src/fix_wall.h b/src/fix_wall.h index 12ceb17b492..81abfab8ea3 100644 --- a/src/fix_wall.h +++ b/src/fix_wall.h @@ -27,6 +27,7 @@ class FixWall : public Fix { int xstyle[6]; int xindex[6]; char *xstr[6]; + enum { NONE = 0, EDGE, CONSTANT, VARIABLE }; FixWall(class LAMMPS *, int, char **); ~FixWall() override; diff --git a/src/fix_wall_region.cpp b/src/fix_wall_region.cpp index da9ee757d98..821849c2e3f 100644 --- a/src/fix_wall_region.cpp +++ b/src/fix_wall_region.cpp @@ -38,7 +38,7 @@ enum { LJ93, LJ126, LJ1043, COLLOID, HARMONIC, MORSE }; FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg), idregion(nullptr), region(nullptr) { - if (narg < 8) error->all(FLERR, "Illegal fix wall/region command"); + if (narg < 8) utils::missing_cmd_args(FLERR, "fix wall/region", error); scalar_flag = 1; vector_flag = 1; @@ -70,12 +70,12 @@ FixWallRegion::FixWallRegion(LAMMPS *lmp, int narg, char **arg) : else if (strcmp(arg[4], "morse") == 0) style = MORSE; else - error->all(FLERR, "Illegal fix wall/region command"); + error->all(FLERR, "Unknown fix wall/region style {}", arg[4]); if (style != COLLOID) dynamic_group_allow = 1; if (style == MORSE) { - if (narg != 9) error->all(FLERR, "Illegal fix wall/region command"); + if (narg != 9) error->all(FLERR, "Illegal fix wall/region morse command"); epsilon = utils::numeric(FLERR, arg[5], false, lmp); alpha = utils::numeric(FLERR, arg[6], false, lmp); diff --git a/src/grid2d.cpp b/src/grid2d.cpp index d39b7b4a78c..ea6e8e4123f 100644 --- a/src/grid2d.cpp +++ b/src/grid2d.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; -#define DELTA 16 +static constexpr int DELTA = 16; static constexpr int OFFSET = 16384; diff --git a/src/grid3d.cpp b/src/grid3d.cpp index 6ca8f7895ce..4ce19786603 100644 --- a/src/grid3d.cpp +++ b/src/grid3d.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define DELTA 16 +static constexpr int DELTA = 16; static constexpr int OFFSET = 16384; diff --git a/src/group.cpp b/src/group.cpp index f841f9d95af..a586c33ed95 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -46,7 +46,7 @@ static constexpr double EPSILON = 1.0e-6; enum{NONE,TYPE,MOLECULE,ID}; enum{LT,LE,GT,GE,EQ,NEQ,BETWEEN}; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- initialize group memory diff --git a/src/image.cpp b/src/image.cpp index 3133723b320..24f94f51f49 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -44,9 +44,9 @@ using MathConst::DEG2RAD; using MathConst::MY_PI; using MathConst::MY_PI4; -#define NCOLORS 140 -#define NELEMENTS 109 -#define EPSILON 1.0e-6 +static constexpr int NCOLORS = 140; +static constexpr int NELEMENTS = 109; +static constexpr double EPSILON = 1.0e-6; enum{NUMERIC,MINVALUE,MAXVALUE}; enum{CONTINUOUS,DISCRETE,SEQUENTIAL}; diff --git a/src/imbalance_neigh.cpp b/src/imbalance_neigh.cpp index 40b7f6b2491..8d4a17976b2 100644 --- a/src/imbalance_neigh.cpp +++ b/src/imbalance_neigh.cpp @@ -21,7 +21,7 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* -------------------------------------------------------------------- */ diff --git a/src/imbalance_time.cpp b/src/imbalance_time.cpp index 4e16ae3e1f7..cf2153011b3 100644 --- a/src/imbalance_time.cpp +++ b/src/imbalance_time.cpp @@ -19,7 +19,7 @@ using namespace LAMMPS_NS; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; /* -------------------------------------------------------------------- */ diff --git a/src/improper_hybrid.cpp b/src/improper_hybrid.cpp index 9aa20d236e8..505488cce64 100644 --- a/src/improper_hybrid.cpp +++ b/src/improper_hybrid.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define EXTRA 1000 +static constexpr int EXTRA = 1000; /* ---------------------------------------------------------------------- */ diff --git a/src/input.cpp b/src/input.cpp index 4d5ef8bee17..c9a3cf5f52f 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -54,8 +54,8 @@ using namespace LAMMPS_NS; -#define DELTALINE 256 -#define DELTA 4 +static constexpr int DELTALINE = 256; +static constexpr int DELTA = 4; // maximum nesting level of input files static constexpr int LMP_MAXFILE = 16; diff --git a/src/integrate.cpp b/src/integrate.cpp index 98ea7a09f9c..08300a8d779 100644 --- a/src/integrate.cpp +++ b/src/integrate.cpp @@ -29,24 +29,11 @@ using namespace LAMMPS_NS; Integrate::Integrate(LAMMPS *lmp, int /*narg*/, char ** /*arg*/) : Pointers(lmp) { - elist_global = elist_atom = nullptr; - vlist_global = vlist_atom = cvlist_atom = nullptr; external_force_clear = 0; } /* ---------------------------------------------------------------------- */ -Integrate::~Integrate() -{ - delete [] elist_global; - delete [] elist_atom; - delete [] vlist_global; - delete [] vlist_atom; - delete [] cvlist_atom; -} - -/* ---------------------------------------------------------------------- */ - void Integrate::init() { if (lmp->citeme) lmp->citeme->flush(); @@ -74,43 +61,18 @@ void Integrate::init() void Integrate::ev_setup() { - delete [] elist_global; - delete [] elist_atom; - delete [] vlist_global; - delete [] vlist_atom; - delete [] cvlist_atom; - elist_global = elist_atom = nullptr; - vlist_global = vlist_atom = cvlist_atom = nullptr; - - nelist_global = nelist_atom = 0; - nvlist_global = nvlist_atom = ncvlist_atom = 0; - for (int i = 0; i < modify->ncompute; i++) { - if (modify->compute[i]->peflag) nelist_global++; - if (modify->compute[i]->peatomflag) nelist_atom++; - if (modify->compute[i]->pressflag) nvlist_global++; - if (modify->compute[i]->pressatomflag & 1) nvlist_atom++; - if (modify->compute[i]->pressatomflag & 2) ncvlist_atom++; - } - - if (nelist_global) elist_global = new Compute*[nelist_global]; - if (nelist_atom) elist_atom = new Compute*[nelist_atom]; - if (nvlist_global) vlist_global = new Compute*[nvlist_global]; - if (nvlist_atom) vlist_atom = new Compute*[nvlist_atom]; - if (ncvlist_atom) cvlist_atom = new Compute*[ncvlist_atom]; - - nelist_global = nelist_atom = 0; - nvlist_global = nvlist_atom = ncvlist_atom = 0; - for (int i = 0; i < modify->ncompute; i++) { - if (modify->compute[i]->peflag) - elist_global[nelist_global++] = modify->compute[i]; - if (modify->compute[i]->peatomflag) - elist_atom[nelist_atom++] = modify->compute[i]; - if (modify->compute[i]->pressflag) - vlist_global[nvlist_global++] = modify->compute[i]; - if (modify->compute[i]->pressatomflag & 1) - vlist_atom[nvlist_atom++] = modify->compute[i]; - if (modify->compute[i]->pressatomflag & 2) - cvlist_atom[ncvlist_atom++] = modify->compute[i]; + elist_global.clear(); + elist_atom.clear(); + vlist_global.clear(); + vlist_atom.clear(); + cvlist_atom.clear(); + + for (const auto &icompute : modify->get_compute_list()) { + if (icompute->peflag) elist_global.push_back(icompute); + if (icompute->peatomflag) elist_atom.push_back(icompute); + if (icompute->pressflag) vlist_global.push_back(icompute); + if (icompute->pressatomflag & 1) vlist_atom.push_back(icompute); + if (icompute->pressatomflag & 2) cvlist_atom.push_back(icompute); } } @@ -137,7 +99,7 @@ void Integrate::ev_setup() void Integrate::ev_set(bigint ntimestep) { - int i,flag; + int flag; int tdflag = 0; if (output->any_time_dumps && @@ -145,15 +107,15 @@ void Integrate::ev_set(bigint ntimestep) flag = 0; int eflag_global = 0; - for (i = 0; i < nelist_global; i++) - if (elist_global[i]->matchstep(ntimestep)) flag = 1; + for (auto &icompute : elist_global) + if (icompute->matchstep(ntimestep)) flag = 1; if (flag) eflag_global = ENERGY_GLOBAL; flag = 0; int eflag_atom = 0; - for (i = 0; i < nelist_atom; i++) - if (elist_atom[i]->matchstep(ntimestep)) flag = 1; - if (flag || (tdflag && nelist_atom)) eflag_atom = ENERGY_ATOM; + for (auto &icompute : elist_atom) + if (icompute->matchstep(ntimestep)) flag = 1; + if (flag || (tdflag && (elist_atom.size() > 0))) eflag_atom = ENERGY_ATOM; if (eflag_global) update->eflag_global = ntimestep; if (eflag_atom) update->eflag_atom = ntimestep; @@ -161,21 +123,21 @@ void Integrate::ev_set(bigint ntimestep) flag = 0; int vflag_global = 0; - for (i = 0; i < nvlist_global; i++) - if (vlist_global[i]->matchstep(ntimestep)) flag = 1; + for (auto &icompute : vlist_global) + if (icompute->matchstep(ntimestep)) flag = 1; if (flag) vflag_global = virial_style; flag = 0; int vflag_atom = 0; - for (i = 0; i < nvlist_atom; i++) - if (vlist_atom[i]->matchstep(ntimestep)) flag = 1; - if (flag || (tdflag && nvlist_atom)) vflag_atom = VIRIAL_ATOM; + for (auto &icompute : vlist_atom) + if (icompute->matchstep(ntimestep)) flag = 1; + if (flag || (tdflag && (vlist_atom.size() > 0))) vflag_atom = VIRIAL_ATOM; flag = 0; int cvflag_atom = 0; - for (i = 0; i < ncvlist_atom; i++) - if (cvlist_atom[i]->matchstep(ntimestep)) flag = 1; - if (flag || (tdflag && ncvlist_atom)) cvflag_atom = VIRIAL_CENTROID; + for (auto &icompute : cvlist_atom) + if (icompute->matchstep(ntimestep)) flag = 1; + if (flag || (tdflag && (cvlist_atom.size() > 0))) cvflag_atom = VIRIAL_CENTROID; if (vflag_global) update->vflag_global = ntimestep; if (vflag_atom || cvflag_atom) update->vflag_atom = ntimestep; diff --git a/src/integrate.h b/src/integrate.h index 85d4bec65b3..e622f6328dd 100644 --- a/src/integrate.h +++ b/src/integrate.h @@ -15,13 +15,13 @@ #define LMP_INTEGRATE_H #include "pointers.h" +#include "compute.h" namespace LAMMPS_NS { class Integrate : protected Pointers { public: Integrate(class LAMMPS *, int, char **); - ~Integrate() override; virtual void init(); virtual void setup(int flag) = 0; virtual void setup_minimal(int) = 0; @@ -36,13 +36,8 @@ class Integrate : protected Pointers { int virial_style; // compute virial explicitly or implicitly int external_force_clear; // clear forces locally or externally - int nelist_global, nelist_atom; // # of PE,virial computes to check - int nvlist_global, nvlist_atom, ncvlist_atom; - class Compute **elist_global; // lists of PE,virial Computes - class Compute **elist_atom; - class Compute **vlist_global; - class Compute **vlist_atom; - class Compute **cvlist_atom; + // lists of PE,virial Computes + std::vector elist_global, elist_atom, vlist_global, vlist_atom, cvlist_atom; int pair_compute_flag; // 0 if pair->compute is skipped int kspace_compute_flag; // 0 if kspace->compute is skipped diff --git a/src/irregular.cpp b/src/irregular.cpp index b571c354451..0c1ecc21a98 100644 --- a/src/irregular.cpp +++ b/src/irregular.cpp @@ -36,9 +36,9 @@ static int compare_standalone(const void *, const void *); static int compare_standalone(const int, const int, void *); #endif -#define BUFFACTOR 1.5 -#define BUFMIN 1024 -#define BUFEXTRA 1024 +static constexpr double BUFFACTOR = 1.5; +static constexpr int BUFMIN = 1024; +static constexpr int BUFEXTRA = 1024; /* ---------------------------------------------------------------------- */ diff --git a/src/kspace.cpp b/src/kspace.cpp index 583df478e70..7d51c46ea8b 100644 --- a/src/kspace.cpp +++ b/src/kspace.cpp @@ -29,7 +29,7 @@ using namespace LAMMPS_NS; -#define SMALL 0.00001 +static constexpr double SMALL = 0.00001; /* ---------------------------------------------------------------------- */ diff --git a/src/lammps.cpp b/src/lammps.cpp index f92a76e6dd3..b3d2171152d 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -276,6 +276,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : error->universe_all(FLERR,"Invalid command-line argument"); helpflag = 1; citeflag = 0; + inflag = -1; // skip inflag check iarg += 1; } else if (strcmp(arg[iarg],"-in") == 0 || @@ -385,6 +386,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : "Cannot use both -restart2data and -restart2dump"); restart2data = 1; restartfile = arg[iarg+1]; + inflag = -1; // skip inflag check // check for restart remap flag if (strcmp(arg[iarg+2],"remap") == 0) { if (iarg+4 > narg) @@ -407,6 +409,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : "Cannot use both -restart2data and -restart2dump"); restart2dump = 1; restartfile = arg[iarg+1]; + inflag = -1; // skip inflag check // check for restart remap flag if (strcmp(arg[iarg+2],"remap") == 0) { if (iarg+4 > narg) @@ -535,7 +538,7 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) : world = universe->uworld; if (universe->me == 0) { - if (inflag == 0) infile = stdin; + if (inflag <= 0) infile = stdin; else if (strcmp(arg[inflag], "none") == 0) infile = stdin; else infile = fopen(arg[inflag],"r"); if (infile == nullptr) diff --git a/src/lattice.cpp b/src/lattice.cpp index edb482cfac7..fa50a9ea940 100644 --- a/src/lattice.cpp +++ b/src/lattice.cpp @@ -25,7 +25,7 @@ using namespace LAMMPS_NS; -#define BIG 1.0e30 +static constexpr double BIG = 1.0e30; /* ---------------------------------------------------------------------- */ diff --git a/src/min.cpp b/src/min.cpp index acc7d176547..e64ff9cb293 100644 --- a/src/min.cpp +++ b/src/min.cpp @@ -74,9 +74,6 @@ Min::Min(LAMMPS *lmp) : Pointers(lmp) alpha_final = 0.0; abcflag = 0; - elist_global = elist_atom = nullptr; - vlist_global = vlist_atom = cvlist_atom = nullptr; - nextra_global = 0; fextra = nullptr; @@ -95,12 +92,6 @@ Min::Min(LAMMPS *lmp) : Pointers(lmp) Min::~Min() { - delete[] elist_global; - delete[] elist_atom; - delete[] vlist_global; - delete[] vlist_atom; - delete[] cvlist_atom; - delete[] fextra; memory->sfree(xextra_atom); @@ -757,43 +748,18 @@ void Min::modify_params(int narg, char **arg) void Min::ev_setup() { - delete[] elist_global; - delete[] elist_atom; - delete[] vlist_global; - delete[] vlist_atom; - delete[] cvlist_atom; - elist_global = elist_atom = nullptr; - vlist_global = vlist_atom = cvlist_atom = nullptr; - - nelist_global = nelist_atom = 0; - nvlist_global = nvlist_atom = ncvlist_atom = 0; - for (int i = 0; i < modify->ncompute; i++) { - if (modify->compute[i]->peflag) nelist_global++; - if (modify->compute[i]->peatomflag) nelist_atom++; - if (modify->compute[i]->pressflag) nvlist_global++; - if (modify->compute[i]->pressatomflag & 1) nvlist_atom++; - if (modify->compute[i]->pressatomflag & 2) ncvlist_atom++; - } - - if (nelist_global) elist_global = new Compute*[nelist_global]; - if (nelist_atom) elist_atom = new Compute*[nelist_atom]; - if (nvlist_global) vlist_global = new Compute*[nvlist_global]; - if (nvlist_atom) vlist_atom = new Compute*[nvlist_atom]; - if (ncvlist_atom) cvlist_atom = new Compute*[ncvlist_atom]; - - nelist_global = nelist_atom = 0; - nvlist_global = nvlist_atom = ncvlist_atom = 0; - for (int i = 0; i < modify->ncompute; i++) { - if (modify->compute[i]->peflag) - elist_global[nelist_global++] = modify->compute[i]; - if (modify->compute[i]->peatomflag) - elist_atom[nelist_atom++] = modify->compute[i]; - if (modify->compute[i]->pressflag) - vlist_global[nvlist_global++] = modify->compute[i]; - if (modify->compute[i]->pressatomflag & 1) - vlist_atom[nvlist_atom++] = modify->compute[i]; - if (modify->compute[i]->pressatomflag & 2) - cvlist_atom[ncvlist_atom++] = modify->compute[i]; + elist_global.clear(); + elist_atom.clear(); + vlist_global.clear(); + vlist_atom.clear(); + cvlist_atom.clear(); + + for (const auto &icompute : modify->get_compute_list()) { + if (icompute->peflag) elist_global.push_back(icompute); + if (icompute->peatomflag) elist_atom.push_back(icompute); + if (icompute->pressflag) vlist_global.push_back(icompute); + if (icompute->pressatomflag & 1) vlist_atom.push_back(icompute); + if (icompute->pressatomflag & 2) cvlist_atom.push_back(icompute); } } @@ -816,16 +782,15 @@ void Min::ev_setup() void Min::ev_set(bigint ntimestep) { - int i,flag; + int flag; int eflag_global = 1; - for (i = 0; i < nelist_global; i++) - elist_global[i]->matchstep(ntimestep); + for (auto &icompute : elist_global) icompute->matchstep(ntimestep); flag = 0; int eflag_atom = 0; - for (i = 0; i < nelist_atom; i++) - if (elist_atom[i]->matchstep(ntimestep)) flag = 1; + for (auto &icompute : elist_atom) + if (icompute->matchstep(ntimestep)) flag = 1; if (flag) eflag_atom = ENERGY_ATOM; if (eflag_global) update->eflag_global = update->ntimestep; @@ -834,20 +799,20 @@ void Min::ev_set(bigint ntimestep) flag = 0; int vflag_global = 0; - for (i = 0; i < nvlist_global; i++) - if (vlist_global[i]->matchstep(ntimestep)) flag = 1; + for (auto &icompute : vlist_global) + if (icompute->matchstep(ntimestep)) flag = 1; if (flag) vflag_global = virial_style; flag = 0; int vflag_atom = 0; - for (i = 0; i < nvlist_atom; i++) - if (vlist_atom[i]->matchstep(ntimestep)) flag = 1; + for (auto &icompute : vlist_atom) + if (icompute->matchstep(ntimestep)) flag = 1; if (flag) vflag_atom = VIRIAL_ATOM; flag = 0; int cvflag_atom = 0; - for (i = 0; i < ncvlist_atom; i++) - if (cvlist_atom[i]->matchstep(ntimestep)) flag = 1; + for (auto &icompute : cvlist_atom) + if (icompute->matchstep(ntimestep)) flag = 1; if (flag) cvflag_atom = VIRIAL_CENTROID; if (vflag_global) update->vflag_global = update->ntimestep; diff --git a/src/min.h b/src/min.h index 16629db69b9..b94d937fa50 100644 --- a/src/min.h +++ b/src/min.h @@ -15,6 +15,7 @@ #define LMP_MIN_H #include "pointers.h" // IWYU pragma: export +#include "compute.h" namespace LAMMPS_NS { @@ -102,13 +103,8 @@ class Min : protected Pointers { int max_vdotf_negatif; // maximum iteration with v.f > 0.0 int abcflag; // when 1 use ABC-FIRE variant instead of FIRE, default 0 - int nelist_global, nelist_atom; // # of PE,virial computes to check - int nvlist_global, nvlist_atom, ncvlist_atom; - class Compute **elist_global; // lists of PE,virial Computes - class Compute **elist_atom; - class Compute **vlist_global; - class Compute **vlist_atom; - class Compute **cvlist_atom; + // lists of PE,virial Computes + std::vector elist_global, elist_atom, vlist_global, vlist_atom, cvlist_atom; int triclinic; // 0 if domain is orthog, 1 if triclinic int pairflag; diff --git a/src/min_linesearch.cpp b/src/min_linesearch.cpp index f875d4249e9..97dcca9d8a7 100644 --- a/src/min_linesearch.cpp +++ b/src/min_linesearch.cpp @@ -47,7 +47,7 @@ using namespace LAMMPS_NS; #define BACKTRACK_SLOPE 0.4 #define QUADRATIC_TOL 0.1 //#define EMACH 1.0e-8 -#define EMACH 1.0e-8 +static constexpr double EMACH = 1.0e-8; #define EPS_QUAD 1.0e-28 /* ---------------------------------------------------------------------- */ diff --git a/src/min_quickmin.cpp b/src/min_quickmin.cpp index 99d95be57d9..c3730f2cd73 100644 --- a/src/min_quickmin.cpp +++ b/src/min_quickmin.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; #define EPS_ENERGY 1.0e-8 -#define DELAYSTEP 5 +static constexpr int DELAYSTEP = 5; /* ---------------------------------------------------------------------- */ diff --git a/src/modify.cpp b/src/modify.cpp index 427c4e259b7..ba04c5969a2 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -33,8 +33,8 @@ using namespace LAMMPS_NS; using namespace FixConst; -#define DELTA 4 -#define BIG 1.0e20 +static constexpr int DELTA = 4; +static constexpr double BIG = 1.0e20; // template for factory function: // there will be one instance for each style keyword in the respective style_xxx.h files diff --git a/src/modify.h b/src/modify.h index 6ca4b4ad269..26e056d5076 100644 --- a/src/modify.h +++ b/src/modify.h @@ -115,9 +115,17 @@ class Modify : protected Pointers { int find_fix(const std::string &); // new API Fix *get_fix_by_id(const std::string &) const; - Fix *get_fix_by_index(int idx) const { return ((idx >= 0) && (idx < nfix)) ? fix[idx] : nullptr; } + Fix *get_fix_by_index(int idx) const { + return ((idx >= 0) && (idx < nfix)) ? fix[idx] : nullptr; + } const std::vector get_fix_by_style(const std::string &) const; const std::vector &get_fix_list(); + int get_fix_mask(Fix *ifix) const { + for (int i = 0; i < nfix; ++i) { + if (fix[i] == ifix) return fmask[i]; + } + return 0; + } Compute *add_compute(int, char **, int trysuffix = 1); Compute *add_compute(const std::string &, int trysuffix = 1); diff --git a/src/molecule.cpp b/src/molecule.cpp index f83d8658dfb..d0c8e793b32 100644 --- a/src/molecule.cpp +++ b/src/molecule.cpp @@ -31,11 +31,11 @@ using namespace LAMMPS_NS; -#define MAXLINE 256 -#define EPSILON 1.0e-7 -#define BIG 1.0e20 +static constexpr int MAXLINE = 1024; +static constexpr double EPSILON = 1.0e-7; +static constexpr double BIG = 1.0e20; -#define SINERTIA 0.4 // moment of inertia prefactor for sphere +static constexpr double SINERTIA = 0.4; // moment of inertia prefactor for sphere /* ---------------------------------------------------------------------- */ @@ -416,7 +416,7 @@ void Molecule::compute_inertia() void Molecule::read(int flag) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; char *eof; // skip 1st line of file @@ -2134,7 +2134,7 @@ void Molecule::readline(char *line) std::string Molecule::parse_keyword(int flag, char *line) { - char line2[MAXLINE]; + char line2[MAXLINE] = {'\0'}; if (flag) { // read upto non-blank line plus 1 following line diff --git a/src/nbin_multi.cpp b/src/nbin_multi.cpp index 0a0f1557de6..15c089bee72 100644 --- a/src/nbin_multi.cpp +++ b/src/nbin_multi.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define SMALL 1.0e-6 +static constexpr double SMALL = 1.0e-6; #define CUT2BIN_RATIO 100 /* ---------------------------------------------------------------------- */ diff --git a/src/nbin_standard.cpp b/src/nbin_standard.cpp index 68cc860dbe5..08ff537d710 100644 --- a/src/nbin_standard.cpp +++ b/src/nbin_standard.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define SMALL 1.0e-6 +static constexpr double SMALL = 1.0e-6; #define CUT2BIN_RATIO 100 /* ---------------------------------------------------------------------- */ diff --git a/src/neigh_list.cpp b/src/neigh_list.cpp index 2d91eebdef5..4bdd58eead9 100644 --- a/src/neigh_list.cpp +++ b/src/neigh_list.cpp @@ -23,7 +23,7 @@ using namespace LAMMPS_NS; -#define PGDELTA 1 +static constexpr int PGDELTA = 1; /* ---------------------------------------------------------------------- */ diff --git a/src/neighbor.cpp b/src/neighbor.cpp index c6c959a8946..662494ea7be 100644 --- a/src/neighbor.cpp +++ b/src/neighbor.cpp @@ -57,11 +57,11 @@ using namespace LAMMPS_NS; using namespace NeighConst; -#define RQDELTA 1 -#define EXDELTA 1 -#define DELTA_PERATOM 64 +static constexpr int RQDELTA = 1; +static constexpr int EXDELTA = 1; +static constexpr int DELTA_PERATOM = 64; -#define BIG 1.0e20 +static constexpr double BIG = 1.0e20; enum{NONE,ALL,PARTIAL,TEMPLATE}; @@ -501,7 +501,7 @@ void Neighbor::init() // fixchecklist = other classes that can induce reneighboring in decide() fixchecklist.clear(); - for (auto &ifix : modify->get_fix_list()) { + for (const auto &ifix : modify->get_fix_list()) { if (ifix->force_reneighbor) { fixchecklist.push_back(ifix); must_check = 1; @@ -1596,10 +1596,16 @@ void Neighbor::init_topology() int bond_off = 0; int angle_off = 0; - for (i = 0; i < modify->nfix; i++) - if (utils::strmatch(modify->fix[i]->style,"^shake") - || utils::strmatch(modify->fix[i]->style,"^rattle")) + int dihedral_off = 0; + int improper_off = 0; + + for (const auto &ifix : modify->get_fix_list()) { + if (utils::strmatch(ifix->style,"^shake") || utils::strmatch(ifix->style,"^rattle")) bond_off = angle_off = 1; + if (utils::strmatch(ifix->style,"gcmc")) + bond_off = angle_off = dihedral_off = improper_off = 1; + } + if (force->bond) if (force->bond->partial_flag) bond_off = 1; @@ -1620,7 +1626,6 @@ void Neighbor::init_topology() } } - int dihedral_off = 0; if (atom->avec->dihedrals_allow && atom->molecular == Atom::MOLECULAR) { for (i = 0; i < atom->nlocal; i++) { if (dihedral_off) break; @@ -1629,7 +1634,6 @@ void Neighbor::init_topology() } } - int improper_off = 0; if (atom->avec->impropers_allow && atom->molecular == Atom::MOLECULAR) { for (i = 0; i < atom->nlocal; i++) { if (improper_off) break; @@ -1638,10 +1642,6 @@ void Neighbor::init_topology() } } - for (i = 0; i < modify->nfix; i++) - if ((strcmp(modify->fix[i]->style,"gcmc") == 0)) - bond_off = angle_off = dihedral_off = improper_off = 1; - // sync on/off settings across all procs int onoff = bond_off; diff --git a/src/ntopo.cpp b/src/ntopo.cpp index 752a8f95a65..a6c7a199e2d 100644 --- a/src/ntopo.cpp +++ b/src/ntopo.cpp @@ -22,8 +22,8 @@ using namespace LAMMPS_NS; -#define LB_FACTOR 1.5 -#define DELTA 10000 +static constexpr double LB_FACTOR = 1.5; +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_angle_all.cpp b/src/ntopo_angle_all.cpp index f6ed1cc2772..593750c7b7d 100644 --- a/src/ntopo_angle_all.cpp +++ b/src/ntopo_angle_all.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_angle_partial.cpp b/src/ntopo_angle_partial.cpp index 4ab56465b7d..277621f0bda 100644 --- a/src/ntopo_angle_partial.cpp +++ b/src/ntopo_angle_partial.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_angle_template.cpp b/src/ntopo_angle_template.cpp index 51f4b0f7263..982ef90a9de 100644 --- a/src/ntopo_angle_template.cpp +++ b/src/ntopo_angle_template.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_bond_all.cpp b/src/ntopo_bond_all.cpp index 8e2fd1adfd7..7e051744e2c 100644 --- a/src/ntopo_bond_all.cpp +++ b/src/ntopo_bond_all.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_bond_partial.cpp b/src/ntopo_bond_partial.cpp index e2d4944b9c0..4df72f9ab86 100644 --- a/src/ntopo_bond_partial.cpp +++ b/src/ntopo_bond_partial.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_bond_template.cpp b/src/ntopo_bond_template.cpp index 865fddc12d5..c8f4bc51d84 100644 --- a/src/ntopo_bond_template.cpp +++ b/src/ntopo_bond_template.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_dihedral_all.cpp b/src/ntopo_dihedral_all.cpp index 216952d9c6e..9f62cda07d2 100644 --- a/src/ntopo_dihedral_all.cpp +++ b/src/ntopo_dihedral_all.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_dihedral_partial.cpp b/src/ntopo_dihedral_partial.cpp index 3e7a4526d57..98246b7b4fd 100644 --- a/src/ntopo_dihedral_partial.cpp +++ b/src/ntopo_dihedral_partial.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_dihedral_template.cpp b/src/ntopo_dihedral_template.cpp index e2ffe7be4c7..2cc41f4a8fb 100644 --- a/src/ntopo_dihedral_template.cpp +++ b/src/ntopo_dihedral_template.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_improper_all.cpp b/src/ntopo_improper_all.cpp index ee08ddb834f..2786fdbfa89 100644 --- a/src/ntopo_improper_all.cpp +++ b/src/ntopo_improper_all.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_improper_partial.cpp b/src/ntopo_improper_partial.cpp index 039da2c9150..559a7b3d7dc 100644 --- a/src/ntopo_improper_partial.cpp +++ b/src/ntopo_improper_partial.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/ntopo_improper_template.cpp b/src/ntopo_improper_template.cpp index 401fb986d98..79712f4ed1e 100644 --- a/src/ntopo_improper_template.cpp +++ b/src/ntopo_improper_template.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define DELTA 10000 +static constexpr int DELTA = 10000; /* ---------------------------------------------------------------------- */ diff --git a/src/output.cpp b/src/output.cpp index cff2e681070..f6da6962933 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -38,8 +38,8 @@ using namespace LAMMPS_NS; -#define DELTA 1 -#define EPSDT 1.0e-6 +static constexpr int DELTA = 1; +static constexpr double EPSDT = 1.0e-6; enum {SETUP, WRITE, RESET_DT}; diff --git a/src/pair_table.cpp b/src/pair_table.cpp index 2b481c83344..730107c856c 100644 --- a/src/pair_table.cpp +++ b/src/pair_table.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; enum { NONE, RLINEAR, RSQ, BMP }; -#define EPSILONR 1.0e-6 +static constexpr double EPSILONR = 1.0e-6; /* ---------------------------------------------------------------------- */ diff --git a/src/procmap.cpp b/src/procmap.cpp index 6fcea50315d..71e1cf5a6b3 100644 --- a/src/procmap.cpp +++ b/src/procmap.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 128 +static constexpr int MAXLINE = 128; /* ---------------------------------------------------------------------- */ @@ -282,7 +282,7 @@ void ProcMap::custom_grid(char *cfile, int nprocs, int me; MPI_Comm_rank(world,&me); - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; FILE *fp = nullptr; if (me == 0) { diff --git a/src/rcb.cpp b/src/rcb.cpp index a42be9b02aa..da7134a0f1c 100644 --- a/src/rcb.cpp +++ b/src/rcb.cpp @@ -21,9 +21,9 @@ using namespace LAMMPS_NS; -#define MYHUGE 1.0e30 -#define TINY 1.0e-6 -#define DELTA 16384 +static constexpr double MYHUGE = 1.0e30; +static constexpr double TINY = 1.0e-6; +static constexpr int DELTA = 16384; // prototypes for non-class functions diff --git a/src/read_dump.cpp b/src/read_dump.cpp index 7f8d4d65590..5972b369c81 100644 --- a/src/read_dump.cpp +++ b/src/read_dump.cpp @@ -33,7 +33,7 @@ using namespace LAMMPS_NS; -#define CHUNK 16384 +static constexpr int CHUNK = 16384; enum { NOADD, YESADD, KEEPADD }; diff --git a/src/reader_native.cpp b/src/reader_native.cpp index 92409389ef9..ae59ca68055 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -24,7 +24,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 // max line length in dump file +static constexpr int MAXLINE = 1024; // max line length in dump file /* ---------------------------------------------------------------------- */ diff --git a/src/reader_xyz.cpp b/src/reader_xyz.cpp index c3e7d0ed992..22b6df0cb96 100644 --- a/src/reader_xyz.cpp +++ b/src/reader_xyz.cpp @@ -23,7 +23,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 1024 // max line length in dump file +static constexpr int MAXLINE = 1024; // max line length in dump file /* ---------------------------------------------------------------------- */ diff --git a/src/replicate.cpp b/src/replicate.cpp index e0fd5b0e3d2..b27304a2a04 100644 --- a/src/replicate.cpp +++ b/src/replicate.cpp @@ -28,8 +28,8 @@ using namespace LAMMPS_NS; -#define LB_FACTOR 1.1 -#define EPSILON 1.0e-6 +static constexpr double LB_FACTOR = 1.1; +static constexpr double EPSILON = 1.0e-6; /* ---------------------------------------------------------------------- */ diff --git a/src/rerun.cpp b/src/rerun.cpp index 5f925560922..74a89569945 100644 --- a/src/rerun.cpp +++ b/src/rerun.cpp @@ -30,7 +30,7 @@ using namespace LAMMPS_NS; -#define EPSDT 1.0e-6 +static constexpr double EPSDT = 1.0e-6; /* ---------------------------------------------------------------------- */ Rerun::Rerun(LAMMPS *lmp) : Command(lmp) {} diff --git a/src/reset_atoms_id.cpp b/src/reset_atoms_id.cpp index a6382e6aee1..9992a49b284 100644 --- a/src/reset_atoms_id.cpp +++ b/src/reset_atoms_id.cpp @@ -38,8 +38,8 @@ static int compare_coords(const void *, const void *); static int compare_coords(const int, const int, void *); #endif -#define PERBIN 10 -#define BIG 1.0e20 +static constexpr int PERBIN = 10; +static constexpr double BIG = 1.0e20; /* ---------------------------------------------------------------------- */ diff --git a/src/set.cpp b/src/set.cpp index 6b21fe92bbc..cee769a573b 100644 --- a/src/set.cpp +++ b/src/set.cpp @@ -52,8 +52,6 @@ enum{TYPE,TYPE_FRACTION,TYPE_RATIO,TYPE_SUBSET, SPH_E,SPH_CV,SPH_RHO,EDPD_TEMP,EDPD_CV,CC,SMD_MASS_DENSITY, SMD_CONTACT_RADIUS,DPDTHETA,EPSILON,IVEC,DVEC,IARRAY,DARRAY}; -#define BIG INT_MAX - /* ---------------------------------------------------------------------- */ void Set::command(int narg, char **arg) diff --git a/src/special.cpp b/src/special.cpp index 5d9b2bb09e0..232ea351703 100644 --- a/src/special.cpp +++ b/src/special.cpp @@ -26,7 +26,7 @@ using namespace LAMMPS_NS; -#define RVOUS 1 // 0 for irregular, 1 for all2all +static constexpr int RVOUS = 1; // 0 for irregular, 1 for all2all /* ---------------------------------------------------------------------- */ diff --git a/src/thermo.cpp b/src/thermo.cpp index 1c4e25dcb0c..3d8b419991a 100644 --- a/src/thermo.cpp +++ b/src/thermo.cpp @@ -93,7 +93,7 @@ static constexpr char id_press[] = "thermo_press"; static constexpr char id_pe[] = "thermo_pe"; static char fmtbuf[512]; -#define DELTA 8 +static constexpr int DELTA = 8; /* ---------------------------------------------------------------------- */ diff --git a/src/universe.cpp b/src/universe.cpp index e743816d92c..edd5b01031f 100644 --- a/src/universe.cpp +++ b/src/universe.cpp @@ -21,7 +21,7 @@ using namespace LAMMPS_NS; -#define MAXLINE 256 +static constexpr int MAXLINE = 256; /* ---------------------------------------------------------------------- create & initialize the universe of processors in communicator @@ -69,7 +69,7 @@ Universe::~Universe() void Universe::reorder(char *style, char *arg) { - char line[MAXLINE]; + char line[MAXLINE] = {'\0'}; if (uworld != uorig) MPI_Comm_free(&uworld); diff --git a/src/variable.cpp b/src/variable.cpp index fe6eba39d92..426dbd8b060 100644 --- a/src/variable.cpp +++ b/src/variable.cpp @@ -48,13 +48,13 @@ using namespace LAMMPS_NS; using namespace MathConst; -#define VARDELTA 4 -#define MAXLEVEL 4 -#define MAXLINE 256 -#define CHUNK 1024 -#define MAXFUNCARG 6 +static constexpr int VARDELTA = 4; +static constexpr int MAXLEVEL = 4; +static constexpr int MAXLINE = 256; +static constexpr int CHUNK = 1024; +static constexpr int MAXFUNCARG = 6; -#define MYROUND(a) (( (a)-floor(a) ) >= .5) ? ceil(a) : floor(a) +static inline double MYROUND(double a) { return ((a - floor(a)) >= 0.5) ? ceil(a) : floor(a); } enum{ARG,OP}; diff --git a/src/velocity.cpp b/src/velocity.cpp index 421c4945535..fd4fd71f686 100644 --- a/src/velocity.cpp +++ b/src/velocity.cpp @@ -38,8 +38,8 @@ enum{ALL,LOCAL,GEOM}; enum{UNIFORM,GAUSSIAN}; enum{NONE,CONSTANT,EQUAL,ATOM}; -#define WARMUP 100 -#define SMALL 0.001 +static constexpr int WARMUP = 100; +static constexpr double SMALL = 0.001; /* ---------------------------------------------------------------------- */