git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@6618 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2011-08-08 19:03:07 +00:00
parent 05e812d16c
commit 5b57bbd2f8
3 changed files with 1205 additions and 1056 deletions

View File

@ -1,7 +1,7 @@
The files in this directory are a user-contributed package for LAMMPS. The files in this directory are a user-contributed package for LAMMPS.
The person who created these files is Axel Kohlmeyer The person who created these files is Axel Kohlmeyer
(axel.kohlmeyer@temple.edu). Contact him directly if you (akohlmey@gmail.com). Contact him directly if you
have questions or for example scripts that use it. have questions or for example scripts that use it.
This package implements a "fix imd" command which can be used in a This package implements a "fix imd" command which can be used in a
@ -9,6 +9,12 @@ LAMMPS input script. IMD stands for interactive molecular dynamics,
and allows realtime visualization and manipulation of MD simulations and allows realtime visualization and manipulation of MD simulations
through the IMD protocol, initially implemented in VMD and NAMD. through the IMD protocol, initially implemented in VMD and NAMD.
If LAMMPS is compiled with the preprocessor flag -DLAMMPS_ASYNC_IMD
then fix imd will use posix threads to spawn a thread on MPI rank 0
in order to offload data reading and writing from the main execution
thread and potentiall lower the inferred latencies for slow
communication links. This feature has only been tested under linux.
There are example scripts for using this package with LAMMPS in There are example scripts for using this package with LAMMPS in
examples/USER/imd. Additional examples and a driver for use with the examples/USER/imd. Additional examples and a driver for use with the
Novint Falcon game controller as haptic device can be found at: Novint Falcon game controller as haptic device can be found at:

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* ---------------------------------------------------------------------- /* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov Steve Plimpton, sjplimp@sandia.gov
@ -52,6 +52,13 @@ FixStyle(imd,FixIMD)
#include "fix.h" #include "fix.h"
#if defined(LAMMPS_ASYNC_IMD)
#include <pthread.h>
#endif
/* prototype for c wrapper that calls the real worker */
extern "C" void *fix_imd_ioworker(void *);
namespace LAMMPS_NS { namespace LAMMPS_NS {
class FixIMD : public Fix { class FixIMD : public Fix {
@ -65,7 +72,7 @@ class FixIMD : public Fix {
void post_force_respa(int, int, int); void post_force_respa(int, int, int);
double memory_usage(); double memory_usage();
private: protected:
int imd_port; int imd_port;
void *localsock; void *localsock;
void *clientsock; void *clientsock;
@ -92,6 +99,21 @@ class FixIMD : public Fix {
int me; // my MPI rank in this "world". int me; // my MPI rank in this "world".
int nlevels_respa; // flag to determine respa levels. int nlevels_respa; // flag to determine respa levels.
int msglen;
char *msgdata;
#if defined(LAMMPS_ASYNC_IMD)
int buf_has_data; // flag to indicate to the i/o thread what to do.
pthread_mutex_t write_mutex; // mutex for sending coordinates to i/o thread
pthread_cond_t write_cond; // conditional variable for coordinate i/o
pthread_mutex_t read_mutex; // mutex for accessing data receieved by i/o thread
pthread_t iothread; // thread id for i/o thread.
pthread_attr_t iot_attr; // i/o thread attributes.
public:
void ioworker(void);
#endif
protected:
int reconnect(); int reconnect();
}; };