Merge branch 'develop' into schererc/develop

This commit is contained in:
Axel Kohlmeyer
2022-06-01 12:07:06 -04:00
110 changed files with 3487 additions and 2056 deletions

View File

@ -5,6 +5,8 @@ on:
push:
branches: [develop]
workflow_dispatch:
jobs:
analyze:
name: Analyze

View File

@ -5,6 +5,8 @@ on:
push:
branches: [develop]
workflow_dispatch:
jobs:
build:
name: Windows Compilation Test

View File

@ -5,6 +5,8 @@ on:
push:
branches: [develop]
workflow_dispatch:
jobs:
build:
name: MacOS Unit Test

615
cmake/CMakeLists.jpeg Normal file
View File

@ -0,0 +1,615 @@
cmake_minimum_required(VERSION 3.10)
# When using CMake 3.4 and later, don't export symbols from executables unless
# the CMAKE_ENABLE_EXPORTS variable is set.
if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
if(CMAKE_EXECUTABLE_SUFFIX)
set(CMAKE_EXECUTABLE_SUFFIX_TMP ${CMAKE_EXECUTABLE_SUFFIX})
endif()
project(libjpeg-turbo C)
set(VERSION 2.1.3)
set(COPYRIGHT_YEAR "1991-2022")
string(REPLACE "." ";" VERSION_TRIPLET ${VERSION})
list(GET VERSION_TRIPLET 0 VERSION_MAJOR)
list(GET VERSION_TRIPLET 1 VERSION_MINOR)
list(GET VERSION_TRIPLET 2 VERSION_REVISION)
function(pad_number NUMBER OUTPUT_LEN)
string(LENGTH "${${NUMBER}}" INPUT_LEN)
if(INPUT_LEN LESS OUTPUT_LEN)
math(EXPR ZEROES "${OUTPUT_LEN} - ${INPUT_LEN} - 1")
set(NUM ${${NUMBER}})
foreach(C RANGE ${ZEROES})
set(NUM "0${NUM}")
endforeach()
set(${NUMBER} ${NUM} PARENT_SCOPE)
endif()
endfunction()
pad_number(VERSION_MINOR 3)
pad_number(VERSION_REVISION 3)
set(LIBJPEG_TURBO_VERSION_NUMBER ${VERSION_MAJOR}${VERSION_MINOR}${VERSION_REVISION})
# CMake 3.14 and later sets CMAKE_MACOSX_BUNDLE to TRUE by default when
# CMAKE_SYSTEM_NAME is iOS, tvOS, or watchOS, which breaks the libjpeg-turbo
# build. (Specifically, when CMAKE_MACOSX_BUNDLE is TRUE, executables for
# Apple platforms are built as application bundles, which causes CMake to
# complain that our install() directives for executables do not specify a
# BUNDLE DESTINATION. Even if CMake did not complain, building executables as
# application bundles would break our iOS packages.)
set(CMAKE_MACOSX_BUNDLE FALSE)
string(TIMESTAMP DEFAULT_BUILD "%Y%m%d")
set(BUILD ${DEFAULT_BUILD} CACHE STRING "Build string (default: ${DEFAULT_BUILD})")
# NOTE: On Windows, this does nothing except when using MinGW or Cygwin.
# CMAKE_BUILD_TYPE has no meaning in Visual Studio, and it always defaults to
# Debug when using NMake.
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
message(STATUS "VERSION = ${VERSION}, BUILD = ${BUILD}")
include(cmakescripts/PackageInfo.cmake)
# Detect CPU type and whether we're building 64-bit or 32-bit code
math(EXPR BITS "${CMAKE_SIZEOF_VOID_P} * 8")
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} CMAKE_SYSTEM_PROCESSOR_LC)
set(COUNT 1)
foreach(ARCH ${CMAKE_OSX_ARCHITECTURES})
if(COUNT GREATER 1)
message(FATAL_ERROR "The libjpeg-turbo build system does not support multiple values in CMAKE_OSX_ARCHITECTURES.")
endif()
math(EXPR COUNT "${COUNT}+1")
endforeach()
if(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86_64" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "amd64" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "i[0-9]86" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "x86" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "ia32")
if(BITS EQUAL 64 OR CMAKE_C_COMPILER_ABI MATCHES "ELF X32")
set(CPU_TYPE x86_64)
else()
set(CPU_TYPE i386)
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL ${CPU_TYPE})
set(CMAKE_SYSTEM_PROCESSOR ${CPU_TYPE})
endif()
elseif(CMAKE_SYSTEM_PROCESSOR_LC STREQUAL "aarch64" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^arm")
if(BITS EQUAL 64)
set(CPU_TYPE arm64)
else()
set(CPU_TYPE arm)
endif()
elseif(CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^ppc" OR
CMAKE_SYSTEM_PROCESSOR_LC MATCHES "^powerpc")
set(CPU_TYPE powerpc)
else()
set(CPU_TYPE ${CMAKE_SYSTEM_PROCESSOR_LC})
endif()
if(CMAKE_OSX_ARCHITECTURES MATCHES "x86_64" OR
CMAKE_OSX_ARCHITECTURES MATCHES "arm64" OR
CMAKE_OSX_ARCHITECTURES MATCHES "i386")
set(CPU_TYPE ${CMAKE_OSX_ARCHITECTURES})
endif()
if(CMAKE_OSX_ARCHITECTURES MATCHES "ppc")
set(CPU_TYPE powerpc)
endif()
if(MSVC_IDE AND CMAKE_GENERATOR_PLATFORM MATCHES "arm64")
set(CPU_TYPE arm64)
endif()
message(STATUS "${BITS}-bit build (${CPU_TYPE})")
macro(report_directory var)
if(CMAKE_INSTALL_${var} STREQUAL CMAKE_INSTALL_FULL_${var})
message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}}")
else()
message(STATUS "CMAKE_INSTALL_${var} = ${CMAKE_INSTALL_${var}} (${CMAKE_INSTALL_FULL_${var}})")
endif()
mark_as_advanced(CLEAR CMAKE_INSTALL_${var})
endmacro()
set(DIRLIST "BINDIR;DATAROOTDIR;DOCDIR;INCLUDEDIR;LIBDIR")
if(UNIX)
list(APPEND DIRLIST "MANDIR")
endif()
foreach(dir ${DIRLIST})
report_directory(${dir})
endforeach()
###############################################################################
# CONFIGURATION OPTIONS
###############################################################################
macro(boolean_number var)
if(${var})
set(${var} 1 ${ARGN})
else()
set(${var} 0 ${ARGN})
endif()
endmacro()
option(ENABLE_SHARED "Build shared libraries" FALSE)
boolean_number(ENABLE_SHARED)
option(ENABLE_STATIC "Build static libraries" TRUE)
boolean_number(ENABLE_STATIC)
option(REQUIRE_SIMD "Generate a fatal error if SIMD extensions are not available for this platform (default is to fall back to a non-SIMD build)" FALSE)
boolean_number(REQUIRE_SIMD)
option(WITH_12BIT "Encode/decode JPEG images with 12-bit samples (implies WITH_ARITH_DEC=0 WITH_ARITH_ENC=0 WITH_JAVA=0 WITH_SIMD=0 WITH_TURBOJPEG=0 )" FALSE)
boolean_number(WITH_12BIT)
option(WITH_ARITH_DEC "Include arithmetic decoding support when emulating the libjpeg v6b API/ABI" TRUE)
boolean_number(WITH_ARITH_DEC)
option(WITH_ARITH_ENC "Include arithmetic encoding support when emulating the libjpeg v6b API/ABI" TRUE)
boolean_number(WITH_ARITH_ENC)
if(CMAKE_C_COMPILER_ABI MATCHES "ELF X32")
set(WITH_JAVA 0)
else()
option(WITH_JAVA "Build Java wrapper for the TurboJPEG API library (implies ENABLE_SHARED=1)" FALSE)
boolean_number(WITH_JAVA)
endif()
option(WITH_JPEG7 "Emulate libjpeg v7 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
boolean_number(WITH_JPEG7)
option(WITH_JPEG8 "Emulate libjpeg v8 API/ABI (this makes ${CMAKE_PROJECT_NAME} backward-incompatible with libjpeg v6b)" FALSE)
boolean_number(WITH_JPEG8)
option(WITH_MEM_SRCDST "Include in-memory source/destination manager functions when emulating the libjpeg v6b or v7 API/ABI" TRUE)
boolean_number(WITH_MEM_SRCDST)
option(WITH_SIMD "Include SIMD extensions, if available for this platform" FALSE)
boolean_number(WITH_SIMD)
option(WITH_TURBOJPEG "Include the TurboJPEG API library and associated test programs" FALSE)
boolean_number(WITH_TURBOJPEG)
option(WITH_FUZZ "Build fuzz targets" FALSE)
macro(report_option var desc)
if(${var})
message(STATUS "${desc} enabled (${var} = ${${var}})")
else()
message(STATUS "${desc} disabled (${var} = ${${var}})")
endif()
endmacro()
if(WITH_JAVA)
set(ENABLE_SHARED 1)
endif()
# Explicitly setting CMAKE_POSITION_INDEPENDENT_CODE=FALSE disables PIC for all
# targets, which will cause the shared library builds to fail. Thus, if shared
# libraries are enabled and CMAKE_POSITION_INDEPENDENT_CODE is explicitly set
# to FALSE, we need to unset it, thus restoring the default behavior
# (automatically using PIC for shared library targets.)
if(DEFINED CMAKE_POSITION_INDEPENDENT_CODE AND
NOT CMAKE_POSITION_INDEPENDENT_CODE AND ENABLE_SHARED)
unset(CMAKE_POSITION_INDEPENDENT_CODE CACHE)
endif()
report_option(ENABLE_SHARED "Shared libraries")
report_option(ENABLE_STATIC "Static libraries")
if(ENABLE_SHARED)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
endif()
if(WITH_JPEG8 OR WITH_JPEG7)
set(WITH_ARITH_ENC 1)
set(WITH_ARITH_DEC 1)
endif()
if(WITH_JPEG8)
set(WITH_MEM_SRCDST 0)
endif()
if(WITH_12BIT)
set(WITH_ARITH_DEC 0)
set(WITH_ARITH_ENC 0)
set(WITH_JAVA 0)
set(WITH_SIMD 0)
set(WITH_TURBOJPEG 0)
set(BITS_IN_JSAMPLE 12)
else()
set(BITS_IN_JSAMPLE 8)
endif()
report_option(WITH_12BIT "12-bit JPEG support")
if(WITH_ARITH_DEC)
set(D_ARITH_CODING_SUPPORTED 1)
endif()
if(NOT WITH_12BIT)
report_option(WITH_ARITH_DEC "Arithmetic decoding support")
endif()
if(WITH_ARITH_ENC)
set(C_ARITH_CODING_SUPPORTED 1)
endif()
if(NOT WITH_12BIT)
report_option(WITH_ARITH_ENC "Arithmetic encoding support")
endif()
if(NOT WITH_12BIT)
report_option(WITH_TURBOJPEG "TurboJPEG API library")
report_option(WITH_JAVA "TurboJPEG Java wrapper")
endif()
if(WITH_MEM_SRCDST)
set(MEM_SRCDST_SUPPORTED 1)
set(MEM_SRCDST_FUNCTIONS "global: jpeg_mem_dest; jpeg_mem_src;")
endif()
if(NOT WITH_JPEG8)
report_option(WITH_MEM_SRCDST "In-memory source/destination managers")
endif()
set(SO_AGE 2)
if(WITH_MEM_SRCDST)
set(SO_AGE 3)
endif()
if(WITH_JPEG8)
set(JPEG_LIB_VERSION 80)
elseif(WITH_JPEG7)
set(JPEG_LIB_VERSION 70)
else()
set(JPEG_LIB_VERSION 62)
endif()
math(EXPR JPEG_LIB_VERSION_DIV10 "${JPEG_LIB_VERSION} / 10")
math(EXPR JPEG_LIB_VERSION_MOD10 "${JPEG_LIB_VERSION} % 10")
if(JPEG_LIB_VERSION STREQUAL "62")
set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION})
else()
set(DEFAULT_SO_MAJOR_VERSION ${JPEG_LIB_VERSION_DIV10})
endif()
if(JPEG_LIB_VERSION STREQUAL "80")
set(DEFAULT_SO_MINOR_VERSION 2)
else()
set(DEFAULT_SO_MINOR_VERSION 0)
endif()
# This causes SO_MAJOR_VERSION/SO_MINOR_VERSION to reset to defaults if
# WITH_JPEG7 or WITH_JPEG8 has changed.
if((DEFINED WITH_JPEG7_INT AND NOT WITH_JPEG7 EQUAL WITH_JPEG7_INT) OR
(DEFINED WITH_JPEG8_INT AND NOT WITH_JPEG8 EQUAL WITH_JPEG8_INT))
set(FORCE_SO_VERSION "FORCE")
endif()
set(WITH_JPEG7_INT ${WITH_JPEG7} CACHE INTERNAL "")
set(WITH_JPEG8_INT ${WITH_JPEG8} CACHE INTERNAL "")
set(SO_MAJOR_VERSION ${DEFAULT_SO_MAJOR_VERSION} CACHE STRING
"Major version of the libjpeg API shared library (default: ${DEFAULT_SO_MAJOR_VERSION})"
${FORCE_SO_VERSION})
set(SO_MINOR_VERSION ${DEFAULT_SO_MINOR_VERSION} CACHE STRING
"Minor version of the libjpeg API shared library (default: ${DEFAULT_SO_MINOR_VERSION})"
${FORCE_SO_VERSION})
set(JPEG_LIB_VERSION_DECIMAL "${JPEG_LIB_VERSION_DIV10}.${JPEG_LIB_VERSION_MOD10}")
message(STATUS "Emulating libjpeg API/ABI v${JPEG_LIB_VERSION_DECIMAL} (WITH_JPEG7 = ${WITH_JPEG7}, WITH_JPEG8 = ${WITH_JPEG8})")
message(STATUS "libjpeg API shared library version = ${SO_MAJOR_VERSION}.${SO_AGE}.${SO_MINOR_VERSION}")
# Because the TurboJPEG API library uses versioned symbols and changes the
# names of functions whenever they are modified in a backward-incompatible
# manner, it is always backward-ABI-compatible with itself, so the major and
# minor SO versions don't change. However, we increase the middle number (the
# SO "age") whenever functions are added to the API.
set(TURBOJPEG_SO_MAJOR_VERSION 0)
set(TURBOJPEG_SO_AGE 2)
set(TURBOJPEG_SO_VERSION 0.${TURBOJPEG_SO_AGE}.0)
###############################################################################
# COMPILER SETTINGS
###############################################################################
if(MSVC)
option(WITH_CRT_DLL
"Link all ${CMAKE_PROJECT_NAME} libraries and executables with the C run-time DLL (msvcr*.dll) instead of the static C run-time library (libcmt*.lib.) The default is to use the C run-time DLL only with the libraries and executables that need it."
FALSE)
if(NOT WITH_CRT_DLL)
# Use the static C library for all build types
foreach(var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${var} "${${var}}")
endif()
endforeach()
endif()
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
endif()
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
# Use the maximum optimization level for release builds
foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${var} MATCHES "-O2")
string(REGEX REPLACE "-O2" "-O3" ${var} "${${var}}")
endif()
endforeach()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
if(CMAKE_C_COMPILER_ID MATCHES "SunPro")
# Use the maximum optimization level for release builds
foreach(var CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO)
if(${var} MATCHES "-xO3")
string(REGEX REPLACE "-xO3" "-xO5" ${var} "${${var}}")
endif()
if(${var} MATCHES "-xO2")
string(REGEX REPLACE "-xO2" "-xO5" ${var} "${${var}}")
endif()
endforeach()
endif()
endif()
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UC)
set(EFFECTIVE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
message(STATUS "Compiler flags = ${EFFECTIVE_C_FLAGS}")
set(EFFECTIVE_LD_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE_UC}}")
message(STATUS "Linker flags = ${EFFECTIVE_LD_FLAGS}")
include(CheckCSourceCompiles)
include(CheckIncludeFiles)
include(CheckTypeSize)
check_type_size("size_t" SIZE_T)
check_type_size("unsigned long" UNSIGNED_LONG)
if(SIZE_T EQUAL UNSIGNED_LONG)
check_c_source_compiles("int main(int argc, char **argv) { unsigned long a = argc; return __builtin_ctzl(a); }"
HAVE_BUILTIN_CTZL)
endif()
if(MSVC)
check_include_files("intrin.h" HAVE_INTRIN_H)
endif()
if(UNIX)
if(CMAKE_CROSSCOMPILING)
set(RIGHT_SHIFT_IS_UNSIGNED 0)
else()
include(CheckCSourceRuns)
check_c_source_runs("
#include <stdio.h>
#include <stdlib.h>
int is_shifting_signed (long arg) {
long res = arg >> 4;
if (res == -0x7F7E80CL)
return 1; /* right shift is signed */
/* see if unsigned-shift hack will fix it. */
/* we can't just test exact value since it depends on width of long... */
res |= (~0L) << (32-4);
if (res == -0x7F7E80CL)
return 0; /* right shift is unsigned */
printf(\"Right shift isn't acting as I expect it to.\\\\n\");
printf(\"I fear the JPEG software will not work at all.\\\\n\\\\n\");
return 0; /* try it with unsigned anyway */
}
int main (void) {
exit(is_shifting_signed(-0x7F7E80B1L));
}" RIGHT_SHIFT_IS_UNSIGNED)
endif()
endif()
if(MSVC)
set(INLINE_OPTIONS "__inline;inline")
else()
set(INLINE_OPTIONS "__inline__;inline")
endif()
option(FORCE_INLINE "Force function inlining" TRUE)
boolean_number(FORCE_INLINE)
if(FORCE_INLINE)
if(MSVC)
list(INSERT INLINE_OPTIONS 0 "__forceinline")
else()
list(INSERT INLINE_OPTIONS 0 "inline __attribute__((always_inline))")
list(INSERT INLINE_OPTIONS 0 "__inline__ __attribute__((always_inline))")
endif()
endif()
foreach(inline ${INLINE_OPTIONS})
check_c_source_compiles("${inline} static int foo(void) { return 0; } int main(void) { return foo(); }"
INLINE_WORKS)
if(INLINE_WORKS)
set(INLINE ${inline})
break()
endif()
endforeach()
if(NOT INLINE_WORKS)
message(FATAL_ERROR "Could not determine how to inline functions.")
endif()
message(STATUS "INLINE = ${INLINE} (FORCE_INLINE = ${FORCE_INLINE})")
if(WITH_TURBOJPEG)
if(MSVC)
set(THREAD_LOCAL "__declspec(thread)")
else()
set(THREAD_LOCAL "__thread")
endif()
check_c_source_compiles("${THREAD_LOCAL} int i; int main(void) { i = 0; return i; }" HAVE_THREAD_LOCAL)
if(HAVE_THREAD_LOCAL)
message(STATUS "THREAD_LOCAL = ${THREAD_LOCAL}")
else()
message(WARNING "Thread-local storage is not available. The TurboJPEG API library's global error handler will not be thread-safe.")
unset(THREAD_LOCAL)
endif()
endif()
if(UNIX AND NOT APPLE)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map "VERS_1 { global: *; };")
set(CMAKE_REQUIRED_FLAGS
"-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
check_c_source_compiles("int main(void) { return 0; }" HAVE_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS)
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
if(HAVE_VERSION_SCRIPT)
message(STATUS "Linker supports GNU-style version scripts")
set(MAPFLAG "-Wl,--version-script,")
set(TJMAPFLAG "-Wl,--version-script,")
else()
message(STATUS "Linker does not support GNU-style version scripts")
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
# The Solaris linker doesn't like our version script for the libjpeg API
# library, but the version script for the TurboJPEG API library should
# still work.
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map
"VERS_1 { global: foo; local: *; }; VERS_2 { global: foo2; } VERS_1;")
set(CMAKE_REQUIRED_FLAGS "-Wl,-M,${CMAKE_CURRENT_BINARY_DIR}/conftest.map -shared")
check_c_source_compiles("int foo() { return 0; } int foo2() { return 2; }"
HAVE_MAPFILE)
set(CMAKE_REQUIRED_FLAGS)
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/conftest.map)
if(HAVE_MAPFILE)
message(STATUS "Linker supports mapfiles")
set(TJMAPFLAG "-Wl,-M,")
else()
message(STATUS "Linker does not support mapfiles")
endif()
endif()
endif()
endif()
# Generate files
if(WIN32)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/win/jconfig.h.in jconfig.h)
else()
configure_file(jconfig.h.in jconfig.h)
endif()
configure_file(jconfigint.h.in jconfigint.h)
configure_file(jversion.h.in jversion.h)
if(UNIX)
configure_file(libjpeg.map.in libjpeg.map)
endif()
# Include directories and compiler definitions
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
###############################################################################
# TARGETS
###############################################################################
if(CMAKE_EXECUTABLE_SUFFIX_TMP)
set(CMAKE_EXECUTABLE_SUFFIX ${CMAKE_EXECUTABLE_SUFFIX_TMP})
endif()
message(STATUS "CMAKE_EXECUTABLE_SUFFIX = ${CMAKE_EXECUTABLE_SUFFIX}")
set(JPEG_SOURCES jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c
jcicc.c jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c
jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c jdatadst.c
jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c jdicc.c jdinput.c
jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c jdpostct.c jdsample.c
jdtrans.c jerror.c jfdctflt.c jfdctfst.c jfdctint.c jidctflt.c jidctfst.c
jidctint.c jidctred.c jquant1.c jquant2.c jutils.c jmemmgr.c jmemnobs.c)
if(WITH_ARITH_ENC OR WITH_ARITH_DEC)
set(JPEG_SOURCES ${JPEG_SOURCES} jaricom.c)
endif()
if(WITH_ARITH_ENC)
set(JPEG_SOURCES ${JPEG_SOURCES} jcarith.c)
endif()
if(WITH_ARITH_DEC)
set(JPEG_SOURCES ${JPEG_SOURCES} jdarith.c)
endif()
if(WITH_SIMD)
add_subdirectory(simd)
if(NEON_INTRINSICS)
add_definitions(-DNEON_INTRINSICS)
endif()
elseif(NOT WITH_12BIT)
message(STATUS "SIMD extensions: None (WITH_SIMD = ${WITH_SIMD})")
endif()
if(WITH_SIMD)
message(STATUS "SIMD extensions: ${CPU_TYPE} (WITH_SIMD = ${WITH_SIMD})")
if(MSVC_IDE OR XCODE)
set_source_files_properties(${SIMD_OBJS} PROPERTIES GENERATED 1)
endif()
else()
add_library(simd OBJECT jsimd_none.c)
if(NOT WIN32 AND (CMAKE_POSITION_INDEPENDENT_CODE OR ENABLE_SHARED))
set_target_properties(simd PROPERTIES POSITION_INDEPENDENT_CODE 1)
endif()
endif()
if(WITH_JAVA)
add_subdirectory(java)
endif()
if(ENABLE_SHARED)
add_subdirectory(sharedlib)
endif()
if(ENABLE_STATIC)
add_library(jpeg-static STATIC ${JPEG_SOURCES} $<TARGET_OBJECTS:simd>
${SIMD_OBJS})
if(NOT MSVC)
set_target_properties(jpeg-static PROPERTIES OUTPUT_NAME jpeg)
endif()
endif()
if(WITH_TURBOJPEG)
if(ENABLE_SHARED)
set(TURBOJPEG_SOURCES ${JPEG_SOURCES} $<TARGET_OBJECTS:simd> ${SIMD_OBJS}
turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c rdppm.c
wrbmp.c wrppm.c)
set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile)
if(WITH_JAVA)
set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES} turbojpeg-jni.c)
include_directories(${JAVA_INCLUDE_PATH} ${JAVA_INCLUDE_PATH2})
set(TJMAPFILE ${CMAKE_CURRENT_SOURCE_DIR}/turbojpeg-mapfile.jni)
endif()
if(MSVC)
configure_file(${CMAKE_SOURCE_DIR}/win/turbojpeg.rc.in
${CMAKE_BINARY_DIR}/win/turbojpeg.rc)
set(TURBOJPEG_SOURCES ${TURBOJPEG_SOURCES}
${CMAKE_BINARY_DIR}/win/turbojpeg.rc)
endif()
add_library(turbojpeg SHARED ${TURBOJPEG_SOURCES})
set_property(TARGET turbojpeg PROPERTY COMPILE_FLAGS
"-DBMP_SUPPORTED -DPPM_SUPPORTED")
if(WIN32)
set_target_properties(turbojpeg PROPERTIES DEFINE_SYMBOL DLLDEFINE)
endif()
if(MINGW)
set_target_properties(turbojpeg PROPERTIES LINK_FLAGS -Wl,--kill-at)
endif()
if(APPLE AND (NOT CMAKE_OSX_DEPLOYMENT_TARGET OR
CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER 10.4))
if(NOT CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG)
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "-Wl,-rpath,")
endif()
set_target_properties(turbojpeg PROPERTIES MACOSX_RPATH 1)
endif()
set_target_properties(turbojpeg PROPERTIES
SOVERSION ${TURBOJPEG_SO_MAJOR_VERSION} VERSION ${TURBOJPEG_SO_VERSION})
if(TJMAPFLAG)
set_target_properties(turbojpeg PROPERTIES
LINK_FLAGS "${TJMAPFLAG}${TJMAPFILE}")
endif()
endif()
if(ENABLE_STATIC)
add_library(turbojpeg-static STATIC ${JPEG_SOURCES} $<TARGET_OBJECTS:simd>
${SIMD_OBJS} turbojpeg.c transupp.c jdatadst-tj.c jdatasrc-tj.c rdbmp.c
rdppm.c wrbmp.c wrppm.c)
set_property(TARGET turbojpeg-static PROPERTY COMPILE_FLAGS
"-DBMP_SUPPORTED -DPPM_SUPPORTED")
if(NOT MSVC)
set_target_properties(turbojpeg-static PROPERTIES OUTPUT_NAME turbojpeg)
endif()
endif()
endif()
if(WIN32)
set(USE_SETMODE "-DUSE_SETMODE")
endif()
if(WITH_12BIT)
set(COMPILE_FLAGS "-DGIF_SUPPORTED -DPPM_SUPPORTED ${USE_SETMODE}")
else()
set(COMPILE_FLAGS "-DBMP_SUPPORTED -DGIF_SUPPORTED -DPPM_SUPPORTED -DTARGA_SUPPORTED ${USE_SETMODE}")
set(CJPEG_BMP_SOURCES rdbmp.c rdtarga.c)
set(DJPEG_BMP_SOURCES wrbmp.c wrtarga.c)
endif()

