Merge pull request #3725 from akohlmey/collected-small-changes

Collected small changes and fixes
This commit is contained in:
Axel Kohlmeyer
2023-04-10 13:53:16 -04:00
committed by GitHub
21 changed files with 1091 additions and 892 deletions

View File

@ -152,7 +152,7 @@ endfunction(FetchPotentials)
# set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux # set CMAKE_LINUX_DISTRO and CMAKE_DISTRO_VERSION on Linux
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (EXISTS /etc/os-release)) if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (EXISTS /etc/os-release))
file(STRINGS /etc/os-release distro REGEX "^NAME=") file(STRINGS /etc/os-release distro REGEX "^NAME=")
string(REGEX REPLACE "NAME=\"?([^\"]*)\"?" "\\1" distro "${distro}") string(REGEX REPLACE "NAME=\"?([^ ]+).*\"?" "\\1" distro "${distro}")
file(STRINGS /etc/os-release disversion REGEX "^VERSION_ID=") file(STRINGS /etc/os-release disversion REGEX "^VERSION_ID=")
string(REGEX REPLACE "VERSION_ID=\"?([^\"]*)\"?" "\\1" disversion "${disversion}") string(REGEX REPLACE "VERSION_ID=\"?([^\"]*)\"?" "\\1" disversion "${disversion}")
set(CMAKE_LINUX_DISTRO ${distro}) set(CMAKE_LINUX_DISTRO ${distro})

View File

@ -1,3 +1,83 @@
# Plumed2 support for PLUMED package
if(BUILD_MPI)
set(PLUMED_CONFIG_MPI "--enable-mpi")
set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER})
set(PLUMED_CONFIG_CXX ${CMAKE_MPI_CXX_COMPILER})
set(PLUMED_CONFIG_CPP "-I ${MPI_CXX_INCLUDE_PATH}")
set(PLUMED_CONFIG_LIB "${MPI_CXX_LIBRARIES}")
set(PLUMED_CONFIG_DEP "mpi4win_build")
else()
set(PLUMED_CONFIG_MPI "--disable-mpi")
set(PLUMED_CONFIG_CC ${CMAKE_C_COMPILER})
set(PLUMED_CONFIG_CXX ${CMAKE_CXX_COMPILER})
set(PLUMED_CONFIG_CPP "")
set(PLUMED_CONFIG_LIB "")
set(PLUMED_CONFIG_DEP "")
endif()
if(BUILD_OMP)
set(PLUMED_CONFIG_OMP "--enable-openmp")
else()
set(PLUMED_CONFIG_OMP "--disable-openmp")
endif()
set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.8.2/plumed-src-2.8.2.tgz"
CACHE STRING "URL for PLUMED tarball")
set(PLUMED_MD5 "599092b6a0aa6fff992612537ad98994" CACHE STRING "MD5 checksum of PLUMED tarball")
mark_as_advanced(PLUMED_URL)
mark_as_advanced(PLUMED_MD5)
GetFallbackURL(PLUMED_URL PLUMED_FALLBACK)
if((CMAKE_SYSTEM_NAME STREQUAL "Windows") AND (CMAKE_CROSSCOMPILING))
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(CROSS_CONFIGURE mingw64-configure)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86")
set(CROSS_CONFIGURE mingw32-configure)
else()
message(FATAL_ERROR "Unsupported target system: ${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR}")
endif()
message(STATUS "Downloading and cross-compiling Plumed2 for ${CMAKE_SYSTEM_NAME}/${CMAKE_SYSTEM_PROCESSOR} with ${CROSS_CONFIGURE}")
include(ExternalProject)
ExternalProject_Add(plumed_build
URL ${PLUMED_URL} ${PLUMED_FALLBACK}
URL_MD5 ${PLUMED_MD5}
BUILD_IN_SOURCE 1
CONFIGURE_COMMAND ${CROSS_CONFIGURE} --disable-shared --disable-bsymbolic
--disable-python --enable-cxx=11
--enable-modules=-adjmat:+crystallization:-dimred:+drr:+eds:-fisst:+funnel:+logmfd:+manyrestraints:+maze:+opes:+multicolvar:-pamm:-piv:+s2cm:-sasa:-ves
${PLUMED_CONFIG_OMP}
${PLUMED_CONFIG_MPI}
CXX=${PLUMED_CONFIG_CXX}
CC=${PLUMED_CONFIG_CC}
CPPFLAGS=${PLUMED_CONFIG_CPP}
LIBS=${PLUMED_CONFIG_LIB}
INSTALL_COMMAND ""
BUILD_BYPRODUCTS "<SOURCE_DIR>/src/lib/install/libplumed.a" "<SOURCE_DIR>/src/lib/install/plumed.exe"
DEPENDS "${PLUMED_MPI_CONFIG_DEP}"
)
ExternalProject_Get_Property(plumed_build SOURCE_DIR)
set(PLUMED_BUILD_DIR ${SOURCE_DIR})
set(PLUMED_INSTALL_DIR ${PLUMED_BUILD_DIR}/src/lib/install)
file(MAKE_DIRECTORY ${PLUMED_BUILD_DIR}/src/include)
add_library(LAMMPS::PLUMED UNKNOWN IMPORTED)
add_dependencies(LAMMPS::PLUMED plumed_build)
set_target_properties(LAMMPS::PLUMED PROPERTIES
IMPORTED_LOCATION "${PLUMED_INSTALL_DIR}/libplumed.a"
INTERFACE_LINK_LIBRARIES "-Wl,--image-base -Wl,0x10000000 -lfftw3 -lz -fstack-protector -lssp -fopenmp"
INTERFACE_INCLUDE_DIRECTORIES "${PLUMED_BUILD_DIR}/src/include")
add_custom_target(plumed_copy ALL ${CMAKE_COMMAND} -E rm -rf ${CMAKE_BINARY_DIR}/plumed.exe ${CMAKE_BINARY_DIR}/plumed_patches
COMMAND ${CMAKE_COMMAND} -E copy ${PLUMED_INSTALL_DIR}/plumed.exe ${CMAKE_BINARY_DIR}/plumed.exe
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PLUMED_BUILD_DIR}/patches ${CMAKE_BINARY_DIR}/patches
BYPRODUCTS ${CMAKE_BINARY_DIR}/plumed.exe ${CMAKE_BINARY_DIR}/patches
DEPENDS plumed_build
COMMENT "Copying Plumed files"
)
else()
set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library") set(PLUMED_MODE "static" CACHE STRING "Linkage mode for Plumed2 library")
set(PLUMED_MODE_VALUES static shared runtime) set(PLUMED_MODE_VALUES static shared runtime)
set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES}) set_property(CACHE PLUMED_MODE PROPERTY STRINGS ${PLUMED_MODE_VALUES})
@ -31,20 +111,6 @@ endif()
option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${DOWNLOAD_PLUMED_DEFAULT}) option(DOWNLOAD_PLUMED "Download Plumed package instead of using an already installed one" ${DOWNLOAD_PLUMED_DEFAULT})
if(DOWNLOAD_PLUMED) if(DOWNLOAD_PLUMED)
if(BUILD_MPI)
set(PLUMED_CONFIG_MPI "--enable-mpi")
set(PLUMED_CONFIG_CC ${CMAKE_MPI_C_COMPILER})
set(PLUMED_CONFIG_CXX ${CMAKE_MPI_CXX_COMPILER})
else()
set(PLUMED_CONFIG_MPI "--disable-mpi")
set(PLUMED_CONFIG_CC ${CMAKE_C_COMPILER})
set(PLUMED_CONFIG_CXX ${CMAKE_CXX_COMPILER})
endif()
if(BUILD_OMP)
set(PLUMED_CONFIG_OMP "--enable-openmp")
else()
set(PLUMED_CONFIG_OMP "--disable-openmp")
endif()
message(STATUS "PLUMED download requested - we will build our own") message(STATUS "PLUMED download requested - we will build our own")
if(PLUMED_MODE STREQUAL "STATIC") if(PLUMED_MODE STREQUAL "STATIC")
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/${CMAKE_STATIC_LIBRARY_PREFIX}plumed${CMAKE_STATIC_LIBRARY_SUFFIX}") set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/${CMAKE_STATIC_LIBRARY_PREFIX}plumed${CMAKE_STATIC_LIBRARY_SUFFIX}")
@ -54,13 +120,6 @@ if(DOWNLOAD_PLUMED)
set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/${CMAKE_STATIC_LIBRARY_PREFIX}plumedWrapper${CMAKE_STATIC_LIBRARY_PREFIX}") set(PLUMED_BUILD_BYPRODUCTS "<INSTALL_DIR>/lib/${CMAKE_STATIC_LIBRARY_PREFIX}plumedWrapper${CMAKE_STATIC_LIBRARY_PREFIX}")
endif() endif()
set(PLUMED_URL "https://github.com/plumed/plumed2/releases/download/v2.8.2/plumed-src-2.8.2.tgz" CACHE STRING "URL for PLUMED tarball")
set(PLUMED_MD5 "599092b6a0aa6fff992612537ad98994" CACHE STRING "MD5 checksum of PLUMED tarball")
mark_as_advanced(PLUMED_URL)
mark_as_advanced(PLUMED_MD5)
GetFallbackURL(PLUMED_URL PLUMED_FALLBACK)
include(ExternalProject) include(ExternalProject)
ExternalProject_Add(plumed_build ExternalProject_Add(plumed_build
URL ${PLUMED_URL} ${PLUMED_FALLBACK} URL ${PLUMED_URL} ${PLUMED_FALLBACK}
@ -69,6 +128,8 @@ if(DOWNLOAD_PLUMED)
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR> CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
${CONFIGURE_REQUEST_PIC} ${CONFIGURE_REQUEST_PIC}
--enable-modules=all --enable-modules=all
--enable-cxx=11
--disable-python
${PLUMED_CONFIG_MPI} ${PLUMED_CONFIG_MPI}
${PLUMED_CONFIG_OMP} ${PLUMED_CONFIG_OMP}
CXX=${PLUMED_CONFIG_CXX} CXX=${PLUMED_CONFIG_CXX}
@ -103,4 +164,6 @@ else()
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_LINK_LIBRARIES "${PLUMED_LOAD}") set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_LINK_LIBRARIES "${PLUMED_LOAD}")
set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PLUMED_INCLUDE_DIRS}") set_target_properties(LAMMPS::PLUMED PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${PLUMED_INCLUDE_DIRS}")
endif() endif()
endif()
target_link_libraries(lammps PRIVATE LAMMPS::PLUMED) target_link_libraries(lammps PRIVATE LAMMPS::PLUMED)

View File

