use newer APIs to access list of fixes in Modify class

This commit is contained in:
Axel Kohlmeyer
2022-03-12 09:23:36 -05:00
parent 7e2bb9a065
commit aca7126cfe
5 changed files with 33 additions and 35 deletions

View File

@ -173,6 +173,9 @@ FixLbFluid::FixLbFluid(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
if (lmp->citeme) lmp->citeme->add(cite_fix_lbfluid);
// we require continuous time stepping
time_depend = 1;
if (narg < 6) error->all(FLERR, "Illegal fix lb/fluid command");
if (comm->style != 0)
@ -730,16 +733,20 @@ int FixLbFluid::setmask()
void FixLbFluid::init(void)
{
if (modify->get_fix_by_style("lb/fluid").size() > 1)
error->all(FLERR, "Only one fix lb/fluid at a time is supported");
if (modify->get_fix_by_style("dt/reset").size() > 1)
error->all(FLERR, "Fix lb/fluid is not compatible with fix dt/reset");
//--------------------------------------------------------------------------
// Check to see if the MD timestep has changed between runs.
//--------------------------------------------------------------------------
double dt_lb_now;
dt_lb_now = nevery * (update->dt);
if (fabs(dt_lb_now - dt_lb) > 1.0e-12) {
error->warning(
FLERR, "Timestep change between runs with the same lb/fluid. Unphysical results may occur");
}
if (fabs(dt_lb_now - dt_lb) > 1.0e-12)
error->warning(FLERR, "Timestep changed between runs. Must re-issue fix lb/fluid command.");
//--------------------------------------------------------------------------
// Make sure the size of the simulation domain has not changed
@ -788,11 +795,12 @@ void FixLbFluid::init(void)
// Check if the lb/viscous fix is also called:
//--------------------------------------------------------------------------
groupbit_viscouslb = 0;
for (int i = 0; i < modify->nfix; i++) {
if (strcmp(modify->fix[i]->style, "lb/viscous") == 0) {
fixviscouslb = 1;
groupbit_viscouslb = group->bitmask[modify->fix[i]->igroup];
}
auto fixlbv = modify->get_fix_by_style("lb/viscous");
if (fixlbv.size() > 0) {
if (fixlbv.size() > 1)
error->all(FLERR, "More than one fix lb/viscous at a time is not supported");
fixviscouslb = 1;
groupbit_viscouslb = group->bitmask[fixlbv[0]->igroup];
}
// Warn if the fluid force is not applied to any of the particles.
@ -4489,22 +4497,16 @@ void FixLbFluid::calc_MPT(double &totalmass, double totalmomentum[3], double &Ta
int FixLbFluid::adjust_dof_fix() /* Based on same private method in compute class */
{ /* altered to return fix_dof */
Fix **fix = modify->fix;
int nfix = modify->nfix;
int fix_dof = 0;
for (int i = 0; i < nfix; i++)
if (fix[i]->dof_flag) fix_dof += fix[i]->dof(igroup);
for (auto &ifix : modify->get_fix_list())
if (ifix->dof_flag) fix_dof += ifix->dof(igroup);
return fix_dof;
}
double FixLbFluid::dof_compute() /* Based on same protected member of compute_temp class */
{ /* with extra_dof variable replaced by its default domain->dimension */
//int fix_dof = adjust_dof_fix();
double dof;
//double dof = domain->dimension * (group->count(igroup));
//dof -= fix_dof; // CM can tranfer to lb fluid so no constraint requiring removal of 1 domain->dimension
if (setdof)
dof = setdof;
@ -4513,8 +4515,6 @@ double FixLbFluid::dof_compute() /* Based on same protected member of compute_te
dof = 3.0 * dof;
}
//std::cout << dof << std::endl;
double tfactor;
if (dof > FLT_EPSILON)
tfactor = force->mvv2e / (dof * force->boltz);

View File

@ -35,7 +35,8 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */
FixLbMomentum::FixLbMomentum(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, arg)
FixLbMomentum::FixLbMomentum(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), fix_lb_fluid(nullptr)
{
if (narg < 4) error->all(FLERR, "Illegal fix lb/momentum command");
nevery = utils::inumeric(FLERR, arg[3], false, lmp);
@ -84,9 +85,8 @@ void FixLbMomentum::init()
if ((count = group->count(igroup)) == 0)
error->warning(FLERR, "Fix lb/momentum group has no atoms: Only fluid momentum affected");
for (int ifix = 0; ifix < modify->nfix; ifix++)
if (strcmp(modify->fix[ifix]->style, "lb/fluid") == 0)
fix_lb_fluid = (FixLbFluid *) modify->fix[ifix];
auto ifix = modify->get_fix_by_style("lb/fluid");
if (ifix.size() > 0) fix_lb_fluid = (FixLbFluid *) ifix[0];
count ? masstotal = group->mass(igroup) : 0;
}

View File

@ -1,6 +1,6 @@
/* -*- c++ -*- ----------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://www.lammps.org/, Sandia National Laboratories
https://www.lammps.org/, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract

View File

@ -36,22 +36,19 @@ FixLbViscous::FixLbViscous(LAMMPS *lmp, int narg, char **arg) : Fix(lmp, narg, a
int groupbit_lb_fluid = 0;
for (int ifix = 0; ifix < modify->nfix; ifix++)
if (strcmp(modify->fix[ifix]->style, "lb/fluid") == 0) {
fix_lb_fluid = (FixLbFluid *) modify->fix[ifix];
groupbit_lb_fluid = group->bitmask[modify->fix[ifix]->igroup];
}
if (groupbit_lb_fluid == 0)
auto ifix = modify->get_fix_by_style("lb/fluid");
if (ifix.size() > 0) {
fix_lb_fluid = (FixLbFluid *) ifix[0];
groupbit_lb_fluid = group->bitmask[ifix[0]->igroup];
} else {
error->all(FLERR, "the lb/fluid fix must also be used if using the lb/viscous fix");
}
int *mask = atom->mask;
int nlocal = atom->nlocal;
for (int j = 0; j < nlocal; j++) {
if ((mask[j] & groupbit) && !(mask[j] & groupbit_lb_fluid))
error->one(
FLERR,
"to apply a fluid force onto an atom, the lb/fluid fix must be used for that atom.");
error->one(FLERR, "Atoms must be in the fix lb/fluid group to apply a fluid force to them");
}
}
@ -70,7 +67,7 @@ int FixLbViscous::setmask()
void FixLbViscous::init()
{
if (utils::strmatch(update->integrate_style,"^respa"))
if (utils::strmatch(update->integrate_style, "^respa"))
nlevels_respa = ((Respa *) update->integrate)->nlevels;
}

View File

@ -27,6 +27,7 @@ namespace LAMMPS_NS {
class FixLbViscous : public Fix {
public:
FixLbViscous(class LAMMPS *, int, char **);
int setmask() override;
void init() override;
void setup(int) override;