add separators

This commit is contained in:
Axel Kohlmeyer
2025-01-11 11:13:47 -05:00
parent 3731513576
commit 0d85c5c704

View File

@ -80,6 +80,8 @@ negotiate an appropriate license for such distribution."
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
using namespace FixConst; using namespace FixConst;
/* ---------------------------------------------------------------------- */
/* re-usable integer hash table code with static linkage. */ /* re-usable integer hash table code with static linkage. */
/** hash table top level data structure */ /** hash table top level data structure */
@ -672,6 +674,7 @@ FixIMD::~FixIMD()
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
int FixIMD::setmask() int FixIMD::setmask()
{ {
int mask = 0; int mask = 0;
@ -682,6 +685,7 @@ int FixIMD::setmask()
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixIMD::init() void FixIMD::init()
{ {
if (utils::strmatch(update->integrate_style,"^respa")) if (utils::strmatch(update->integrate_style,"^respa"))
@ -771,6 +775,8 @@ void FixIMD::setup(int)
} }
} }
/* ---------------------------------------------------------------------- */
void FixIMD::setup_v2() { void FixIMD::setup_v2() {
/* nme: number of atoms in group on this MPI task /* nme: number of atoms in group on this MPI task
* nmax: max number of atoms in group across all MPI tasks * nmax: max number of atoms in group across all MPI tasks
@ -858,6 +864,8 @@ void FixIMD::setup_v2() {
} }
/* ---------------------------------------------------------------------- */
void FixIMD::setup_v3() void FixIMD::setup_v3()
{ {
/* nme: number of atoms in group on this MPI task /* nme: number of atoms in group on this MPI task
@ -1026,12 +1034,15 @@ void FixIMD::post_force(int /*vflag*/)
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
void FixIMD::post_force_respa(int vflag, int ilevel, int /*iloop*/) void FixIMD::post_force_respa(int vflag, int ilevel, int /*iloop*/)
{ {
/* only process IMD on the outmost RESPA level. */ /* only process IMD on the outmost RESPA level. */
if (ilevel == nlevels_respa-1) post_force(vflag); if (ilevel == nlevels_respa-1) post_force(vflag);
} }
/* ---------------------------------------------------------------------- */
void FixIMD::end_of_step() void FixIMD::end_of_step()
{ {
if (imd_version == 3 && update->ntimestep % imd_trate == 0) { if (imd_version == 3 && update->ntimestep % imd_trate == 0) {
@ -1041,11 +1052,14 @@ void FixIMD::end_of_step()
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
/* local memory usage. approximately. */ /* local memory usage. approximately. */
double FixIMD::memory_usage() double FixIMD::memory_usage()
{ {
return static_cast<double>(num_coords+maxbuf+imd_forces)*size_one; return static_cast<double>(num_coords+maxbuf+imd_forces)*size_one;
} }
/* ---------------------------------------------------------------------- */
void FixIMD::handle_step_v2() { void FixIMD::handle_step_v2() {
/* check for reconnect */ /* check for reconnect */
@ -1358,6 +1372,8 @@ void FixIMD::handle_step_v2() {
} }
/* ---------------------------------------------------------------------- */
void FixIMD::handle_client_input_v3() { void FixIMD::handle_client_input_v3() {
// IMDV3 // IMDV3
@ -1542,6 +1558,8 @@ void FixIMD::handle_client_input_v3() {
} }
} }
/* ---------------------------------------------------------------------- */
void FixIMD::handle_output_v3() { void FixIMD::handle_output_v3() {
tagint *tag = atom->tag; tagint *tag = atom->tag;
@ -1818,6 +1836,7 @@ int imdsock_init() {
#endif #endif
} }
/* ---------------------------------------------------------------------- */
void * imdsock_create() { void * imdsock_create() {
imdsocket * s; imdsocket * s;
@ -1836,6 +1855,8 @@ void * imdsock_create() {
return (void *) s; return (void *) s;
} }
/* ---------------------------------------------------------------------- */
int imdsock_bind(void * v, int port) { int imdsock_bind(void * v, int port) {
auto s = (imdsocket *) v; auto s = (imdsocket *) v;
auto *addr = &(s->addr); auto *addr = &(s->addr);
@ -1847,11 +1868,15 @@ int imdsock_bind(void * v, int port) {
return bind(s->sd, (struct sockaddr *) addr, s->addrlen); return bind(s->sd, (struct sockaddr *) addr, s->addrlen);
} }
/* ---------------------------------------------------------------------- */
int imdsock_listen(void * v) { int imdsock_listen(void * v) {
auto s = (imdsocket *) v; auto s = (imdsocket *) v;
return listen(s->sd, 5); return listen(s->sd, 5);
} }
/* ---------------------------------------------------------------------- */
void *imdsock_accept(void * v) { void *imdsock_accept(void * v) {
int rc; int rc;
imdsocket *new_s = nullptr, *s = (imdsocket *) v; imdsocket *new_s = nullptr, *s = (imdsocket *) v;
@ -1881,6 +1906,8 @@ void *imdsock_accept(void * v) {
return (void *)new_s; return (void *)new_s;
} }
/* ---------------------------------------------------------------------- */
int imdsock_write(void * v, const void *buf, int len) { int imdsock_write(void * v, const void *buf, int len) {
auto s = (imdsocket *) v; auto s = (imdsocket *) v;
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__)
@ -1890,6 +1917,8 @@ int imdsock_write(void * v, const void *buf, int len) {
#endif #endif
} }
/* ---------------------------------------------------------------------- */
int imdsock_read(void * v, void *buf, int len) { int imdsock_read(void * v, void *buf, int len) {
auto s = (imdsocket *) v; auto s = (imdsocket *) v;
#if defined(_MSC_VER) || defined(__MINGW32__) #if defined(_MSC_VER) || defined(__MINGW32__)
@ -1900,6 +1929,8 @@ int imdsock_read(void * v, void *buf, int len) {
} }
/* ---------------------------------------------------------------------- */
void imdsock_shutdown(void *v) { void imdsock_shutdown(void *v) {
auto s = (imdsocket *) v; auto s = (imdsocket *) v;
if (s == nullptr) if (s == nullptr)
@ -1912,6 +1943,8 @@ void imdsock_shutdown(void *v) {
#endif #endif
} }
/* ---------------------------------------------------------------------- */
void imdsock_destroy(void * v) { void imdsock_destroy(void * v) {
auto s = (imdsocket *) v; auto s = (imdsocket *) v;
if (s == nullptr) if (s == nullptr)
@ -1925,6 +1958,8 @@ void imdsock_destroy(void * v) {
free(s); free(s);
} }
/* ---------------------------------------------------------------------- */
int imdsock_selread(void *v, int sec) { int imdsock_selread(void *v, int sec) {
auto s = (imdsocket *)v; auto s = (imdsocket *)v;
fd_set rfd; fd_set rfd;
@ -1944,6 +1979,8 @@ int imdsock_selread(void *v, int sec) {
} }
/* ---------------------------------------------------------------------- */
int imdsock_selwrite(void *v, int sec) { int imdsock_selwrite(void *v, int sec) {
auto s = (imdsocket *)v; auto s = (imdsocket *)v;
fd_set wfd; fd_set wfd;
@ -1979,6 +2016,8 @@ typedef union {
} b; } b;
} netint; } netint;
/* ---------------------------------------------------------------------- */
static int32 imd_htonl(int32 h) { static int32 imd_htonl(int32 h) {
netint n; netint n;
n.b.highest = h >> 24; n.b.highest = h >> 24;
@ -1988,22 +2027,30 @@ static int32 imd_htonl(int32 h) {
return n.i; return n.i;
} }
/* ---------------------------------------------------------------------- */
static int32 imd_ntohl(int32 n) { static int32 imd_ntohl(int32 n) {
netint u; netint u;
u.i = n; u.i = n;
return (u.b.highest << 24 | u.b.high << 16 | u.b.low << 8 | u.b.lowest); return (u.b.highest << 24 | u.b.high << 16 | u.b.low << 8 | u.b.lowest);
} }
/* ---------------------------------------------------------------------- */
static void imd_fill_header(IMDheader *header, IMDType type, int32 length) { static void imd_fill_header(IMDheader *header, IMDType type, int32 length) {
header->type = imd_htonl((int32)type); header->type = imd_htonl((int32)type);
header->length = imd_htonl(length); header->length = imd_htonl(length);
} }
/* ---------------------------------------------------------------------- */
static void swap_header(IMDheader *header) { static void swap_header(IMDheader *header) {
header->type = imd_ntohl(header->type); header->type = imd_ntohl(header->type);
header->length= imd_ntohl(header->length); header->length= imd_ntohl(header->length);
} }
/* ---------------------------------------------------------------------- */
static int32 imd_readn(void *s, char *ptr, int32 n) { static int32 imd_readn(void *s, char *ptr, int32 n) {
int32 nleft; int32 nleft;
int32 nread; int32 nread;
@ -2023,6 +2070,8 @@ static int32 imd_readn(void *s, char *ptr, int32 n) {
return n-nleft; return n-nleft;
} }
/* ---------------------------------------------------------------------- */
static int32 imd_writen(void *s, const char *ptr, int32 n) { static int32 imd_writen(void *s, const char *ptr, int32 n) {
int32 nleft; int32 nleft;
int32 nwritten; int32 nwritten;
@ -2041,6 +2090,8 @@ static int32 imd_writen(void *s, const char *ptr, int32 n) {
return n; return n;
} }
/* ---------------------------------------------------------------------- */
int imd_handshake_v2(void *s) { int imd_handshake_v2(void *s) {
IMDheader header; IMDheader header;
imd_fill_header(&header, IMD_HANDSHAKE, 1); imd_fill_header(&header, IMD_HANDSHAKE, 1);
@ -2048,6 +2099,8 @@ int imd_handshake_v2(void *s) {
return (imd_writen(s, (char *)&header, IMDHEADERSIZE) != IMDHEADERSIZE); return (imd_writen(s, (char *)&header, IMDHEADERSIZE) != IMDHEADERSIZE);
} }
/* ---------------------------------------------------------------------- */
int imd_handshake_v3(void *s, IMDSessionInfo *imdsinfo) { int imd_handshake_v3(void *s, IMDSessionInfo *imdsinfo) {
IMDheader header; IMDheader header;
imd_fill_header(&header, IMD_HANDSHAKE, 1); imd_fill_header(&header, IMD_HANDSHAKE, 1);
@ -2081,17 +2134,23 @@ IMDType imd_recv_header(void *s, int32 *length) {
return IMDType(header.type); return IMDType(header.type);
} }
/* ---------------------------------------------------------------------- */
int imd_recv_mdcomm(void *s, int32 n, int32 *indices, float *forces) { int imd_recv_mdcomm(void *s, int32 n, int32 *indices, float *forces) {
if (imd_readn(s, (char *)indices, 4*n) != 4*n) return 1; if (imd_readn(s, (char *)indices, 4*n) != 4*n) return 1;
if (imd_readn(s, (char *)forces, 12*n) != 12*n) return 1; if (imd_readn(s, (char *)forces, 12*n) != 12*n) return 1;
return 0; return 0;
} }
/* ---------------------------------------------------------------------- */
int imd_recv_energies(void *s, IMDEnergies *energies) { int imd_recv_energies(void *s, IMDEnergies *energies) {
return (imd_readn(s, (char *)energies, sizeof(IMDEnergies)) return (imd_readn(s, (char *)energies, sizeof(IMDEnergies))
!= sizeof(IMDEnergies)); != sizeof(IMDEnergies));
} }
/* ---------------------------------------------------------------------- */
int imd_recv_fcoords(void *s, int32 n, float *coords) { int imd_recv_fcoords(void *s, int32 n, float *coords) {
return (imd_readn(s, (char *)coords, 12*n) != 12*n); return (imd_readn(s, (char *)coords, 12*n) != 12*n);
} }