add minimization support
This commit is contained in:
@ -101,15 +101,18 @@ FixPair::FixPair(LAMMPS *lmp, int narg, char **arg) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// settings
|
// if set peratom_freq = Nevery, then cannot access the per-atom
|
||||||
// freq = 1 since vector/array always have values
|
// values as part of thermo output during minimiziation
|
||||||
// allows user to specify nevery = 0 for a dump
|
// at different frequency or on last step of minimization
|
||||||
// which this fix outputs whenever it wants
|
// instead set peratom_freq = 1
|
||||||
|
// ok, since vector/array always have values
|
||||||
|
// but requires the vector/array be persisted between Nevery steps
|
||||||
|
// since it may be accessed
|
||||||
|
|
||||||
peratom_flag = 1;
|
peratom_flag = 1;
|
||||||
if (ncols == 1) size_peratom_cols = 0;
|
if (ncols == 1) size_peratom_cols = 0;
|
||||||
else size_peratom_cols = ncols;
|
else size_peratom_cols = ncols;
|
||||||
peratom_freq = nevery;
|
peratom_freq = 1;
|
||||||
|
|
||||||
// perform initial allocation of atom-based array
|
// perform initial allocation of atom-based array
|
||||||
// register with Atom class
|
// register with Atom class
|
||||||
@ -163,7 +166,9 @@ int FixPair::setmask()
|
|||||||
{
|
{
|
||||||
int mask = 0;
|
int mask = 0;
|
||||||
mask |= PRE_FORCE;
|
mask |= PRE_FORCE;
|
||||||
|
mask |= MIN_PRE_FORCE;
|
||||||
mask |= POST_FORCE;
|
mask |= POST_FORCE;
|
||||||
|
mask |= MIN_POST_FORCE;
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,6 +210,13 @@ void FixPair::pre_force(int /*vflag*/)
|
|||||||
if (trigger[ifield]) *(triggerptr[ifield]) = 1;
|
if (trigger[ifield]) *(triggerptr[ifield]) = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void FixPair::min_pre_force(int vflag)
|
||||||
|
{
|
||||||
|
pre_force(vflag);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
extract results from pair style
|
extract results from pair style
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
@ -253,6 +265,13 @@ void FixPair::post_force(int /*vflag*/)
|
|||||||
if (trigger[ifield]) *(triggerptr[ifield]) = 0;
|
if (trigger[ifield]) *(triggerptr[ifield]) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void FixPair::min_post_force(int vflag)
|
||||||
|
{
|
||||||
|
post_force(vflag);
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
allocate atom-based vector or array
|
allocate atom-based vector or array
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
@ -268,6 +287,52 @@ void FixPair::grow_arrays(int nmax)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
copy values within local atom-based array
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
void FixPair::copy_arrays(int i, int j, int /*delflag*/)
|
||||||
|
{
|
||||||
|
if (ncols == 1) {
|
||||||
|
vector[j] = vector[i];
|
||||||
|
} else {
|
||||||
|
for (int m = 0; m < ncols; m++)
|
||||||
|
array[j][m] = array[i][m];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
pack values in local atom-based array for exchange with another proc
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int FixPair::pack_exchange(int i, double *buf)
|
||||||
|
{
|
||||||
|
if (ncols == 1) {
|
||||||
|
buf[0] = vector[i];
|
||||||
|
} else {
|
||||||
|
for (int m = 0; m < ncols; m++)
|
||||||
|
buf[m] = array[i][m];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ncols;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
unpack values in local atom-based array from exchange with another proc
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
int FixPair::unpack_exchange(int nlocal, double *buf)
|
||||||
|
{
|
||||||
|
if (ncols == 1) {
|
||||||
|
vector[nlocal] = buf[0];
|
||||||
|
} else {
|
||||||
|
for (int m = 0; m < ncols; m++)
|
||||||
|
array[nlocal][m] = buf[m];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ncols;
|
||||||
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
memory usage of local atom-based vector or array
|
memory usage of local atom-based vector or array
|
||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|||||||
@ -33,9 +33,15 @@ class FixPair : public Fix {
|
|||||||
void setup(int) override;
|
void setup(int) override;
|
||||||
void setup_pre_force(int) override;
|
void setup_pre_force(int) override;
|
||||||
void pre_force(int) override;
|
void pre_force(int) override;
|
||||||
|
void min_pre_force(int) override;
|
||||||
void post_force(int) override;
|
void post_force(int) override;
|
||||||
|
void min_post_force(int) override;
|
||||||
|
|
||||||
void grow_arrays(int) override;
|
void grow_arrays(int) override;
|
||||||
|
void copy_arrays(int, int, int) override;
|
||||||
|
int pack_exchange(int, double *) override;
|
||||||
|
int unpack_exchange(int, double *) override;
|
||||||
|
|
||||||
double memory_usage() override;
|
double memory_usage() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
Reference in New Issue
Block a user