741
cmake/CMakeLists.png Normal file
View File

@ -0,0 +1,741 @@
# CMakeLists.txt
# Copyright (C) 2018 Cosmin Truta
# Copyright (C) 2007,2009-2018 Glenn Randers-Pehrson
# Written by Christian Ehrlicher, 2007
# Revised by Roger Lowman, 2009-2010
# Revised by Clifford Yapp, 2011-2012,2017
# Revised by Roger Leigh, 2016
# Revised by Andreas Franek, 2016
# Revised by Sam Serrels, 2017
# Revised by Vadim Barkov, 2017
# Revised by Vicky Pfau, 2018
# Revised by Cameron Cawley, 2018
# Revised by Cosmin Truta, 2018
# Revised by Kyle Bentley, 2018
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
cmake_minimum_required(VERSION 3.10)
cmake_policy(VERSION 3.1)
# When using CMake 3.4 and later, don't export symbols from executables unless
# the CMAKE_ENABLE_EXPORTS variable is set.
if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
project(libpng C ASM)
enable_testing()
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
set(PNGLIB_RELEASE 37)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
include(GNUInstallDirs)
# needed packages
# Allow users to specify location of Zlib.
# Useful if zlib is being built alongside this as a sub-project.
option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" ON)
if(NOT PNG_BUILD_ZLIB)
find_package(ZLIB REQUIRED)
include_directories(${ZLIB_INCLUDE_DIR})
endif()
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
find_library(M_LIBRARY m)
else()
# libm is not needed and/or not available
set(M_LIBRARY "")
endif()
# COMMAND LINE OPTIONS
option(PNG_SHARED "Build shared lib" OFF)
option(PNG_STATIC "Build static lib" ON)
option(PNG_TESTS "Build libpng tests" OFF)
# Many more configuration options could be added here
option(PNG_FRAMEWORK "Build OS X framework" OFF)
option(PNG_DEBUG "Build with debug output" OFF)
option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" OFF)
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
if(PNG_HARDWARE_OPTIMIZATIONS)
# set definitions and sources for arm
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
check: (default) use internal checking code;
off: disable the optimizations;
on: turn on unconditionally.")
set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS
${PNG_ARM_NEON_POSSIBLE_VALUES})
list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
if(index EQUAL -1)
message(FATAL_ERROR
"PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_ARM_NEON} STREQUAL "off")
set(libpng_arm_sources
arm/arm_init.c
arm/filter_neon.S
arm/filter_neon_intrinsics.c
arm/palette_neon_intrinsics.c)
if(${PNG_ARM_NEON} STREQUAL "on")
add_definitions(-DPNG_ARM_NEON_OPT=2)
elseif(${PNG_ARM_NEON} STREQUAL "check")
add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
endif()
else()
add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
endif()
# set definitions and sources for powerpc
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*")
set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations:
off: disable the optimizations.")
set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS
${PNG_POWERPC_VSX_POSSIBLE_VALUES})
list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
if(index EQUAL -1)
message(FATAL_ERROR
"PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off")
set(libpng_powerpc_sources
powerpc/powerpc_init.c
powerpc/filter_vsx_intrinsics.c)
if(${PNG_POWERPC_VSX} STREQUAL "on")
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
endif()
else()
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
endif()
endif()
# set definitions and sources for intel
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*")
set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations:
off: disable the optimizations")
set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS
${PNG_INTEL_SSE_POSSIBLE_VALUES})
list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
if(index EQUAL -1)
message(FATAL_ERROR
"PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off")
set(libpng_intel_sources
intel/intel_init.c
intel/filter_sse2_intrinsics.c)
if(${PNG_INTEL_SSE} STREQUAL "on")
add_definitions(-DPNG_INTEL_SSE_OPT=1)
endif()
else()
add_definitions(-DPNG_INTEL_SSE_OPT=0)
endif()
endif()
# set definitions and sources for MIPS
if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*")
set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations:
off: disable the optimizations")
set_property(CACHE PNG_MIPS_MSA PROPERTY STRINGS
${PNG_MIPS_MSA_POSSIBLE_VALUES})
list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index)
if(index EQUAL -1)
message(FATAL_ERROR
"PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off")
set(libpng_mips_sources
mips/mips_init.c
mips/filter_msa_intrinsics.c)
if(${PNG_MIPS_MSA} STREQUAL "on")
add_definitions(-DPNG_MIPS_MSA_OPT=2)
endif()
else()
add_definitions(-DPNG_MIPS_MSA_OPT=0)
endif()
endif()
else(PNG_HARDWARE_OPTIMIZATIONS)
# set definitions and sources for arm
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
# set definitions and sources for powerpc
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*")
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
endif()
# set definitions and sources for intel
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*")
add_definitions(-DPNG_INTEL_SSE_OPT=0)
endif()
# set definitions and sources for MIPS
if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*")
add_definitions(-DPNG_MIPS_MSA_OPT=0)
endif()
endif(PNG_HARDWARE_OPTIMIZATIONS)
# SET LIBNAME
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
# to distinguish between debug and release lib
set(CMAKE_DEBUG_POSTFIX "d")
include(CheckCSourceCompiles)
option(ld-version-script "Enable linker version script" ON)
if(ld-version-script AND NOT APPLE)
# Check if LD supports linker scripts.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
local: *;
};
VERS_2 {
global: sym2;
main;
} VERS_1;
")
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
check_c_source_compiles("void sym(void) {}
void sym2(void) {}
int main(void) {return 0;}
" HAVE_LD_VERSION_SCRIPT)
if(NOT HAVE_LD_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
check_c_source_compiles("void sym(void) {}
void sym2(void) {}
int main(void) {return 0;}
" HAVE_SOLARIS_LD_VERSION_SCRIPT)
endif()
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
endif()
# Find symbol prefix. Likely obsolete and unnecessary with recent
# toolchains (it's not done in many other projects).
function(symbol_prefix)
set(SYMBOL_PREFIX)
execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-"
INPUT_FILE /dev/null
OUTPUT_VARIABLE OUT
RESULT_VARIABLE STATUS)
if(CPP_FAIL)
message(WARNING "Failed to run the C preprocessor")
endif()
string(REPLACE "\n" ";" OUT "${OUT}")
foreach(line ${OUT})
string(REGEX MATCH "^PREFIX=" found_match "${line}")
if(found_match)
string(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}")
if(found_match)
string(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
endif()
set(SYMBOL_PREFIX "${prefix}")
endif()
endforeach()
message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
endfunction()
if(UNIX)
symbol_prefix()
endif()
find_program(AWK NAMES gawk awk)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(NOT AWK OR ANDROID)
# No awk available to generate sources; use pre-built pnglibconf.h
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
add_custom_target(genfiles) # Dummy
else()
include(CMakeParseArguments)
# Generate .chk from .out with awk
# generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_chk)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GC_INPUT)
message(FATAL_ERROR "generate_chk: Missing INPUT argument")
endif()
if(NOT _GC_OUTPUT)
message(FATAL_ERROR "generate_chk: Missing OUTPUT argument")
endif()
add_custom_command(OUTPUT "${_GC_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GC_INPUT}"
"-DOUTPUT=${_GC_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake"
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate .out from .c with awk
# generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_out)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GO_INPUT)
message(FATAL_ERROR "generate_out: Missing INPUT argument")
endif()
if(NOT _GO_OUTPUT)
message(FATAL_ERROR "generate_out: Missing OUTPUT argument")
endif()
add_custom_command(OUTPUT "${_GO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GO_INPUT}"
"-DOUTPUT=${_GO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake"
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate specific source file with awk
# generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_source)
set(options)
set(oneValueArgs OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GSO_OUTPUT)
message(FATAL_ERROR "generate_source: Missing OUTPUT argument")
endif()
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=${_GSO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
DEPENDS ${_GSO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Copy file
function(generate_copy source destination)
add_custom_command(OUTPUT "${destination}"
COMMAND "${CMAKE_COMMAND}" -E remove "${destination}"
COMMAND "${CMAKE_COMMAND}" -E copy "${source}"
"${destination}"
DEPENDS "${source}")
endfunction()
# Generate scripts/pnglibconf.h
generate_source(OUTPUT "scripts/pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
# Generate pnglibconf.c
generate_source(OUTPUT "pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
if(PNG_PREFIX)
set(PNGLIBCONF_H_EXTRA_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst")
set(PNGPREFIX_H_EXTRA_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
endif()
generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pnglibconf.h
generate_source(OUTPUT "pnglibconf.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
${PNGLIBCONF_H_EXTRA_DEPENDS})
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pngprefix.h
generate_source(OUTPUT "pngprefix.h"
DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
add_custom_target(symbol-check DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
add_custom_target("genprebuilt"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=scripts/pnglibconf.h.prebuilt"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
# A single target handles generation of all generated files. If
# they are depended upon separately by multiple targets, this
# confuses parallel make (it would require a separate top-level
# target for each file to track the dependencies properly).
add_custom_target(genfiles DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
"${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
endif(NOT AWK OR ANDROID)
# OUR SOURCES
set(libpng_public_hdrs
png.h
pngconf.h
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
)
set(libpng_private_hdrs
pngpriv.h
pngdebug.h
pnginfo.h
pngstruct.h
)
if(AWK AND NOT ANDROID)
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
endif()
set(libpng_sources
${libpng_public_hdrs}
${libpng_private_hdrs}
png.c
pngerror.c
pngget.c
pngmem.c
pngpread.c
pngread.c
pngrio.c
pngrtran.c
pngrutil.c
pngset.c
pngtrans.c
pngwio.c
pngwrite.c
pngwtran.c
pngwutil.c
${libpng_arm_sources}
${libpng_intel_sources}
${libpng_mips_sources}
${libpng_powerpc_sources}
)
set(pngtest_sources
pngtest.c
)
set(pngvalid_sources
contrib/libtests/pngvalid.c
)
set(pngstest_sources
contrib/libtests/pngstest.c
)
set(pngunknown_sources
contrib/libtests/pngunknown.c
)
set(pngimage_sources
contrib/libtests/pngimage.c
)
set(pngfix_sources
contrib/tools/pngfix.c
)
set(png_fix_itxt_sources
contrib/tools/png-fix-itxt.c
)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif()
if(PNG_DEBUG)
add_definitions(-DPNG_DEBUG)
endif()
# NOW BUILD OUR TARGET
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
unset(PNG_LIB_TARGETS)
if(PNG_STATIC)
# does not work without changing name
set(PNG_LIB_NAME_STATIC png_static)
add_library(png_static STATIC ${libpng_sources})
add_dependencies(png_static genfiles)
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
if(NOT MSVC)
set_target_properties(png_static PROPERTIES
OUTPUT_NAME "${PNG_LIB_NAME}"
CLEAN_DIRECT_OUTPUT 1)
else()
set_target_properties(png_static PROPERTIES
OUTPUT_NAME "${PNG_LIB_NAME}_static"
CLEAN_DIRECT_OUTPUT 1)
endif()
list(APPEND PNG_LIB_TARGETS png_static)
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(png_static PROPERTIES PREFIX "lib")
endif()
target_link_libraries(png_static ${M_LIBRARY})
endif()
if(NOT PNG_LIB_TARGETS)
message(SEND_ERROR
"No library variant selected to build. "
"Please enable at least one of the following options: "
"PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
endif()
# Set a variable with CMake code which:
# Creates a symlink from src to dest (if possible) or alternatively
# copies if different.
include(CMakeParseArguments)
function(create_symlink DEST_FILE)
cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN})
if(NOT S_TARGET AND NOT S_FILE)
message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument")
endif()
if(S_TARGET AND S_FILE)
message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.")
endif()
if(S_FILE)
# If we don't need to symlink something that's coming from a build target,
# we can go ahead and symlink/copy at configure time.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
execute_process(
COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
else()
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif()
endif()
if(S_TARGET)
# We need to use generator expressions, which can be a bit tricky, so for
# simplicity make the symlink a POST_BUILD step and use the TARGET
# signature of add_custom_command.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
add_custom_command(TARGET ${S_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
else()
add_custom_command(TARGET ${S_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E create_symlink $<TARGET_LINKER_FILE_NAME:${S_TARGET}> $<TARGET_LINKER_FILE_DIR:${S_TARGET}>/${DEST_FILE})
endif()
endif()
endfunction()
# Create source generation scripts.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY)
# libpng is a library so default to 'lib'
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
endif()
# CREATE PKGCONFIG FILES
# We use the same files like ./configure, so we have to set its vars.
# Only do this on Windows for Cygwin - the files don't make much sense outside
# of a UNIX look-alike.
if(NOT WIN32 OR CYGWIN OR MINGW)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(LIBS "-lz -lm")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
create_symlink(libpng-config FILE ${PNGLIB_NAME}-config)
endif()
# SET UP LINKS
if(PNG_SHARED)
set_target_properties(png PROPERTIES
# VERSION 16.${PNGLIB_RELEASE}.1.6.37
VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16
CLEAN_DIRECT_OUTPUT 1)
endif()
# INSTALL
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
install(TARGETS ${PNG_LIB_TARGETS}
EXPORT libpng
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(PNG_SHARED)
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(CYGWIN OR MINGW)
create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png)
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
if(NOT WIN32)
create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png)
install(FILES $<TARGET_LINKER_FILE_DIR:png>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
if(PNG_STATIC)
if(NOT WIN32 OR CYGWIN OR MINGW)
create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endif()
endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
install(FILES ${libpng_public_hdrs} DESTINATION include)
install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
endif()
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL)
if(NOT WIN32 OR CYGWIN OR MINGW)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config DESTINATION bin)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin)
endif()
endif()
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL)
install(TARGETS ${PNG_BIN_TARGETS}
RUNTIME DESTINATION bin)
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
# Install man pages
if(NOT PNG_MAN_DIR)
set(PNG_MAN_DIR "share/man")
endif()
install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
# Install pkg-config files
if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
DESTINATION bin)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
DESTINATION bin)
endif()
endif()
# Create an export file that CMake users can include() to import our targets.
if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL)
install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
endif()
# what's with libpng-manual.txt and all the extra files?
# UNINSTALL
# do we need this?
# DIST
# do we need this?
# to create msvc import lib for mingw compiled shared lib
# pexports libpng.dll > libpng.def
# lib /def:libpng.def /machine:x86

View File

@ -138,6 +138,9 @@ if(MSVC)
add_compile_options(/Zc:__cplusplus)
add_compile_options(/wd4244)
add_compile_options(/wd4267)
if(LAMMPS_EXCEPTIONS)
add_compile_options(/EHsc)
endif()
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
endif()

195
cmake/CMakeLists.zlib Normal file
View File

@ -0,0 +1,195 @@
cmake_minimum_required(VERSION 3.10)
# When using CMake 3.4 and later, don't export symbols from executables unless
# the CMAKE_ENABLE_EXPORTS variable is set.
if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()
if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
project(zlib C)
set(VERSION "1.2.11")
option(ASM686 "Enable building i686 assembly implementation" OFF)
option(AMD64 "Enable building amd64 assembly implementation" OFF)
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)
#
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
# We add these other definitions here because CheckTypeSize.cmake
# in CMake 2.4.x does not automatically do so and we want
# compatibility with CMake 2.4.x.
if(HAVE_SYS_TYPES_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
endif()
if(HAVE_STDINT_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
endif()
if(HAVE_STDDEF_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
endif()
check_type_size(off64_t OFF64_T)
check_type_size(off64_t OFF64_T)
if(HAVE_OFF64_T)
add_definitions(-D_LARGEFILE64_SOURCE=1)
endif()
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
if(NOT HAVE_FSEEKO)
add_definitions(-DNO_FSEEKO)
endif()
#
# Check for unistd.h
#
check_include_file(unistd.h Z_HAVE_UNISTD_H)
if(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
# If we're doing an out of source build and the user has a zconf.h
# in their source tree...
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
endif()
endif()
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
#============================================================================
# zlib
#============================================================================
set(ZLIB_PUBLIC_HDRS
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
zlib.h
)
set(ZLIB_PRIVATE_HDRS
crc32.h
deflate.h
gzguts.h
inffast.h
inffixed.h
inflate.h
inftrees.h
trees.h
zutil.h
)
set(ZLIB_SRCS
adler32.c
compress.c
crc32.c
deflate.c
gzclose.c
gzlib.c
gzread.c
gzwrite.c
inflate.c
infback.c
inftrees.c
inffast.c
trees.c
uncompr.c
zutil.c
)
if(NOT MINGW)
set(ZLIB_DLL_SRCS
win32/zlib1.rc # If present will override custom build rule below.
)
endif()
if(CMAKE_COMPILER_IS_GNUCC)
if(ASM686)
set(ZLIB_ASMS contrib/asm686/match.S)
elseif (AMD64)
set(ZLIB_ASMS contrib/amd64/amd64-match.S)
endif ()
if(ZLIB_ASMS)
add_definitions(-DASMV)
set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE)
endif()
endif()
if(MSVC)
if(ASM686)
ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS
contrib/masmx86/inffas32.asm
contrib/masmx86/match686.asm
)
elseif (AMD64)
ENABLE_LANGUAGE(ASM_MASM)
set(ZLIB_ASMS
contrib/masmx64/gvmat64.asm
contrib/masmx64/inffasx64.asm
)
endif()
if(ZLIB_ASMS)
add_definitions(-DASMV -DASMINF)
endif()
endif()
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
if(MINGW)
# This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER)
set(CMAKE_RC_COMPILER windres.exe)
endif()
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
COMMAND ${CMAKE_RC_COMPILER}
-D GCC_WINDRES
-I ${CMAKE_CURRENT_SOURCE_DIR}
-I ${CMAKE_CURRENT_BINARY_DIR}
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
if(UNIX)
# On unix-like platforms the library is almost always called libz
set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME z)
endif()

View File

@ -8,7 +8,7 @@
"installRoot": "${workspaceRoot}\\install\\${name}",
"cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows.cmake",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"ctestCommandArgs": "-V",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
@ -26,11 +26,6 @@
"value": "True",
"type": "BOOL"
},
{
"name": "PKG_PYTHON",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_TESTING",
"value": "True",
@ -46,7 +41,7 @@
"installRoot": "${workspaceRoot}\\install\\${name}",
"cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows.cmake",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"ctestCommandArgs": "-V",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
@ -64,11 +59,6 @@
"value": "True",
"type": "BOOL"
},
{
"name": "PKG_PYTHON",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_TESTING",
"value": "True",
@ -102,11 +92,6 @@
"value": "True",
"type": "BOOL"
},
{
"name": "PKG_PYTHON",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_TESTING",
"value": "True",
@ -122,7 +107,7 @@
"installRoot": "${workspaceRoot}\\install\\${name}",
"cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows.cmake -DCMAKE_C_COMPILER=clang-cl.exe -DCMAKE_CXX_COMPILER=clang-cl.exe",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"ctestCommandArgs": "-V",
"inheritEnvironments": [ "clang_cl_x64" ],
"variables": [
{
@ -140,11 +125,6 @@
"value": "True",
"type": "BOOL"
},
{
"name": "PKG_PYTHON",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_TESTING",
"value": "True",
@ -158,9 +138,16 @@
"configurationType": "Debug",
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${workspaceRoot}\\install\\${name}",
"buildCommandArgs": "",
"ctestCommandArgs": "-V",
"inheritEnvironments": [],
"cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows-intel-llvm.cmake -C ${workspaceRoot}\\cmake\\presets\\windows.cmake",
"variables": [
{
"name": "PKG_ELECTRODE",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "True",
@ -176,11 +163,6 @@
"value": "True",
"type": "BOOL"
},
{
"name": "PKG_PYTHON",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_TESTING",
"value": "True",
@ -190,11 +172,6 @@
"name": "FFT",
"value": "MKL",
"type": "STRING"
},
{
"name": "PKG_PLUGIN",
"value": "True",
"type": "BOOL"
}
]
},
@ -205,8 +182,15 @@
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${workspaceRoot}\\install\\${name}",
"cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows-intel-llvm.cmake -C ${workspaceRoot}\\cmake\\presets\\windows.cmake",
"buildCommandArgs": "",
"ctestCommandArgs": "-V",
"inheritEnvironments": [],
"variables": [
{
"name": "PKG_ELECTRODE",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "True",
@ -222,11 +206,6 @@
"value": "True",
"type": "BOOL"
},
{
"name": "PKG_PYTHON",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_TESTING",
"value": "True",
@ -236,11 +215,6 @@
"name": "FFT",
"value": "MKL",
"type": "STRING"
},
{
"name": "PKG_PLUGIN",
"value": "True",
"type": "BOOL"
}
]
},
@ -251,8 +225,15 @@
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${workspaceRoot}\\install\\${name}",
"cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows-intel-classic.cmake -C ${workspaceRoot}\\cmake\\presets\\windows.cmake",
"buildCommandArgs": "",
"ctestCommandArgs": "-V",
"inheritEnvironments": [],
"variables": [
{
"name": "PKG_ELECTRODE",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "True",
@ -268,11 +249,6 @@
"value": "True",
"type": "BOOL"
},
{
"name": "PKG_PYTHON",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_TESTING",
"value": "False",
@ -282,11 +258,6 @@
"name": "FFT",
"value": "MKL",
"type": "STRING"
},
{
"name": "PKG_PLUGIN",
"value": "True",
"type": "BOOL"
}
]
},
@ -297,8 +268,15 @@
"buildRoot": "${workspaceRoot}\\build\\${name}",
"installRoot": "${workspaceRoot}\\install\\${name}",
"cmakeCommandArgs": "-C ${workspaceRoot}\\cmake\\presets\\windows-intel-classic.cmake -C ${workspaceRoot}\\cmake\\presets\\windows.cmake",
"buildCommandArgs": "",
"ctestCommandArgs": "-V",
"inheritEnvironments": [],
"variables": [
{
"name": "PKG_ELECTRODE",
"value": "True",
"type": "BOOL"
},
{
"name": "BUILD_SHARED_LIBS",
"value": "True",
@ -314,11 +292,6 @@
"value": "True",
"type": "BOOL"
},
{
"name": "PKG_PYTHON",
"value": "True",
"type": "BOOL"
},
{
"name": "ENABLE_TESTING",
"value": "False",
@ -328,11 +301,6 @@
"name": "FFT",
"value": "MKL",
"type": "STRING"
},
{
"name": "PKG_PLUGIN",
"value": "True",
"type": "BOOL"
}
]
}

View File

@ -31,5 +31,7 @@ set(temp "${temp}const char *LAMMPS_NS::LAMMPS::git_descriptor() { return \"${te
set(temp "${temp}#endif\n\n")
message(STATUS "Generating lmpgitversion.h...")
file(WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${temp}" )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h")
string(REPLACE "\\ " " " LAMMPS_GIT_HEADER "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h")
file(WRITE "${LAMMPS_GIT_HEADER}.tmp" "${temp}" )
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_GIT_HEADER}.tmp" "${LAMMPS_GIT_HEADER}")

View File

@ -43,6 +43,7 @@ set(WIN_PACKAGES
PERI
PHONON
POEMS
PLUGIN
PTM
QEQ
QTB

View File

@ -13,6 +13,7 @@ VENV = $(BUILDDIR)/docenv
ANCHORCHECK = $(VENV)/bin/rst_anchor_check
SPHINXCONFIG = $(BUILDDIR)/utils/sphinx-config
MATHJAX = $(SPHINXCONFIG)/_static/mathjax
MATHJAXTAG = 3.2.1
PYTHON = $(word 3,$(shell type python3))
DOXYGEN = $(word 3,$(shell type doxygen))
@ -230,12 +231,13 @@ $(VENV):
$(PYTHON) -m venv $(VENV); \
. $(VENV)/bin/activate; \
pip $(PIP_OPTIONS) install --upgrade pip; \
pip $(PIP_OPTIONS) install --upgrade wheel; \
pip $(PIP_OPTIONS) install -r $(BUILDDIR)/utils/requirements.txt; \
deactivate;\
)
$(MATHJAX):
@git clone -b 3.2.0 -c advice.detachedHead=0 --depth 1 https://github.com/mathjax/MathJax.git $@
@git clone -b $(MATHJAXTAG) -c advice.detachedHead=0 --depth 1 https://github.com/mathjax/MathJax.git $@
$(ANCHORCHECK): $(VENV)
@( \

View File

@ -287,8 +287,8 @@ Output of JPG, PNG, and movie files
The :doc:`dump image <dump_image>` command has options to output JPEG or
PNG image files. Likewise the :doc:`dump movie <dump_image>` command
outputs movie files in MPEG format. Using these options requires the
following settings:
outputs movie files in a variety of movie formats. Using these options
requires the following settings:
.. tabs::
@ -328,11 +328,12 @@ following settings:
JPG_LIB = -ljpeg -lpng -lz # library names
As with CMake, you do not need to set ``JPG_INC`` or ``JPG_PATH``,
if make can find the graphics header and library files. You must
specify ``JPG_LIB`` with a list of graphics libraries to include
in the link. You must insure ffmpeg is in a directory where
LAMMPS can find it at runtime, that is a directory in your PATH
environment variable.
if make can find the graphics header and library files in their
default system locations. You must specify ``JPG_LIB`` with a
list of graphics libraries to include in the link. You must make
certain that the ffmpeg executable (or ffmpeg.exe on Windows) is
in a directory where LAMMPS can find it at runtime; that is
usually a directory list in your ``PATH`` environment variable.
Using ``ffmpeg`` to output movie files requires that your machine
supports the "popen" function in the standard runtime library.

View File

@ -239,7 +239,7 @@ is consistent with the 6 moments of inertia: ixx iyy izz ixy ixz iyz =
.. parsed-literal::
3 1 27
3 1 19
4
1 1 4 0 0 0
-0.7071 -0.7071 0

View File

@ -30,8 +30,8 @@ initial versions of LAMMPS is:
`S. Plimpton, Fast Parallel Algorithms for Short-Range Molecular Dynamics, J Comp Phys, 117, 1-19 (1995). <http://www.sandia.gov/~sjplimp/papers/jcompphys95.pdf>`_
DOI for the LAMMPS code
^^^^^^^^^^^^^^^^^^^^^^^
DOI for the LAMMPS source code
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LAMMPS developers use the `Zenodo service at CERN <https://zenodo.org/>`_
to create digital object identifies (DOI) for stable releases of the

View File

@ -475,8 +475,8 @@ that package **and** the KSPACE package. See the :doc:`Build package
<Build_package>` page for more info.
For MSM, a simulation must be 3d and one can use any combination of
periodic, non-periodic, or shrink-wrapped boundaries (specified using
the :doc:`boundary <boundary>` command).
periodic, non-periodic, but not shrink-wrapped boundaries (specified
using the :doc:`boundary <boundary>` command).
For Ewald and PPPM, a simulation must be 3d and periodic in all
dimensions. The only exception is if the slab option is set with

View File

@ -4,7 +4,7 @@ min_style cg command
====================
min_style hftn command
====================
======================
min_style sd command
====================

View File

@ -20,28 +20,37 @@ Examples
Description
"""""""""""
Using a pair style of none means pair forces and energies are not
computed.
Using a pair style of *none* means that any previous pair style setting
will be deleted and pairwise forces and energies are not computed.
With this choice, the force cutoff is 0.0, which means that only atoms
within the neighbor skin distance (see the :doc:`neighbor <neighbor>`
command) are communicated between processors. You must insure the
skin distance is large enough to acquire atoms needed for computing
bonds, angles, etc.
As a consequence there will be a pairwise force cutoff of 0.0, which has
implications for the default setting of the neighbor list and the
communication cutoff. Those are the sum of the largest pairwise cutoff
and the neighbor skin distance (see the documentation of the
:doc:`neighbor <neighbor>` command and the :doc:`comm_modify
<comm_modify>` command). When you have bonds, angles, dihedrals, or
impropers defined at the same time, you must set the communication
cutoff so that communication cutoff distance is large enough to acquire
and communicate sufficient ghost atoms from neighboring sub-domains as
needed for computing bonds, angles, etc.
A pair style of *none* will also prevent pairwise neighbor lists from
being built. However if the :doc:`neighbor <neighbor>` style is *bin*,
data structures for binning are still allocated. If the neighbor skin
distance is small, then these data structures can consume a large
amount of memory. So you should either set the neighbor style to
*nsq* or set the skin distance to a larger value.
A pair style of *none* will also not request a pairwise neighbor list.
However if the :doc:`neighbor <neighbor>` style is *bin*, data
structures for binning are still allocated. If the neighbor list cutoff
is small, then these data structures can consume a large amount of
memory. So you should either set the neighbor style to *nsq* or set the
skin distance to a larger value.
See the :doc:`pair_style zero <pair_zero>` for a way to trigger the
building of a neighbor lists, but compute no pairwise interactions.
See the :doc:`pair_style zero <pair_zero>` for a way to set a pairwise
cutoff and thus trigger the building of a neighbor lists and setting
a corresponding communication cutoff, but compute no pairwise interactions.
Restrictions
""""""""""""
none
You must not use a :doc:`pair_coeff <pair_coeff>` command with this pair
style. Since there is no interaction computed, you cannot set any
coefficients for it.
Related commands
""""""""""""""""

View File

@ -6,4 +6,3 @@ breathe
Pygments
six
pyyaml
wheel

View File

@ -1324,6 +1324,7 @@ hexatic
hexorder
Heyes
HfO
hftn
hgrid
hhmrr
Hibbs
@ -2804,6 +2805,7 @@ quatk
quatw
queryargs
Queteschiner
quickmin
qw
qx
qy
@ -3058,6 +3060,7 @@ screenshot
screenshots
Scripps
Scripta
sd
sdk
sdpd
SDPD

View File

@ -62,10 +62,10 @@ shutil.copy(args.lib,'lammps')
# create a virtual environment for building the wheel
shutil.rmtree('buildwheel',True)
try:
txt = subprocess.check_output([sys.executable, '-m', 'virtualenv', 'buildwheel', '-p', sys.executable], stderr=subprocess.STDOUT, shell=False)
txt = subprocess.check_output([sys.executable, '-m', 'venv', 'buildwheel'], stderr=subprocess.STDOUT, shell=False)
print(txt.decode('UTF-8'))
except subprocess.CalledProcessError as err:
sys.exit("Failed to create a virtualenv: {0}".format(err.output.decode('UTF-8')))
sys.exit("Failed to create a virtual environment: {0}".format(err.output.decode('UTF-8')))
# now run the commands to build the wheel. those must be in a separate script
# and run in subprocess, since this will use the virtual environment and

View File

@ -58,6 +58,9 @@ PPPMDielectric::PPPMDielectric(LAMMPS *_lmp) : PPPM(_lmp)
phi = nullptr;
potflag = 0;
// no warnings about non-neutral systems from qsum_qsq()
warn_nonneutral = 2;
avec = dynamic_cast<AtomVecDielectric *>( atom->style_match("dielectric"));
if (!avec) error->all(FLERR,"pppm/dielectric requires atom style dielectric");
}
@ -463,25 +466,3 @@ void PPPMDielectric::slabcorr()
efield[i][2] += ffact * eps[i]*(dipole_all - qsum*x[i][2]);
}
}
/* ----------------------------------------------------------------------
compute qsum,qsqsum,q2 and ignore error/warning if not charge neutral
called whenever charges are changed
------------------------------------------------------------------------- */
void PPPMDielectric::qsum_qsq()
{
const double * const q = atom->q;
const int nlocal = atom->nlocal;
double qsum_local(0.0), qsqsum_local(0.0);
for (int i = 0; i < nlocal; i++) {
qsum_local += q[i];
qsqsum_local += q[i]*q[i];
}
MPI_Allreduce(&qsum_local,&qsum,1,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(&qsqsum_local,&qsqsum,1,MPI_DOUBLE,MPI_SUM,world);
q2 = qsqsum * force->qqrd2e;
}

View File

@ -34,8 +34,6 @@ class PPPMDielectric : public PPPM {
double *phi;
int potflag; // 1/0 if per-atom electrostatic potential phi is needed
void qsum_qsq();
protected:
void slabcorr() override;

View File

@ -65,6 +65,9 @@ PPPMDispDielectric::PPPMDispDielectric(LAMMPS *_lmp) : PPPMDisp(_lmp)
mu_flag = 0;
// no warnings about non-neutral systems from qsum_qsq()
warn_nonneutral = 2;
efield = nullptr;
phi = nullptr;
potflag = 0;
@ -837,25 +840,3 @@ double PPPMDispDielectric::memory_usage()
bytes += nmax * sizeof(double);
return bytes;
}
/* ----------------------------------------------------------------------
compute qsum,qsqsum,q2 and give error/warning if not charge neutral
called initially, when particle count changes, when charges are changed
------------------------------------------------------------------------- */
void PPPMDispDielectric::qsum_qsq()
{
const double * const q = atom->q;
const int nlocal = atom->nlocal;
double qsum_local(0.0), qsqsum_local(0.0);
for (int i = 0; i < nlocal; i++) {
qsum_local += q[i];
qsqsum_local += q[i]*q[i];
}
MPI_Allreduce(&qsum_local,&qsum,1,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(&qsqsum_local,&qsqsum,1,MPI_DOUBLE,MPI_SUM,world);
q2 = qsqsum * force->qqrd2e;
}

View File

@ -30,8 +30,7 @@ class PPPMDispDielectric : public PPPMDisp {
~PPPMDispDielectric() override;
double memory_usage() override;
void compute(int, int) override;
void qsum_qsq();
void slabcorr(int);
void slabcorr(int) override;
double **efield;
double *phi;

View File

@ -95,6 +95,7 @@ PairBOP::PairBOP(LAMMPS *lmp) : Pair(lmp)
pairParameters = nullptr;
tripletParameters = nullptr;
bop_elements = nullptr;
bop_masses = nullptr;
bop_types = 0;
pairlist1 = nullptr;
@ -183,17 +184,13 @@ PairBOP::~PairBOP()
if (bop_elements)
for (int i = 0; i < bop_types; i++) delete[] bop_elements[i];
delete[] bop_elements;
delete[] bop_masses;
}
/* ---------------------------------------------------------------------- */
void PairBOP::compute(int eflag, int vflag)
{
double minbox = MIN(MIN(domain->xprd, domain->yprd), domain->zprd);
if (minbox-0.001 < 6.0*cutmax)
error->all(FLERR,"Pair style bop requires system dimension "
"of at least {:.4}",6.0*cutmax);
int i, ii, j, jj;
int nlisti, *ilist;
tagint i_tag,j_tag, itype, jtype;
@ -203,6 +200,7 @@ void PairBOP::compute(int eflag, int vflag)
int newton_pair = force->newton_pair;
int nlocal = atom->nlocal;
double **x = atom->x;
double **f = atom->f;
int *type = atom->type;
tagint *tag = atom->tag;
@ -226,7 +224,15 @@ void PairBOP::compute(int eflag, int vflag)
temp_ij = BOP_index[i] + jj;
j = ilist[neigh_index[temp_ij]];
j_tag = tag[j];
if (j_tag <= i_tag) continue;
if (i_tag > j_tag) {
if ((i_tag+j_tag) % 2 == 0) continue;
} else if (i_tag < j_tag) {
if ((i_tag+j_tag) % 2 == 1) continue;
} else {
if (x[j][2] < x[i][2]) continue;
if (x[j][2] == x[i][2] && x[j][1] < x[i][1]) continue;
if (x[j][2] == x[i][2] && x[j][1] == x[i][1] && x[j][0] < x[i][0]) continue;
}
jtype = map[type[j]];
int param_ij = elem2param[itype][jtype];
sigB_0 = SigmaBo(ii,jj);
@ -256,7 +262,15 @@ void PairBOP::compute(int eflag, int vflag)
temp_ij = BOP_index2[i] + jj;
j = ilist[neigh_index2[temp_ij]];
j_tag = tag[j];
if (j_tag <= i_tag) continue;
if (i_tag > j_tag) {
if ((i_tag+j_tag) % 2 == 0) continue;
} else if (i_tag < j_tag) {
if ((i_tag+j_tag) % 2 == 1) continue;
} else {
if (x[j][2] < x[i][2]) continue;
if (x[j][2] == x[i][2] && x[j][1] < x[i][1]) continue;
if (x[j][2] == x[i][2] && x[j][1] == x[i][1] && x[j][0] < x[i][0]) continue;
}
PairList2 & p2_ij = pairlist2[temp_ij];
dpr2 = -p2_ij.dRep / p2_ij.r;
ftmp1 = dpr2 * p2_ij.dis[0];
@ -349,16 +363,16 @@ void PairBOP::settings(int narg, char **arg)
void PairBOP::coeff(int narg, char **arg)
{
const int n = atom->ntypes;
delete [] map;
map = new int[n+1];
const int np1 = atom->ntypes+1;
delete[] map;
map = new int[np1];
memory->destroy(setflag);
memory->destroy(cutsq);
memory->destroy(cutghost);
memory->create(setflag,n+1,n+1,"BOP:setflag");
memory->create(cutsq,n+1,n+1,"BOP:cutsq");
memory->create(cutghost,n+1,n+1,"BOP:cutghost");
bytes = (n+1)*(n+1) * (sizeof (int) + 2.0*sizeof (double));
memory->create(setflag,np1,np1,"BOP:setflag");
memory->create(cutsq,np1,np1,"BOP:cutsq");
memory->create(cutghost,np1,np1,"BOP:cutghost");
bytes = np1*np1*(sizeof (int) + 2.0*sizeof (double));
map_element2type(narg-3, arg+3);
@ -370,22 +384,23 @@ void PairBOP::coeff(int narg, char **arg)
// and check for missing elements
if (comm->me == 0) {
for (int i = 1; i <= n; i++) {
for (int i = 1; i < np1; i++) {
int j;
if (map[i] >= 0) {
for (j = 0; j < bop_types; j++) {
if (strcmp(elements[map[i]],bop_elements[j]) == 0) {
if (strcmp(elements[map[i]], bop_elements[j]) == 0) {
map[i] = j;
atom->set_mass(FLERR, i, bop_masses[j]);
break;
}
}
if (j == bop_types)
error->one(FLERR,"Element {} not found in bop potential file {}",
elements[map[i]],arg[2]);
elements[map[i]], arg[2]);
}
}
}
MPI_Bcast(map,atom->ntypes+1,MPI_INT,0,world);
MPI_Bcast(map,np1,MPI_INT,0,world);
}
/* ----------------------------------------------------------------------
@ -1849,9 +1864,10 @@ void PairBOP::read_table(char *filename)
PotentialFileReader *reader = nullptr;
if (bop_elements) {
for (int i = 0; i < bop_types; i++) delete [] bop_elements[i];
delete [] bop_elements;
for (int i = 0; i < bop_types; i++) delete[] bop_elements[i];
delete[] bop_elements;
}
delete[] bop_masses;
if (comm->me == 0) {
try {
@ -1862,10 +1878,11 @@ void PairBOP::read_table(char *filename)
"elements",bop_types));
bop_elements = new char*[bop_types];
bop_masses = new double[bop_types];
for (int i=0; i < bop_types; ++i) {
ValueTokenizer values = reader->next_values(3);
values.next_int(); // element number in PTE (ignored)
values.next_double(); // element mass (ignored)
values.next_int(); // element number (ignored)
bop_masses[i] = values.next_double(); // element mass
bop_elements[i] = utils::strdup(values.next_string());
}
} catch (TokenizerException &e) {
@ -1878,8 +1895,12 @@ void PairBOP::read_table(char *filename)
allocate();
memory->create(rcut,npairs,"BOP:rcut");
// copy element labels to all MPI ranks for use with write_tables()
if (comm->me != 0) bop_elements = new char*[bop_types];
// copy element labels and masses to all MPI ranks for use with
// write_tables() and to set the per-type masses
if (comm->me != 0) {
bop_elements = new char*[bop_types];
bop_masses = new double[bop_types];
}
for (int i = 0; i < bop_types; ++i) {
int n=0;
if (comm->me == 0) n = strlen(bop_elements[i])+1;
@ -1887,6 +1908,7 @@ void PairBOP::read_table(char *filename)
if (comm->me != 0) bop_elements[i] = new char[n];
MPI_Bcast(bop_elements[i],n,MPI_CHAR,0,world);
}
MPI_Bcast(bop_masses, bop_types, MPI_DOUBLE, 0, world);
if (comm->me == 0) {
try {
@ -2015,7 +2037,7 @@ void PairBOP::read_table(char *filename)
}
}
}
delete [] singletable;
delete[] singletable;
singletable = new double[nr];
for (int i = 0; i < npairs; i++) {
@ -2043,7 +2065,7 @@ void PairBOP::read_table(char *filename)
p.betaP = new TabularFunction();
(p.betaP)->set_values(nr, 0.0, rcut[i], singletable);
}
delete [] singletable;
delete[] singletable;
singletable = new double[nBOt];
for (int i = 0; i < npairs; i++) {
@ -2053,7 +2075,7 @@ void PairBOP::read_table(char *filename)
p.bo = new TabularFunction();
(p.bo)->set_values(nBOt, 0.0, 1.0, singletable);
}
delete [] singletable;
delete[] singletable;
nbuf = 0;
for (int i = 0; i < bop_types; i++) {
@ -2107,7 +2129,7 @@ void PairBOP::read_table(char *filename)
(p.cphi)->set_values(nr, 0.0, rcut[i], singletable);
}
}
delete [] singletable;
delete[] singletable;
}
memory->destroy(rcut);

View File

@ -109,6 +109,7 @@ class PairBOP : public Pair {
int npairs; // number of element pairs
int ntriples; // number of all triples
char **bop_elements; // names of elements in potential file
double *bop_masses; // masses of elements in potential file
double bytes;
int otfly; // = 1 faster, more memory, = 0 slower, less memory

View File

@ -402,26 +402,20 @@ void AngleTable::read_table(Table *tb, char *file, char *keyword)
// read a,e,f table values from file
int cerror = 0;
reader.skip_line();
for (int i = 0; i < tb->ninput; i++) {
line = reader.next_line(4);
line = reader.next_line();
try {
ValueTokenizer values(line);
values.next_int();
tb->afile[i] = values.next_double();
tb->efile[i] = values.next_double();
tb->ffile[i] = values.next_double();
} catch (TokenizerException &) {
++cerror;
} catch (TokenizerException &e) {
error->one(FLERR, "Error parsing angle table '{}' line {} of {}. {}\nLine was: {}", keyword,
i + 1, tb->ninput, e.what(), line);
}
}
// warn if data was read incompletely, e.g. columns were missing
if (cerror)
error->warning(FLERR, "{} of {} lines in table incomplete or could not be parsed", cerror,
tb->ninput);
}
/* ----------------------------------------------------------------------

View File

@ -325,20 +325,20 @@ void BondTable::read_table(Table *tb, char *file, char *keyword)
// read r,e,f table values from file
int cerror = 0;
int r0idx = -1;
reader.skip_line();
for (int i = 0; i < tb->ninput; i++) {
line = reader.next_line(4);
line = reader.next_line();
try {
ValueTokenizer values(line);
values.next_int();
tb->rfile[i] = values.next_double();
tb->efile[i] = values.next_double();
tb->ffile[i] = values.next_double();
} catch (TokenizerException &) {
++cerror;
} catch (TokenizerException &e) {
error->one(FLERR, "Error parsing bond table '{}' line {} of {}. {}\nLine was: {}", keyword,
i + 1, tb->ninput, e.what(), line);
}
if (tb->efile[i] < emin) {
@ -373,21 +373,11 @@ void BondTable::read_table(Table *tb, char *file, char *keyword)
if (f > fleft && f > fright) ferror++;
}
if (ferror) {
if (ferror)
error->warning(FLERR,
"{} of {} force values in table are inconsistent with -dE/dr.\n"
"WARNING: Should only be flagged at inflection points",
ferror, tb->ninput);
}
// warn if data was read incompletely, e.g. columns were missing
if (cerror) {
error->warning(FLERR,
"{} of {} lines in table were incomplete or could not be"
" parsed completely",
cerror, tb->ninput);
}
}
/* ----------------------------------------------------------------------

View File

@ -1020,23 +1020,24 @@ void DihedralTable::read_table(Table *tb, char *file, char *keyword)
// read a,e,f table values from file
for (int i = 0; i < tb->ninput; i++) {
line = reader.next_line();
try {
ValueTokenizer values(line);
if (tb->f_unspecified) {
ValueTokenizer values = reader.next_values(3);
values.next_int();
tb->phifile[i] = values.next_double();
tb->efile[i] = values.next_double();
} else {
ValueTokenizer values = reader.next_values(4);
values.next_int();
tb->phifile[i] = values.next_double();
tb->efile[i] = values.next_double();
tb->ffile[i] = values.next_double();
}
} catch (TokenizerException &e) {
error->one(FLERR, e.what());
error->one(FLERR, "Error parsing dihedral table '{}' line {} of {}. {}\nLine was: {}",
keyword, i + 1, tb->ninput, e.what(), line);
}
}
} //for (int i = 0; (i < tb->ninput) && fp; i++) {
}
/* ----------------------------------------------------------------------

View File

@ -52,6 +52,11 @@ namespace ReaxFF {
sin_jkl = sin(p_jkl->theta);
cos_jkl = cos(p_jkl->theta);
if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) sin_ijk = MIN_SINE;
else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) sin_ijk = -MIN_SINE;
if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) sin_jkl = MIN_SINE;
else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) sin_jkl = -MIN_SINE;
/* omega */
unnorm_cos_omega = -rvec_Dot(dvec_ij, dvec_jk) * rvec_Dot(dvec_jk, dvec_kl) +
SQR(r_jk) * rvec_Dot(dvec_ij, dvec_kl);
@ -71,22 +76,16 @@ namespace ReaxFF {
hnhd = r_ij * r_kl * cos_ijk * sin_jkl;
hnhe = r_ij * r_kl * sin_ijk * cos_jkl;
poem = 2.0 * r_ij * r_kl * sin_ijk * sin_jkl;
if (poem < 1e-20) poem = 1e-20;
tel = SQR(r_ij) + SQR(r_jk) + SQR(r_kl) - SQR(r_li) -
2.0 * (r_ij * r_jk * cos_ijk - r_ij * r_kl * cos_ijk * cos_jkl +
r_jk * r_kl * cos_jkl);
poem = 2.0 * r_ij * r_kl * sin_ijk * sin_jkl;
arg = tel / poem;
if (arg > 1.0) arg = 1.0;
if (arg < -1.0) arg = -1.0;
if (sin_ijk >= 0 && sin_ijk <= MIN_SINE) sin_ijk = MIN_SINE;
else if (sin_ijk <= 0 && sin_ijk >= -MIN_SINE) sin_ijk = -MIN_SINE;
if (sin_jkl >= 0 && sin_jkl <= MIN_SINE) sin_jkl = MIN_SINE;
else if (sin_jkl <= 0 && sin_jkl >= -MIN_SINE) sin_jkl = -MIN_SINE;
// dcos_omega_di
rvec_ScaledSum(dcos_omega_di, (htra-arg*hnra)/r_ij, dvec_ij, -1., dvec_li);
rvec_ScaledAdd(dcos_omega_di,-(hthd-arg*hnhd)/sin_ijk, p_ijk->dcos_dk);

View File

@ -253,9 +253,10 @@ void FixEHEX::rescale()
escale = 1. + (F * dt) / Kr;
// safety check for kinetic energy
// safety checks for kinetic energy rescaling
if (escale < 0.0) error->all(FLERR, "Fix ehex kinetic energy went negative");
if (escale < 0.0) error->all(FLERR, "Fix ehex kinetic energy went negative: {}", escale);
if (escale > 100.0) error->all(FLERR, "Fix ehex kinetic energy rescaling too large: {}", escale);
scale = sqrt(escale);
vsub[0] = (scale - 1.0) * vcm[0];
@ -569,7 +570,11 @@ void FixEHEX::com_properties(double *vr, double *sfr, double *sfvr, double *K, d
*mr = buf[4];
if (*mr < 1.e-14) { error->all(FLERR, "Fix ehex error mass of region is close to zero"); }
if (nlocal > 0)
mi = (rmass) ? rmass[0] : mass[type[0]];
else
mi = 1.0;
if ((*mr / mi) < 1.e-14) error->all(FLERR, "Fix ehex error mass of region is close to zero");
// total kinetic energy of region

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -19,8 +18,8 @@
#include "angle_deprecated.h"
#include "angle_hybrid.h"
#include "comm.h"
#include "force.h"
#include "error.h"
#include "force.h"
using namespace LAMMPS_NS;
@ -33,17 +32,14 @@ void AngleDeprecated::settings(int, char **)
// hybrid substyles are created in AngleHybrid::settings(), so when this is
// called, our style was just added at the end of the list of substyles
if (utils::strmatch(my_style,"^hybrid")) {
if (utils::strmatch(my_style, "^hybrid")) {
auto hybrid = dynamic_cast<AngleHybrid *>(force->angle);
my_style = hybrid->keywords[hybrid->nstyles];
}
if (my_style == "DEPRECATED") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nAngle style 'DEPRECATED' is a dummy style\n\n");
if (lmp->comm->me == 0) utils::logmesg(lmp, "\nAngle style 'DEPRECATED' is a dummy style\n\n");
return;
}
error->all(FLERR,"This angle style is no longer available");
error->all(FLERR, "This angle style is no longer available");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -29,5 +28,5 @@ Body::Body(LAMMPS *lmp, int /*narg*/, char **arg) : Pointers(lmp)
Body::~Body()
{
delete [] style;
delete[] style;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -34,17 +33,14 @@ void BondDeprecated::settings(int, char **)
// hybrid substyles are created in BondHybrid::settings(), so when this is
// called, our style was just added at the end of the list of substyles
if (utils::strmatch(my_style,"^hybrid")) {
if (utils::strmatch(my_style, "^hybrid")) {
auto hybrid = dynamic_cast<BondHybrid *>(force->bond);
my_style = hybrid->keywords[hybrid->nstyles];
}
if (my_style == "DEPRECATED") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nBond style 'DEPRECATED' is a dummy style\n\n");
if (lmp->comm->me == 0) utils::logmesg(lmp, "\nBond style 'DEPRECATED' is a dummy style\n\n");
return;
}
error->all(FLERR,"This bond style is no longer available");
error->all(FLERR, "This bond style is no longer available");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -25,10 +24,9 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeAngle::ComputeAngle(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg),
emine(nullptr)
Compute(lmp, narg, arg), emine(nullptr)
{
if (narg != 3) error->all(FLERR,"Illegal compute angle command");
if (narg != 3) error->all(FLERR, "Illegal compute angle command");
vector_flag = 1;
extvector = 1;
@ -37,9 +35,8 @@ ComputeAngle::ComputeAngle(LAMMPS *lmp, int narg, char **arg) :
// check if bond style hybrid exists
angle = dynamic_cast<AngleHybrid *>( force->angle_match("hybrid"));
if (!angle)
error->all(FLERR,"Angle style for compute angle command is not hybrid");
angle = dynamic_cast<AngleHybrid *>(force->angle_match("hybrid"));
if (!angle) error->all(FLERR, "Angle style for compute angle command is not hybrid");
size_vector = nsub = angle->nstyles;
emine = new double[nsub];
@ -50,8 +47,8 @@ ComputeAngle::ComputeAngle(LAMMPS *lmp, int narg, char **arg) :
ComputeAngle::~ComputeAngle()
{
delete [] emine;
delete [] vector;
delete[] emine;
delete[] vector;
}
/* ---------------------------------------------------------------------- */
@ -60,11 +57,10 @@ void ComputeAngle::init()
{
// recheck angle style in case it has been changed
angle = dynamic_cast<AngleHybrid *>( force->angle_match("hybrid"));
if (!angle)
error->all(FLERR,"Angle style for compute angle command is not hybrid");
angle = dynamic_cast<AngleHybrid *>(force->angle_match("hybrid"));
if (!angle) error->all(FLERR, "Angle style for compute angle command is not hybrid");
if (angle->nstyles != nsub)
error->all(FLERR,"Angle style for compute angle command has changed");
error->all(FLERR, "Angle style for compute angle command has changed");
}
/* ---------------------------------------------------------------------- */
@ -73,10 +69,9 @@ void ComputeAngle::compute_vector()
{
invoked_vector = update->ntimestep;
if (update->eflag_global != invoked_vector)
error->all(FLERR,"Energy was not tallied on needed timestep");
error->all(FLERR, "Energy was not tallied on needed timestep");
for (int i = 0; i < nsub; i++)
emine[i] = angle->styles[i]->energy;
for (int i = 0; i < nsub; i++) emine[i] = angle->styles[i]->energy;
MPI_Allreduce(emine,vector,nsub,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(emine, vector, nsub, MPI_DOUBLE, MPI_SUM, world);
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -25,10 +24,9 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeBond::ComputeBond(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg),
emine(nullptr)
Compute(lmp, narg, arg), emine(nullptr)
{
if (narg != 3) error->all(FLERR,"Illegal compute bond command");
if (narg != 3) error->all(FLERR, "Illegal compute bond command");
vector_flag = 1;
extvector = 1;
@ -37,9 +35,8 @@ ComputeBond::ComputeBond(LAMMPS *lmp, int narg, char **arg) :
// check if bond style hybrid exists
bond = dynamic_cast<BondHybrid *>( force->bond_match("hybrid"));
if (!bond)
error->all(FLERR,"Bond style for compute bond command is not hybrid");
bond = dynamic_cast<BondHybrid *>(force->bond_match("hybrid"));
if (!bond) error->all(FLERR, "Bond style for compute bond command is not hybrid");
size_vector = nsub = bond->nstyles;
emine = new double[nsub];
@ -50,8 +47,8 @@ ComputeBond::ComputeBond(LAMMPS *lmp, int narg, char **arg) :
ComputeBond::~ComputeBond()
{
delete [] emine;
delete [] vector;
delete[] emine;
delete[] vector;
}
/* ---------------------------------------------------------------------- */
@ -60,11 +57,9 @@ void ComputeBond::init()
{
// recheck bond style in case it has been changed
bond = dynamic_cast<BondHybrid *>( force->bond_match("hybrid"));
if (!bond)
error->all(FLERR,"Bond style for compute bond command is not hybrid");
if (bond->nstyles != nsub)
error->all(FLERR,"Bond style for compute bond command has changed");
bond = dynamic_cast<BondHybrid *>(force->bond_match("hybrid"));
if (!bond) error->all(FLERR, "Bond style for compute bond command is not hybrid");
if (bond->nstyles != nsub) error->all(FLERR, "Bond style for compute bond command has changed");
}
/* ---------------------------------------------------------------------- */
@ -73,10 +68,9 @@ void ComputeBond::compute_vector()
{
invoked_vector = update->ntimestep;
if (update->eflag_global != invoked_vector)
error->all(FLERR,"Energy was not tallied on needed timestep");
error->all(FLERR, "Energy was not tallied on needed timestep");
for (int i = 0; i < nsub; i++)
emine[i] = bond->styles[i]->energy;
for (int i = 0; i < nsub; i++) emine[i] = bond->styles[i]->energy;
MPI_Allreduce(emine,vector,nsub,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(emine, vector, nsub, MPI_DOUBLE, MPI_SUM, world);
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -13,18 +12,17 @@
------------------------------------------------------------------------- */
#include "compute_com.h"
#include "update.h"
#include "group.h"
#include "error.h"
#include "group.h"
#include "update.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeCOM::ComputeCOM(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
ComputeCOM::ComputeCOM(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
{
if (narg != 3) error->all(FLERR,"Illegal compute com command");
if (narg != 3) error->all(FLERR, "Illegal compute com command");
vector_flag = 1;
size_vector = 3;
@ -37,7 +35,7 @@ ComputeCOM::ComputeCOM(LAMMPS *lmp, int narg, char **arg) :
ComputeCOM::~ComputeCOM()
{
delete [] vector;
delete[] vector;
}
/* ---------------------------------------------------------------------- */
@ -54,5 +52,5 @@ void ComputeCOM::compute_vector()
invoked_vector = update->ntimestep;
if (group->dynamic[igroup]) masstotal = group->mass(igroup);
group->xcm(igroup,masstotal,vector);
group->xcm(igroup, masstotal, vector);
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -21,15 +20,14 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeDeprecated::ComputeDeprecated(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
ComputeDeprecated::ComputeDeprecated(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
{
std::string my_style = style;
if (my_style == "DEPRECATED") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nCompute style 'DEPRECATED' is a dummy style\n\n");
utils::logmesg(lmp, "\nCompute style 'DEPRECATED' is a dummy style\n\n");
return;
}
error->all(FLERR,"This compute style is no longer available");
error->all(FLERR, "This compute style is no longer available");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -25,10 +24,9 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeDihedral::ComputeDihedral(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg),
emine(nullptr)
Compute(lmp, narg, arg), emine(nullptr)
{
if (narg != 3) error->all(FLERR,"Illegal compute dihedral command");
if (narg != 3) error->all(FLERR, "Illegal compute dihedral command");
vector_flag = 1;
extvector = 1;
@ -37,9 +35,8 @@ ComputeDihedral::ComputeDihedral(LAMMPS *lmp, int narg, char **arg) :
// check if dihedral style hybrid exists
dihedral = dynamic_cast<DihedralHybrid *>( force->dihedral_match("hybrid"));
if (!dihedral)
error->all(FLERR, "Dihedral style for compute dihedral command is not hybrid");
dihedral = dynamic_cast<DihedralHybrid *>(force->dihedral_match("hybrid"));
if (!dihedral) error->all(FLERR, "Dihedral style for compute dihedral command is not hybrid");
size_vector = nsub = dihedral->nstyles;
emine = new double[nsub];
@ -50,8 +47,8 @@ ComputeDihedral::ComputeDihedral(LAMMPS *lmp, int narg, char **arg) :
ComputeDihedral::~ComputeDihedral()
{
delete [] emine;
delete [] vector;
delete[] emine;
delete[] vector;
}
/* ---------------------------------------------------------------------- */
@ -60,11 +57,10 @@ void ComputeDihedral::init()
{
// recheck dihedral style in case it has been changed
dihedral = dynamic_cast<DihedralHybrid *>( force->dihedral_match("hybrid"));
if (!dihedral)
error->all(FLERR, "Dihedral style for compute dihedral command is not hybrid");
dihedral = dynamic_cast<DihedralHybrid *>(force->dihedral_match("hybrid"));
if (!dihedral) error->all(FLERR, "Dihedral style for compute dihedral command is not hybrid");
if (dihedral->nstyles != nsub)
error->all(FLERR,"Dihedral style for compute dihedral command has changed");
error->all(FLERR, "Dihedral style for compute dihedral command has changed");
}
/* ---------------------------------------------------------------------- */
@ -73,10 +69,9 @@ void ComputeDihedral::compute_vector()
{
invoked_vector = update->ntimestep;
if (update->eflag_global != invoked_vector)
error->all(FLERR,"Energy was not tallied on needed timestep");
error->all(FLERR, "Energy was not tallied on needed timestep");
for (int i = 0; i < nsub; i++)
emine[i] = dihedral->styles[i]->energy;
for (int i = 0; i < nsub; i++) emine[i] = dihedral->styles[i]->energy;
MPI_Allreduce(emine,vector,nsub,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(emine, vector, nsub, MPI_DOUBLE, MPI_SUM, world);
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -28,15 +27,14 @@ using namespace LAMMPS_NS;
ComputeERotateSphere::ComputeERotateSphere(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
{
if (narg != 3) error->all(FLERR,"Illegal compute erotate/sphere command");
if (narg != 3) error->all(FLERR, "Illegal compute erotate/sphere command");
scalar_flag = 1;
extscalar = 1;
// error check
if (!atom->sphere_flag)
error->all(FLERR,"Compute erotate/sphere requires atom style sphere");
if (!atom->sphere_flag) error->all(FLERR, "Compute erotate/sphere requires atom style sphere");
}
/* ---------------------------------------------------------------------- */
@ -64,10 +62,11 @@ double ComputeERotateSphere::compute_scalar()
double erotate = 0.0;
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit)
erotate += (omega[i][0]*omega[i][0] + omega[i][1]*omega[i][1] +
omega[i][2]*omega[i][2]) * radius[i]*radius[i]*rmass[i];
erotate +=
(omega[i][0] * omega[i][0] + omega[i][1] * omega[i][1] + omega[i][2] * omega[i][2]) *
radius[i] * radius[i] * rmass[i];
MPI_Allreduce(&erotate,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(&erotate, &scalar, 1, MPI_DOUBLE, MPI_SUM, world);
scalar *= pfactor;
return scalar;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -14,21 +13,20 @@
#include "compute_improper.h"
#include "update.h"
#include "error.h"
#include "force.h"
#include "improper.h"
#include "improper_hybrid.h"
#include "error.h"
#include "update.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeImproper::ComputeImproper(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg),
emine(nullptr)
Compute(lmp, narg, arg), emine(nullptr)
{
if (narg != 3) error->all(FLERR,"Illegal compute improper command");
if (narg != 3) error->all(FLERR, "Illegal compute improper command");
vector_flag = 1;
extvector = 1;
@ -37,9 +35,8 @@ ComputeImproper::ComputeImproper(LAMMPS *lmp, int narg, char **arg) :
// check if improper style hybrid exists
improper = dynamic_cast<ImproperHybrid *>( force->improper_match("hybrid"));
if (!improper)
error->all(FLERR, "Improper style for compute improper command is not hybrid");
improper = dynamic_cast<ImproperHybrid *>(force->improper_match("hybrid"));
if (!improper) error->all(FLERR, "Improper style for compute improper command is not hybrid");
size_vector = nsub = improper->nstyles;
emine = new double[nsub];
@ -50,8 +47,8 @@ ComputeImproper::ComputeImproper(LAMMPS *lmp, int narg, char **arg) :
ComputeImproper::~ComputeImproper()
{
delete [] emine;
delete [] vector;
delete[] emine;
delete[] vector;
}
/* ---------------------------------------------------------------------- */
@ -60,11 +57,10 @@ void ComputeImproper::init()
{
// recheck improper style in case it has been changed
improper = dynamic_cast<ImproperHybrid *>( force->improper_match("hybrid"));
if (!improper)
error->all(FLERR, "Improper style for compute improper command is not hybrid");
improper = dynamic_cast<ImproperHybrid *>(force->improper_match("hybrid"));
if (!improper) error->all(FLERR, "Improper style for compute improper command is not hybrid");
if (improper->nstyles != nsub)
error->all(FLERR,"Improper style for compute improper command has changed");
error->all(FLERR, "Improper style for compute improper command has changed");
}
/* ---------------------------------------------------------------------- */
@ -73,10 +69,9 @@ void ComputeImproper::compute_vector()
{
invoked_vector = update->ntimestep;
if (update->eflag_global != invoked_vector)
error->all(FLERR,"Energy was not tallied on needed timestep");
error->all(FLERR, "Energy was not tallied on needed timestep");
for (int i = 0; i < nsub; i++)
emine[i] = improper->styles[i]->energy;
for (int i = 0; i < nsub; i++) emine[i] = improper->styles[i]->energy;
MPI_Allreduce(emine,vector,nsub,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(emine, vector, nsub, MPI_DOUBLE, MPI_SUM, world);
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -15,18 +14,17 @@
#include "compute_ke.h"
#include "atom.h"
#include "update.h"
#include "force.h"
#include "error.h"
#include "force.h"
#include "update.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
ComputeKE::ComputeKE(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg)
ComputeKE::ComputeKE(LAMMPS *lmp, int narg, char **arg) : Compute(lmp, narg, arg)
{
if (narg != 3) error->all(FLERR,"Illegal compute ke command");
if (narg != 3) error->all(FLERR, "Illegal compute ke command");
scalar_flag = 1;
extscalar = 1;
@ -57,15 +55,14 @@ double ComputeKE::compute_scalar()
if (rmass) {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit)
ke += rmass[i] * (v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]);
ke += rmass[i] * (v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]);
} else {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit)
ke += mass[type[i]] *
(v[i][0]*v[i][0] + v[i][1]*v[i][1] + v[i][2]*v[i][2]);
ke += mass[type[i]] * (v[i][0] * v[i][0] + v[i][1] * v[i][1] + v[i][2] * v[i][2]);
}
MPI_Allreduce(&ke,&scalar,1,MPI_DOUBLE,MPI_SUM,world);
MPI_Allreduce(&ke, &scalar, 1, MPI_DOUBLE, MPI_SUM, world);
scalar *= pfactor;
return scalar;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -33,15 +32,14 @@
using namespace LAMMPS_NS;
enum{NOBIAS,BIAS};
enum { NOBIAS, BIAS };
/* ---------------------------------------------------------------------- */
ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg),
id_temp(nullptr), stress(nullptr)
Compute(lmp, narg, arg), id_temp(nullptr), stress(nullptr)
{
if (narg < 4) error->all(FLERR,"Illegal compute stress/atom command");
if (narg < 4) error->all(FLERR, "Illegal compute stress/atom command");
peratom_flag = 1;
size_peratom_cols = 6;
@ -52,17 +50,15 @@ ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) :
// store temperature ID used by stress computation
// insure it is valid for temperature computation
if (strcmp(arg[3],"NULL") == 0) id_temp = nullptr;
if (strcmp(arg[3], "NULL") == 0)
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 (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");
error->all(FLERR, "Compute stress/atom temperature ID does not compute temperature");
}
// process optional args
@ -81,19 +77,28 @@ ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) :
fixflag = 0;
int iarg = 4;
while (iarg < narg) {
if (strcmp(arg[iarg],"ke") == 0) keflag = 1;
else if (strcmp(arg[iarg],"pair") == 0) pairflag = 1;
else if (strcmp(arg[iarg],"bond") == 0) bondflag = 1;
else if (strcmp(arg[iarg],"angle") == 0) angleflag = 1;
else if (strcmp(arg[iarg],"dihedral") == 0) dihedralflag = 1;
else if (strcmp(arg[iarg],"improper") == 0) improperflag = 1;
else if (strcmp(arg[iarg],"kspace") == 0) kspaceflag = 1;
else if (strcmp(arg[iarg],"fix") == 0) fixflag = 1;
else if (strcmp(arg[iarg],"virial") == 0) {
if (strcmp(arg[iarg], "ke") == 0)
keflag = 1;
else if (strcmp(arg[iarg], "pair") == 0)
pairflag = 1;
else if (strcmp(arg[iarg], "bond") == 0)
bondflag = 1;
else if (strcmp(arg[iarg], "angle") == 0)
angleflag = 1;
else if (strcmp(arg[iarg], "dihedral") == 0)
dihedralflag = 1;
else if (strcmp(arg[iarg], "improper") == 0)
improperflag = 1;
else if (strcmp(arg[iarg], "kspace") == 0)
kspaceflag = 1;
else if (strcmp(arg[iarg], "fix") == 0)
fixflag = 1;
else if (strcmp(arg[iarg], "virial") == 0) {
pairflag = 1;
bondflag = angleflag = dihedralflag = improperflag = 1;
kspaceflag = fixflag = 1;
} else error->all(FLERR,"Illegal compute stress/atom command");
} else
error->all(FLERR, "Illegal compute stress/atom command");
iarg++;
}
}
@ -105,7 +110,7 @@ ComputeStressAtom::ComputeStressAtom(LAMMPS *lmp, int narg, char **arg) :
ComputeStressAtom::~ComputeStressAtom()
{
delete [] id_temp;
delete[] id_temp;
memory->destroy(stress);
}
@ -118,24 +123,26 @@ void ComputeStressAtom::init()
if (id_temp) {
int icompute = modify->find_compute(id_temp);
if (icompute < 0)
error->all(FLERR,"Could not find compute stress/atom temperature ID");
if (icompute < 0) error->all(FLERR, "Could not find compute stress/atom temperature ID");
temperature = modify->compute[icompute];
if (temperature->tempbias) biasflag = BIAS;
else biasflag = NOBIAS;
} else biasflag = NOBIAS;
if (temperature->tempbias)
biasflag = BIAS;
else
biasflag = NOBIAS;
} else
biasflag = NOBIAS;
}
/* ---------------------------------------------------------------------- */
void ComputeStressAtom::compute_peratom()
{
int i,j;
int i, j;
double onemass;
invoked_peratom = update->ntimestep;
if (update->vflag_atom != invoked_peratom)
error->all(FLERR,"Per-atom virial was not tallied on needed timestep");
error->all(FLERR, "Per-atom virial was not tallied on needed timestep");
// grow local stress array if necessary
// needs to be atom->nmax in length
@ -143,7 +150,7 @@ void ComputeStressAtom::compute_peratom()
if (atom->nmax > nmax) {
memory->destroy(stress);
nmax = atom->nmax;
memory->create(stress,nmax,6,"stress/atom:stress");
memory->create(stress, nmax, 6, "stress/atom:stress");
array_atom = stress;
}
@ -166,51 +173,44 @@ void ComputeStressAtom::compute_peratom()
// clear local stress array
for (i = 0; i < ntotal; i++)
for (j = 0; j < 6; j++)
stress[i][j] = 0.0;
for (j = 0; j < 6; j++) stress[i][j] = 0.0;
// add in per-atom contributions from each force
if (pairflag && force->pair && force->pair->compute_flag) {
double **vatom = force->pair->vatom;
for (i = 0; i < npair; i++)
for (j = 0; j < 6; j++)
stress[i][j] += vatom[i][j];
for (j = 0; j < 6; j++) stress[i][j] += vatom[i][j];
}
if (bondflag && force->bond) {
double **vatom = force->bond->vatom;
for (i = 0; i < nbond; i++)
for (j = 0; j < 6; j++)
stress[i][j] += vatom[i][j];
for (j = 0; j < 6; j++) stress[i][j] += vatom[i][j];
}
if (angleflag && force->angle) {
double **vatom = force->angle->vatom;
for (i = 0; i < nbond; i++)
for (j = 0; j < 6; j++)
stress[i][j] += vatom[i][j];
for (j = 0; j < 6; j++) stress[i][j] += vatom[i][j];
}
if (dihedralflag && force->dihedral) {
double **vatom = force->dihedral->vatom;
for (i = 0; i < nbond; i++)
for (j = 0; j < 6; j++)
stress[i][j] += vatom[i][j];
for (j = 0; j < 6; j++) stress[i][j] += vatom[i][j];
}
if (improperflag && force->improper) {
double **vatom = force->improper->vatom;
for (i = 0; i < nbond; i++)
for (j = 0; j < 6; j++)
stress[i][j] += vatom[i][j];
for (j = 0; j < 6; j++) stress[i][j] += vatom[i][j];
}
if (kspaceflag && force->kspace && force->kspace->compute_flag) {
double **vatom = force->kspace->vatom;
for (i = 0; i < nkspace; i++)
for (j = 0; j < 6; j++)
stress[i][j] += vatom[i][j];
for (j = 0; j < 6; j++) stress[i][j] += vatom[i][j];
}
// add in per-atom contributions from relevant fixes
@ -225,15 +225,13 @@ void ComputeStressAtom::compute_peratom()
double **vatom = ifix->vatom;
if (vatom)
for (i = 0; i < nlocal; i++)
for (j = 0; j < 6; j++)
stress[i][j] += vatom[i][j];
for (j = 0; j < 6; j++) stress[i][j] += vatom[i][j];
}
}
// communicate ghost virials between neighbor procs
if (force->newton || (force->kspace && force->kspace->tip4pflag))
comm->reverse_comm(this);
if (force->newton || (force->kspace && force->kspace->tip4pflag)) comm->reverse_comm(this);
// zero virial of atoms not in group
// only do this after comm since ghost contributions must be included
@ -266,24 +264,24 @@ void ComputeStressAtom::compute_peratom()
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
onemass = mvv2e * rmass[i];
stress[i][0] += onemass*v[i][0]*v[i][0];
stress[i][1] += onemass*v[i][1]*v[i][1];
stress[i][2] += onemass*v[i][2]*v[i][2];
stress[i][3] += onemass*v[i][0]*v[i][1];
stress[i][4] += onemass*v[i][0]*v[i][2];
stress[i][5] += onemass*v[i][1]*v[i][2];
stress[i][0] += onemass * v[i][0] * v[i][0];
stress[i][1] += onemass * v[i][1] * v[i][1];
stress[i][2] += onemass * v[i][2] * v[i][2];
stress[i][3] += onemass * v[i][0] * v[i][1];
stress[i][4] += onemass * v[i][0] * v[i][2];
stress[i][5] += onemass * v[i][1] * v[i][2];
}
} else {
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
onemass = mvv2e * mass[type[i]];
stress[i][0] += onemass*v[i][0]*v[i][0];
stress[i][1] += onemass*v[i][1]*v[i][1];
stress[i][2] += onemass*v[i][2]*v[i][2];
stress[i][3] += onemass*v[i][0]*v[i][1];
stress[i][4] += onemass*v[i][0]*v[i][2];
stress[i][5] += onemass*v[i][1]*v[i][2];
stress[i][0] += onemass * v[i][0] * v[i][0];
stress[i][1] += onemass * v[i][1] * v[i][1];
stress[i][2] += onemass * v[i][2] * v[i][2];
stress[i][3] += onemass * v[i][0] * v[i][1];
stress[i][4] += onemass * v[i][0] * v[i][2];
stress[i][5] += onemass * v[i][1] * v[i][2];
}
}
@ -292,35 +290,34 @@ void ComputeStressAtom::compute_peratom()
// invoke temperature if it hasn't been already
// this insures bias factor is pre-computed
if (keflag && temperature->invoked_scalar != update->ntimestep)
temperature->compute_scalar();
if (keflag && temperature->invoked_scalar != update->ntimestep) temperature->compute_scalar();
if (rmass) {
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
temperature->remove_bias(i,v[i]);
temperature->remove_bias(i, v[i]);
onemass = mvv2e * rmass[i];
stress[i][0] += onemass*v[i][0]*v[i][0];
stress[i][1] += onemass*v[i][1]*v[i][1];
stress[i][2] += onemass*v[i][2]*v[i][2];
stress[i][3] += onemass*v[i][0]*v[i][1];
stress[i][4] += onemass*v[i][0]*v[i][2];
stress[i][5] += onemass*v[i][1]*v[i][2];
temperature->restore_bias(i,v[i]);
stress[i][0] += onemass * v[i][0] * v[i][0];
stress[i][1] += onemass * v[i][1] * v[i][1];
stress[i][2] += onemass * v[i][2] * v[i][2];
stress[i][3] += onemass * v[i][0] * v[i][1];
stress[i][4] += onemass * v[i][0] * v[i][2];
stress[i][5] += onemass * v[i][1] * v[i][2];
temperature->restore_bias(i, v[i]);
}
} else {
for (i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
temperature->remove_bias(i,v[i]);
temperature->remove_bias(i, v[i]);
onemass = mvv2e * mass[type[i]];
stress[i][0] += onemass*v[i][0]*v[i][0];
stress[i][1] += onemass*v[i][1]*v[i][1];
stress[i][2] += onemass*v[i][2]*v[i][2];
stress[i][3] += onemass*v[i][0]*v[i][1];
stress[i][4] += onemass*v[i][0]*v[i][2];
stress[i][5] += onemass*v[i][1]*v[i][2];
temperature->restore_bias(i,v[i]);
stress[i][0] += onemass * v[i][0] * v[i][0];
stress[i][1] += onemass * v[i][1] * v[i][1];
stress[i][2] += onemass * v[i][2] * v[i][2];
stress[i][3] += onemass * v[i][0] * v[i][1];
stress[i][4] += onemass * v[i][0] * v[i][2];
stress[i][5] += onemass * v[i][1] * v[i][2];
temperature->restore_bias(i, v[i]);
}
}
}
@ -344,7 +341,7 @@ void ComputeStressAtom::compute_peratom()
int ComputeStressAtom::pack_reverse_comm(int n, int first, double *buf)
{
int i,m,last;
int i, m, last;
m = 0;
last = first + n;
@ -363,7 +360,7 @@ int ComputeStressAtom::pack_reverse_comm(int n, int first, double *buf)
void ComputeStressAtom::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++) {
@ -383,6 +380,6 @@ void ComputeStressAtom::unpack_reverse_comm(int n, int *list, double *buf)
double ComputeStressAtom::memory_usage()
{
double bytes = (double)nmax*6 * sizeof(double);
double bytes = (double) nmax * 6 * sizeof(double);
return bytes;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -23,7 +22,6 @@
#include "error.h"
#include "force.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
@ -36,15 +34,15 @@ void DihedralDeprecated::settings(int, char **)
// so when this is called, our style was just added at the end
// of the list of substyles
if (utils::strmatch(my_style,"^hybrid")) {
if (utils::strmatch(my_style, "^hybrid")) {
auto hybrid = dynamic_cast<DihedralHybrid *>(force->dihedral);
my_style = hybrid->keywords[hybrid->nstyles];
}
if (my_style == "DEPRECATED") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nDihedral style 'DEPRECATED' is a dummy style\n\n");
utils::logmesg(lmp, "\nDihedral style 'DEPRECATED' is a dummy style\n\n");
return;
}
error->all(FLERR,"This dihedral style is no longer available");
error->all(FLERR, "This dihedral style is no longer available");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -21,15 +20,13 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
DumpDeprecated::DumpDeprecated(LAMMPS *lmp, int narg, char **arg) :
Dump(lmp, narg, arg)
DumpDeprecated::DumpDeprecated(LAMMPS *lmp, int narg, char **arg) : Dump(lmp, narg, arg)
{
std::string my_style = style;
if (my_style == "DEPRECATED") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nDump style 'DEPRECATED' is a dummy style\n\n");
if (lmp->comm->me == 0) utils::logmesg(lmp, "\nDump style 'DEPRECATED' is a dummy style\n\n");
return;
}
error->all(FLERR,"This dump style is no longer available");
error->all(FLERR, "This dump style is no longer available");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -17,23 +16,21 @@
#include "comm.h"
#include "error.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
FixDeprecated::FixDeprecated(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)
FixDeprecated::FixDeprecated(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
{
std::string my_style = style;
if (my_style == "DEPRECATED") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nFix style 'DEPRECATED' is a dummy style\n\n");
if (lmp->comm->me == 0) utils::logmesg(lmp, "\nFix style 'DEPRECATED' is a dummy style\n\n");
return;
} else if (utils::strmatch(my_style,"^ave/spatial")) {
} else if (utils::strmatch(my_style, "^ave/spatial")) {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nFix styles 'ave/spatial' and 'ave/spatial/sphere'"
utils::logmesg(lmp,
"\nFix styles 'ave/spatial' and 'ave/spatial/sphere'"
" have been replaced\nby the more general fix ave/chunk "
"and compute chunk/atom commands.\nAll ave/spatial and "
"ave/spatial/sphere functionality is available in these"
@ -44,14 +41,16 @@ FixDeprecated::FixDeprecated(LAMMPS *lmp, int narg, char **arg) :
"compute chunk/atom:\n dim, origin, delta, region, "
"bound, discard, units\n\n");
} else if (my_style == "lb/pc") {
utils::logmesg(lmp,"\nFix style 'lb/pc' has been removed from the LATBOLTZ"
utils::logmesg(lmp,
"\nFix style 'lb/pc' has been removed from the LATBOLTZ"
" package; 'fix nve' can be used in its place.\n\n");
} else if (my_style == "lb/rigid/pc/sphere") {
utils::logmesg(lmp,"\nFix style 'lb/rigid/pc/sphere' has been removed from"
utils::logmesg(lmp,
"\nFix style 'lb/rigid/pc/sphere' has been removed from"
" the LATBOLTZ package; 'fix rigid' can be used in its place.\n\n");
} else if (my_style == "client/md") {
if (lmp->comm->me == 0)
utils::logmesg(lmp, "\nThe MESSAGE package has been replaced by the MDI package.\n\n");
}
error->all(FLERR,"This fix style is no longer available");
error->all(FLERR, "This fix style is no longer available");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -13,16 +12,16 @@
------------------------------------------------------------------------- */
#include "fix_dummy.h"
#include <cstring>
#include "error.h"
#include <cstring>
using namespace LAMMPS_NS;
using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixDummy::FixDummy(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)
FixDummy::FixDummy(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
{
// process optional args
// customize here and in setmask() by adding a new keyword from fix.h
@ -39,14 +38,22 @@ FixDummy::FixDummy(LAMMPS *lmp, int narg, char **arg) :
int iarg = 3;
while (iarg < narg) {
if (strcmp(arg[iarg],"initial_integrate") == 0) initial_integrate_flag = 1;
else if (strcmp(arg[iarg],"final_integrate") == 0) final_integrate_flag = 1;
else if (strcmp(arg[iarg],"pre_exchange") == 0) pre_exchange_flag = 1;
else if (strcmp(arg[iarg],"pre_neighbor") == 0) pre_neighbor_flag = 1;
else if (strcmp(arg[iarg],"pre_force") == 0) pre_force_flag = 1;
else if (strcmp(arg[iarg],"post_force") == 0) post_force_flag = 1;
else if (strcmp(arg[iarg],"end_of_step") == 0) end_of_step_flag = 1;
else error->all(FLERR,"Illegal fix DUMMY command");
if (strcmp(arg[iarg], "initial_integrate") == 0)
initial_integrate_flag = 1;
else if (strcmp(arg[iarg], "final_integrate") == 0)
final_integrate_flag = 1;
else if (strcmp(arg[iarg], "pre_exchange") == 0)
pre_exchange_flag = 1;
else if (strcmp(arg[iarg], "pre_neighbor") == 0)
pre_neighbor_flag = 1;
else if (strcmp(arg[iarg], "pre_force") == 0)
pre_force_flag = 1;
else if (strcmp(arg[iarg], "post_force") == 0)
post_force_flag = 1;
else if (strcmp(arg[iarg], "end_of_step") == 0)
end_of_step_flag = 1;
else
error->all(FLERR, "Illegal fix DUMMY command");
iarg++;
}
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -22,13 +21,10 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixNPH::FixNPH(LAMMPS *lmp, int narg, char **arg) :
FixNH(lmp, narg, arg)
FixNPH::FixNPH(LAMMPS *lmp, int narg, char **arg) : FixNH(lmp, narg, arg)
{
if (tstat_flag)
error->all(FLERR,"Temperature control can not be used with fix nph");
if (!pstat_flag)
error->all(FLERR,"Pressure control must be used with fix nph");
if (tstat_flag) error->all(FLERR, "Temperature control can not be used with fix nph");
if (!pstat_flag) error->all(FLERR, "Pressure control must be used with fix nph");
// create a new compute temp style
// id = fix-ID + temp
@ -36,7 +32,7 @@ FixNPH::FixNPH(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} all temp",id_temp));
modify->add_compute(fmt::format("{} all temp", id_temp));
tcomputeflag = 1;
// create a new compute pressure style
@ -44,6 +40,6 @@ FixNPH::FixNPH(LAMMPS *lmp, int narg, char **arg) :
// pass id_temp as 4th arg to pressure constructor
id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
modify->add_compute(fmt::format("{} all pressure {}", id_press, id_temp));
pcomputeflag = 1;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -22,13 +21,10 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixNPHSphere::FixNPHSphere(LAMMPS *lmp, int narg, char **arg) :
FixNHSphere(lmp, narg, arg)
FixNPHSphere::FixNPHSphere(LAMMPS *lmp, int narg, char **arg) : FixNHSphere(lmp, narg, arg)
{
if (tstat_flag)
error->all(FLERR,"Temperature control can not be used with fix nph/sphere");
if (!pstat_flag)
error->all(FLERR,"Pressure control must be used with fix nph/sphere");
if (tstat_flag) error->all(FLERR, "Temperature control can not be used with fix nph/sphere");
if (!pstat_flag) error->all(FLERR, "Pressure control must be used with fix nph/sphere");
// create a new compute temp style
// id = fix-ID + temp
@ -36,7 +32,7 @@ FixNPHSphere::FixNPHSphere(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} all temp/sphere",id_temp));
modify->add_compute(fmt::format("{} all temp/sphere", id_temp));
tcomputeflag = 1;
// create a new compute pressure style
@ -44,6 +40,6 @@ FixNPHSphere::FixNPHSphere(LAMMPS *lmp, int narg, char **arg) :
// pass id_temp as 4th arg to pressure constructor
id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
modify->add_compute(fmt::format("{} all pressure {}", id_press, id_temp));
pcomputeflag = 1;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -22,13 +21,10 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) :
FixNH(lmp, narg, arg)
FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) : FixNH(lmp, narg, arg)
{
if (!tstat_flag)
error->all(FLERR,"Temperature control must be used with fix npt");
if (!pstat_flag)
error->all(FLERR,"Pressure control must be used with fix npt");
if (!tstat_flag) error->all(FLERR, "Temperature control must be used with fix npt");
if (!pstat_flag) error->all(FLERR, "Pressure control must be used with fix npt");
// create a new compute temp style
// id = fix-ID + temp
@ -36,7 +32,7 @@ FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} all temp",id_temp));
modify->add_compute(fmt::format("{} all temp", id_temp));
tcomputeflag = 1;
// create a new compute pressure style
@ -44,6 +40,6 @@ FixNPT::FixNPT(LAMMPS *lmp, int narg, char **arg) :
// pass id_temp as 4th arg to pressure constructor
id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
modify->add_compute(fmt::format("{} all pressure {}", id_press, id_temp));
pcomputeflag = 1;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -22,13 +21,10 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixNPTSphere::FixNPTSphere(LAMMPS *lmp, int narg, char **arg) :
FixNHSphere(lmp, narg, arg)
FixNPTSphere::FixNPTSphere(LAMMPS *lmp, int narg, char **arg) : FixNHSphere(lmp, narg, arg)
{
if (!tstat_flag)
error->all(FLERR,"Temperature control must be used with fix npt/sphere");
if (!pstat_flag)
error->all(FLERR,"Pressure control must be used with fix npt/sphere");
if (!tstat_flag) error->all(FLERR, "Temperature control must be used with fix npt/sphere");
if (!pstat_flag) error->all(FLERR, "Pressure control must be used with fix npt/sphere");
// create a new compute temp style
// id = fix-ID + temp
@ -36,7 +32,7 @@ FixNPTSphere::FixNPTSphere(LAMMPS *lmp, int narg, char **arg) :
// and thus its KE/temperature contribution should use group all
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} all temp/sphere",id_temp));
modify->add_compute(fmt::format("{} all temp/sphere", id_temp));
tcomputeflag = 1;
// create a new compute pressure style
@ -44,6 +40,6 @@ FixNPTSphere::FixNPTSphere(LAMMPS *lmp, int narg, char **arg) :
// pass id_temp as 4th arg to pressure constructor
id_press = utils::strdup(std::string(id) + "_press");
modify->add_compute(fmt::format("{} all pressure {}",id_press, id_temp));
modify->add_compute(fmt::format("{} all pressure {}", id_press, id_temp));
pcomputeflag = 1;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -24,10 +23,9 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixNVENoforce::FixNVENoforce(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg)
FixNVENoforce::FixNVENoforce(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
{
if (narg != 3) error->all(FLERR,"Illegal fix nve/noforce command");
if (narg != 3) error->all(FLERR, "Illegal fix nve/noforce command");
time_integrate = 1;
}
@ -48,8 +46,8 @@ void FixNVENoforce::init()
{
dtv = update->dt;
if (utils::strmatch(update->integrate_style,"^respa"))
step_respa = (dynamic_cast<Respa *>( update->integrate))->step;
if (utils::strmatch(update->integrate_style, "^respa"))
step_respa = (dynamic_cast<Respa *>(update->integrate))->step;
}
/* ---------------------------------------------------------------------- */

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -23,18 +22,15 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixNVT::FixNVT(LAMMPS *lmp, int narg, char **arg) :
FixNH(lmp, narg, arg)
FixNVT::FixNVT(LAMMPS *lmp, int narg, char **arg) : FixNH(lmp, narg, arg)
{
if (!tstat_flag)
error->all(FLERR,"Temperature control must be used with fix nvt");
if (pstat_flag)
error->all(FLERR,"Pressure control can not be used with fix nvt");
if (!tstat_flag) error->all(FLERR, "Temperature control must be used with fix nvt");
if (pstat_flag) error->all(FLERR, "Pressure control can not be used with fix nvt");
// create a new compute temp style
// id = fix-ID + temp
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} {} temp",id_temp,group->names[igroup]));
modify->add_compute(fmt::format("{} {} temp", id_temp, group->names[igroup]));
tcomputeflag = 1;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -23,19 +22,15 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixNVTSphere::FixNVTSphere(LAMMPS *lmp, int narg, char **arg) :
FixNHSphere(lmp, narg, arg)
FixNVTSphere::FixNVTSphere(LAMMPS *lmp, int narg, char **arg) : FixNHSphere(lmp, narg, arg)
{
if (!tstat_flag)
error->all(FLERR,"Temperature control must be used with fix nvt/sphere");
if (pstat_flag)
error->all(FLERR,"Pressure control can not be used with fix nvt/sphere");
if (!tstat_flag) error->all(FLERR, "Temperature control must be used with fix nvt/sphere");
if (pstat_flag) error->all(FLERR, "Pressure control can not be used with fix nvt/sphere");
// create a new compute temp style
// id = fix-ID + temp
id_temp = utils::strdup(std::string(id) + "_temp");
modify->add_compute(fmt::format("{} {} temp/sphere",
id_temp,group->names[igroup]));
modify->add_compute(fmt::format("{} {} temp/sphere", id_temp, group->names[igroup]));
tcomputeflag = 1;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -21,8 +20,7 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixWallHarmonic::FixWallHarmonic(LAMMPS *lmp, int narg, char **arg) :
FixWall(lmp, narg, arg)
FixWallHarmonic::FixWallHarmonic(LAMMPS *lmp, int narg, char **arg) : FixWall(lmp, narg, arg)
{
dynamic_group_allow = 1;
}
@ -36,7 +34,7 @@ FixWallHarmonic::FixWallHarmonic(LAMMPS *lmp, int narg, char **arg) :
void FixWallHarmonic::wall_particle(int m, int which, double coord)
{
double delta,dr,fwall;
double delta, dr, fwall;
double vn;
double **x = atom->x;
@ -52,25 +50,29 @@ void FixWallHarmonic::wall_particle(int m, int which, double coord)
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
if (side < 0) delta = x[i][dim] - coord;
else delta = coord - x[i][dim];
if (side < 0)
delta = x[i][dim] - coord;
else
delta = coord - x[i][dim];
if (delta >= cutoff[m]) continue;
if (delta <= 0.0) {
onflag = 1;
continue;
}
dr = cutoff[m]-delta;
fwall = side * 2.0*epsilon[m]*dr;
dr = cutoff[m] - delta;
fwall = side * 2.0 * epsilon[m] * dr;
f[i][dim] -= fwall;
ewall[0] += epsilon[m]*dr*dr;
ewall[m+1] += fwall;
ewall[0] += epsilon[m] * dr * dr;
ewall[m + 1] += fwall;
if (evflag) {
if (side < 0) vn = -fwall*delta;
else vn = fwall*delta;
v_tally(dim,i,vn);
if (side < 0)
vn = -fwall * delta;
else
vn = fwall * delta;
v_tally(dim, i, vn);
}
}
if (onflag) error->one(FLERR,"Particle on or inside fix wall surface");
if (onflag) error->one(FLERR, "Particle on or inside fix wall surface");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -13,17 +12,17 @@
------------------------------------------------------------------------- */
#include "fix_wall_morse.h"
#include <cmath>
#include "atom.h"
#include "error.h"
#include <cmath>
using namespace LAMMPS_NS;
using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixWallMorse::FixWallMorse(LAMMPS *lmp, int narg, char **arg) :
FixWall(lmp, narg, arg)
FixWallMorse::FixWallMorse(LAMMPS *lmp, int narg, char **arg) : FixWall(lmp, narg, arg)
{
dynamic_group_allow = 1;
}
@ -34,7 +33,7 @@ void FixWallMorse::precompute(int m)
{
coeff1[m] = 2.0 * epsilon[m] * alpha[m];
const double alpha_dr = -alpha[m] * (cutoff[m] - sigma[m]);
offset[m] = epsilon[m] * (exp(2.0*alpha_dr) - 2.0*exp(alpha_dr));
offset[m] = epsilon[m] * (exp(2.0 * alpha_dr) - 2.0 * exp(alpha_dr));
}
/* ----------------------------------------------------------------------
@ -46,7 +45,7 @@ void FixWallMorse::precompute(int m)
void FixWallMorse::wall_particle(int m, int which, double coord)
{
double delta,fwall;
double delta, fwall;
double vn;
double **x = atom->x;
@ -62,8 +61,10 @@ void FixWallMorse::wall_particle(int m, int which, double coord)
for (int i = 0; i < nlocal; i++) {
if (mask[i] & groupbit) {
if (side < 0) delta = x[i][dim] - coord;
else delta = coord - x[i][dim];
if (side < 0)
delta = x[i][dim] - coord;
else
delta = coord - x[i][dim];
if (delta >= cutoff[m]) continue;
if (delta <= 0.0) {
onflag = 1;
@ -71,18 +72,20 @@ void FixWallMorse::wall_particle(int m, int which, double coord)
}
double dr = delta - sigma[m];
double dexp = exp(-alpha[m] * dr);
fwall = side * coeff1[m] * (dexp*dexp - dexp) / delta;
ewall[0] += epsilon[m] * (dexp*dexp - 2.0*dexp) - offset[m];
fwall = side * coeff1[m] * (dexp * dexp - dexp) / delta;
ewall[0] += epsilon[m] * (dexp * dexp - 2.0 * dexp) - offset[m];
f[i][dim] -= fwall;
ewall[m+1] += fwall;
ewall[m + 1] += fwall;
if (evflag) {
if (side < 0) vn = -fwall*delta;
else vn = fwall*delta;
if (side < 0)
vn = -fwall * delta;
else
vn = fwall * delta;
v_tally(dim, i, vn);
}
}
}
if (onflag) error->one(FLERR,"Particle on or inside fix wall surface");
if (onflag) error->one(FLERR, "Particle on or inside fix wall surface");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -19,8 +18,8 @@
#include "kspace_deprecated.h"
#include "comm.h"
#include "force.h"
#include "error.h"
#include "force.h"
using namespace LAMMPS_NS;
@ -31,11 +30,8 @@ void KSpaceDeprecated::settings(int, char **)
std::string my_style = force->kspace_style;
if (my_style == "DEPRECATED") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nKSpace style 'DEPRECATED' is a dummy style\n\n");
if (lmp->comm->me == 0) utils::logmesg(lmp, "\nKSpace style 'DEPRECATED' is a dummy style\n\n");
return;
}
error->all(FLERR,"This kspace style is no longer available");
error->all(FLERR, "This kspace style is no longer available");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -32,28 +31,26 @@ Minimize::Minimize(LAMMPS *lmp) : Command(lmp) {}
void Minimize::command(int narg, char **arg)
{
if (narg != 4) error->all(FLERR,"Illegal minimize command");
if (narg != 4) error->all(FLERR, "Illegal minimize command");
if (domain->box_exist == 0)
error->all(FLERR,"Minimize command before simulation box is defined");
error->all(FLERR, "Minimize command before simulation box is defined");
// ignore minimize command, if walltime limit was already reached
if (timer->is_timeout()) return;
update->etol = utils::numeric(FLERR,arg[0],false,lmp);
update->ftol = utils::numeric(FLERR,arg[1],false,lmp);
update->nsteps = utils::inumeric(FLERR,arg[2],false,lmp);
update->max_eval = utils::inumeric(FLERR,arg[3],false,lmp);
update->etol = utils::numeric(FLERR, arg[0], false, lmp);
update->ftol = utils::numeric(FLERR, arg[1], false, lmp);
update->nsteps = utils::inumeric(FLERR, arg[2], false, lmp);
update->max_eval = utils::inumeric(FLERR, arg[3], false, lmp);
if (update->etol < 0.0 || update->ftol < 0.0)
error->all(FLERR,"Illegal minimize command");
if (update->etol < 0.0 || update->ftol < 0.0) error->all(FLERR, "Illegal minimize command");
if (lmp->citeme) lmp->citeme->flush();
update->whichflag = 2;
update->beginstep = update->firststep = update->ntimestep;
update->endstep = update->laststep = update->firststep + update->nsteps;
if (update->laststep < 0)
error->all(FLERR,"Too many iterations");
if (update->laststep < 0) error->all(FLERR, "Too many iterations");
lmp->init();
timer->init_timeout();

View File

@ -1742,15 +1742,15 @@ void Neighbor::requests_new2old()
/* ----------------------------------------------------------------------
find and return request made by classptr
if not found or classptr = nullptr, return nullptr
TODO: should have optional argument "id" to match ID if multiple requests
id is optional and defaults to 0, which is the request id value unless set explicitly
------------------------------------------------------------------------- */
NeighRequest *Neighbor::find_request(void *classptr) const
NeighRequest *Neighbor::find_request(void *classptr, const int id) const
{
if (classptr == nullptr) return nullptr;
for (int i = 0; i < nrequest; i++)
if (requests[i]->requestor == classptr) return requests[i];
if ((requests[i]->requestor == classptr) && (requests[i]->id == id)) return requests[i];
return nullptr;
}
@ -1770,15 +1770,15 @@ const std::vector<NeighRequest *> Neighbor::get_pair_requests() const
/* ----------------------------------------------------------------------
find and return list requested by classptr
if not found or classptr = nullptr, return nullptr
TODO: should have optional argument "id" to match ID if multiple requests
id is optional and defaults to 0, which is the request id value unless set explicitly
------------------------------------------------------------------------- */
NeighList *Neighbor::find_list(void *classptr) const
NeighList *Neighbor::find_list(void *classptr, const int id) const
{
if (classptr == nullptr) return nullptr;
for (int i = 0; i < nlist; i++)
if (lists[i]->requestor == classptr) return lists[i];
if ((lists[i]->requestor == classptr) && (lists[i]->id == id)) return lists[i];
return nullptr;
}

View File

@ -153,8 +153,12 @@ class Neighbor : protected Pointers {
void exclusion_group_group_delete(int, int); // rm a group-group exclusion
int exclude_setting(); // return exclude value to accelerator pkg
NeighList *find_list(void *) const; // find a neighbor list based on requestor
NeighRequest *find_request(void *) const; // find a neighbor request based on requestor
// find a neighbor list based on requestor
NeighList *find_list(void *, const int id = 0) const;
// find a neighbor request based on requestor
NeighRequest *find_request(void *, const int id = 0) const;
const std::vector<NeighRequest *> get_pair_requests() const;
int any_full(); // Check if any old requests had full neighbor lists
void build_collection(int); // build peratom collection array starting at the given index

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -32,8 +31,8 @@ NPairFullBinAtomonly::NPairFullBinAtomonly(LAMMPS *lmp) : NPair(lmp) {}
void NPairFullBinAtomonly::build(NeighList *list)
{
int i,j,k,n,itype,jtype,ibin;
double xtmp,ytmp,ztmp,delx,dely,delz,rsq;
int i, j, k, n, itype, jtype, ibin;
double xtmp, ytmp, ztmp, delx, dely, delz, rsq;
int *neighptr;
double **x = atom->x;
@ -66,16 +65,16 @@ void NPairFullBinAtomonly::build(NeighList *list)
ibin = atom2bin[i];
for (k = 0; k < nstencil; k++) {
for (j = binhead[ibin+stencil[k]]; j >= 0; j = bins[j]) {
for (j = binhead[ibin + stencil[k]]; j >= 0; j = bins[j]) {
if (i == j) continue;
jtype = type[j];
if (exclude && exclusion(i,j,itype,jtype,mask,molecule)) continue;
if (exclude && exclusion(i, j, itype, jtype, mask, molecule)) continue;
delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
rsq = delx * delx + dely * dely + delz * delz;
if (rsq <= cutneighsq[itype][jtype]) neighptr[n++] = j;
}
@ -85,8 +84,7 @@ void NPairFullBinAtomonly::build(NeighList *list)
firstneigh[i] = neighptr;
numneigh[i] = n;
ipage->vgot(n);
if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one");
}
list->inum = inum;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -35,8 +34,8 @@ NPairHalffullNewtoff::NPairHalffullNewtoff(LAMMPS *lmp) : NPair(lmp) {}
void NPairHalffullNewtoff::build(NeighList *list)
{
int i,j,ii,jj,n,jnum,joriginal;
int *neighptr,*jlist;
int i, j, ii, jj, n, jnum, joriginal;
int *neighptr, *jlist;
int *ilist = list->ilist;
int *numneigh = list->numneigh;
@ -74,8 +73,7 @@ void NPairHalffullNewtoff::build(NeighList *list)
firstneigh[i] = neighptr;
numneigh[i] = n;
ipage->vgot(n);
if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one");
}
list->inum = inum;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -32,8 +31,8 @@ NPairSkipSize::NPairSkipSize(LAMMPS *lmp) : NPair(lmp) {}
void NPairSkipSize::build(NeighList *list)
{
int i,j,ii,jj,n,itype,jnum,joriginal;
int *neighptr,*jlist;
int i, j, ii, jj, n, itype, jnum, joriginal;
int *neighptr, *jlist;
int *type = atom->type;
int *ilist = list->ilist;
@ -80,8 +79,7 @@ void NPairSkipSize::build(NeighList *list)
firstneigh[i] = neighptr;
numneigh[i] = n;
ipage->vgot(n);
if (ipage->status())
error->one(FLERR,"Neighbor list overflow, boost neigh_modify one");
if (ipage->status()) error->one(FLERR, "Neighbor list overflow, boost neigh_modify one");
}
list->inum = inum;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -26,12 +25,11 @@ NStencilFullBin2d::NStencilFullBin2d(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilFullBin2d::create()
{
int i,j;
int i, j;
nstencil = 0;
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (bin_distance(i,j,0) < cutneighmaxsq)
stencil[nstencil++] = j*mbinx + i;
if (bin_distance(i, j, 0) < cutneighmaxsq) stencil[nstencil++] = j * mbinx + i;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -26,13 +25,13 @@ NStencilFullBin3d::NStencilFullBin3d(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilFullBin3d::create()
{
int i,j,k;
int i, j, k;
nstencil = 0;
for (k = -sz; k <= sz; k++)
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (bin_distance(i,j,k) < cutneighmaxsq)
stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i;
if (bin_distance(i, j, k) < cutneighmaxsq)
stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -29,16 +28,16 @@ NStencilFullGhostBin2d::NStencilFullGhostBin2d(LAMMPS *lmp) : NStencil(lmp)
void NStencilFullGhostBin2d::create()
{
int i,j;
int i, j;
nstencil = 0;
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (bin_distance(i,j,0) < cutneighmaxsq) {
if (bin_distance(i, j, 0) < cutneighmaxsq) {
stencilxyz[nstencil][0] = i;
stencilxyz[nstencil][1] = j;
stencilxyz[nstencil][2] = 0;
stencil[nstencil++] = j*mbinx + i;
stencil[nstencil++] = j * mbinx + i;
}
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -29,17 +28,17 @@ NStencilFullGhostBin3d::NStencilFullGhostBin3d(LAMMPS *lmp) : NStencil(lmp)
void NStencilFullGhostBin3d::create()
{
int i,j,k;
int i, j, k;
nstencil = 0;
for (k = -sz; k <= sz; k++)
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (bin_distance(i,j,k) < cutneighmaxsq) {
if (bin_distance(i, j, k) < cutneighmaxsq) {
stencilxyz[nstencil][0] = i;
stencilxyz[nstencil][1] = j;
stencilxyz[nstencil][2] = k;
stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i;
stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i;
}
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -50,7 +49,6 @@ void NStencilFullMulti2d::create()
int n = ncollections;
double cutsq;
for (icollection = 0; icollection < n; icollection++) {
for (jcollection = 0; jcollection < n; jcollection++) {
if (flag_skip_multi[icollection][jcollection]) {
@ -72,8 +70,8 @@ void NStencilFullMulti2d::create()
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (bin_distance_multi(i,j,0,bin_collection) < cutsq)
stencil_multi[icollection][jcollection][ns++] = j*mbinx + i;
if (bin_distance_multi(i, j, 0, bin_collection) < cutsq)
stencil_multi[icollection][jcollection][ns++] = j * mbinx + i;
nstencil_multi[icollection][jcollection] = ns;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -27,8 +26,8 @@ NStencilFullMultiOld2d::NStencilFullMultiOld2d(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilFullMultiOld2d::create()
{
int i,j,n;
double rsq,typesq;
int i, j, n;
double rsq, typesq;
int *s;
double *distsq;
@ -40,10 +39,10 @@ void NStencilFullMultiOld2d::create()
n = 0;
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++) {
rsq = bin_distance(i,j,0);
rsq = bin_distance(i, j, 0);
if (rsq < typesq) {
distsq[n] = rsq;
s[n++] = j*mbinx + i;
s[n++] = j * mbinx + i;
}
}
nstencil_multi_old[itype] = n;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -27,8 +26,8 @@ NStencilFullMultiOld3d::NStencilFullMultiOld3d(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilFullMultiOld3d::create()
{
int i,j,k,n;
double rsq,typesq;
int i, j, k, n;
double rsq, typesq;
int *s;
double *distsq;
@ -41,10 +40,10 @@ void NStencilFullMultiOld3d::create()
for (k = -sz; k <= sz; k++)
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++) {
rsq = bin_distance(i,j,k);
rsq = bin_distance(i, j, k);
if (rsq < typesq) {
distsq[n] = rsq;
s[n++] = k*mbiny*mbinx + j*mbinx + i;
s[n++] = k * mbiny * mbinx + j * mbinx + i;
}
}
nstencil_multi_old[itype] = n;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -26,13 +25,12 @@ NStencilHalfBin2d::NStencilHalfBin2d(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilHalfBin2d::create()
{
int i,j;
int i, j;
nstencil = 0;
for (j = 0; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (j > 0 || (j == 0 && i > 0))
if (bin_distance(i,j,0) < cutneighmaxsq)
stencil[nstencil++] = j*mbinx + i;
if (bin_distance(i, j, 0) < cutneighmaxsq) stencil[nstencil++] = j * mbinx + i;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -18,8 +17,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
NStencilHalfBin2dTri::NStencilHalfBin2dTri(LAMMPS *lmp) :
NStencil(lmp) {}
NStencilHalfBin2dTri::NStencilHalfBin2dTri(LAMMPS *lmp) : NStencil(lmp) {}
/* ----------------------------------------------------------------------
create stencil based on bin geometry and cutoff
@ -27,12 +25,11 @@ NStencilHalfBin2dTri::NStencilHalfBin2dTri(LAMMPS *lmp) :
void NStencilHalfBin2dTri::create()
{
int i,j;
int i, j;
nstencil = 0;
for (j = 0; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (bin_distance(i,j,0) < cutneighmaxsq)
stencil[nstencil++] = j*mbinx + i;
if (bin_distance(i, j, 0) < cutneighmaxsq) stencil[nstencil++] = j * mbinx + i;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -26,7 +25,7 @@ NStencilHalfBin3d::NStencilHalfBin3d(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilHalfBin3d::create()
{
int i,j,k;
int i, j, k;
nstencil = 0;
@ -34,6 +33,6 @@ void NStencilHalfBin3d::create()
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (k > 0 || j > 0 || (j == 0 && i > 0))
if (bin_distance(i,j,k) < cutneighmaxsq)
stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i;
if (bin_distance(i, j, k) < cutneighmaxsq)
stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -18,8 +17,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
NStencilHalfBin3dTri::NStencilHalfBin3dTri(LAMMPS *lmp) :
NStencil(lmp) {}
NStencilHalfBin3dTri::NStencilHalfBin3dTri(LAMMPS *lmp) : NStencil(lmp) {}
/* ----------------------------------------------------------------------
create stencil based on bin geometry and cutoff
@ -27,13 +25,13 @@ NStencilHalfBin3dTri::NStencilHalfBin3dTri(LAMMPS *lmp) :
void NStencilHalfBin3dTri::create()
{
int i,j,k;
int i, j, k;
nstencil = 0;
for (k = 0; k <= sz; k++)
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (bin_distance(i,j,k) < cutneighmaxsq)
stencil[nstencil++] = k*mbiny*mbinx + j*mbinx + i;
if (bin_distance(i, j, k) < cutneighmaxsq)
stencil[nstencil++] = k * mbiny * mbinx + j * mbinx + i;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -19,8 +18,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
NStencilHalfMultiOld2d::
NStencilHalfMultiOld2d(LAMMPS *lmp) : NStencil(lmp) {}
NStencilHalfMultiOld2d::NStencilHalfMultiOld2d(LAMMPS *lmp) : NStencil(lmp) {}
/* ----------------------------------------------------------------------
create stencil based on bin geometry and cutoff
@ -28,8 +26,8 @@ NStencilHalfMultiOld2d(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilHalfMultiOld2d::create()
{
int i,j,n;
double rsq,typesq;
int i, j, n;
double rsq, typesq;
int *s;
double *distsq;
@ -42,10 +40,10 @@ void NStencilHalfMultiOld2d::create()
for (j = 0; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (j > 0 || (j == 0 && i > 0)) {
rsq = bin_distance(i,j,0);
rsq = bin_distance(i, j, 0);
if (rsq < typesq) {
distsq[n] = rsq;
s[n++] = j*mbinx + i;
s[n++] = j * mbinx + i;
}
}
nstencil_multi_old[itype] = n;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -19,8 +18,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
NStencilHalfMultiOld2dTri::
NStencilHalfMultiOld2dTri(LAMMPS *lmp) : NStencil(lmp) {}
NStencilHalfMultiOld2dTri::NStencilHalfMultiOld2dTri(LAMMPS *lmp) : NStencil(lmp) {}
/* ----------------------------------------------------------------------
create stencil based on bin geometry and cutoff
@ -28,8 +26,8 @@ NStencilHalfMultiOld2dTri(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilHalfMultiOld2dTri::create()
{
int i,j,n;
double rsq,typesq;
int i, j, n;
double rsq, typesq;
int *s;
double *distsq;
@ -41,10 +39,10 @@ void NStencilHalfMultiOld2dTri::create()
n = 0;
for (j = 0; j <= sy; j++)
for (i = -sx; i <= sx; i++) {
rsq = bin_distance(i,j,0);
rsq = bin_distance(i, j, 0);
if (rsq < typesq) {
distsq[n] = rsq;
s[n++] = j*mbinx + i;
s[n++] = j * mbinx + i;
}
}
nstencil_multi_old[itype] = n;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -19,8 +18,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
NStencilHalfMultiOld3d::
NStencilHalfMultiOld3d(LAMMPS *lmp) : NStencil(lmp) {}
NStencilHalfMultiOld3d::NStencilHalfMultiOld3d(LAMMPS *lmp) : NStencil(lmp) {}
/* ----------------------------------------------------------------------
create stencil based on bin geometry and cutoff
@ -28,8 +26,8 @@ NStencilHalfMultiOld3d(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilHalfMultiOld3d::create()
{
int i,j,k,n;
double rsq,typesq;
int i, j, k, n;
double rsq, typesq;
int *s;
double *distsq;
@ -43,10 +41,10 @@ void NStencilHalfMultiOld3d::create()
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++)
if (k > 0 || j > 0 || (j == 0 && i > 0)) {
rsq = bin_distance(i,j,k);
rsq = bin_distance(i, j, k);
if (rsq < typesq) {
distsq[n] = rsq;
s[n++] = k*mbiny*mbinx + j*mbinx + i;
s[n++] = k * mbiny * mbinx + j * mbinx + i;
}
}
nstencil_multi_old[itype] = n;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -19,8 +18,7 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
NStencilHalfMultiOld3dTri::
NStencilHalfMultiOld3dTri(LAMMPS *lmp) : NStencil(lmp) {}
NStencilHalfMultiOld3dTri::NStencilHalfMultiOld3dTri(LAMMPS *lmp) : NStencil(lmp) {}
/* ----------------------------------------------------------------------
create stencil based on bin geometry and cutoff
@ -28,8 +26,8 @@ NStencilHalfMultiOld3dTri(LAMMPS *lmp) : NStencil(lmp) {}
void NStencilHalfMultiOld3dTri::create()
{
int i,j,k,n;
double rsq,typesq;
int i, j, k, n;
double rsq, typesq;
int *s;
double *distsq;
@ -42,10 +40,10 @@ void NStencilHalfMultiOld3dTri::create()
for (k = 0; k <= sz; k++)
for (j = -sy; j <= sy; j++)
for (i = -sx; i <= sx; i++) {
rsq = bin_distance(i,j,k);
rsq = bin_distance(i, j, k);
if (rsq < typesq) {
distsq[n] = rsq;
s[n++] = k*mbiny*mbinx + j*mbinx + i;
s[n++] = k * mbiny * mbinx + j * mbinx + i;
}
}
nstencil_multi_old[itype] = n;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -15,14 +14,13 @@
#include "ntopo_bond_all.h"
#include "atom.h"
#include "force.h"
#include "domain.h"
#include "update.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "output.h"
#include "thermo.h"
#include "memory.h"
#include "error.h"
#include "update.h"
using namespace LAMMPS_NS;
@ -39,7 +37,7 @@ NTopoBondAll::NTopoBondAll(LAMMPS *lmp) : NTopo(lmp)
void NTopoBondAll::build()
{
int i,m,atom1;
int i, m, atom1;
int nlocal = atom->nlocal;
int *num_bond = atom->num_bond;
@ -58,16 +56,17 @@ void NTopoBondAll::build()
if (atom1 == -1) {
nmissing++;
if (lostbond == Thermo::ERROR)
error->one(FLERR,"Bond atoms {} {} missing on "
"proc {} at step {}",tag[i],
bond_atom[i][m],me,update->ntimestep);
error->one(FLERR,
"Bond atoms {} {} missing on "
"proc {} at step {}",
tag[i], bond_atom[i][m], me, update->ntimestep);
continue;
}
atom1 = domain->closest_image(i,atom1);
atom1 = domain->closest_image(i, atom1);
if (newton_bond || i < atom1) {
if (nbondlist == maxbond) {
maxbond += DELTA;
memory->grow(bondlist,maxbond,3,"neigh_topo:bondlist");
memory->grow(bondlist, maxbond, 3, "neigh_topo:bondlist");
}
bondlist[nbondlist][0] = i;
bondlist[nbondlist][1] = atom1;
@ -80,7 +79,6 @@ void NTopoBondAll::build()
if (lostbond == Thermo::IGNORE) return;
int all;
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
if (all && (me == 0))
error->warning(FLERR,"Bond atoms missing at step {}",update->ntimestep);
MPI_Allreduce(&nmissing, &all, 1, MPI_INT, MPI_SUM, world);
if (all && (me == 0)) error->warning(FLERR, "Bond atoms missing at step {}", update->ntimestep);
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -15,14 +14,13 @@
#include "ntopo_bond_partial.h"
#include "atom.h"
#include "force.h"
#include "domain.h"
#include "update.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "output.h"
#include "thermo.h"
#include "memory.h"
#include "error.h"
#include "update.h"
using namespace LAMMPS_NS;
@ -39,7 +37,7 @@ NTopoBondPartial::NTopoBondPartial(LAMMPS *lmp) : NTopo(lmp)
void NTopoBondPartial::build()
{
int i,m,atom1;
int i, m, atom1;
int nlocal = atom->nlocal;
int *num_bond = atom->num_bond;
@ -59,16 +57,17 @@ void NTopoBondPartial::build()
if (atom1 == -1) {
nmissing++;
if (lostbond == Thermo::ERROR)
error->one(FLERR,"Bond atoms {} {} missing on "
"proc {} at step {}",tag[i],
bond_atom[i][m],me,update->ntimestep);
error->one(FLERR,
"Bond atoms {} {} missing on "
"proc {} at step {}",
tag[i], bond_atom[i][m], me, update->ntimestep);
continue;
}
atom1 = domain->closest_image(i,atom1);
atom1 = domain->closest_image(i, atom1);
if (newton_bond || i < atom1) {
if (nbondlist == maxbond) {
maxbond += DELTA;
memory->grow(bondlist,maxbond,3,"neigh_topo:bondlist");
memory->grow(bondlist, maxbond, 3, "neigh_topo:bondlist");
}
bondlist[nbondlist][0] = i;
bondlist[nbondlist][1] = atom1;
@ -81,7 +80,6 @@ void NTopoBondPartial::build()
if (lostbond == Thermo::IGNORE) return;
int all;
MPI_Allreduce(&nmissing,&all,1,MPI_INT,MPI_SUM,world);
if (all && (me == 0))
error->warning(FLERR,"Bond atoms missing at step {}",update->ntimestep);
MPI_Allreduce(&nmissing, &all, 1, MPI_INT, MPI_SUM, world);
if (all && (me == 0)) error->warning(FLERR, "Bond atoms missing at step {}", update->ntimestep);
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -18,11 +17,10 @@
#include "pair_deprecated.h"
#include "pair_hybrid.h"
#include "comm.h"
#include "force.h"
#include "error.h"
#include "force.h"
#include "pair_hybrid.h"
using namespace LAMMPS_NS;
@ -35,21 +33,21 @@ void PairDeprecated::settings(int, char **)
// hybrid substyles are created in PairHybrid::settings(), so when this is
// called, our style was just added at the end of the list of substyles
if (utils::strmatch(my_style,"^hybrid")) {
if (utils::strmatch(my_style, "^hybrid")) {
auto hybrid = dynamic_cast<PairHybrid *>(force->pair);
my_style = hybrid->keywords[hybrid->nstyles];
}
if (my_style == "DEPRECATED") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nPair style 'DEPRECATED' is a dummy style\n\n");
if (lmp->comm->me == 0) utils::logmesg(lmp, "\nPair style 'DEPRECATED' is a dummy style\n\n");
return;
}
if (my_style == "reax") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nPair style 'reax' has been removed from LAMMPS "
utils::logmesg(lmp,
"\nPair style 'reax' has been removed from LAMMPS "
"after the 12 December 2018 version\n\n");
}
error->all(FLERR,"This pair style is no longer available");
error->all(FLERR, "This pair style is no longer available");
}

View File

@ -395,20 +395,18 @@ void PairTable::read_table(Table *tb, char *file, char *keyword)
union_int_float_t rsq_lookup;
int rerror = 0;
int cerror = 0;
reader.skip_line();
for (int i = 0; i < tb->ninput; i++) {
line = reader.next_line(4);
line = reader.next_line();
try {
ValueTokenizer values(line);
values.next_int();
rfile = values.next_double();
tb->efile[i] = conversion_factor * values.next_double();
tb->ffile[i] = conversion_factor * values.next_double();
} catch (TokenizerException &) {
++cerror;
} catch (TokenizerException &e) {
error->one(FLERR, "Error parsing pair table '{}' line {} of {}. {}\nLine was: {}", keyword,
i + 1, tb->ninput, e.what(), line);
}
rnew = rfile;
@ -474,14 +472,6 @@ void PairTable::read_table(Table *tb, char *file, char *keyword)
"{} of {} distance values in table {} with relative error\n"
"WARNING: over {} to re-computed values",
rerror, tb->ninput, EPSILONR, keyword);
// warn if data was read incompletely, e.g. columns were missing
if (cerror)
error->warning(FLERR,
"{} of {} lines in table {} were incomplete\n"
"WARNING: or could not be parsed completely",
cerror, tb->ninput, keyword);
}
/* ----------------------------------------------------------------------

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -14,14 +13,14 @@
#include "pair_yukawa.h"
#include <cmath>
#include "atom.h"
#include "force.h"
#include "comm.h"
#include "neigh_list.h"
#include "memory.h"
#include "error.h"
#include "force.h"
#include "memory.h"
#include "neigh_list.h"
#include <cmath>
using namespace LAMMPS_NS;
@ -53,13 +52,13 @@ PairYukawa::~PairYukawa()
void PairYukawa::compute(int eflag, int vflag)
{
int i,j,ii,jj,inum,jnum,itype,jtype;
double xtmp,ytmp,ztmp,delx,dely,delz,evdwl,fpair;
double rsq,r2inv,r,rinv,screening,forceyukawa,factor;
int *ilist,*jlist,*numneigh,**firstneigh;
int i, j, ii, jj, inum, jnum, itype, jtype;
double xtmp, ytmp, ztmp, delx, dely, delz, evdwl, fpair;
double rsq, r2inv, r, rinv, screening, forceyukawa, factor;
int *ilist, *jlist, *numneigh, **firstneigh;
evdwl = 0.0;
ev_init(eflag,vflag);
ev_init(eflag, vflag);
double **x = atom->x;
double **f = atom->f;
@ -92,25 +91,25 @@ void PairYukawa::compute(int eflag, int vflag)
delx = xtmp - x[j][0];
dely = ytmp - x[j][1];
delz = ztmp - x[j][2];
rsq = delx*delx + dely*dely + delz*delz;
rsq = delx * delx + dely * dely + delz * delz;
jtype = type[j];
if (rsq < cutsq[itype][jtype]) {
r2inv = 1.0/rsq;
r2inv = 1.0 / rsq;
r = sqrt(rsq);
rinv = 1.0/r;
screening = exp(-kappa*r);
rinv = 1.0 / r;
screening = exp(-kappa * r);
forceyukawa = a[itype][jtype] * screening * (kappa + rinv);
fpair = factor*forceyukawa * r2inv;
fpair = factor * forceyukawa * r2inv;
f[i][0] += delx*fpair;
f[i][1] += dely*fpair;
f[i][2] += delz*fpair;
f[i][0] += delx * fpair;
f[i][1] += dely * fpair;
f[i][2] += delz * fpair;
if (newton_pair || j < nlocal) {
f[j][0] -= delx*fpair;
f[j][1] -= dely*fpair;
f[j][2] -= delz*fpair;
f[j][0] -= delx * fpair;
f[j][1] -= dely * fpair;
f[j][2] -= delz * fpair;
}
if (eflag) {
@ -118,8 +117,7 @@ void PairYukawa::compute(int eflag, int vflag)
evdwl *= factor;
}
if (evflag) ev_tally(i,j,nlocal,newton_pair,
evdwl,0.0,fpair,delx,dely,delz);
if (evflag) ev_tally(i, j, nlocal, newton_pair, evdwl, 0.0, fpair, delx, dely, delz);
}
}
}
@ -134,18 +132,17 @@ void PairYukawa::compute(int eflag, int vflag)
void PairYukawa::allocate()
{
allocated = 1;
int n = atom->ntypes;
int np1 = atom->ntypes + 1;
memory->create(setflag,n+1,n+1,"pair:setflag");
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
setflag[i][j] = 0;
memory->create(setflag, np1, np1, "pair:setflag");
for (int i = 1; i < np1; i++)
for (int j = i; j < np1; j++) setflag[i][j] = 0;
memory->create(cutsq,n+1,n+1,"pair:cutsq");
memory->create(rad,n+1,"pair:rad");
memory->create(cut,n+1,n+1,"pair:cut");
memory->create(a,n+1,n+1,"pair:a");
memory->create(offset,n+1,n+1,"pair:offset");
memory->create(cutsq, np1, np1, "pair:cutsq");
memory->create(rad, np1, "pair:rad");
memory->create(cut, np1, np1, "pair:cut");
memory->create(a, np1, np1, "pair:a");
memory->create(offset, np1, np1, "pair:offset");
}
/* ----------------------------------------------------------------------
@ -154,15 +151,15 @@ void PairYukawa::allocate()
void PairYukawa::settings(int narg, char **arg)
{
if (narg != 2) error->all(FLERR,"Illegal pair_style command");
if (narg != 2) error->all(FLERR, "Illegal pair_style command");
kappa = utils::numeric(FLERR,arg[0],false,lmp);
cut_global = utils::numeric(FLERR,arg[1],false,lmp);
kappa = utils::numeric(FLERR, arg[0], false, lmp);
cut_global = utils::numeric(FLERR, arg[1], false, lmp);
// reset cutoffs that have been explicitly set
if (allocated) {
int i,j;
int i, j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++)
if (setflag[i][j]) cut[i][j] = cut_global;
@ -175,22 +172,21 @@ void PairYukawa::settings(int narg, char **arg)
void PairYukawa::coeff(int narg, char **arg)
{
if (narg < 3 || narg > 4)
error->all(FLERR,"Incorrect args for pair coefficients");
if (narg < 3 || narg > 4) error->all(FLERR, "Incorrect args for pair coefficients");
if (!allocated) allocate();
int ilo,ihi,jlo,jhi;
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
int ilo, ihi, jlo, jhi;
utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error);
utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error);
double a_one = utils::numeric(FLERR,arg[2],false,lmp);
double a_one = utils::numeric(FLERR, arg[2], false, lmp);
double cut_one = cut_global;
if (narg == 4) cut_one = utils::numeric(FLERR,arg[3],false,lmp);
if (narg == 4) cut_one = utils::numeric(FLERR, arg[3], false, lmp);
int count = 0;
for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) {
for (int j = MAX(jlo, i); j <= jhi; j++) {
a[i][j] = a_one;
cut[i][j] = cut_one;
setflag[i][j] = 1;
@ -198,7 +194,7 @@ void PairYukawa::coeff(int narg, char **arg)
}
}
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
}
/* ----------------------------------------------------------------------
@ -208,14 +204,15 @@ void PairYukawa::coeff(int narg, char **arg)
double PairYukawa::init_one(int i, int j)
{
if (setflag[i][j] == 0) {
a[i][j] = mix_energy(a[i][i],a[j][j],1.0,1.0);
cut[i][j] = mix_distance(cut[i][i],cut[j][j]);
a[i][j] = mix_energy(a[i][i], a[j][j], 1.0, 1.0);
cut[i][j] = mix_distance(cut[i][i], cut[j][j]);
}
if (offset_flag && (cut[i][j] > 0.0)) {
double screening = exp(-kappa * cut[i][j]);
offset[i][j] = a[i][j] * screening / cut[i][j];
} else offset[i][j] = 0.0;
} else
offset[i][j] = 0.0;
a[j][i] = a[i][j];
offset[j][i] = offset[i][j];
@ -231,13 +228,13 @@ void PairYukawa::write_restart(FILE *fp)
{
write_restart_settings(fp);
int i,j;
int i, j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
fwrite(&setflag[i][j],sizeof(int),1,fp);
fwrite(&setflag[i][j], sizeof(int), 1, fp);
if (setflag[i][j]) {
fwrite(&a[i][j],sizeof(double),1,fp);
fwrite(&cut[i][j],sizeof(double),1,fp);
fwrite(&a[i][j], sizeof(double), 1, fp);
fwrite(&cut[i][j], sizeof(double), 1, fp);
}
}
}
@ -252,19 +249,19 @@ void PairYukawa::read_restart(FILE *fp)
allocate();
int i,j;
int i, j;
int me = comm->me;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,nullptr,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world);
if (setflag[i][j]) {
if (me == 0) {
utils::sfread(FLERR,&a[i][j],sizeof(double),1,fp,nullptr,error);
utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error);
utils::sfread(FLERR, &a[i][j], sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR, &cut[i][j], sizeof(double), 1, fp, nullptr, error);
}
MPI_Bcast(&a[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
MPI_Bcast(&a[i][j], 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world);
}
}
}
@ -275,10 +272,10 @@ void PairYukawa::read_restart(FILE *fp)
void PairYukawa::write_restart_settings(FILE *fp)
{
fwrite(&kappa,sizeof(double),1,fp);
fwrite(&cut_global,sizeof(double),1,fp);
fwrite(&offset_flag,sizeof(int),1,fp);
fwrite(&mix_flag,sizeof(int),1,fp);
fwrite(&kappa, sizeof(double), 1, fp);
fwrite(&cut_global, sizeof(double), 1, fp);
fwrite(&offset_flag, sizeof(int), 1, fp);
fwrite(&mix_flag, sizeof(int), 1, fp);
}
/* ----------------------------------------------------------------------
@ -288,15 +285,15 @@ void PairYukawa::write_restart_settings(FILE *fp)
void PairYukawa::read_restart_settings(FILE *fp)
{
if (comm->me == 0) {
utils::sfread(FLERR,&kappa,sizeof(double),1,fp,nullptr,error);
utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error);
utils::sfread(FLERR,&offset_flag,sizeof(int),1,fp,nullptr,error);
utils::sfread(FLERR,&mix_flag,sizeof(int),1,fp,nullptr,error);
utils::sfread(FLERR, &kappa, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR, &cut_global, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR, &offset_flag, sizeof(int), 1, fp, nullptr, error);
utils::sfread(FLERR, &mix_flag, sizeof(int), 1, fp, nullptr, error);
}
MPI_Bcast(&kappa,1,MPI_DOUBLE,0,world);
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&offset_flag,1,MPI_INT,0,world);
MPI_Bcast(&mix_flag,1,MPI_INT,0,world);
MPI_Bcast(&kappa, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&cut_global, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&offset_flag, 1, MPI_INT, 0, world);
MPI_Bcast(&mix_flag, 1, MPI_INT, 0, world);
}
/* ----------------------------------------------------------------------
@ -305,8 +302,7 @@ void PairYukawa::read_restart_settings(FILE *fp)
void PairYukawa::write_data(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
fprintf(fp,"%d %g\n",i,a[i][i]);
for (int i = 1; i <= atom->ntypes; i++) fprintf(fp, "%d %g\n", i, a[i][i]);
}
/* ----------------------------------------------------------------------
@ -316,25 +312,23 @@ void PairYukawa::write_data(FILE *fp)
void PairYukawa::write_data_all(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
fprintf(fp,"%d %d %g %g\n",i,j,a[i][j],cut[i][j]);
for (int j = i; j <= atom->ntypes; j++) fprintf(fp, "%d %d %g %g\n", i, j, a[i][j], cut[i][j]);
}
/* ---------------------------------------------------------------------- */
double PairYukawa::single(int /*i*/, int /*j*/, int itype, int jtype, double rsq,
double /*factor_coul*/, double factor_lj,
double &fforce)
double /*factor_coul*/, double factor_lj, double &fforce)
{
double r2inv,r,rinv,screening,forceyukawa,phi;
double r2inv, r, rinv, screening, forceyukawa, phi;
r2inv = 1.0/rsq;
r2inv = 1.0 / rsq;
r = sqrt(rsq);
rinv = 1.0/r;
screening = exp(-kappa*r);
rinv = 1.0 / r;
screening = exp(-kappa * r);
forceyukawa = a[itype][jtype] * screening * (kappa + rinv);
fforce = factor_lj*forceyukawa * r2inv;
fforce = factor_lj * forceyukawa * r2inv;
phi = a[itype][jtype] * screening * rinv - offset[itype][jtype];
return factor_lj*phi;
return factor_lj * phi;
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -20,8 +19,8 @@
#include "atom.h"
#include "comm.h"
#include "memory.h"
#include "error.h"
#include "memory.h"
#include <cstring>
@ -29,11 +28,12 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
PairZero::PairZero(LAMMPS *lmp) : Pair(lmp) {
coeffflag=1;
writedata=1;
single_enable=1;
respa_enable=1;
PairZero::PairZero(LAMMPS *lmp) : Pair(lmp)
{
coeffflag = 1;
writedata = 1;
single_enable = 1;
respa_enable = 1;
}
/* ---------------------------------------------------------------------- */
@ -51,7 +51,7 @@ PairZero::~PairZero()
void PairZero::compute(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
if (vflag_fdotr) virial_fdotr_compute();
}
@ -59,7 +59,7 @@ void PairZero::compute(int eflag, int vflag)
void PairZero::compute_outer(int eflag, int vflag)
{
ev_init(eflag,vflag);
ev_init(eflag, vflag);
}
/* ----------------------------------------------------------------------
@ -69,15 +69,14 @@ void PairZero::compute_outer(int eflag, int vflag)
void PairZero::allocate()
{
allocated = 1;
int n = atom->ntypes;
int np1 = atom->ntypes + 1;
memory->create(setflag,n+1,n+1,"pair:setflag");
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
setflag[i][j] = 0;
memory->create(setflag, np1, np1, "pair:setflag");
for (int i = 1; i < np1; i++)
for (int j = i; j < np1; j++) setflag[i][j] = 0;
memory->create(cutsq,n+1,n+1,"pair:cutsq");
memory->create(cut,n+1,n+1,"pair:cut");
memory->create(cutsq, np1, np1, "pair:cutsq");
memory->create(cut, np1, np1, "pair:cut");
}
/* ----------------------------------------------------------------------
@ -86,22 +85,22 @@ void PairZero::allocate()
void PairZero::settings(int narg, char **arg)
{
if ((narg != 1) && (narg != 2))
error->all(FLERR,"Illegal pair_style command");
if ((narg != 1) && (narg != 2)) error->all(FLERR, "Illegal pair_style command");
cut_global = utils::numeric(FLERR,arg[0],false,lmp);
cut_global = utils::numeric(FLERR, arg[0], false, lmp);
if (narg == 2) {
if (strcmp("nocoeff",arg[1]) == 0) coeffflag=0;
else error->all(FLERR,"Illegal pair_style command");
if (strcmp("nocoeff", arg[1]) == 0)
coeffflag = 0;
else
error->all(FLERR, "Illegal pair_style command");
}
// reset cutoffs that have been explicitly set
if (allocated) {
int i,j;
int i, j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i+1; j <= atom->ntypes; j++)
cut[i][j] = cut_global;
for (j = i + 1; j <= atom->ntypes; j++) cut[i][j] = cut_global;
}
}
@ -112,27 +111,27 @@ void PairZero::settings(int narg, char **arg)
void PairZero::coeff(int narg, char **arg)
{
if ((narg < 2) || (coeffflag && narg > 3))
error->all(FLERR,"Incorrect args for pair coefficients");
error->all(FLERR, "Incorrect args for pair coefficients");
if (!allocated) allocate();
int ilo,ihi,jlo,jhi;
utils::bounds(FLERR,arg[0],1,atom->ntypes,ilo,ihi,error);
utils::bounds(FLERR,arg[1],1,atom->ntypes,jlo,jhi,error);
int ilo, ihi, jlo, jhi;
utils::bounds(FLERR, arg[0], 1, atom->ntypes, ilo, ihi, error);
utils::bounds(FLERR, arg[1], 1, atom->ntypes, jlo, jhi, error);
double cut_one = cut_global;
if (coeffflag && (narg == 3)) cut_one = utils::numeric(FLERR,arg[2],false,lmp);
if (coeffflag && (narg == 3)) cut_one = utils::numeric(FLERR, arg[2], false, lmp);
int count = 0;
for (int i = ilo; i <= ihi; i++) {
for (int j = MAX(jlo,i); j <= jhi; j++) {
for (int j = MAX(jlo, i); j <= jhi; j++) {
cut[i][j] = cut_one;
setflag[i][j] = 1;
count++;
}
}
if (count == 0) error->all(FLERR,"Incorrect args for pair coefficients");
if (count == 0) error->all(FLERR, "Incorrect args for pair coefficients");
}
/* ----------------------------------------------------------------------
@ -141,9 +140,7 @@ void PairZero::coeff(int narg, char **arg)
double PairZero::init_one(int i, int j)
{
if (setflag[i][j] == 0) {
cut[i][j] = mix_distance(cut[i][i],cut[j][j]);
}
if (setflag[i][j] == 0) { cut[i][j] = mix_distance(cut[i][i], cut[j][j]); }
return cut[i][j];
}
@ -156,13 +153,11 @@ void PairZero::write_restart(FILE *fp)
{
write_restart_settings(fp);
int i,j;
int i, j;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
fwrite(&setflag[i][j],sizeof(int),1,fp);
if (setflag[i][j]) {
fwrite(&cut[i][j],sizeof(double),1,fp);
}
fwrite(&setflag[i][j], sizeof(int), 1, fp);
if (setflag[i][j]) { fwrite(&cut[i][j], sizeof(double), 1, fp); }
}
}
@ -175,17 +170,15 @@ void PairZero::read_restart(FILE *fp)
read_restart_settings(fp);
allocate();
int i,j;
int i, j;
int me = comm->me;
for (i = 1; i <= atom->ntypes; i++)
for (j = i; j <= atom->ntypes; j++) {
if (me == 0) utils::sfread(FLERR,&setflag[i][j],sizeof(int),1,fp,nullptr,error);
MPI_Bcast(&setflag[i][j],1,MPI_INT,0,world);
if (me == 0) utils::sfread(FLERR, &setflag[i][j], sizeof(int), 1, fp, nullptr, error);
MPI_Bcast(&setflag[i][j], 1, MPI_INT, 0, world);
if (setflag[i][j]) {
if (me == 0) {
utils::sfread(FLERR,&cut[i][j],sizeof(double),1,fp,nullptr,error);
}
MPI_Bcast(&cut[i][j],1,MPI_DOUBLE,0,world);
if (me == 0) { utils::sfread(FLERR, &cut[i][j], sizeof(double), 1, fp, nullptr, error); }
MPI_Bcast(&cut[i][j], 1, MPI_DOUBLE, 0, world);
}
}
}
@ -196,8 +189,8 @@ void PairZero::read_restart(FILE *fp)
void PairZero::write_restart_settings(FILE *fp)
{
fwrite(&cut_global,sizeof(double),1,fp);
fwrite(&coeffflag,sizeof(int),1,fp);
fwrite(&cut_global, sizeof(double), 1, fp);
fwrite(&coeffflag, sizeof(int), 1, fp);
}
/* ----------------------------------------------------------------------
@ -208,11 +201,11 @@ void PairZero::read_restart_settings(FILE *fp)
{
int me = comm->me;
if (me == 0) {
utils::sfread(FLERR,&cut_global,sizeof(double),1,fp,nullptr,error);
utils::sfread(FLERR,&coeffflag,sizeof(int),1,fp,nullptr,error);
utils::sfread(FLERR, &cut_global, sizeof(double), 1, fp, nullptr, error);
utils::sfread(FLERR, &coeffflag, sizeof(int), 1, fp, nullptr, error);
}
MPI_Bcast(&cut_global,1,MPI_DOUBLE,0,world);
MPI_Bcast(&coeffflag,1,MPI_INT,0,world);
MPI_Bcast(&cut_global, 1, MPI_DOUBLE, 0, world);
MPI_Bcast(&coeffflag, 1, MPI_INT, 0, world);
}
/* ----------------------------------------------------------------------
@ -221,8 +214,7 @@ void PairZero::read_restart_settings(FILE *fp)
void PairZero::write_data(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
fprintf(fp,"%d\n",i);
for (int i = 1; i <= atom->ntypes; i++) fprintf(fp, "%d\n", i);
}
/* ----------------------------------------------------------------------
@ -232,17 +224,14 @@ void PairZero::write_data(FILE *fp)
void PairZero::write_data_all(FILE *fp)
{
for (int i = 1; i <= atom->ntypes; i++)
for (int j = i; j <= atom->ntypes; j++)
fprintf(fp,"%d %d %g\n",i,j,cut[i][j]);
for (int j = i; j <= atom->ntypes; j++) fprintf(fp, "%d %d %g\n", i, j, cut[i][j]);
}
/* ---------------------------------------------------------------------- */
double PairZero::single(int /*i*/, int /*j*/, int /* itype */, int /* jtype */,
double /* rsq */, double /*factor_coul*/,
double /* factor_lj */, double &fforce)
double PairZero::single(int /*i*/, int /*j*/, int /* itype */, int /* jtype */, double /* rsq */,
double /*factor_coul*/, double /* factor_lj */, double &fforce)
{
fforce = 0.0;
return 0.0;
}

View File

@ -186,13 +186,63 @@ std::string platform::os_info()
char value[1024];
DWORD value_length = 1024;
const char *subkey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";
const char *entry = "CurrentBuild";
RegGetValue(HKEY_LOCAL_MACHINE, subkey, entry, RRF_RT_REG_SZ, nullptr, &value,
(LPDWORD) &value_length);
// enforce zero termination
value[1023] = '\0';
auto build = std::string(value);
if (build == "6002") {
buf = "Windows Vista";
} else if (build == "6003") {
buf = "Windows Server 2008";
} else if (build == "7601") {
buf = "Windows 7";
} else if (build == "9200") {
buf = "Windows 8";
} else if (build == "9600") {
buf = "Windows 8.1";
} else if (build == "10240") {
buf = "Windows 10 1507";
} else if (build == "10586") {
buf = "Windows 10 1511";
} else if (build == "14393") {
buf = "Windows 10 1607";
} else if (build == "15063") {
buf = "Windows 10 1703";
} else if (build == "16299") {
buf = "Windows 10 1709";
} else if (build == "17134") {
buf = "Windows 10 1803";
} else if (build == "17763") {
buf = "Windows 10 1809";
} else if (build == "18362") {
buf = "Windows 10 1903";
} else if (build == "18363") {
buf = "Windows 10 1909";
} else if (build == "19041") {
buf = "Windows 10 2004";
} else if (build == "19042") {
buf = "Windows 10 20H2";
} else if (build == "19043") {
buf = "Windows 10 21H1";
} else if (build == "19044") {
buf = "Windows 10 21H2";
} else if (build == "20348") {
buf = "Windows Server 2022";
} else if (build == "22000") {
buf = "Windows 11 21H2";
} else if (build == "22621") {
buf = "Windows 11 22H2";
} else {
const char *entry = "ProductName";
RegGetValue(HKEY_LOCAL_MACHINE, subkey, entry, RRF_RT_REG_SZ, nullptr, &value,
(LPDWORD) &value_length);
// enforce zero termination
value[1023] = '\0';
buf = value;
}
DWORD fullversion, majorv, minorv, buildv = 0;
fullversion = GetVersion();
majorv = (DWORD) (LOBYTE(LOWORD(fullversion)));
@ -303,11 +353,18 @@ std::string platform::compiler_info()
__MINGW32_MINOR_VERSION, __VERSION__);
#elif defined(__GNUC__)
buf = fmt::format("GNU C++ {}", __VERSION__);
#elif defined(_MSC_VER) && (_MSC_VER > 1920) && (_MSC_VER < 2000)
#elif defined(_MSC_VER) && (_MSC_VER >= 1920) && (_MSC_VER < 1930)
constexpr int major = _MSC_VER / 100;
constexpr int minor = _MSC_VER - major * 100;
buf = "Microsoft Visual Studio 20" + std::to_string(major) + ", C/C++ " +
std::to_string(major - 5) + "." + std::to_string(minor);
constexpr int patch = minor - 20;
buf = fmt::format("Microsoft Visual Studio 2019 Version 16.{}, C/C++ {}.{}", patch, major - 5,
minor);
#elif defined(_MSC_VER) && (_MSC_VER >= 1930) && (_MSC_VER < 2000)
constexpr int major = _MSC_VER / 100;
constexpr int minor = _MSC_VER - major * 100;
constexpr int patch = minor - 30;
buf = fmt::format("Microsoft Visual Studio 2022 Version 17.{}, C/C++ {}.{}", patch, major - 5,
minor);
#else
buf = "(Unknown)";
#endif

View File

@ -313,11 +313,9 @@ void ReadData::command(int narg, char **arg)
error->all(FLERR,"Reading a data file with shrinkwrap boundaries is "
"not compatible with a MSM KSpace style");
if (domain->box_exist && !addflag)
error->all(FLERR,"Cannot read_data without add keyword "
"after simulation box is defined");
error->all(FLERR,"Cannot read_data without add keyword after simulation box is defined");
if (!domain->box_exist && addflag)
error->all(FLERR,"Cannot use read_data add before "
"simulation box is defined");
error->all(FLERR,"Cannot use read_data add before simulation box is defined");
if (offsetflag && addflag == NONE)
error->all(FLERR,"Cannot use read_data offset without add flag");
if (shiftflag && addflag == NONE)
@ -330,8 +328,7 @@ void ReadData::command(int narg, char **arg)
// check if data file is available and readable
if (!platform::file_is_readable(arg[0]))
error->all(FLERR,fmt::format("Cannot open file {}: {}",
arg[0], utils::getsyserror()));
error->all(FLERR,fmt::format("Cannot open file {}: {}", arg[0], utils::getsyserror()));
// reset so we can warn about reset image flags exactly once per data file

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -41,19 +40,19 @@ void Reader::open_file(const std::string &file)
if (platform::has_compress_extension(file)) {
compressed = true;
fp = platform::compressed_read(file);
if (!fp) error->one(FLERR,"Cannot open compressed file for reading");
if (!fp) error->one(FLERR, "Cannot open compressed file for reading");
} else {
compressed = false;
if (utils::strmatch(file, "\\.bin$")) {
binary = true;
fp = fopen(file.c_str(),"rb");
fp = fopen(file.c_str(), "rb");
} else {
fp = fopen(file.c_str(),"r");
fp = fopen(file.c_str(), "r");
binary = false;
}
}
if (!fp) error->one(FLERR,"Cannot open file {}: {}", file, utils::getsyserror());
if (!fp) error->one(FLERR, "Cannot open file {}: {}", file, utils::getsyserror());
}
/* ----------------------------------------------------------------------
@ -64,8 +63,10 @@ void Reader::open_file(const std::string &file)
void Reader::close_file()
{
if (fp == nullptr) return;
if (compressed) platform::pclose(fp);
else fclose(fp);
if (compressed)
platform::pclose(fp);
else
fclose(fp);
fp = nullptr;
}
@ -73,8 +74,7 @@ void Reader::close_file()
detect unused arguments
------------------------------------------------------------------------- */
void Reader::settings(int narg, char** /*args*/)
void Reader::settings(int narg, char ** /*args*/)
{
if (narg > 0)
error->all(FLERR,"Illegal read_dump command");
if (narg > 0) error->all(FLERR, "Illegal read_dump command");
}

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -17,20 +16,17 @@
#include "comm.h"
#include "error.h"
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
RegionDeprecated::RegionDeprecated(LAMMPS *lmp, int narg, char **arg) :
Region(lmp, narg, arg)
RegionDeprecated::RegionDeprecated(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
{
std::string my_style = style;
if (my_style == "DEPRECATED") {
if (lmp->comm->me == 0)
utils::logmesg(lmp,"\nRegion style 'DEPRECATED' is a dummy style\n\n");
if (lmp->comm->me == 0) utils::logmesg(lmp, "\nRegion style 'DEPRECATED' is a dummy style\n\n");
return;
}
error->all(FLERR,"This region style is no longer available");
error->all(FLERR, "This region style is no longer available");
}

View File

@ -165,6 +165,7 @@ void Rerun::command(int narg, char **arg)
modify->init();
update->integrate->setup_minimal(1);
modify->end_of_step();
output->next_dump_any = ntimestep;
if (firstflag) output->setup();
else if (output->next) output->write(ntimestep);

View File

@ -1,4 +1,3 @@
// clang-format off
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories
@ -34,41 +33,39 @@ using namespace LAMMPS_NS;
void WriteDump::command(int narg, char **arg)
{
if (narg < 3) error->all(FLERR,"Illegal write_dump command");
if (narg < 3) error->all(FLERR, "Illegal write_dump command");
// modindex = index in args of "modify" keyword
// will be narg if "modify" is not present
int modindex;
for (modindex = 0; modindex < narg; modindex++)
if (strcmp(arg[modindex],"modify") == 0) break;
if (strcmp(arg[modindex], "modify") == 0) break;
// create the Dump instance
// create dump command line with extra required args
auto dumpargs = new char*[modindex+2];
auto dumpargs = new char *[modindex + 2];
dumpargs[0] = (char *) "WRITE_DUMP"; // dump id
dumpargs[1] = arg[0]; // group
dumpargs[2] = arg[1]; // dump style
std::string ntimestep = std::to_string(MAX(update->ntimestep,1));
std::string ntimestep = std::to_string(MAX(update->ntimestep, 1));
dumpargs[3] = (char *) ntimestep.c_str(); // dump frequency
for (int i = 2; i < modindex; ++i) dumpargs[i+2] = arg[i];
for (int i = 2; i < modindex; ++i) dumpargs[i + 2] = arg[i];
Dump *dump = output->add_dump(modindex+2, dumpargs);
if (modindex < narg) dump->modify_params(narg-modindex-1,&arg[modindex+1]);
Dump *dump = output->add_dump(modindex + 2, dumpargs);
if (modindex < narg) dump->modify_params(narg - modindex - 1, &arg[modindex + 1]);
// write out one frame and then delete the dump again
// set multifile_override for DumpImage so that filename needs no "*"
if (strcmp(arg[1],"image") == 0)
(dynamic_cast<DumpImage *>( dump))->multifile_override = 1;
if (strcmp(arg[1], "image") == 0) (dynamic_cast<DumpImage *>(dump))->multifile_override = 1;
if (strcmp(arg[1],"cfg") == 0)
(dynamic_cast<DumpCFG *>( dump))->multifile_override = 1;
if (strcmp(arg[1], "cfg") == 0) (dynamic_cast<DumpCFG *>(dump))->multifile_override = 1;
if ((update->first_update == 0) && (comm->me == 0))
error->warning(FLERR,"Calling write_dump before a full system init.");
error->warning(FLERR, "Calling write_dump before a full system init.");
dump->init();
dump->write();

View File

@ -4,8 +4,8 @@ From: ubuntu:22.04
%post
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install --no-install-recommends -y software-properties-common
# add-apt-repository ppa:openkim/latest
apt-get install --no-install-recommends -y software-properties-common gpg gpg-agent
add-apt-repository ppa:openkim/latest
apt-get update
apt-get upgrade --no-install-recommends -y
apt-get install --no-install-recommends -y \
@ -74,29 +74,28 @@ From: ubuntu:22.04
zstd \
libyaml-cpp-dev \
libkim-api-dev \
gpg-agent \
# openkim-models
openkim-models
# ###########################################################################
# # KIM-API
# ###########################################################################
#
# # workaround for installing files in /usr/share/doc inside of a container
# sed -i 's/path-exclude=\/usr\/share\/doc/#path-exclude=\/usr\/share\/doc/g' /etc/dpkg/dpkg.cfg.d/excludes
# apt-get install -y libkim-api-doc
# sed -i 's/#path-exclude=\/usr\/share\/doc/path-exclude=\/usr\/share\/doc/g' /etc/dpkg/dpkg.cfg.d/excludes
#
# # install KIM models
# KIM_API_EXAMPLES=/usr/share/doc/libkim-api-dev/examples
###########################################################################
# KIM-API
###########################################################################
# workaround for installing files in /usr/share/doc inside of a container
sed -i 's/path-exclude=\/usr\/share\/doc/#path-exclude=\/usr\/share\/doc/g' /etc/dpkg/dpkg.cfg.d/excludes
apt-get install -y libkim-api-doc
sed -i 's/#path-exclude=\/usr\/share\/doc/path-exclude=\/usr\/share\/doc/g' /etc/dpkg/dpkg.cfg.d/excludes
# install KIM models
KIM_API_EXAMPLES=/usr/share/doc/libkim-api-dev/examples
# gunzip $KIM_API_EXAMPLES/portable-models/LennardJones612_UniversalShifted__MO_959249795837_003/LennardJones612_UniversalShifted.params.gz
# gunzip $KIM_API_EXAMPLES/model-drivers/ex_model_driver_P_LJ/ex_model_driver_P_LJ.f90.gz
#
# kim-api-collections-management install system $KIM_API_EXAMPLES/model-drivers/LennardJones612__MD_414112407348_003
# kim-api-collections-management install system $KIM_API_EXAMPLES/model-drivers/ex_model_driver_P_LJ
# kim-api-collections-management install system $KIM_API_EXAMPLES/portable-models/LennardJones_Ar
# kim-api-collections-management install system $KIM_API_EXAMPLES/portable-models/ex_model_Ar_P_LJ
# kim-api-collections-management install system $KIM_API_EXAMPLES/portable-models/LennardJones612_UniversalShifted__MO_959249795837_003
# kim-api-collections-management install system $KIM_API_EXAMPLES/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu
kim-api-collections-management install system $KIM_API_EXAMPLES/model-drivers/LennardJones612__MD_414112407348_003
kim-api-collections-management install system $KIM_API_EXAMPLES/model-drivers/ex_model_driver_P_LJ
kim-api-collections-management install system $KIM_API_EXAMPLES/portable-models/LennardJones_Ar
kim-api-collections-management install system $KIM_API_EXAMPLES/portable-models/ex_model_Ar_P_LJ
kim-api-collections-management install system $KIM_API_EXAMPLES/portable-models/LennardJones612_UniversalShifted__MO_959249795837_003
kim-api-collections-management install system $KIM_API_EXAMPLES/simulator-models/Sim_LAMMPS_LJcut_AkersonElliott_Alchemy_PbAu
###########################################################################

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -46,9 +46,8 @@ target_link_libraries(test_dump_atom PRIVATE lammps GTest::GMock)
add_test(NAME DumpAtom COMMAND test_dump_atom)
set_tests_properties(DumpAtom PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR}")
if(PKG_COMPRESS)
find_program(GZIP_BINARY NAMES gzip REQUIRED)
find_program(GZIP_EXECUTABLE NAMES gzip)
if(PKG_COMPRESS AND GZIP_FOUND)
add_executable(test_dump_atom_compressed test_dump_atom_compressed.cpp compressed_dump_test_main.cpp)
target_link_libraries(test_dump_atom_compressed PRIVATE lammps GTest::GMock)
@ -65,39 +64,39 @@ if(PKG_COMPRESS)
target_link_libraries(test_dump_xyz_compressed PRIVATE lammps GTest::GMock)
add_test(NAME DumpAtomGZ COMMAND test_dump_atom_compressed gz)
set_tests_properties(DumpAtomGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
set_tests_properties(DumpAtomGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${GZIP_EXECUTABLE}")
add_test(NAME DumpCustomGZ COMMAND test_dump_custom_compressed gz)
set_tests_properties(DumpCustomGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
set_tests_properties(DumpCustomGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${GZIP_EXECUTABLE}")
add_test(NAME DumpCfgGZ COMMAND test_dump_cfg_compressed gz)
set_tests_properties(DumpCfgGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
set_tests_properties(DumpCfgGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${GZIP_EXECUTABLE}")
add_test(NAME DumpLocalGZ COMMAND test_dump_local_compressed gz)
set_tests_properties(DumpLocalGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
set_tests_properties(DumpLocalGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${GZIP_EXECUTABLE}")
add_test(NAME DumpXYZGZ COMMAND test_dump_xyz_compressed gz)
set_tests_properties(DumpXYZGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${GZIP_BINARY}")
set_tests_properties(DumpXYZGZ PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${GZIP_EXECUTABLE}")
find_package(PkgConfig REQUIRED)
find_package(PkgConfig)
pkg_check_modules(Zstd IMPORTED_TARGET libzstd>=1.4)
find_program(ZSTD_BINARY NAMES zstd)
find_program(ZSTD_EXECUTABLE NAMES zstd)
if(Zstd_FOUND AND ZSTD_BINARY)
if(Zstd_FOUND AND ZSTD_EXECUTABLE)
add_test(NAME DumpAtomZstd COMMAND test_dump_atom_compressed zstd)
set_tests_properties(DumpAtomZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
set_tests_properties(DumpAtomZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${ZSTD_EXECUTABLE}")
add_test(NAME DumpCustomZstd COMMAND test_dump_custom_compressed zstd)
set_tests_properties(DumpCustomZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
set_tests_properties(DumpCustomZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${ZSTD_EXECUTABLE}")
add_test(NAME DumpCfgZstd COMMAND test_dump_cfg_compressed zstd)
set_tests_properties(DumpCfgZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
set_tests_properties(DumpCfgZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${ZSTD_EXECUTABLE}")
add_test(NAME DumpLocalZstd COMMAND test_dump_local_compressed zstd)
set_tests_properties(DumpLocalZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
set_tests_properties(DumpLocalZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${ZSTD_EXECUTABLE}")
add_test(NAME DumpXYZZstd COMMAND test_dump_xyz_compressed zstd)
set_tests_properties(DumpXYZZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_BINARY=${ZSTD_BINARY}")
set_tests_properties(DumpXYZZstd PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};COMPRESS_EXECUTABLE=${ZSTD_EXECUTABLE}")
endif()
endif()
@ -122,11 +121,11 @@ if(PKG_NETCDF)
target_link_libraries(test_dump_netcdf PRIVATE lammps GTest::GMock)
add_test(NAME DumpNetCDF COMMAND test_dump_netcdf)
if(NOT (NCDUMP STREQUAL "NCDUMP-NOTFOUND"))
set_tests_properties(DumpNetCDF PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};NCDUMP_BINARY=${NCDUMP}")
set_tests_properties(DumpNetCDF PROPERTIES ENVIRONMENT "LAMMPS_POTENTIALS=${LAMMPS_POTENTIALS_DIR};NCDUMP_EXECUTABLE=${NCDUMP}")
endif()
endif()
if(BUILD_TOOLS)
set_tests_properties(DumpAtom PROPERTIES ENVIRONMENT "BINARY2TXT_BINARY=$<TARGET_FILE:binary2txt>")
set_tests_properties(DumpCustom PROPERTIES ENVIRONMENT "BINARY2TXT_BINARY=$<TARGET_FILE:binary2txt>")
set_tests_properties(DumpAtom PROPERTIES ENVIRONMENT "BINARY2TXT_EXECUTABLE=$<TARGET_FILE:binary2txt>")
set_tests_properties(DumpCustom PROPERTIES ENVIRONMENT "BINARY2TXT_EXECUTABLE=$<TARGET_FILE:binary2txt>")
endif()

View File

@ -19,7 +19,7 @@
extern const char *COMPRESS_SUFFIX;
extern const char *COMPRESS_EXTENSION;
extern char *COMPRESS_BINARY;
extern char *COMPRESS_EXECUTABLE;
class CompressedDumpTest : public MeltTest {
protected:
@ -102,7 +102,7 @@ public:
BEGIN_HIDE_OUTPUT();
std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.'));
std::string cmdline =
fmt::format("{} -d -c {} > {}", COMPRESS_BINARY, compressed_file, converted_file);
fmt::format("\"{}\" -d -c {} > {}", COMPRESS_EXECUTABLE, compressed_file, converted_file);
system(cmdline.c_str());
END_HIDE_OUTPUT();
return converted_file;

View File

@ -22,7 +22,7 @@
const char *COMPRESS_SUFFIX = nullptr;
const char *COMPRESS_EXTENSION = nullptr;
char *COMPRESS_BINARY = nullptr;
char *COMPRESS_EXECUTABLE = nullptr;
bool verbose = false;
int main(int argc, char **argv)
@ -46,7 +46,7 @@ int main(int argc, char **argv)
return 1;
}
COMPRESS_BINARY = getenv("COMPRESS_BINARY");
COMPRESS_EXECUTABLE = getenv("COMPRESS_EXECUTABLE");
// handle arguments passed via environment variable
if (const char *var = getenv("TEST_ARGS")) {

View File

@ -5246,7 +5246,6 @@ TEST_F(AtomStyleTest, oxdna)
ASSERT_EQ(id5p[GETIDX(10)], -1);
END_HIDE_OUTPUT();
}
} // namespace LAMMPS_NS

View File

@ -25,7 +25,7 @@
using ::testing::Eq;
char *BINARY2TXT_BINARY = nullptr;
char *BINARY2TXT_EXECUTABLE = nullptr;
bool verbose = false;
class DumpAtomTest : public MeltTest {
@ -100,7 +100,7 @@ public:
std::string convert_binary_to_text(std::string binary_file)
{
BEGIN_HIDE_OUTPUT();
std::string cmdline = fmt::format("{} {}", BINARY2TXT_BINARY, binary_file);
std::string cmdline = fmt::format("\"{}\" {}", BINARY2TXT_EXECUTABLE, binary_file);
system(cmdline.c_str());
END_HIDE_OUTPUT();
return fmt::format("{}.txt", binary_file);
@ -328,7 +328,7 @@ TEST_F(DumpAtomTest, triclinic_with_image_run0)
TEST_F(DumpAtomTest, binary_run0)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_EXECUTABLE) GTEST_SKIP();
auto text_file = text_dump_filename("run0");
auto binary_file = binary_dump_filename("run0");
@ -349,7 +349,7 @@ TEST_F(DumpAtomTest, binary_run0)
TEST_F(DumpAtomTest, binary_with_units_run0)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_EXECUTABLE) GTEST_SKIP();
auto text_file = text_dump_filename("with_units_run0");
auto binary_file = binary_dump_filename("with_units_run0");
@ -370,7 +370,7 @@ TEST_F(DumpAtomTest, binary_with_units_run0)
TEST_F(DumpAtomTest, binary_with_time_run0)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_EXECUTABLE) GTEST_SKIP();
auto text_file = text_dump_filename("with_time_run0");
auto binary_file = binary_dump_filename("with_time_run0");
@ -391,7 +391,7 @@ TEST_F(DumpAtomTest, binary_with_time_run0)
TEST_F(DumpAtomTest, binary_triclinic_run0)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_EXECUTABLE) GTEST_SKIP();
auto text_file = text_dump_filename("tri_run0");
auto binary_file = binary_dump_filename("tri_run0");
@ -413,7 +413,7 @@ TEST_F(DumpAtomTest, binary_triclinic_run0)
TEST_F(DumpAtomTest, binary_triclinic_with_units_run0)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_EXECUTABLE) GTEST_SKIP();
auto text_file = text_dump_filename("tri_with_units_run0");
auto binary_file = binary_dump_filename("tri_with_units_run0");
@ -435,7 +435,7 @@ TEST_F(DumpAtomTest, binary_triclinic_with_units_run0)
TEST_F(DumpAtomTest, binary_triclinic_with_time_run0)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_EXECUTABLE) GTEST_SKIP();
auto text_file = text_dump_filename("tri_with_time_run0");
auto binary_file = binary_dump_filename("tri_with_time_run0");
@ -457,7 +457,7 @@ TEST_F(DumpAtomTest, binary_triclinic_with_time_run0)
TEST_F(DumpAtomTest, binary_triclinic_with_image_run0)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_EXECUTABLE) GTEST_SKIP();
auto text_file = text_dump_filename("tri_with_image_run0");
auto binary_file = binary_dump_filename("tri_with_image_run0");
@ -649,7 +649,7 @@ TEST_F(DumpAtomTest, write_dump)
TEST_F(DumpAtomTest, binary_write_dump)
{
if (!BINARY2TXT_BINARY) GTEST_SKIP();
if (!BINARY2TXT_EXECUTABLE) GTEST_SKIP();
auto reference = binary_dump_filename("write_run0_ref");
auto dump_file = fmt::format("write_{}", binary_dump_filename("write_dump_atom_run*_p%"));
@ -693,7 +693,7 @@ int main(int argc, char **argv)
}
}
BINARY2TXT_BINARY = getenv("BINARY2TXT_BINARY");
BINARY2TXT_EXECUTABLE = getenv("BINARY2TXT_EXECUTABLE");
if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) verbose = true;

Some files were not shown because too many files have changed in this diff Show More