2014-10-22 01:09:24 +08:00
|
|
|
/* -*- c++ -*- ----------------------------------------------------------
|
2007-01-30 08:31:11 +08:00
|
|
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
|
|
|
http://lammps.sandia.gov, Sandia National Laboratories
|
|
|
|
Steve Plimpton, sjplimp@sandia.gov
|
|
|
|
|
|
|
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
|
|
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
2012-06-07 06:47:51 +08:00
|
|
|
certain rights in this software. This software is distributed under
|
2007-01-30 08:31:11 +08:00
|
|
|
the GNU General Public License.
|
|
|
|
|
|
|
|
See the README file in the top-level LAMMPS directory.
|
|
|
|
------------------------------------------------------------------------- */
|
|
|
|
|
2010-01-12 09:37:48 +08:00
|
|
|
#ifndef LMP_COMPUTE_H
|
|
|
|
#define LMP_COMPUTE_H
|
2007-01-30 08:31:11 +08:00
|
|
|
|
2019-06-27 21:14:36 +08:00
|
|
|
#include "pointers.h" // IWYU pragma: export
|
2007-01-30 08:31:11 +08:00
|
|
|
|
|
|
|
namespace LAMMPS_NS {
|
|
|
|
|
|
|
|
class Compute : protected Pointers {
|
|
|
|
public:
|
2015-01-20 07:38:26 +08:00
|
|
|
static int instance_total; // # of Compute classes ever instantiated
|
|
|
|
|
2007-01-30 08:31:11 +08:00
|
|
|
char *id,*style;
|
|
|
|
int igroup,groupbit;
|
|
|
|
|
2007-02-21 08:15:29 +08:00
|
|
|
double scalar; // computed global scalar
|
|
|
|
double *vector; // computed global vector
|
2009-12-10 05:12:49 +08:00
|
|
|
double **array; // computed global array
|
2009-12-05 05:03:54 +08:00
|
|
|
double *vector_atom; // computed per-atom vector
|
|
|
|
double **array_atom; // computed per-atom array
|
|
|
|
double *vector_local; // computed local vector
|
|
|
|
double **array_local; // computed local array
|
2007-01-30 08:31:11 +08:00
|
|
|
|
|
|
|
int scalar_flag; // 0/1 if compute_scalar() function exists
|
|
|
|
int vector_flag; // 0/1 if compute_vector() function exists
|
2009-12-05 05:03:54 +08:00
|
|
|
int array_flag; // 0/1 if compute_array() function exists
|
|
|
|
int size_vector; // length of global vector
|
|
|
|
int size_array_rows; // rows in global array
|
|
|
|
int size_array_cols; // columns in global array
|
2015-01-31 02:51:56 +08:00
|
|
|
int size_vector_variable; // 1 if vec length is unknown in advance
|
|
|
|
int size_array_rows_variable; // 1 if array rows is unknown in advance
|
2009-12-05 05:03:54 +08:00
|
|
|
|
2007-10-10 01:20:33 +08:00
|
|
|
int peratom_flag; // 0/1 if compute_peratom() function exists
|
2009-12-05 05:03:54 +08:00
|
|
|
int size_peratom_cols; // 0 = vector, N = columns in peratom array
|
|
|
|
|
|
|
|
int local_flag; // 0/1 if compute_local() function exists
|
|
|
|
int size_local_rows; // rows in local vector or array
|
|
|
|
int size_local_cols; // 0 = vector, N = columns in local array
|
|
|
|
|
|
|
|
int extscalar; // 0/1 if global scalar is intensive/extensive
|
|
|
|
int extvector; // 0/1/-1 if global vector is all int/ext/extlist
|
2008-01-03 03:24:46 +08:00
|
|
|
int *extlist; // list of 0/1 int/ext for each vec component
|
2009-12-10 05:12:49 +08:00
|
|
|
int extarray; // 0/1 if global array is all intensive/extensive
|
2007-01-30 08:31:11 +08:00
|
|
|
|
|
|
|
int tempflag; // 1 if Compute can be used as temperature
|
|
|
|
// must have both compute_scalar, compute_vector
|
|
|
|
int pressflag; // 1 if Compute can be used as pressure (uses virial)
|
|
|
|
// must have both compute_scalar, compute_vector
|
2007-12-01 05:54:30 +08:00
|
|
|
int pressatomflag; // 1 if Compute calculates per-atom virial
|
2019-10-04 16:34:15 +08:00
|
|
|
// 2 if Compute calculates per-atom centroid virial
|
|
|
|
// 3 if Compute calculates both
|
2007-11-03 04:25:11 +08:00
|
|
|
int peflag; // 1 if Compute calculates PE (uses Force energies)
|
2007-12-01 05:54:30 +08:00
|
|
|
int peatomflag; // 1 if Compute calculates per-atom PE
|
2015-01-28 23:55:56 +08:00
|
|
|
int create_attribute; // 1 if compute stores attributes that need
|
|
|
|
// setting when a new atom is created
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2008-03-21 08:14:38 +08:00
|
|
|
int tempbias; // 0/1 if Compute temp includes self/extra bias
|
2008-03-12 01:15:30 +08:00
|
|
|
|
2007-11-03 04:25:11 +08:00
|
|
|
int timeflag; // 1 if Compute stores list of timesteps it's called on
|
|
|
|
int ntime; // # of entries in time list
|
|
|
|
int maxtime; // max # of entries time list can hold
|
2011-01-11 08:41:00 +08:00
|
|
|
bigint *tlist; // list of timesteps the Compute is called on
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2011-01-11 08:41:00 +08:00
|
|
|
int invoked_flag; // non-zero if invoked or accessed this step, 0 if not
|
|
|
|
bigint invoked_scalar; // last timestep on which compute_scalar() was invoked
|
|
|
|
bigint invoked_vector; // ditto for compute_vector()
|
|
|
|
bigint invoked_array; // ditto for compute_array()
|
|
|
|
bigint invoked_peratom; // ditto for compute_peratom()
|
|
|
|
bigint invoked_local; // ditto for compute_local()
|
2007-01-30 08:31:11 +08:00
|
|
|
|
2008-01-03 03:24:46 +08:00
|
|
|
double dof; // degrees-of-freedom for temperature
|
2007-10-04 00:22:30 +08:00
|
|
|
|
2014-05-02 23:49:01 +08:00
|
|
|
int comm_forward; // size of forward communication (0 if none)
|
|
|
|
int comm_reverse; // size of reverse communication (0 if none)
|
|
|
|
int dynamic_group_allow; // 1 if can be used with dynamic group, else 0
|
2007-01-30 08:31:11 +08:00
|
|
|
|
2015-09-25 04:34:59 +08:00
|
|
|
// KOKKOS host/device flag and data masks
|
|
|
|
|
|
|
|
ExecutionSpace execution_space;
|
|
|
|
unsigned int datamask_read,datamask_modify;
|
|
|
|
|
2020-02-25 06:43:29 +08:00
|
|
|
int copymode,kokkosable;
|
2015-09-25 04:34:59 +08:00
|
|
|
|
2007-01-30 08:31:11 +08:00
|
|
|
Compute(class LAMMPS *, int, char **);
|
|
|
|
virtual ~Compute();
|
|
|
|
void modify_params(int, char **);
|
2008-05-17 05:58:06 +08:00
|
|
|
void reset_extra_dof();
|
|
|
|
|
2007-01-30 08:31:11 +08:00
|
|
|
virtual void init() = 0;
|
2007-10-04 00:22:30 +08:00
|
|
|
virtual void init_list(int, class NeighList *) {}
|
2013-02-13 07:09:54 +08:00
|
|
|
virtual void setup() {}
|
2007-01-30 08:31:11 +08:00
|
|
|
virtual double compute_scalar() {return 0.0;}
|
|
|
|
virtual void compute_vector() {}
|
2009-12-05 05:03:54 +08:00
|
|
|
virtual void compute_array() {}
|
2007-01-30 08:31:11 +08:00
|
|
|
virtual void compute_peratom() {}
|
2009-12-05 05:03:54 +08:00
|
|
|
virtual void compute_local() {}
|
2015-01-28 23:55:56 +08:00
|
|
|
virtual void set_arrays(int) {}
|
2007-01-30 08:31:11 +08:00
|
|
|
|
2014-08-07 00:16:32 +08:00
|
|
|
virtual int pack_forward_comm(int, int *, double *, int, int *) {return 0;}
|
|
|
|
virtual void unpack_forward_comm(int, int, double *) {}
|
2007-01-30 08:31:11 +08:00
|
|
|
virtual int pack_reverse_comm(int, int, double *) {return 0;}
|
|
|
|
virtual void unpack_reverse_comm(int, int *, double *) {}
|
|
|
|
|
2014-05-02 23:03:34 +08:00
|
|
|
virtual void dof_remove_pre() {}
|
2008-03-21 08:14:38 +08:00
|
|
|
virtual int dof_remove(int) {return 0;}
|
2008-03-12 01:15:30 +08:00
|
|
|
virtual void remove_bias(int, double *) {}
|
2017-05-17 06:15:13 +08:00
|
|
|
virtual void remove_bias_thr(int, double *, double *) {}
|
2008-03-20 22:53:21 +08:00
|
|
|
virtual void remove_bias_all() {}
|
2015-02-07 04:39:07 +08:00
|
|
|
virtual void reapply_bias_all() {}
|
2008-03-20 23:32:33 +08:00
|
|
|
virtual void restore_bias(int, double *) {}
|
2017-05-17 06:15:13 +08:00
|
|
|
virtual void restore_bias_thr(int, double *, double *) {}
|
2008-03-20 22:53:21 +08:00
|
|
|
virtual void restore_bias_all() {}
|
2008-03-12 01:15:30 +08:00
|
|
|
|
2011-12-17 05:15:49 +08:00
|
|
|
virtual void reset_extra_compute_fix(const char *);
|
2009-07-02 04:28:37 +08:00
|
|
|
|
2015-02-12 08:10:23 +08:00
|
|
|
virtual void lock_enable() {}
|
|
|
|
virtual void lock_disable() {}
|
|
|
|
virtual int lock_length() {return 0;}
|
|
|
|
virtual void lock(class Fix *, bigint, bigint) {}
|
|
|
|
virtual void unlock(class Fix *) {}
|
|
|
|
|
2018-03-28 04:37:04 +08:00
|
|
|
virtual void refresh() {}
|
|
|
|
|
2011-01-11 08:41:00 +08:00
|
|
|
void addstep(bigint);
|
|
|
|
int matchstep(bigint);
|
2009-01-06 06:26:08 +08:00
|
|
|
void clearstep();
|
2007-11-03 04:25:11 +08:00
|
|
|
|
2007-10-05 01:57:04 +08:00
|
|
|
virtual double memory_usage() {return 0.0;}
|
2007-01-30 08:31:11 +08:00
|
|
|
|
2017-06-13 10:12:12 +08:00
|
|
|
virtual void pair_setup_callback(int, int) {}
|
2015-08-19 23:11:20 +08:00
|
|
|
virtual void pair_tally_callback(int, int, int, int,
|
|
|
|
double, double, double,
|
|
|
|
double, double, double) {}
|
|
|
|
|
2007-01-30 08:31:11 +08:00
|
|
|
protected:
|
2015-01-20 07:38:26 +08:00
|
|
|
int instance_me; // which Compute class instantiation I am
|
|
|
|
|
2015-04-01 22:41:30 +08:00
|
|
|
double natoms_temp; // # of atoms used for temperature calculation
|
2016-07-16 06:47:23 +08:00
|
|
|
double extra_dof; // extra DOF for temperature computes
|
2014-05-07 22:30:27 +08:00
|
|
|
int fix_dof; // DOF due to fixes
|
2007-11-03 04:25:11 +08:00
|
|
|
int dynamic; // recount atoms for temperature computes
|
2014-11-18 02:11:29 +08:00
|
|
|
int dynamic_user; // user request for temp compute to be dynamic
|
2009-04-30 00:54:06 +08:00
|
|
|
|
|
|
|
double vbias[3]; // stored velocity bias for one atom
|
|
|
|
double **vbiasall; // stored velocity bias for all atoms
|
|
|
|
int maxbias; // size of vbiasall array
|
2009-12-22 01:24:04 +08:00
|
|
|
|
2017-06-08 05:10:33 +08:00
|
|
|
inline int sbmask(int j) const {
|
2011-04-06 03:10:43 +08:00
|
|
|
return j >> SBBITS & 3;
|
|
|
|
}
|
2014-05-24 02:37:20 +08:00
|
|
|
|
2015-04-01 02:47:58 +08:00
|
|
|
// private methods
|
|
|
|
|
|
|
|
void adjust_dof_fix();
|
2007-01-30 08:31:11 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2011-12-16 09:37:13 +08:00
|
|
|
|
|
|
|
/* ERROR/WARNING messages:
|
|
|
|
|
|
|
|
E: Illegal ... command
|
|
|
|
|
|
|
|
Self-explanatory. Check the input script syntax and compare to the
|
|
|
|
documentation for the command. You can use -echo screen as a
|
|
|
|
command-line option when running LAMMPS to see the offending line.
|
|
|
|
|
|
|
|
E: Compute ID must be alphanumeric or underscore characters
|
|
|
|
|
|
|
|
Self-explanatory.
|
|
|
|
|
|
|
|
E: Could not find compute group ID
|
|
|
|
|
|
|
|
Self-explanatory.
|
|
|
|
|
|
|
|
E: Compute does not allow an extra compute or fix to be reset
|
|
|
|
|
|
|
|
This is an internal LAMMPS error. Please report it to the
|
|
|
|
developers.
|
|
|
|
|
|
|
|
*/
|