@ -18,29 +18,33 @@ if(ENABLE_TESTING)
# we need to build and link a LOT of tester executables, so it is worth checking if # we need to build and link a LOT of tester executables, so it is worth checking if
# a faster linker is available. requires GNU or Clang compiler, newer CMake. # a faster linker is available. requires GNU or Clang compiler, newer CMake.
# also only verified with Fedora Linux > 30 and Ubuntu <= 18.04 (Ubuntu 20.04 fails) # also only verified with Fedora Linux > 30 and Ubuntu 18.04 or 22.04+(Ubuntu 20.04 fails)
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13) if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
AND ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")))
OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))) if(((CMAKE_LINUX_DISTRO STREQUAL "Ubuntu") AND
if(((CMAKE_LINUX_DISTRO STREQUAL "Ubuntu") AND (CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04)) ((CMAKE_DISTRO_VERSION VERSION_LESS_EQUAL 18.04) OR (CMAKE_DISTRO_VERSION VERSION_GREATER_EQUAL 22.04)))
OR ((CMAKE_LINUX_DISTRO STREQUAL "Fedora") AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30))) OR ((CMAKE_LINUX_DISTRO STREQUAL "Fedora") AND (CMAKE_DISTRO_VERSION VERSION_GREATER 30)))
include(CheckCXXCompilerFlag) include(CheckCXXCompilerFlag)
set(CMAKE_CUSTOM_LINKER_DEFAULT default) set(CMAKE_CUSTOM_LINKER_DEFAULT default)
check_cxx_compiler_flag(-fuse-ld=mold HAVE_MOLD_LINKER_FLAG)
check_cxx_compiler_flag(-fuse-ld=lld HAVE_LLD_LINKER_FLAG) check_cxx_compiler_flag(-fuse-ld=lld HAVE_LLD_LINKER_FLAG)
check_cxx_compiler_flag(-fuse-ld=gold HAVE_GOLD_LINKER_FLAG) check_cxx_compiler_flag(-fuse-ld=gold HAVE_GOLD_LINKER_FLAG)
check_cxx_compiler_flag(-fuse-ld=bfd HAVE_BFD_LINKER_FLAG) check_cxx_compiler_flag(-fuse-ld=bfd HAVE_BFD_LINKER_FLAG)
find_program(HAVE_MOLD_LINKER_BIN ld.mold)
find_program(HAVE_LLD_LINKER_BIN lld ld.lld) find_program(HAVE_LLD_LINKER_BIN lld ld.lld)
find_program(HAVE_GOLD_LINKER_BIN ld.gold) find_program(HAVE_GOLD_LINKER_BIN ld.gold)
find_program(HAVE_BFD_LINKER_BIN ld.bfd) find_program(HAVE_BFD_LINKER_BIN ld.bfd)
if(HAVE_LLD_LINKER_FLAG AND HAVE_LLD_LINKER_BIN) if(HAVE_MOLD_LINKER_FLAG AND HAVE_MOLD_LINKER_BIN)
set(CMAKE_CUSTOM_LINKER_DEFAULT mold)
elseif(HAVE_LLD_LINKER_FLAG AND HAVE_LLD_LINKER_BIN)
set(CMAKE_CUSTOM_LINKER_DEFAULT lld) set(CMAKE_CUSTOM_LINKER_DEFAULT lld)
elseif(HAVE_GOLD_LINKER_FLAG AND HAVE_GOLD_LINKER_BIN) elseif(HAVE_GOLD_LINKER_FLAG AND HAVE_GOLD_LINKER_BIN)
set(CMAKE_CUSTOM_LINKER_DEFAULT gold) set(CMAKE_CUSTOM_LINKER_DEFAULT gold)
elseif(HAVE_BFD_LINKER_FLAG AND HAVE_BFD_LINKER_BIN) elseif(HAVE_BFD_LINKER_FLAG AND HAVE_BFD_LINKER_BIN)
set(CMAKE_CUSTOM_LINKER_DEFAULT bfd) set(CMAKE_CUSTOM_LINKER_DEFAULT bfd)
endif() endif()
set(CMAKE_CUSTOM_LINKER_VALUES lld gold bfd default) set(CMAKE_CUSTOM_LINKER_VALUES mold lld gold bfd default)
set(CMAKE_CUSTOM_LINKER ${CMAKE_CUSTOM_LINKER_DEFAULT} CACHE STRING "Choose a custom linker for faster linking (lld, gold, bfd, default)") set(CMAKE_CUSTOM_LINKER ${CMAKE_CUSTOM_LINKER_DEFAULT} CACHE STRING "Choose a custom linker for faster linking (mold, lld, gold, bfd, default)")
validate_option(CMAKE_CUSTOM_LINKER CMAKE_CUSTOM_LINKER_VALUES) validate_option(CMAKE_CUSTOM_LINKER CMAKE_CUSTOM_LINKER_VALUES)
mark_as_advanced(CMAKE_CUSTOM_LINKER) mark_as_advanced(CMAKE_CUSTOM_LINKER)
if(NOT "${CMAKE_CUSTOM_LINKER}" STREQUAL "default") if(NOT "${CMAKE_CUSTOM_LINKER}" STREQUAL "default")

View File

@ -683,20 +683,11 @@ This list was last updated for version 3.7.1 of the Kokkos library.
-D Kokkos_ARCH_GPUARCH=yes # GPUARCH = GPU from list above -D Kokkos_ARCH_GPUARCH=yes # GPUARCH = GPU from list above
-D Kokkos_ENABLE_CUDA=yes -D Kokkos_ENABLE_CUDA=yes
-D Kokkos_ENABLE_OPENMP=yes -D Kokkos_ENABLE_OPENMP=yes
-D CMAKE_CXX_COMPILER=wrapper # wrapper = full path to Cuda nvcc wrapper
This will also enable executing FFTs on the GPU, either via the This will also enable executing FFTs on the GPU, either via the
internal KISSFFT library, or - by preference - with the cuFFT internal KISSFFT library, or - by preference - with the cuFFT
library bundled with the CUDA toolkit, depending on whether CMake library bundled with the CUDA toolkit, depending on whether CMake
can identify its location. The *wrapper* value for can identify its location.
``CMAKE_CXX_COMPILER`` variable is the path to the CUDA nvcc
compiler wrapper provided in the Kokkos library:
``lib/kokkos/bin/nvcc_wrapper``\ . The setting should include the
full path name to the wrapper, e.g.
.. code-block:: bash
-D CMAKE_CXX_COMPILER=${HOME}/lammps/lib/kokkos/bin/nvcc_wrapper
For AMD or NVIDIA GPUs using HIP, set these variables: For AMD or NVIDIA GPUs using HIP, set these variables:

View File

@ -71,9 +71,9 @@ Examples
fix 1 all wall/gran hooke 200000.0 NULL 50.0 NULL 0.5 0 xplane -10.0 10.0 fix 1 all wall/gran hooke 200000.0 NULL 50.0 NULL 0.5 0 xplane -10.0 10.0
fix 1 all wall/gran hooke/history 200000.0 NULL 50.0 NULL 0.5 0 zplane 0.0 NULL fix 1 all wall/gran hooke/history 200000.0 NULL 50.0 NULL 0.5 0 zplane 0.0 NULL
fix 2 all wall/gran hooke 100000.0 20000.0 50.0 30.0 0.5 1 zcylinder 15.0 wiggle z 3.0 2.0 fix 2 all wall/gran hooke 100000.0 20000.0 50.0 30.0 0.5 1 zcylinder 15.0 wiggle z 3.0 2.0
fix 3 all wall/gran/region granular hooke 1000.0 50.0 tangential linear_nohistory 1.0 0.4 damping velocity region myBox fix 3 all wall/gran granular hooke 1000.0 50.0 tangential linear_nohistory 1.0 0.4 damping velocity region myBox
fix 4 all wall/gran/region granular jkr 1e5 1500.0 0.3 10.0 tangential mindlin NULL 1.0 0.5 rolling sds 500.0 200.0 0.5 twisting marshall region myCone fix 4 all wall/gran granular jkr 1e5 1500.0 0.3 10.0 tangential mindlin NULL 1.0 0.5 rolling sds 500.0 200.0 0.5 twisting marshall region myCone
fix 5 all wall/gran/region granular dmt 1e5 0.2 0.3 10.0 tangential mindlin NULL 1.0 0.5 rolling sds 500.0 200.0 0.5 twisting marshall damping tsuji heat 10 region myCone temperature 1.0 fix 5 all wall/gran granular dmt 1e5 0.2 0.3 10.0 tangential mindlin NULL 1.0 0.5 rolling sds 500.0 200.0 0.5 twisting marshall damping tsuji heat 10 region myCone temperature 1.0
fix 6 all wall/gran hooke 200000.0 NULL 50.0 NULL 0.5 0 xplane -10.0 10.0 contacts fix 6 all wall/gran hooke 200000.0 NULL 50.0 NULL 0.5 0 xplane -10.0 10.0 contacts
Description Description

View File

@ -93,7 +93,7 @@ with :math:`A_{ss}` set appropriately, which results from letting both
particle sizes go to zero. particle sizes go to zero.
When used in combination with :doc:`pair_style yukawa/colloid When used in combination with :doc:`pair_style yukawa/colloid
<pair_colloid>`, the two terms become the so-called DLVO potential, <pair_yukawa_colloid>`, the two terms become the so-called DLVO potential,
which combines electrostatic repulsion and van der Waals attraction. which combines electrostatic repulsion and van der Waals attraction.
The following coefficients must be defined for each pair of atoms The following coefficients must be defined for each pair of atoms

View File

@ -86,7 +86,6 @@ class LinearModel():
energy[:] = bispectrum @ self.weights + self.bias energy[:] = bispectrum @ self.weights + self.bias
beta[:] = self.weights beta[:] = self.weights
mymodel = LinearModel("Ta06A.mliap.model") mymodel = LinearModel("Ta06A.mliap.model")
import lammps import lammps
@ -98,4 +97,5 @@ lammps.mliap.activate_mliappy(lmp)
lmp.commands_string(before_loading) lmp.commands_string(before_loading)
lammps.mliap.load_model(mymodel) lammps.mliap.load_model(mymodel)
lmp.commands_string(after_loading) lmp.commands_string(after_loading)
lmp.close()
lmp.finalize()

View File

@ -106,3 +106,5 @@ lammps.mliap.load_model(model)
# run the simulation with the mliap pair style # run the simulation with the mliap pair style
lmp.commands_string(after_loading) lmp.commands_string(after_loading)
lmp.close()
lmp.finalize()

View File

@ -106,3 +106,5 @@ lammps.mliap.load_model_kokkos(model)
# run the simulation with the mliap pair style # run the simulation with the mliap pair style
lmp.commands_string(after_loading) lmp.commands_string(after_loading)
lmp.close()
lmp.finalize()

View File

@ -63,3 +63,5 @@ lammps.mliap.load_unified(unified)
# Run the simulation with the mliap unified pair style # Run the simulation with the mliap unified pair style
# Use pre-loaded model by specifying model filename as "EXISTS" # Use pre-loaded model by specifying model filename as "EXISTS"
lmp.commands_string(after_loading) lmp.commands_string(after_loading)
lmp.close()
lmp.finalize()

View File

@ -38,6 +38,8 @@ PairBornGauss::PairBornGauss(LAMMPS *lmp) :
single_enable = 1; single_enable = 1;
respa_enable = 0; respa_enable = 0;
writedata = 1; writedata = 1;
cut_global = 0.0;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -1873,8 +1873,7 @@ void PairBOP::read_table(char *filename)
reader = new PotentialFileReader(lmp, filename, "BOP"); reader = new PotentialFileReader(lmp, filename, "BOP");
bop_types = reader->next_int(); bop_types = reader->next_int();
if (bop_types <= 0) if (bop_types <= 0)
error->one(FLERR,fmt::format("BOP potential file with {} " error->one(FLERR,fmt::format("BOP potential file with {} elements",bop_types));
"elements",bop_types));
bop_elements = new char*[bop_types]; bop_elements = new char*[bop_types];
bop_masses = new double[bop_types]; bop_masses = new double[bop_types];

