Merge pull request #4550 from akohlmey/collected-small-fixes
Collected small changes and fixes
This commit is contained in:
1
README
1
README
@ -34,6 +34,7 @@ lib additional provided or external libraries
|
||||
potentials interatomic potential files
|
||||
python Python module for LAMMPS
|
||||
src source files
|
||||
third_party Copies of thirdparty software bundled with LAMMPS
|
||||
tools pre- and post-processing tools
|
||||
unittest test programs for use with CTest
|
||||
.github Git and GitHub related files and tools
|
||||
|
||||
@ -44,6 +44,7 @@ set(LAMMPS_DOC_DIR ${LAMMPS_DIR}/doc)
|
||||
set(LAMMPS_TOOLS_DIR ${LAMMPS_DIR}/tools)
|
||||
set(LAMMPS_PYTHON_DIR ${LAMMPS_DIR}/python)
|
||||
set(LAMMPS_POTENTIALS_DIR ${LAMMPS_DIR}/potentials)
|
||||
set(LAMMPS_THIRDPARTY_DIR ${LAMMPS_DIR}/third_party)
|
||||
|
||||
set(LAMMPS_DOWNLOADS_URL "https://download.lammps.org" CACHE STRING "Base URL for LAMMPS downloads")
|
||||
set(LAMMPS_POTENTIALS_URL "${LAMMPS_DOWNLOADS_URL}/potentials")
|
||||
@ -131,7 +132,7 @@ endif()
|
||||
|
||||
# silence nvcc warnings
|
||||
if((PKG_KOKKOS) AND (Kokkos_ENABLE_CUDA) AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" "-Xcudafe --diag_suppress=unrecognized_pragma,--diag_suppress=128")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xcudafe --diag_suppress=unrecognized_pragma,--diag_suppress=128")
|
||||
endif()
|
||||
|
||||
# we *require* C++11 without extensions but prefer C++17.
|
||||
@ -370,6 +371,7 @@ endforeach()
|
||||
# packages with special compiler needs or external libs
|
||||
######################################################
|
||||
target_include_directories(lammps PUBLIC $<BUILD_INTERFACE:${LAMMPS_SOURCE_DIR}>)
|
||||
target_include_directories(lammps PUBLIC $<BUILD_INTERFACE:${LAMMPS_THIRDPARTY_DIR}>)
|
||||
|
||||
if(PKG_ADIOS)
|
||||
# The search for ADIOS2 must come before MPI because
|
||||
|
||||
@ -30,7 +30,7 @@ function(check_omp_h_include)
|
||||
if(OpenMP_CXX_FOUND)
|
||||
set(CMAKE_REQUIRED_FLAGS ${OpenMP_CXX_FLAGS})
|
||||
set(CMAKE_REQUIRED_INCLUDES ${OpenMP_CXX_INCLUDE_DIRS})
|
||||
set(CMAKE_REQUIRED_LINK_OPTIONS ${OpenMP_CXX_FLAGS})
|
||||
separate_arguments(CMAKE_REQUIRED_LINK_OPTIONS NATIVE_COMMAND ${OpenMP_CXX_FLAGS}) # needs to be a list
|
||||
set(CMAKE_REQUIRED_LIBRARIES ${OpenMP_CXX_LIBRARIES})
|
||||
# there are all kinds of problems with finding omp.h
|
||||
# for Clang and derived compilers so we pretend it is there.
|
||||
|
||||
@ -23,7 +23,7 @@ set(MPI_CXX_COMPILER "mpicxx" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_STANDARD 17 CACHE STRING "" FORCE)
|
||||
|
||||
# set(_intel_sycl_flags " -w -fsycl -flink-huge-device-code -fsycl-targets=spir64_gen "
|
||||
set(_intel_sycl_flags " -w -fsycl -fsycl-device-code-split=per_kernel -fsycl-targets=spir64_gen "
|
||||
set(_intel_sycl_flags " -w -fsycl -fsycl-device-code-split=per_kernel -fsycl-targets=spir64_gen ")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_intel_sycl_flags}" CACHE STRING "" FORCE)
|
||||
|
||||
#set(CMAKE_EXE_LINKER_FLAGS "-fsycl -flink-huge-device-code -fsycl-targets=spir64_gen " CACHE STRING "" FORCE)
|
||||
|
||||
@ -12,19 +12,10 @@ several advantages:
|
||||
LAMMPS. For that, you should first create your own :doc:`fork on
|
||||
GitHub <Howto_github>`, though.
|
||||
|
||||
You must have `git <git_>`_ installed on your system to use the
|
||||
commands explained below to communicate with the git servers on
|
||||
GitHub. For people still using subversion (svn), GitHub also
|
||||
provides `limited support for subversion clients <svn_>`_.
|
||||
|
||||
.. note::
|
||||
|
||||
As of October 2016, the official home of public LAMMPS development is
|
||||
on GitHub. The previously advertised LAMMPS git repositories on
|
||||
git.lammps.org and bitbucket.org are now offline or deprecated.
|
||||
You must have `git <git_>`_ installed on your system to use the commands
|
||||
explained below to communicate with the git servers on GitHub.
|
||||
|
||||
.. _git: https://git-scm.com
|
||||
.. _svn: https://help.github.com/en/github/importing-your-projects-to-github/working-with-subversion-on-github
|
||||
|
||||
You can follow the LAMMPS development on 4 different git branches:
|
||||
|
||||
|
||||
@ -101,6 +101,6 @@ void sfree(void *ptr)
|
||||
if (ptr == nullptr) return;
|
||||
|
||||
free(ptr);
|
||||
ptr = nullptr;
|
||||
ptr = nullptr; // NOTE: this has no effect
|
||||
}
|
||||
} // namespace ReaxFF
|
||||
|
||||
@ -125,7 +125,7 @@ void DisplaceAtoms::command(int narg, char **arg)
|
||||
else if (strcmp(arg[2],"y") == 0) d_dim = 1;
|
||||
else if (strcmp(arg[2],"z") == 0) d_dim = 2;
|
||||
else error->all(FLERR, 2, "Unknown displace_atoms ramp dimension {}", arg[2]);
|
||||
if ((domain->dimension == 2) && (d_dim = 2))
|
||||
if ((domain->dimension == 2) && (d_dim == 2))
|
||||
error->all(FLERR, 2, "Must not displace atoms in z-direction with 2d system");
|
||||
|
||||
double d_lo,d_hi;
|
||||
|
||||
@ -78,8 +78,8 @@ DumpCustom::DumpCustom(LAMMPS *lmp, int narg, char **arg) :
|
||||
|
||||
int ioffset = 5;
|
||||
expand = 0;
|
||||
nfield = nargnew = utils::expand_args(FLERR,narg-5,&arg[5],1,earg,lmp);
|
||||
if (earg != &arg[5]) expand = 1;
|
||||
nfield = nargnew = utils::expand_args(FLERR,narg-ioffset,&arg[ioffset],1,earg,lmp);
|
||||
if (earg != &arg[ioffset]) expand = 1;
|
||||
|
||||
// allocate field vectors
|
||||
|
||||
|
||||
10
src/info.cpp
10
src/info.cpp
@ -44,7 +44,9 @@
|
||||
#include "region.h"
|
||||
#include "update.h"
|
||||
#include "variable.h"
|
||||
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
||||
#include "fmt/chrono.h"
|
||||
#endif
|
||||
|
||||
#include <cctype>
|
||||
#include <cmath>
|
||||
@ -270,8 +272,16 @@ void Info::command(int narg, char **arg)
|
||||
if (out == nullptr) return;
|
||||
|
||||
fputs("\nInfo-Info-Info-Info-Info-Info-Info-Info-Info-Info-Info\n",out);
|
||||
#if defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
||||
{
|
||||
time_t tv = time(nullptr);
|
||||
struct tm *now = localtime(&tv);
|
||||
utils::print(out, "Printed on {}", asctime(now));
|
||||
}
|
||||
#else
|
||||
std::tm now = fmt::localtime(std::time(nullptr));
|
||||
utils::print(out,"Printed on {}", std::asctime(&now));
|
||||
#endif
|
||||
|
||||
if (flags & CONFIG) {
|
||||
utils::print(out,"\nLAMMPS version: {} / {}\n", lmp->version, lmp->num_ver);
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
// wrapper around including the JSON parsing and writing class
|
||||
// Do NOT include in any header file
|
||||
|
||||
#include "../third_party/nlohmann/json.hpp"
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
using json = ::nlohmann_lmp::json;
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
#include "atom.h"
|
||||
#include "atom_vec.h"
|
||||
#include "comm.h"
|
||||
#include "command.h"
|
||||
#include "compute.h"
|
||||
#include "domain.h"
|
||||
#include "dump.h"
|
||||
@ -42,6 +43,7 @@
|
||||
#include "molecule.h"
|
||||
#include "neigh_list.h"
|
||||
#include "neighbor.h"
|
||||
#include "neigh_request.h"
|
||||
#include "output.h"
|
||||
#include "pair.h"
|
||||
#if defined(LMP_PLUGIN)
|
||||
@ -6119,6 +6121,96 @@ int lammps_find_compute_neighlist(void *handle, const char *id, int reqid) {
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
// helper Command class for a single neighbor list build
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
class NeighProxy : protected Command
|
||||
{
|
||||
public:
|
||||
NeighProxy(class LAMMPS *lmp) : Command(lmp), neigh_idx(-1) {};
|
||||
|
||||
void command(int, char **) override;
|
||||
int get_index() const { return neigh_idx; }
|
||||
protected:
|
||||
int neigh_idx;
|
||||
};
|
||||
}
|
||||
|
||||
void NeighProxy::command(int narg, char **arg)
|
||||
{
|
||||
neigh_idx = -1;
|
||||
if (narg != 3) return;
|
||||
auto *req = neighbor->add_request(this, arg[0]);
|
||||
int flags = atoi(arg[1]);
|
||||
double cutoff = atof(arg[2]);
|
||||
req->apply_flags(flags);
|
||||
if (cutoff > 0.0) req->set_cutoff(cutoff);
|
||||
lmp->init();
|
||||
|
||||
// setup domain, communication and neighboring
|
||||
// acquire ghosts and build standard neighbor lists
|
||||
|
||||
if (domain->triclinic) domain->x2lamda(atom->nlocal);
|
||||
domain->pbc();
|
||||
domain->reset_box();
|
||||
comm->setup();
|
||||
if (neighbor->style) neighbor->setup_bins();
|
||||
comm->exchange();
|
||||
comm->borders();
|
||||
if (domain->triclinic) domain->lamda2x(atom->nlocal + atom->nghost);
|
||||
neighbor->build(1);
|
||||
|
||||
// build neighbor list this command needs based on earlier request
|
||||
|
||||
auto list = neighbor->find_list(this);
|
||||
neighbor->build_one(list);
|
||||
|
||||
// find neigh list
|
||||
for (int i = 0; i < neighbor->nlist; i++) {
|
||||
NeighList *list = neighbor->lists[i];
|
||||
if (this == list->requestor) {
|
||||
neigh_idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Build a single neighbor list in between runs and return its index
|
||||
*
|
||||
* A neighbor list request is created and the neighbor list built from a
|
||||
* proxy command. The request ID is typically 0, but will be
|
||||
* > 0 in case a compute has multiple neighbor list requests.
|
||||
*
|
||||
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.
|
||||
* \param id Identifier of neighbor list request
|
||||
* \param flags Neighbor list flags
|
||||
* \param cutoff Custom neighbor list cutoff if > 0, use default cutoff if < 0
|
||||
* \return return neighbor list index if valid, otherwise -1 */
|
||||
|
||||
int lammps_request_single_neighlist(void *handle, const char *id, int flags, double cutoff) {
|
||||
auto lmp = (LAMMPS *)handle;
|
||||
int idx = -1;
|
||||
if (!lmp || !lmp->error || !lmp->neighbor) {
|
||||
lammps_last_global_errormessage = fmt::format("ERROR: {}(): Invalid LAMMPS handle\n", FNERR);
|
||||
return -1;
|
||||
}
|
||||
|
||||
BEGIN_CAPTURE
|
||||
{
|
||||
NeighProxy proxy(lmp);
|
||||
std::vector<std::string> args = {id, std::to_string(flags), std::to_string(cutoff)};
|
||||
std::vector<char *> c_args;
|
||||
std::transform(args.begin(), args.end(), std::back_inserter(c_args),
|
||||
[](const std::string& s) { return (char *)s.c_str(); });
|
||||
proxy.command(static_cast<int>(c_args.size()), c_args.data());
|
||||
idx = proxy.get_index();
|
||||
}
|
||||
END_CAPTURE
|
||||
return idx;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
/** Return the number of entries in the neighbor list with given index
|
||||
*
|
||||
* \param handle pointer to a previously created LAMMPS instance cast to ``void *``.
|
||||
|
||||
@ -109,6 +109,17 @@ enum _LMP_VAR_CONST {
|
||||
LMP_VAR_STRING = 3 /*!< return value will be a string (catch-all) */
|
||||
};
|
||||
|
||||
/** Neighbor list settings constants
|
||||
*
|
||||
* Must be kept in sync with the equivalent constants in ``python/lammps/constants.py``,
|
||||
* ``fortran/lammps.f90``, ``tools/swig/lammps.i``, and
|
||||
* ``examples/COUPLE/plugin/liblammpsplugin.h`` */
|
||||
|
||||
enum _LMP_NEIGH_CONST {
|
||||
LMP_NEIGH_HALF = 0, /*!< request (default) half neighbor list */
|
||||
LMP_NEIGH_FULL = 1, /*!< request full neighbor list */
|
||||
};
|
||||
|
||||
/* Ifdefs to allow this file to be included in C and C++ programs */
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -235,6 +246,7 @@ int lammps_create_atoms(void *handle, int n, const int64_t *id, const int *type,
|
||||
int lammps_find_pair_neighlist(void *handle, const char *style, int exact, int nsub, int request);
|
||||
int lammps_find_fix_neighlist(void *handle, const char *id, int request);
|
||||
int lammps_find_compute_neighlist(void *handle, const char *id, int request);
|
||||
int lammps_request_single_neighlist(void *handle, const char *id, int flags, double cutoff);
|
||||
int lammps_neighlist_num_elements(void *handle, int idx);
|
||||
void lammps_neighlist_element_neighbors(void *handle, int idx, int element, int *iatom,
|
||||
int *numneigh, int **neighbors);
|
||||
|
||||
@ -113,6 +113,9 @@ void Min::init()
|
||||
// create fix needed for storing atom-based quantities
|
||||
// will delete it at end of run
|
||||
|
||||
if (lmp->kokkos)
|
||||
fix_minimize = dynamic_cast<FixMinimize *>(modify->add_fix("MINIMIZE all MINIMIZE/kk"));
|
||||
else
|
||||
fix_minimize = dynamic_cast<FixMinimize *>(modify->add_fix("MINIMIZE all MINIMIZE"));
|
||||
|
||||
// clear out extra global and per-atom dof
|
||||
|
||||
@ -15,7 +15,9 @@
|
||||
|
||||
#include "comm.h"
|
||||
#include "error.h"
|
||||
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
||||
#include "fmt/chrono.h"
|
||||
#endif
|
||||
#include "tokenizer.h"
|
||||
|
||||
#include <cstring>
|
||||
@ -264,8 +266,15 @@ void Timer::modify_params(int narg, char **arg)
|
||||
// format timeout setting
|
||||
std::string timeout = "off";
|
||||
if (_timeout >= 0.0) {
|
||||
#if defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
||||
char outstr[200];
|
||||
struct tm *tv = gmtime(&((time_t) _timeout));
|
||||
strftime(outstr, 200, "%02d:%M:%S", tv);
|
||||
timeout = outstr;
|
||||
#else
|
||||
std::tm tv = fmt::gmtime((std::time_t) _timeout);
|
||||
timeout = fmt::format("{:02d}:{:%M:%S}", tv.tm_yday * 24 + tv.tm_hour, tv);
|
||||
#endif
|
||||
}
|
||||
|
||||
utils::logmesg(lmp, "New timer settings: style={} mode={} timeout={}\n", timer_style[_level],
|
||||
|
||||
@ -20,7 +20,9 @@
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
#include "fix.h"
|
||||
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
||||
#include "fmt/chrono.h"
|
||||
#endif
|
||||
#include "input.h"
|
||||
#include "label_map.h"
|
||||
#include "memory.h"
|
||||
@ -1953,8 +1955,15 @@ int utils::date2num(const std::string &date)
|
||||
std::string utils::current_date()
|
||||
{
|
||||
time_t tv = time(nullptr);
|
||||
#if defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
||||
char outstr[200];
|
||||
struct tm *today = localtime(&tv);
|
||||
strftime(outstr, 200, "%Y-%m-%d", today);
|
||||
return std::string(outstr);
|
||||
#else
|
||||
std::tm today = fmt::localtime(tv);
|
||||
return fmt::format("{:%Y-%m-%d}", today);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
14
third_party/README
vendored
14
third_party/README
vendored
@ -1 +1,13 @@
|
||||
This folder contains copies of third-party software
|
||||
This folder contains copies of third-party software.
|
||||
These packages may be either included in the source
|
||||
code tarball or downloaded on-the-fly during compilation
|
||||
as needed. In some cases, some small customizations
|
||||
are made to avoid namespace conflicts where the
|
||||
included third party software needs workarounds for
|
||||
issues on platforms (OS or compiler related) to
|
||||
function consistently with LAMMPS.
|
||||
|
||||
The following software source packages are included
|
||||
|
||||
Folder: Package: Version: Original URL
|
||||
nlohmann/json JSON for Modern C++ 3.12.0 https://github.com/nlohmann/json/releases/tag/v3.12.0
|
||||
|
||||
2781
third_party/nlohmann/json.hpp
vendored
2781
third_party/nlohmann/json.hpp
vendored
File diff suppressed because it is too large
Load Diff
@ -48,7 +48,11 @@ TEST(JSON, serialize_deserialize)
|
||||
j1["nothing"] = nullptr;
|
||||
|
||||
std::string expected = "{\"happy\":true,\"name\":\"Niels\",\"nothing\":null,\"pi\":3.141}";
|
||||
std::string dumped = j1.dump();
|
||||
std::string dumped = j1.dump(-1);
|
||||
ASSERT_THAT(expected, Eq(dumped));
|
||||
|
||||
expected = "{\n \"happy\": true,\n \"name\": \"Niels\",\n \"nothing\": null,\n \"pi\": 3.141\n}";
|
||||
dumped = j1.dump(2, ' ');
|
||||
ASSERT_THAT(expected, Eq(dumped));
|
||||
|
||||
json j2 = json::parse(expected);
|
||||
|
||||
Reference in New Issue
Block a user