View File

@ -160,7 +160,12 @@ FixChargeRegulation::~FixChargeRegulation() {
if (exclusion_group_bit && group) { if (exclusion_group_bit && group) {
auto group_id = std::string("FixChargeRegulation:gcmc_exclusion_group:") + id; auto group_id = std::string("FixChargeRegulation:gcmc_exclusion_group:") + id;
try {
group->assign(group_id + " delete"); group->assign(group_id + " delete");
} catch (std::exception &e) {
if (comm->me == 0)
fprintf(stderr, "Error deleting group %s: %s\n", group_id.c_str(), e.what());
}
} }
if (group) { if (group) {

View File

@ -427,12 +427,22 @@ FixGCMC::~FixGCMC()
if (exclusion_group_bit && group) { if (exclusion_group_bit && group) {
auto group_id = std::string("FixGCMC:gcmc_exclusion_group:") + id; auto group_id = std::string("FixGCMC:gcmc_exclusion_group:") + id;
try {
group->assign(group_id + " delete"); group->assign(group_id + " delete");
} catch (std::exception &e) {
if (comm->me == 0)
fprintf(stderr, "Error deleting group %s: %s\n", group_id.c_str(), e.what());
}
} }
if (molecule_group_bit && group) { if (molecule_group_bit && group) {
auto group_id = std::string("FixGCMC:rotation_gas_atoms:") + id; auto group_id = std::string("FixGCMC:rotation_gas_atoms:") + id;
try {
group->assign(group_id + " delete"); group->assign(group_id + " delete");
} catch (std::exception &e) {
if (comm->me == 0)
fprintf(stderr, "Error deleting group %s: %s\n", group_id.c_str(), e.what());
}
} }
if (full_flag && group && neighbor) { if (full_flag && group && neighbor) {

View File

@ -255,12 +255,22 @@ FixWidom::~FixWidom()
if (exclusion_group_bit && group) { if (exclusion_group_bit && group) {
auto group_id = std::string("FixWidom:widom_exclusion_group:") + id; auto group_id = std::string("FixWidom:widom_exclusion_group:") + id;
try {
group->assign(group_id + " delete"); group->assign(group_id + " delete");
} catch (std::exception &e) {
if (comm->me == 0)
fprintf(stderr, "Error deleting group %s: %s\n", group_id.c_str(), e.what());
}
} }
if (molecule_group_bit && group) { if (molecule_group_bit && group) {
auto group_id = std::string("FixWidom:rotation_gas_atoms:") + id; auto group_id = std::string("FixWidom:rotation_gas_atoms:") + id;
try {
group->assign(group_id + " delete"); group->assign(group_id + " delete");
} catch (std::exception &e) {
if (comm->me == 0)
fprintf(stderr, "Error deleting group %s: %s\n", group_id.c_str(), e.what());
}
} }
if (full_flag && group && neighbor) { if (full_flag && group && neighbor) {

View File

@ -31,8 +31,8 @@
#include "respa.h" #include "respa.h"
#include "update.h" #include "update.h"
#include <cmath>
#include <cctype> #include <cctype>
#include <cmath>
#include <cstring> #include <cstring>
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -47,15 +47,15 @@ static constexpr double MASSDELTA = 0.1;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) : FixShake::FixShake(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), bond_flag(nullptr), angle_flag(nullptr), Fix(lmp, narg, arg), bond_flag(nullptr), angle_flag(nullptr), type_flag(nullptr),
type_flag(nullptr), mass_list(nullptr), bond_distance(nullptr), angle_distance(nullptr), mass_list(nullptr), bond_distance(nullptr), angle_distance(nullptr), loop_respa(nullptr),
loop_respa(nullptr), step_respa(nullptr), x(nullptr), v(nullptr), f(nullptr), ftmp(nullptr), step_respa(nullptr), x(nullptr), v(nullptr), f(nullptr), ftmp(nullptr), vtmp(nullptr),
vtmp(nullptr), mass(nullptr), rmass(nullptr), type(nullptr), shake_flag(nullptr), mass(nullptr), rmass(nullptr), type(nullptr), shake_flag(nullptr), shake_atom(nullptr),
shake_atom(nullptr), shake_type(nullptr), xshake(nullptr), nshake(nullptr), list(nullptr), shake_type(nullptr), xshake(nullptr), nshake(nullptr), list(nullptr), closest_list(nullptr),
b_count(nullptr), b_count_all(nullptr), b_ave(nullptr), b_max(nullptr), b_min(nullptr), b_count(nullptr), b_count_all(nullptr), b_ave(nullptr), b_max(nullptr), b_min(nullptr),
b_ave_all(nullptr), b_max_all(nullptr), b_min_all(nullptr), a_count(nullptr), b_ave_all(nullptr), b_max_all(nullptr), b_min_all(nullptr), a_count(nullptr),
a_count_all(nullptr), a_ave(nullptr), a_max(nullptr), a_min(nullptr), a_ave_all(nullptr), a_count_all(nullptr), a_ave(nullptr), a_max(nullptr), a_min(nullptr), a_ave_all(nullptr),
a_max_all(nullptr), a_min_all(nullptr), atommols(nullptr), onemols(nullptr), closest_list(nullptr) a_max_all(nullptr), a_min_all(nullptr), atommols(nullptr), onemols(nullptr)
{ {
energy_global_flag = energy_peratom_flag = 1; energy_global_flag = energy_peratom_flag = 1;
virial_global_flag = virial_peratom_flag = 1; virial_global_flag = virial_peratom_flag = 1;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -26,98 +25,125 @@ using namespace LAMMPS_NS;
enum { CONSTANT, VARIABLE }; enum { CONSTANT, VARIABLE };
#define BIG 1.0e20 static constexpr double BIG = 1.0e20;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
RegBlock::RegBlock(LAMMPS *lmp, int narg, char **arg) : RegBlock::RegBlock(LAMMPS *lmp, int narg, char **arg) :
Region(lmp, narg, arg), xlostr(nullptr), xhistr(nullptr), ylostr(nullptr), yhistr(nullptr), zlostr(nullptr), zhistr(nullptr) Region(lmp, narg, arg), xlostr(nullptr), ylostr(nullptr), zlostr(nullptr), xhistr(nullptr),
yhistr(nullptr), zhistr(nullptr)
{ {
xlovar = xhivar = ylovar = yhivar = zlovar = zhivar = -1;
options(narg - 8, &arg[8]); options(narg - 8, &arg[8]);
xlostyle = CONSTANT; xlostyle = CONSTANT;
if (strcmp(arg[2], "INF") == 0 || strcmp(arg[2], "EDGE") == 0) { if (strcmp(arg[2], "INF") == 0 || strcmp(arg[2], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[2],"INF") == 0) xlo = -BIG; if (strcmp(arg[2], "INF") == 0)
else if (domain->triclinic == 0) xlo = domain->boxlo[0]; xlo = -BIG;
else xlo = domain->boxlo_bound[0]; else if (domain->triclinic == 0)
xlo = domain->boxlo[0];
else
xlo = domain->boxlo_bound[0];
} else if (utils::strmatch(arg[2], "^v_")) { } else if (utils::strmatch(arg[2], "^v_")) {
xlostr = utils::strdup(arg[2] + 2); xlostr = utils::strdup(arg[2] + 2);
xlo = 0.0; xlo = 0.0;
xlostyle = VARIABLE; xlostyle = VARIABLE;
varshape = 1; varshape = 1;
} else xlo = xscale*utils::numeric(FLERR,arg[2],false,lmp); } else
xlo = xscale * utils::numeric(FLERR, arg[2], false, lmp);
xhistyle = CONSTANT; xhistyle = CONSTANT;
if (strcmp(arg[3], "INF") == 0 || strcmp(arg[3], "EDGE") == 0) { if (strcmp(arg[3], "INF") == 0 || strcmp(arg[3], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[3],"INF") == 0) xhi = BIG; if (strcmp(arg[3], "INF") == 0)
else if (domain->triclinic == 0) xhi = domain->boxhi[0]; xhi = BIG;
else xhi = domain->boxhi_bound[0]; else if (domain->triclinic == 0)
xhi = domain->boxhi[0];
else
xhi = domain->boxhi_bound[0];
} else if (utils::strmatch(arg[3], "^v_")) { } else if (utils::strmatch(arg[3], "^v_")) {
xhistr = utils::strdup(arg[3] + 2); xhistr = utils::strdup(arg[3] + 2);
xhi = 0.0; xhi = 0.0;
xhistyle = VARIABLE; xhistyle = VARIABLE;
varshape = 1; varshape = 1;
} else xhi = xscale*utils::numeric(FLERR,arg[3],false,lmp); } else
xhi = xscale * utils::numeric(FLERR, arg[3], false, lmp);
ylostyle = CONSTANT; ylostyle = CONSTANT;
if (strcmp(arg[4], "INF") == 0 || strcmp(arg[4], "EDGE") == 0) { if (strcmp(arg[4], "INF") == 0 || strcmp(arg[4], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[4],"INF") == 0) ylo = -BIG; if (strcmp(arg[4], "INF") == 0)
else if (domain->triclinic == 0) ylo = domain->boxlo[1]; ylo = -BIG;
else ylo = domain->boxlo_bound[1]; else if (domain->triclinic == 0)
ylo = domain->boxlo[1];
else
ylo = domain->boxlo_bound[1];
} else if (utils::strmatch(arg[4], "^v_")) { } else if (utils::strmatch(arg[4], "^v_")) {
ylostr = utils::strdup(arg[4] + 2); ylostr = utils::strdup(arg[4] + 2);
ylo = 0.0; ylo = 0.0;
ylostyle = VARIABLE; ylostyle = VARIABLE;
varshape = 1; varshape = 1;
} else ylo = yscale*utils::numeric(FLERR,arg[4],false,lmp); } else
ylo = yscale * utils::numeric(FLERR, arg[4], false, lmp);
yhistyle = CONSTANT; yhistyle = CONSTANT;
if (strcmp(arg[5], "INF") == 0 || strcmp(arg[5], "EDGE") == 0) { if (strcmp(arg[5], "INF") == 0 || strcmp(arg[5], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[5],"INF") == 0) yhi = BIG; if (strcmp(arg[5], "INF") == 0)
else if (domain->triclinic == 0) yhi = domain->boxhi[1]; yhi = BIG;
else yhi = domain->boxhi_bound[1]; else if (domain->triclinic == 0)
yhi = domain->boxhi[1];
else
yhi = domain->boxhi_bound[1];
} else if (utils::strmatch(arg[5], "^v_")) { } else if (utils::strmatch(arg[5], "^v_")) {
yhistr = utils::strdup(arg[5] + 2); yhistr = utils::strdup(arg[5] + 2);
yhi = 0.0; yhi = 0.0;
yhistyle = VARIABLE; yhistyle = VARIABLE;
varshape = 1; varshape = 1;
} else yhi = yscale*utils::numeric(FLERR,arg[5],false,lmp); } else
yhi = yscale * utils::numeric(FLERR, arg[5], false, lmp);
zlostyle = CONSTANT; zlostyle = CONSTANT;
if (strcmp(arg[6], "INF") == 0 || strcmp(arg[6], "EDGE") == 0) { if (strcmp(arg[6], "INF") == 0 || strcmp(arg[6], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[6],"INF") == 0) zlo = -BIG; if (strcmp(arg[6], "INF") == 0)
else if (domain->triclinic == 0) zlo = domain->boxlo[2]; zlo = -BIG;
else zlo = domain->boxlo_bound[2]; else if (domain->triclinic == 0)
zlo = domain->boxlo[2];
else
zlo = domain->boxlo_bound[2];
} else if (utils::strmatch(arg[6], "^v_")) { } else if (utils::strmatch(arg[6], "^v_")) {
zlostr = utils::strdup(arg[6] + 2); zlostr = utils::strdup(arg[6] + 2);
zlo = 0.0; zlo = 0.0;
zlostyle = VARIABLE; zlostyle = VARIABLE;
varshape = 1; varshape = 1;
} else zlo = zscale*utils::numeric(FLERR,arg[6],false,lmp); } else
zlo = zscale * utils::numeric(FLERR, arg[6], false, lmp);
zhistyle = CONSTANT; zhistyle = CONSTANT;
if (strcmp(arg[7], "INF") == 0 || strcmp(arg[7], "EDGE") == 0) { if (strcmp(arg[7], "INF") == 0 || strcmp(arg[7], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[7],"INF") == 0) zhi = BIG; if (strcmp(arg[7], "INF") == 0)
else if (domain->triclinic == 0) zhi = domain->boxhi[2]; zhi = BIG;
else zhi = domain->boxhi_bound[2]; else if (domain->triclinic == 0)
zhi = domain->boxhi[2];
else
zhi = domain->boxhi_bound[2];
} else if (utils::strmatch(arg[7], "^v_")) { } else if (utils::strmatch(arg[7], "^v_")) {
zhistr = utils::strdup(arg[7] + 2); zhistr = utils::strdup(arg[7] + 2);
zhi = 0.0; zhi = 0.0;
zhistyle = VARIABLE; zhistyle = VARIABLE;
varshape = 1; varshape = 1;
} else zhi = zscale*utils::numeric(FLERR,arg[7],false,lmp); } else
zhi = zscale * utils::numeric(FLERR, arg[7], false, lmp);
if (varshape) { if (varshape) {
variable_check(); variable_check();
@ -140,15 +166,18 @@ RegBlock::RegBlock(LAMMPS *lmp, int narg, char **arg) :
extent_yhi = yhi; extent_yhi = yhi;
extent_zlo = zlo; extent_zlo = zlo;
extent_zhi = zhi; extent_zhi = zhi;
} else bboxflag = 0; } else
bboxflag = 0;
// particle could be close to all 6 planes // particle could be close to all 6 planes
// particle can only touch 3 planes // particle can only touch 3 planes
cmax = 6; cmax = 6;
contact = new Contact[cmax]; contact = new Contact[cmax];
if (interior) tmax = 3; if (interior)
else tmax = 1; tmax = 3;
else
tmax = 1;
// open face data structs // open face data structs
@ -259,8 +288,7 @@ void RegBlock::init()
int RegBlock::inside(double x, double y, double z) int RegBlock::inside(double x, double y, double z)
{ {
if (x >= xlo && x <= xhi && y >= ylo && y <= yhi && z >= zlo && z <= zhi) if (x >= xlo && x <= xhi && y >= ylo && y <= yhi && z >= zlo && z <= zhi) return 1;
return 1;
return 0; return 0;
} }
@ -277,8 +305,7 @@ int RegBlock::surface_interior(double *x, double cutoff)
// x is exterior to block // x is exterior to block
if (x[0] < xlo || x[0] > xhi || x[1] < ylo || x[1] > yhi || if (x[0] < xlo || x[0] > xhi || x[1] < ylo || x[1] > yhi || x[2] < zlo || x[2] > zhi) return 0;
x[2] < zlo || x[2] > zhi) return 0;
// x is interior to block or on its surface // x is interior to block or on its surface
@ -358,11 +385,10 @@ int RegBlock::surface_exterior(double *x, double cutoff)
// x is far enough from block that there is no contact // x is far enough from block that there is no contact
// x is interior to block // x is interior to block
if (x[0] <= xlo-cutoff || x[0] >= xhi+cutoff || if (x[0] <= xlo - cutoff || x[0] >= xhi + cutoff || x[1] <= ylo - cutoff ||
x[1] <= ylo-cutoff || x[1] >= yhi+cutoff || x[1] >= yhi + cutoff || x[2] <= zlo - cutoff || x[2] >= zhi + cutoff)
x[2] <= zlo-cutoff || x[2] >= zhi+cutoff) return 0; return 0;
if (x[0] > xlo && x[0] < xhi && x[1] > ylo && x[1] < yhi && if (x[0] > xlo && x[0] < xhi && x[1] > ylo && x[1] < yhi && x[2] > zlo && x[2] < zhi) return 0;
x[2] > zlo && x[2] < zhi) return 0;
// x is exterior to block or on its surface // x is exterior to block or on its surface
// xp,yp,zp = point on surface of block that x is closest to // xp,yp,zp = point on surface of block that x is closest to
@ -370,15 +396,24 @@ int RegBlock::surface_exterior(double *x, double cutoff)
// do not add contact point if r >= cutoff // do not add contact point if r >= cutoff
if (!openflag) { if (!openflag) {
if (x[0] < xlo) xp = xlo; if (x[0] < xlo)
else if (x[0] > xhi) xp = xhi; xp = xlo;
else xp = x[0]; else if (x[0] > xhi)
if (x[1] < ylo) yp = ylo; xp = xhi;
else if (x[1] > yhi) yp = yhi; else
else yp = x[1]; xp = x[0];
if (x[2] < zlo) zp = zlo; if (x[1] < ylo)
else if (x[2] > zhi) zp = zhi; yp = ylo;
else zp = x[2]; else if (x[1] > yhi)
yp = yhi;
else
yp = x[1];
if (x[2] < zlo)
zp = zlo;
else if (x[2] > zhi)
zp = zhi;
else
zp = x[2];
} else { } else {
mindist = BIG; mindist = BIG;
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
@ -405,23 +440,12 @@ int RegBlock::surface_exterior(double *x, double cutoff)
void RegBlock::shape_update() // addition void RegBlock::shape_update() // addition
{ {
if (xlostyle == VARIABLE) if (xlostyle == VARIABLE) xlo = xscale * input->variable->compute_equal(xlovar);
xlo = xscale * input->variable->compute_equal(xlovar); if (xhistyle == VARIABLE) xhi = xscale * input->variable->compute_equal(xhivar);
if (ylostyle == VARIABLE) ylo = yscale * input->variable->compute_equal(ylovar);
if (xhistyle == VARIABLE) if (yhistyle == VARIABLE) yhi = yscale * input->variable->compute_equal(yhivar);
xhi = xscale * input->variable->compute_equal(xhivar); if (zlostyle == VARIABLE) zlo = zscale * input->variable->compute_equal(zlovar);
if (zhistyle == VARIABLE) zhi = zscale * input->variable->compute_equal(zhivar);
if (ylostyle == VARIABLE)
ylo = yscale * input->variable->compute_equal(ylovar);
if (yhistyle == VARIABLE)
yhi = yscale * input->variable->compute_equal(yhivar);
if (zlostyle == VARIABLE)
zlo = zscale * input->variable->compute_equal(zlovar);
if (zhistyle == VARIABLE)
zhi = zscale * input->variable->compute_equal(zhivar);
if (xlo > xhi || ylo > yhi || zlo > zhi) if (xlo > xhi || ylo > yhi || zlo > zhi)
error->one(FLERR, "Variable evaluation in region gave bad value"); error->one(FLERR, "Variable evaluation in region gave bad value");
@ -493,50 +517,41 @@ void RegBlock::variable_check() // addition
{ {
if (xlostyle == VARIABLE) { if (xlostyle == VARIABLE) {
xlovar = input->variable->find(xlostr); xlovar = input->variable->find(xlostr);
if (xlovar < 0) if (xlovar < 0) error->all(FLERR, "Variable {} for region block does not exist", xlostr);
error->all(FLERR,"Variable name for region block does not exist");
if (!input->variable->equalstyle(xlovar)) if (!input->variable->equalstyle(xlovar))
error->all(FLERR,"Variable for region block is invalid style"); error->all(FLERR, "Variable {} for region block is invalid style", xlostr);
} }
if (xhistyle == VARIABLE) { if (xhistyle == VARIABLE) {
xhivar = input->variable->find(xhistr); xhivar = input->variable->find(xhistr);
if (xhivar < 0) if (xhivar < 0) error->all(FLERR, "Variable {} for region block does not exist", xhistr);
error->all(FLERR,"Variable name for region block does not exist");
if (!input->variable->equalstyle(xhivar)) if (!input->variable->equalstyle(xhivar))
error->all(FLERR,"Variable for region block is invalid style"); error->all(FLERR, "Variable {} for region block is invalid style", xhistr);
} }
if (ylostyle == VARIABLE) { if (ylostyle == VARIABLE) {
ylovar = input->variable->find(ylostr); ylovar = input->variable->find(ylostr);
if (ylovar < 0) if (ylovar < 0) error->all(FLERR, "Variable {} for region block does not exist", ylostr);
error->all(FLERR,"Variable name for region block does not exist");
if (!input->variable->equalstyle(ylovar)) if (!input->variable->equalstyle(ylovar))
error->all(FLERR,"Variable for region block is invalid style"); error->all(FLERR, "Variable {} for region block is invalid style", ylostr);
} }
if (yhistyle == VARIABLE) { if (yhistyle == VARIABLE) {
yhivar = input->variable->find(yhistr); yhivar = input->variable->find(yhistr);
if (yhivar < 0) if (yhivar < 0) error->all(FLERR, "Variable {} for region block does not exist", yhistr);
error->all(FLERR,"Variable name for region block does not exist");
if (!input->variable->equalstyle(yhivar)) if (!input->variable->equalstyle(yhivar))
error->all(FLERR,"Variable for region block is invalid style"); error->all(FLERR, "Variable {} for region block is invalid style", yhistr);
} }
if (zlostyle == VARIABLE) { if (zlostyle == VARIABLE) {
zlovar = input->variable->find(zlostr); zlovar = input->variable->find(zlostr);
if (zlovar < 0) if (zlovar < 0) error->all(FLERR, "Variable {} for region block does not exist", zlostr);
error->all(FLERR,"Variable name for region block does not exist");
if (!input->variable->equalstyle(zlovar)) if (!input->variable->equalstyle(zlovar))
error->all(FLERR,"Variable for region block is invalid style"); error->all(FLERR, "Variable {} for region block is invalid style", zlostr);
} }
if (zhistyle == VARIABLE) { if (zhistyle == VARIABLE) {
zhivar = input->variable->find(zhistr); zhivar = input->variable->find(zhistr);
if (zhivar < 0) if (zhivar < 0) error->all(FLERR, "Variable {} for region block does not exist", zhistr);
error->all(FLERR,"Variable name for region block does not exist");
if (!input->variable->equalstyle(zhivar)) if (!input->variable->equalstyle(zhivar))
error->all(FLERR,"Variable for region block is invalid style"); error->all(FLERR, "Variable {} for region block is invalid style", zhistr);
} }
} }
@ -545,8 +560,7 @@ void RegBlock::variable_check() // addition
store closest point in xc,yc,zc store closest point in xc,yc,zc
--------------------------------------------------------------------------*/ --------------------------------------------------------------------------*/
double RegBlock::find_closest_point(int i, double *x, double RegBlock::find_closest_point(int i, double *x, double &xc, double &yc, double &zc)
double &xc, double &yc, double &zc)
{ {
double dot, d2, d2min; double dot, d2, d2min;
double xr[3], xproj[3], p[3]; double xr[3], xproj[3], p[3];
@ -623,14 +637,12 @@ double RegBlock::find_closest_point(int i, double *x,
int RegBlock::inside_face(double *xproj, int iface) int RegBlock::inside_face(double *xproj, int iface)
{ {
if (iface < 2) { if (iface < 2) {
if (xproj[1] > 0 && (xproj[1] < yhi-ylo) && if (xproj[1] > 0 && (xproj[1] < yhi - ylo) && xproj[2] > 0 && (xproj[2] < zhi - zlo)) return 1;
xproj[2] > 0 && (xproj[2] < zhi-zlo)) return 1;
} else if (iface < 4) { } else if (iface < 4) {
if (xproj[0] > 0 && (xproj[0] < (xhi-xlo)) && if (xproj[0] > 0 && (xproj[0] < (xhi - xlo)) && xproj[2] > 0 && (xproj[2] < (zhi - zlo)))
xproj[2] > 0 && (xproj[2] < (zhi-zlo))) return 1; return 1;
} else { } else {
if (xproj[0] > 0 && xproj[0] < (xhi-xlo) && if (xproj[0] > 0 && xproj[0] < (xhi - xlo) && xproj[1] > 0 && xproj[1] < (yhi - ylo)) return 1;
xproj[1] > 0 && xproj[1] < (yhi-ylo)) return 1;
} }
return 0; return 0;

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -26,12 +25,11 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define BIG 1.0e20 static constexpr double BIG = 1.0e20;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
RegCone::RegCone(LAMMPS *lmp, int narg, char **arg) : RegCone::RegCone(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg), lo(0.0), hi(0.0)
Region(lmp, narg, arg), lo(0.0), hi(0.0)
{ {
options(narg - 9, &arg[9]); options(narg - 9, &arg[9]);
@ -66,19 +64,28 @@ RegCone::RegCone(LAMMPS *lmp, int narg, char **arg) :
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (axis == 'x') { if (axis == 'x') {
if (strcmp(arg[7],"INF") == 0) lo = -BIG; if (strcmp(arg[7], "INF") == 0)
else if (domain->triclinic == 0) lo = domain->boxlo[0]; lo = -BIG;
else lo = domain->boxlo_bound[0]; else if (domain->triclinic == 0)
lo = domain->boxlo[0];
else
lo = domain->boxlo_bound[0];
} }
if (axis == 'y') { if (axis == 'y') {
if (strcmp(arg[7],"INF") == 0) lo = -BIG; if (strcmp(arg[7], "INF") == 0)
else if (domain->triclinic == 0) lo = domain->boxlo[1]; lo = -BIG;
else lo = domain->boxlo_bound[1]; else if (domain->triclinic == 0)
lo = domain->boxlo[1];
else
lo = domain->boxlo_bound[1];
} }
if (axis == 'z') { if (axis == 'z') {
if (strcmp(arg[7],"INF") == 0) lo = -BIG; if (strcmp(arg[7], "INF") == 0)
else if (domain->triclinic == 0) lo = domain->boxlo[2]; lo = -BIG;
else lo = domain->boxlo_bound[2]; else if (domain->triclinic == 0)
lo = domain->boxlo[2];
else
lo = domain->boxlo_bound[2];
} }
} else { } else {
if (axis == 'x') lo = xscale * utils::numeric(FLERR, arg[7], false, lmp); if (axis == 'x') lo = xscale * utils::numeric(FLERR, arg[7], false, lmp);
@ -90,19 +97,27 @@ RegCone::RegCone(LAMMPS *lmp, int narg, char **arg) :
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (axis == 'x') { if (axis == 'x') {
if (strcmp(arg[8],"INF") == 0) hi = BIG; if (strcmp(arg[8], "INF") == 0)
else if (domain->triclinic == 0) hi = domain->boxhi[0]; hi = BIG;
else hi = domain->boxhi_bound[0]; else if (domain->triclinic == 0)
hi = domain->boxhi[0];
else
hi = domain->boxhi_bound[0];
} }
if (axis == 'y') { if (axis == 'y') {
if (strcmp(arg[8], "INF") == 0) hi = BIG; if (strcmp(arg[8], "INF") == 0) hi = BIG;
if (domain->triclinic == 0) hi = domain->boxhi[1]; if (domain->triclinic == 0)
else hi = domain->boxhi_bound[1]; hi = domain->boxhi[1];
else
hi = domain->boxhi_bound[1];
} }
if (axis == 'z') { if (axis == 'z') {
if (strcmp(arg[8],"INF") == 0) hi = BIG; if (strcmp(arg[8], "INF") == 0)
else if (domain->triclinic == 0) hi = domain->boxhi[2]; hi = BIG;
else hi = domain->boxhi_bound[2]; else if (domain->triclinic == 0)
hi = domain->boxhi[2];
else
hi = domain->boxhi_bound[2];
} }
} else { } else {
if (axis == 'x') hi = xscale * utils::numeric(FLERR, arg[8], false, lmp); if (axis == 'x') hi = xscale * utils::numeric(FLERR, arg[8], false, lmp);
@ -120,8 +135,10 @@ RegCone::RegCone(LAMMPS *lmp, int narg, char **arg) :
// extent of cone // extent of cone
if (radiuslo > radiushi) maxradius = radiuslo; if (radiuslo > radiushi)
else maxradius = radiushi; maxradius = radiuslo;
else
maxradius = radiushi;
if (interior) { if (interior) {
bboxflag = 1; bboxflag = 1;
@ -149,15 +166,18 @@ RegCone::RegCone(LAMMPS *lmp, int narg, char **arg) :
extent_zlo = lo; extent_zlo = lo;
extent_zhi = hi; extent_zhi = hi;
} }
} else bboxflag = 0; } else
bboxflag = 0;
// particle could be close to cone surface and 2 ends // particle could be close to cone surface and 2 ends
// particle can only touch surface and 1 end // particle can only touch surface and 1 end
cmax = 3; cmax = 3;
contact = new Contact[cmax]; contact = new Contact[cmax];
if (interior) tmax = 2; if (interior)
else tmax = 1; tmax = 2;
else
tmax = 1;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -182,22 +202,28 @@ int RegCone::inside(double x, double y, double z)
del2 = z - c2; del2 = z - c2;
dist = sqrt(del1 * del1 + del2 * del2); dist = sqrt(del1 * del1 + del2 * del2);
currentradius = radiuslo + (x - lo) * (radiushi - radiuslo) / (hi - lo); currentradius = radiuslo + (x - lo) * (radiushi - radiuslo) / (hi - lo);
if (dist <= currentradius && x >= lo && x <= hi) return 1; if (dist <= currentradius && x >= lo && x <= hi)
else return 0; return 1;
else
return 0;
} else if (axis == 'y') { } else if (axis == 'y') {
del1 = x - c1; del1 = x - c1;
del2 = z - c2; del2 = z - c2;
dist = sqrt(del1 * del1 + del2 * del2); dist = sqrt(del1 * del1 + del2 * del2);
currentradius = radiuslo + (y - lo) * (radiushi - radiuslo) / (hi - lo); currentradius = radiuslo + (y - lo) * (radiushi - radiuslo) / (hi - lo);
if (dist <= currentradius && y >= lo && y <= hi) return 1; if (dist <= currentradius && y >= lo && y <= hi)
else return 0; return 1;
else
return 0;
} else if (axis == 'z') { } else if (axis == 'z') {
del1 = x - c1; del1 = x - c1;
del2 = y - c2; del2 = y - c2;
dist = sqrt(del1 * del1 + del2 * del2); dist = sqrt(del1 * del1 + del2 * del2);
currentradius = radiuslo + (z - lo) * (radiushi - radiuslo) / (hi - lo); currentradius = radiuslo + (z - lo) * (radiushi - radiuslo) / (hi - lo);
if (dist <= currentradius && z >= lo && z <= hi) return 1; if (dist <= currentradius && z >= lo && z <= hi)
else return 0; return 1;
else
return 0;
} }
return 0; return 0;
@ -249,8 +275,7 @@ int RegCone::surface_interior(double *x, double cutoff)
contact[n].delx = delx; contact[n].delx = delx;
contact[n].dely = dely; contact[n].dely = dely;
contact[n].delz = delz; contact[n].delz = delz;
contact[n].radius = -2.0*(radiuslo + (xs[0]-lo)* contact[n].radius = -2.0 * (radiuslo + (xs[0] - lo) * (radiushi - radiuslo) / (hi - lo));
(radiushi-radiuslo)/(hi-lo));
contact[n].iwall = 2; contact[n].iwall = 2;
n++; n++;
} }
@ -279,8 +304,7 @@ int RegCone::surface_interior(double *x, double cutoff)
del1 = x[0] - c1; del1 = x[0] - c1;
del2 = x[2] - c2; del2 = x[2] - c2;
r = sqrt(del1 * del1 + del2 * del2); r = sqrt(del1 * del1 + del2 * del2);
currentradius = radiuslo + (x[1]-lo)* currentradius = radiuslo + (x[1] - lo) * (radiushi - radiuslo) / (hi - lo);
(radiushi-radiuslo)/(hi-lo);
// y is exterior to cone // y is exterior to cone
@ -308,8 +332,7 @@ int RegCone::surface_interior(double *x, double cutoff)
contact[n].dely = dely; contact[n].dely = dely;
contact[n].delz = delz; contact[n].delz = delz;
contact[n].iwall = 2; contact[n].iwall = 2;
contact[n].radius = -2.0*(radiuslo + (xs[1]-lo)* contact[n].radius = -2.0 * (radiuslo + (xs[1] - lo) * (radiushi - radiuslo) / (hi - lo));
(radiushi-radiuslo)/(hi-lo));
n++; n++;
} }
} }
@ -365,8 +388,7 @@ int RegCone::surface_interior(double *x, double cutoff)
contact[n].dely = dely; contact[n].dely = dely;
contact[n].delz = delz; contact[n].delz = delz;
contact[n].iwall = 2; contact[n].iwall = 2;
contact[n].radius = -2.0*(radiuslo + (xs[2]-lo)* contact[n].radius = -2.0 * (radiuslo + (xs[2] - lo) * (radiushi - radiuslo) / (hi - lo));
(radiushi-radiuslo)/(hi-lo));
n++; n++;
} }
} }
@ -418,8 +440,7 @@ int RegCone::surface_exterior(double *x, double cutoff)
// x is far enough from cone that there is no contact // x is far enough from cone that there is no contact
// x is interior to cone // x is interior to cone
if (r >= maxradius+cutoff || x[0] <= lo-cutoff || x[0] >= hi+cutoff) if (r >= maxradius + cutoff || x[0] <= lo - cutoff || x[0] >= hi + cutoff) return 0;
return 0;
if (r < currentradius && x[0] > lo && x[0] < hi) return 0; if (r < currentradius && x[0] > lo && x[0] < hi) return 0;
// x is exterior to cone or on its surface // x is exterior to cone or on its surface
@ -484,8 +505,7 @@ int RegCone::surface_exterior(double *x, double cutoff)
// y is far enough from cone that there is no contact // y is far enough from cone that there is no contact
// y is interior to cone // y is interior to cone
if (r >= maxradius+cutoff || if (r >= maxradius + cutoff || x[1] <= lo - cutoff || x[1] >= hi + cutoff) return 0;
x[1] <= lo-cutoff || x[1] >= hi+cutoff) return 0;
if (r < currentradius && x[1] > lo && x[1] < hi) return 0; if (r < currentradius && x[1] > lo && x[1] < hi) return 0;
// y is exterior to cone or on its surface // y is exterior to cone or on its surface
@ -549,8 +569,7 @@ int RegCone::surface_exterior(double *x, double cutoff)
// z is far enough from cone that there is no contact // z is far enough from cone that there is no contact
// z is interior to cone // z is interior to cone
if (r >= maxradius+cutoff || x[2] <= lo-cutoff || x[2] >= hi+cutoff) if (r >= maxradius + cutoff || x[2] <= lo - cutoff || x[2] >= hi + cutoff) return 0;
return 0;
if (r < currentradius && x[2] > lo && x[2] < hi) return 0; if (r < currentradius && x[2] > lo && x[2] < hi) return 0;
// z is exterior to cone or on its surface // z is exterior to cone or on its surface

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -25,7 +24,8 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define BIG 1.0e20 static constexpr double BIG = 1.0e20;
enum { CONSTANT, VARIABLE }; enum { CONSTANT, VARIABLE };
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -111,8 +111,10 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) :
varshape = 1; varshape = 1;
} else { } else {
radius = utils::numeric(FLERR, arg[5], false, lmp); radius = utils::numeric(FLERR, arg[5], false, lmp);
if (axis == 'x') radius *= yscale; if (axis == 'x')
else radius *= xscale; radius *= yscale;
else
radius *= xscale;
rstyle = CONSTANT; rstyle = CONSTANT;
} }
@ -125,19 +127,28 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) :
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (axis == 'x') { if (axis == 'x') {
if (strcmp(arg[6],"INF") == 0) lo = -BIG; if (strcmp(arg[6], "INF") == 0)
else if (domain->triclinic == 0) lo = domain->boxlo[0]; lo = -BIG;
else lo = domain->boxlo_bound[0]; else if (domain->triclinic == 0)
lo = domain->boxlo[0];
else
lo = domain->boxlo_bound[0];
} }
if (axis == 'y') { if (axis == 'y') {
if (strcmp(arg[6],"INF") == 0) lo = -BIG; if (strcmp(arg[6], "INF") == 0)
else if (domain->triclinic == 0) lo = domain->boxlo[1]; lo = -BIG;
else lo = domain->boxlo_bound[1]; else if (domain->triclinic == 0)
lo = domain->boxlo[1];
else
lo = domain->boxlo_bound[1];
} }
if (axis == 'z') { if (axis == 'z') {
if (strcmp(arg[6],"INF") == 0) lo = -BIG; if (strcmp(arg[6], "INF") == 0)
else if (domain->triclinic == 0) lo = domain->boxlo[2]; lo = -BIG;
else lo = domain->boxlo_bound[2]; else if (domain->triclinic == 0)
lo = domain->boxlo[2];
else
lo = domain->boxlo_bound[2];
} }
} else { } else {
if (axis == 'x') lo = xscale * utils::numeric(FLERR, arg[6], false, lmp); if (axis == 'x') lo = xscale * utils::numeric(FLERR, arg[6], false, lmp);
@ -149,19 +160,28 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) :
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (axis == 'x') { if (axis == 'x') {
if (strcmp(arg[7],"INF") == 0) hi = BIG; if (strcmp(arg[7], "INF") == 0)
else if (domain->triclinic == 0) hi = domain->boxhi[0]; hi = BIG;
else hi = domain->boxhi_bound[0]; else if (domain->triclinic == 0)
hi = domain->boxhi[0];
else
hi = domain->boxhi_bound[0];
} }
if (axis == 'y') { if (axis == 'y') {
if (strcmp(arg[7],"INF") == 0) hi = BIG; if (strcmp(arg[7], "INF") == 0)
else if (domain->triclinic == 0) hi = domain->boxhi[1]; hi = BIG;
else hi = domain->boxhi_bound[1]; else if (domain->triclinic == 0)
hi = domain->boxhi[1];
else
hi = domain->boxhi_bound[1];
} }
if (axis == 'z') { if (axis == 'z') {
if (strcmp(arg[7],"INF") == 0) hi = BIG; if (strcmp(arg[7], "INF") == 0)
else if (domain->triclinic == 0) hi = domain->boxhi[2]; hi = BIG;
else hi = domain->boxhi_bound[2]; else if (domain->triclinic == 0)
hi = domain->boxhi[2];
else
hi = domain->boxhi_bound[2];
} }
} else { } else {
if (axis == 'x') hi = xscale * utils::numeric(FLERR, arg[7], false, lmp); if (axis == 'x') hi = xscale * utils::numeric(FLERR, arg[7], false, lmp);
@ -202,15 +222,18 @@ RegCylinder::RegCylinder(LAMMPS *lmp, int narg, char **arg) :
extent_zlo = lo; extent_zlo = lo;
extent_zhi = hi; extent_zhi = hi;
} }
} else bboxflag = 0; } else
bboxflag = 0;
// particle could be close to cylinder surface and 2 ends // particle could be close to cylinder surface and 2 ends
// particle can only touch surface and 1 end // particle can only touch surface and 1 end
cmax = 3; cmax = 3;
contact = new Contact[cmax]; contact = new Contact[cmax];
if (interior) tmax = 2; if (interior)
else tmax = 1; tmax = 2;
else
tmax = 1;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -245,20 +268,26 @@ int RegCylinder::inside(double x, double y, double z)
del1 = y - c1; del1 = y - c1;
del2 = z - c2; del2 = z - c2;
dist = sqrt(del1 * del1 + del2 * del2); dist = sqrt(del1 * del1 + del2 * del2);
if (dist <= radius && x >= lo && x <= hi) inside = 1; if (dist <= radius && x >= lo && x <= hi)
else inside = 0; inside = 1;
else
inside = 0;
} else if (axis == 'y') { } else if (axis == 'y') {
del1 = x - c1; del1 = x - c1;
del2 = z - c2; del2 = z - c2;
dist = sqrt(del1 * del1 + del2 * del2); dist = sqrt(del1 * del1 + del2 * del2);
if (dist <= radius && y >= lo && y <= hi) inside = 1; if (dist <= radius && y >= lo && y <= hi)
else inside = 0; inside = 1;
else
inside = 0;
} else { } else {
del1 = x - c1; del1 = x - c1;
del2 = y - c2; del2 = y - c2;
dist = sqrt(del1 * del1 + del2 * del2); dist = sqrt(del1 * del1 + del2 * del2);
if (dist <= radius && z >= lo && z <= hi) inside = 1; if (dist <= radius && z >= lo && z <= hi)
else inside = 0; inside = 1;
else
inside = 0;
} }
return inside; return inside;
@ -456,9 +485,12 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
yp = x[1]; yp = x[1];
zp = x[2]; zp = x[2];
} }
if (x[0] < lo) xp = lo; if (x[0] < lo)
else if (x[0] > hi) xp = hi; xp = lo;
else xp = x[0]; else if (x[0] > hi)
xp = hi;
else
xp = x[0];
} else { } else {
@ -472,12 +504,10 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
if (x[0] < lo) { if (x[0] < lo) {
dx = lo - x[0]; dx = lo - x[0];
xp = lo; xp = lo;
} } else if (x[0] > hi) {
else if (x[0] > hi) {
dx = x[0] - hi; dx = x[0] - hi;
xp = hi; xp = hi;
} } else {
else {
dx = 0; dx = 0;
xp = x[0]; xp = x[0];
} }
@ -488,8 +518,10 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
if (!open_faces[0]) { if (!open_faces[0]) {
dx = lo - x[0]; dx = lo - x[0];
if (r < radius) d2 = dx*dx; if (r < radius)
else d2 = dr2 + dx*dx; d2 = dx * dx;
else
d2 = dr2 + dx * dx;
if (d2 < d2prev) { if (d2 < d2prev) {
xp = lo; xp = lo;
if (r < radius) { if (r < radius) {
@ -504,8 +536,10 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
if (!open_faces[1]) { if (!open_faces[1]) {
dx = hi - x[0]; dx = hi - x[0];
if (r < radius) d2 = dx*dx; if (r < radius)
else d2 = dr2 + dx*dx; d2 = dx * dx;
else
d2 = dr2 + dx * dx;
if (d2 < d2prev) { if (d2 < d2prev) {
xp = hi; xp = hi;
if (r < radius) { if (r < radius) {
@ -550,9 +584,12 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
xp = x[0]; xp = x[0];
zp = x[2]; zp = x[2];
} }
if (x[1] < lo) yp = lo; if (x[1] < lo)
else if (x[1] > hi) yp = hi; yp = lo;
else yp = x[1]; else if (x[1] > hi)
yp = hi;
else
yp = x[1];
} else { } else {
@ -566,12 +603,10 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
if (x[1] < lo) { if (x[1] < lo) {
dx = lo - x[1]; dx = lo - x[1];
yp = lo; yp = lo;
} } else if (x[1] > hi) {
else if (x[1] > hi) {
dx = x[1] - hi; dx = x[1] - hi;
yp = hi; yp = hi;
} } else {
else {
dx = 0; dx = 0;
yp = x[1]; yp = x[1];
} }
@ -582,8 +617,10 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
if (!open_faces[0]) { if (!open_faces[0]) {
dx = lo - x[1]; dx = lo - x[1];
if (r < radius) d2 = dx*dx; if (r < radius)
else d2 = dr2 + dx*dx; d2 = dx * dx;
else
d2 = dr2 + dx * dx;
if (d2 < d2prev) { if (d2 < d2prev) {
yp = lo; yp = lo;
if (r < radius) { if (r < radius) {
@ -598,8 +635,10 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
if (!open_faces[1]) { if (!open_faces[1]) {
dx = hi - x[1]; dx = hi - x[1];
if (r < radius) d2 = dx*dx; if (r < radius)
else d2 = dr2 + dx*dx; d2 = dx * dx;
else
d2 = dr2 + dx * dx;
if (d2 < d2prev) { if (d2 < d2prev) {
yp = hi; yp = hi;
if (r < radius) { if (r < radius) {
@ -644,9 +683,12 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
xp = x[0]; xp = x[0];
yp = x[1]; yp = x[1];
} }
if (x[2] < lo) zp = lo; if (x[2] < lo)
else if (x[2] > hi) zp = hi; zp = lo;
else zp = x[2]; else if (x[2] > hi)
zp = hi;
else
zp = x[2];
} else { } else {
@ -674,8 +716,10 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
if (!open_faces[0]) { if (!open_faces[0]) {
dx = lo - x[2]; dx = lo - x[2];
if (r < radius) d2 = dx*dx; if (r < radius)
else d2 = dr2 + dx*dx; d2 = dx * dx;
else
d2 = dr2 + dx * dx;
if (d2 < d2prev) { if (d2 < d2prev) {
zp = lo; zp = lo;
if (r < radius) { if (r < radius) {
@ -690,8 +734,10 @@ int RegCylinder::surface_exterior(double *x, double cutoff)
if (!open_faces[1]) { if (!open_faces[1]) {
dx = hi - x[2]; dx = hi - x[2];
if (r < radius) d2 = dx*dx; if (r < radius)
else d2 = dr2 + dx*dx; d2 = dx * dx;
else
d2 = dr2 + dx * dx;
if (d2 < d2prev) { if (d2 < d2prev) {
zp = hi; zp = hi;
if (r < radius) { if (r < radius) {
@ -721,8 +767,7 @@ void RegCylinder::shape_update()
if (c2style == VARIABLE) c2 = input->variable->compute_equal(c2var); if (c2style == VARIABLE) c2 = input->variable->compute_equal(c2var);
if (rstyle == VARIABLE) { if (rstyle == VARIABLE) {
radius = input->variable->compute_equal(rvar); radius = input->variable->compute_equal(rvar);
if (radius < 0.0) if (radius < 0.0) error->one(FLERR, "Variable evaluation in region gave bad value");
error->one(FLERR,"Variable evaluation in region gave bad value");
} }
if (axis == 'x') { if (axis == 'x') {
@ -748,30 +793,26 @@ void RegCylinder::variable_check()
{ {
if (c1style == VARIABLE) { if (c1style == VARIABLE) {
c1var = input->variable->find(c1str); c1var = input->variable->find(c1str);
if (c1var < 0) if (c1var < 0) error->all(FLERR, "Variable {} for region cylinder does not exist", c1str);
error->all(FLERR,"Variable name for region cylinder does not exist");
if (!input->variable->equalstyle(c1var)) if (!input->variable->equalstyle(c1var))
error->all(FLERR,"Variable for region cylinder is invalid style"); error->all(FLERR, "Variable {} for region cylinder is invalid style", c1str);
} }
if (c2style == VARIABLE) { if (c2style == VARIABLE) {
c2var = input->variable->find(c2str); c2var = input->variable->find(c2str);
if (c2var < 0) if (c2var < 0) error->all(FLERR, "Variable {} for region cylinder does not exist", c2str);
error->all(FLERR,"Variable name for region cylinder does not exist");
if (!input->variable->equalstyle(c2var)) if (!input->variable->equalstyle(c2var))
error->all(FLERR,"Variable for region cylinder is invalid style"); error->all(FLERR, "Variable {} for region cylinder is invalid style", c2str);
} }
if (rstyle == VARIABLE) { if (rstyle == VARIABLE) {
rvar = input->variable->find(rstr); rvar = input->variable->find(rstr);
if (rvar < 0) if (rvar < 0) error->all(FLERR, "Variable {} for region cylinder does not exist", rstr);
error->all(FLERR,"Variable name for region cylinder does not exist");
if (!input->variable->equalstyle(rvar)) if (!input->variable->equalstyle(rvar))
error->all(FLERR,"Variable for region cylinder is invalid style"); error->all(FLERR, "Variable {} for region cylinder is invalid style", rstr);
} }
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
Set values needed to calculate velocity due to shape changes. Set values needed to calculate velocity due to shape changes.
These values do not depend on the contact, so this function is These values do not depend on the contact, so this function is
@ -795,13 +836,13 @@ void RegCylinder::set_velocity_shape()
xcenter[2] = 0; xcenter[2] = 0;
} }
forward_transform(xcenter[0], xcenter[1], xcenter[2]); forward_transform(xcenter[0], xcenter[1], xcenter[2]);
if (update->ntimestep > 0) rprev = prev[4]; if (update->ntimestep > 0)
else rprev = radius; rprev = prev[4];
else
rprev = radius;
prev[4] = radius; prev[4] = radius;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
add velocity due to shape change to wall velocity add velocity due to shape change to wall velocity
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -826,4 +867,3 @@ void RegCylinder::velocity_contact_shape(double *vwall, double *xc)
vwall[1] += dely / update->dt; vwall[1] += dely / update->dt;
vwall[2] += delz / update->dt; vwall[2] += delz / update->dt;
} }

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -26,7 +25,7 @@
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
#define BIG 1.0e20 static constexpr double BIG = 1.0e20;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -37,44 +36,62 @@ RegPrism::RegPrism(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
if (strcmp(arg[2], "INF") == 0 || strcmp(arg[2], "EDGE") == 0) { if (strcmp(arg[2], "INF") == 0 || strcmp(arg[2], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[2],"INF") == 0) xlo = -BIG; if (strcmp(arg[2], "INF") == 0)
else xlo = domain->boxlo[0]; xlo = -BIG;
} else xlo = xscale*utils::numeric(FLERR,arg[2],false,lmp); else
xlo = domain->boxlo[0];
} else
xlo = xscale * utils::numeric(FLERR, arg[2], false, lmp);
if (strcmp(arg[3], "INF") == 0 || strcmp(arg[3], "EDGE") == 0) { if (strcmp(arg[3], "INF") == 0 || strcmp(arg[3], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[3],"INF") == 0) xhi = BIG; if (strcmp(arg[3], "INF") == 0)
else xhi = domain->boxhi[0]; xhi = BIG;
} else xhi = xscale*utils::numeric(FLERR,arg[3],false,lmp); else
xhi = domain->boxhi[0];
} else
xhi = xscale * utils::numeric(FLERR, arg[3], false, lmp);
if (strcmp(arg[4], "INF") == 0 || strcmp(arg[4], "EDGE") == 0) { if (strcmp(arg[4], "INF") == 0 || strcmp(arg[4], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[4],"INF") == 0) ylo = -BIG; if (strcmp(arg[4], "INF") == 0)
else ylo = domain->boxlo[1]; ylo = -BIG;
} else ylo = yscale*utils::numeric(FLERR,arg[4],false,lmp); else
ylo = domain->boxlo[1];
} else
ylo = yscale * utils::numeric(FLERR, arg[4], false, lmp);
if (strcmp(arg[5], "INF") == 0 || strcmp(arg[5], "EDGE") == 0) { if (strcmp(arg[5], "INF") == 0 || strcmp(arg[5], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[5],"INF") == 0) yhi = BIG; if (strcmp(arg[5], "INF") == 0)
else yhi = domain->boxhi[1]; yhi = BIG;
} else yhi = yscale*utils::numeric(FLERR,arg[5],false,lmp); else
yhi = domain->boxhi[1];
} else
yhi = yscale * utils::numeric(FLERR, arg[5], false, lmp);
if (strcmp(arg[6], "INF") == 0 || strcmp(arg[6], "EDGE") == 0) { if (strcmp(arg[6], "INF") == 0 || strcmp(arg[6], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[6],"INF") == 0) zlo = -BIG; if (strcmp(arg[6], "INF") == 0)
else zlo = domain->boxlo[2]; zlo = -BIG;
} else zlo = zscale*utils::numeric(FLERR,arg[6],false,lmp); else
zlo = domain->boxlo[2];
} else
zlo = zscale * utils::numeric(FLERR, arg[6], false, lmp);
if (strcmp(arg[7], "INF") == 0 || strcmp(arg[7], "EDGE") == 0) { if (strcmp(arg[7], "INF") == 0 || strcmp(arg[7], "EDGE") == 0) {
if (domain->box_exist == 0) if (domain->box_exist == 0)
error->all(FLERR, "Cannot use region INF or EDGE when box does not exist"); error->all(FLERR, "Cannot use region INF or EDGE when box does not exist");
if (strcmp(arg[7],"INF") == 0) zhi = BIG; if (strcmp(arg[7], "INF") == 0)
else zhi = domain->boxhi[2]; zhi = BIG;
} else zhi = zscale*utils::numeric(FLERR,arg[7],false,lmp); else
zhi = domain->boxhi[2];
} else
zhi = zscale * utils::numeric(FLERR, arg[7], false, lmp);
xy = xscale * utils::numeric(FLERR, arg[8], false, lmp); xy = xscale * utils::numeric(FLERR, arg[8], false, lmp);
xz = xscale * utils::numeric(FLERR, arg[9], false, lmp); xz = xscale * utils::numeric(FLERR, arg[9], false, lmp);
@ -116,15 +133,18 @@ RegPrism::RegPrism(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
extent_xhi = MAX(extent_xhi, extent_xhi + xz); extent_xhi = MAX(extent_xhi, extent_xhi + xz);
extent_yhi = MAX(yhi, yhi + yz); extent_yhi = MAX(yhi, yhi + yz);
extent_zhi = zhi; extent_zhi = zhi;
} else bboxflag = 0; } else
bboxflag = 0;
// particle could be close to all 6 planes // particle could be close to all 6 planes
// particle can only touch 3 planes // particle can only touch 3 planes
cmax = 6; cmax = 6;
contact = new Contact[cmax]; contact = new Contact[cmax];
if (interior) tmax = 3; if (interior)
else tmax = 1; tmax = 3;
else
tmax = 1;
// h = transformation matrix from tilt coords (0-1) to box coords (xyz) // h = transformation matrix from tilt coords (0-1) to box coords (xyz)
// columns of h are edge vectors of tilted box // columns of h are edge vectors of tilted box
@ -207,8 +227,7 @@ RegPrism::RegPrism(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
if (openflag) { if (openflag) {
int temp[6]; int temp[6];
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++) temp[i] = open_faces[i];
temp[i] = open_faces[i];
open_faces[0] = temp[4]; open_faces[0] = temp[4];
open_faces[1] = temp[5]; open_faces[1] = temp[5];
open_faces[2] = temp[2]; open_faces[2] = temp[2];
@ -223,20 +242,44 @@ RegPrism::RegPrism(LAMMPS *lmp, int narg, char **arg) : Region(lmp, narg, arg)
// verts in each tri are ordered so that right-hand rule gives inward norm // verts in each tri are ordered so that right-hand rule gives inward norm
// order = xy plane, xz plane, yz plane // order = xy plane, xz plane, yz plane
tri[0][0] = 0; tri[0][1] = 1; tri[0][2] = 3; tri[0][0] = 0;
tri[1][0] = 0; tri[1][1] = 3; tri[1][2] = 2; tri[0][1] = 1;
tri[2][0] = 4; tri[2][1] = 7; tri[2][2] = 5; tri[0][2] = 3;
tri[3][0] = 4; tri[3][1] = 6; tri[3][2] = 7; tri[1][0] = 0;
tri[1][1] = 3;
tri[1][2] = 2;
tri[2][0] = 4;
tri[2][1] = 7;
tri[2][2] = 5;
tri[3][0] = 4;
tri[3][1] = 6;
tri[3][2] = 7;
tri[4][0] = 0; tri[4][1] = 4; tri[4][2] = 5; tri[4][0] = 0;
tri[5][0] = 0; tri[5][1] = 5; tri[5][2] = 1; tri[4][1] = 4;
tri[6][0] = 2; tri[6][1] = 7; tri[6][2] = 6; tri[4][2] = 5;
tri[7][0] = 2; tri[7][1] = 3; tri[7][2] = 7; tri[5][0] = 0;
tri[5][1] = 5;
tri[5][2] = 1;
tri[6][0] = 2;
tri[6][1] = 7;
tri[6][2] = 6;
tri[7][0] = 2;
tri[7][1] = 3;
tri[7][2] = 7;
tri[8][0] = 2; tri[8][1] = 6; tri[8][2] = 4; tri[8][0] = 2;
tri[9][0] = 2; tri[9][1] = 4; tri[9][2] = 0; tri[8][1] = 6;
tri[10][0] = 1; tri[10][1] = 5; tri[10][2] = 7; tri[8][2] = 4;
tri[11][0] = 1; tri[11][1] = 7; tri[11][2] = 3; tri[9][0] = 2;
tri[9][1] = 4;
tri[9][2] = 0;
tri[10][0] = 1;
tri[10][1] = 5;
tri[10][2] = 7;
tri[11][0] = 1;
tri[11][1] = 7;
tri[11][2] = 3;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -262,8 +305,7 @@ int RegPrism::inside(double x, double y, double z)
double b = hinv[1][1] * (y - ylo) + hinv[1][2] * (z - zlo); double b = hinv[1][1] * (y - ylo) + hinv[1][2] * (z - zlo);
double c = hinv[2][2] * (z - zlo); double c = hinv[2][2] * (z - zlo);
if (a >= 0.0 && a <= 1.0 && b >= 0.0 && b <= 1.0 && c >= 0.0 && c <= 1.0) if (a >= 0.0 && a <= 1.0 && b >= 0.0 && b <= 1.0 && c >= 0.0 && c <= 1.0) return 1;
return 1;
return 0; return 0;
} }
@ -283,8 +325,10 @@ int RegPrism::surface_interior(double *x, double cutoff)
// x is exterior to prism // x is exterior to prism
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (i % 2) corner = chi; if (i % 2)
else corner = clo; corner = chi;
else
corner = clo;
dot = (x[0] - corner[0]) * face[i][0] + (x[1] - corner[1]) * face[i][1] + dot = (x[0] - corner[0]) * face[i][0] + (x[1] - corner[1]) * face[i][1] +
(x[2] - corner[2]) * face[i][2]; (x[2] - corner[2]) * face[i][2];
if (dot < 0.0) return 0; if (dot < 0.0) return 0;
@ -296,8 +340,10 @@ int RegPrism::surface_interior(double *x, double cutoff)
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (open_faces[i]) continue; if (open_faces[i]) continue;
if (i % 2) corner = chi; if (i % 2)
else corner = clo; corner = chi;
else
corner = clo;
dot = (x[0] - corner[0]) * face[i][0] + (x[1] - corner[1]) * face[i][1] + dot = (x[0] - corner[0]) * face[i][0] + (x[1] - corner[1]) * face[i][1] +
(x[2] - corner[2]) * face[i][2]; (x[2] - corner[2]) * face[i][2];
if (dot < cutoff) { if (dot < cutoff) {
@ -330,8 +376,10 @@ int RegPrism::surface_exterior(double *x, double cutoff)
// x is far enough from prism that there is no contact // x is far enough from prism that there is no contact
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (i % 2) corner = chi; if (i % 2)
else corner = clo; corner = chi;
else
corner = clo;
dot = (x[0] - corner[0]) * face[i][0] + (x[1] - corner[1]) * face[i][1] + dot = (x[0] - corner[0]) * face[i][0] + (x[1] - corner[1]) * face[i][1] +
(x[2] - corner[2]) * face[i][2]; (x[2] - corner[2]) * face[i][2];
if (dot <= -cutoff) return 0; if (dot <= -cutoff) return 0;
@ -340,8 +388,10 @@ int RegPrism::surface_exterior(double *x, double cutoff)
// x is interior to prism // x is interior to prism
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (i % 2) corner = chi; if (i % 2)
else corner = clo; corner = chi;
else
corner = clo;
dot = (x[0] - corner[0]) * face[i][0] + (x[1] - corner[1]) * face[i][1] + dot = (x[0] - corner[0]) * face[i][0] + (x[1] - corner[1]) * face[i][1] +
(x[2] - corner[2]) * face[i][2]; (x[2] - corner[2]) * face[i][2];
if (dot <= 0.0) break; if (dot <= 0.0) break;
@ -389,16 +439,14 @@ void RegPrism::find_nearest(double *x, double &xp, double &yp, double &zp)
i = tri[itri][0]; i = tri[itri][0];
j = tri[itri][1]; j = tri[itri][1];
k = tri[itri][2]; k = tri[itri][2];
dot = (x[0]-corners[i][0])*face[iface][0] + dot = (x[0] - corners[i][0]) * face[iface][0] + (x[1] - corners[i][1]) * face[iface][1] +
(x[1]-corners[i][1])*face[iface][1] +
(x[2] - corners[i][2]) * face[iface][2]; (x[2] - corners[i][2]) * face[iface][2];
xproj[0] = x[0] - dot * face[iface][0]; xproj[0] = x[0] - dot * face[iface][0];
xproj[1] = x[1] - dot * face[iface][1]; xproj[1] = x[1] - dot * face[iface][1];
xproj[2] = x[2] - dot * face[iface][2]; xproj[2] = x[2] - dot * face[iface][2];
if (inside_tri(xproj, corners[i], corners[j], corners[k], face[iface])) { if (inside_tri(xproj, corners[i], corners[j], corners[k], face[iface])) {
distsq = closest(x, xproj, nearest, distsq); distsq = closest(x, xproj, nearest, distsq);
} } else {
else {
point_on_line_segment(corners[i], corners[j], xproj, xline); point_on_line_segment(corners[i], corners[j], xproj, xline);
distsq = closest(x, xline, nearest, distsq); distsq = closest(x, xline, nearest, distsq);
point_on_line_segment(corners[j], corners[k], xproj, xline); point_on_line_segment(corners[j], corners[k], xproj, xline);
@ -422,8 +470,7 @@ void RegPrism::find_nearest(double *x, double &xp, double &yp, double &zp)
if xproduct dot norm < 0.0 for any of 3 edges, then x is outside triangle if xproduct dot norm < 0.0 for any of 3 edges, then x is outside triangle
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
int RegPrism::inside_tri(double *x, double *v1, double *v2, double *v3, int RegPrism::inside_tri(double *x, double *v1, double *v2, double *v3, double *norm)
double *norm)
{ {
double edge[3], pvec[3], xproduct[3]; double edge[3], pvec[3], xproduct[3];

View File

@ -1,4 +1,3 @@
// clang-format off
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
https://www.lammps.org/, Sandia National Laboratories https://www.lammps.org/, Sandia National Laboratories
@ -92,7 +91,8 @@ RegSphere::RegSphere(LAMMPS *lmp, int narg, char **arg) :
extent_yhi = yc + radius; extent_yhi = yc + radius;
extent_zlo = zc - radius; extent_zlo = zc - radius;
extent_zhi = zc + radius; extent_zhi = zc + radius;
} else bboxflag = 0; } else
bboxflag = 0;
cmax = 1; cmax = 1;
contact = new Contact[cmax]; contact = new Contact[cmax];
@ -197,19 +197,15 @@ int RegSphere::surface_exterior(double *x, double cutoff)
void RegSphere::shape_update() void RegSphere::shape_update()
{ {
if (xstyle == VARIABLE) if (xstyle == VARIABLE) xc = xscale * input->variable->compute_equal(xvar);
xc = xscale * input->variable->compute_equal(xvar);
if (ystyle == VARIABLE) if (ystyle == VARIABLE) yc = yscale * input->variable->compute_equal(yvar);
yc = yscale * input->variable->compute_equal(yvar);
if (zstyle == VARIABLE) if (zstyle == VARIABLE) zc = zscale * input->variable->compute_equal(zvar);
zc = zscale * input->variable->compute_equal(zvar);
if (rstyle == VARIABLE) { if (rstyle == VARIABLE) {
radius = xscale * input->variable->compute_equal(rvar); radius = xscale * input->variable->compute_equal(rvar);
if (radius < 0.0) if (radius < 0.0) error->one(FLERR, "Variable evaluation in region gave bad value");
error->one(FLERR,"Variable evaluation in region gave bad value");
} }
} }
@ -221,34 +217,30 @@ void RegSphere::variable_check()
{ {
if (xstyle == VARIABLE) { if (xstyle == VARIABLE) {
xvar = input->variable->find(xstr); xvar = input->variable->find(xstr);
if (xvar < 0) if (xvar < 0) error->all(FLERR, "Variable {} for region sphere does not exist", xstr);
error->all(FLERR,"Variable name for region sphere does not exist");
if (!input->variable->equalstyle(xvar)) if (!input->variable->equalstyle(xvar))
error->all(FLERR,"Variable for region sphere is invalid style"); error->all(FLERR, "Variable {} for region sphere is invalid style", xstr);
} }
if (ystyle == VARIABLE) { if (ystyle == VARIABLE) {
yvar = input->variable->find(ystr); yvar = input->variable->find(ystr);
if (yvar < 0) if (yvar < 0) error->all(FLERR, "Variable {} for region sphere does not exist", ystr);
error->all(FLERR,"Variable name for region sphere does not exist");
if (!input->variable->equalstyle(yvar)) if (!input->variable->equalstyle(yvar))
error->all(FLERR,"Variable for region sphere is invalid style"); error->all(FLERR, "Variable {} for region sphere is invalid style", ystr);
} }
if (zstyle == VARIABLE) { if (zstyle == VARIABLE) {
zvar = input->variable->find(zstr); zvar = input->variable->find(zstr);
if (zvar < 0) if (zvar < 0) error->all(FLERR, "Variable {} for region sphere does not exist", zstr);
error->all(FLERR,"Variable name for region sphere does not exist");
if (!input->variable->equalstyle(zvar)) if (!input->variable->equalstyle(zvar))
error->all(FLERR,"Variable for region sphere is invalid style"); error->all(FLERR, "Variable {} for region sphere is invalid style", zstr);
} }
if (rstyle == VARIABLE) { if (rstyle == VARIABLE) {
rvar = input->variable->find(rstr); rvar = input->variable->find(rstr);
if (rvar < 0) if (rvar < 0) error->all(FLERR, "Variable {} for region sphere does not exist", rstr);
error->all(FLERR,"Variable name for region sphere does not exist");
if (!input->variable->equalstyle(rvar)) if (!input->variable->equalstyle(rvar))
error->all(FLERR,"Variable for region sphere is invalid style"); error->all(FLERR, "Variable {} for region sphere is invalid style", rstr);
} }
} }
@ -265,13 +257,13 @@ void RegSphere::set_velocity_shape()
xcenter[1] = yc; xcenter[1] = yc;
xcenter[2] = zc; xcenter[2] = zc;
forward_transform(xcenter[0], xcenter[1], xcenter[2]); forward_transform(xcenter[0], xcenter[1], xcenter[2]);
if (update->ntimestep > 0) rprev = prev[4]; if (update->ntimestep > 0)
else rprev = radius; rprev = prev[4];
else
rprev = radius;
prev[4] = radius; prev[4] = radius;
} }
/* ---------------------------------------------------------------------- /* ----------------------------------------------------------------------
add velocity due to shape change to wall velocity add velocity due to shape change to wall velocity
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
@ -288,4 +280,3 @@ void RegSphere::velocity_contact_shape(double *vwall, double *xc)
vwall[1] += dely / update->dt; vwall[1] += dely / update->dt;
vwall[2] += delz / update->dt; vwall[2] += delz / update->dt;
} }