Reorganizing optional subargs for fix rheo

This commit is contained in:
jtclemm
2024-11-11 11:31:16 -07:00
parent bd9bcb3bf7
commit c0edafc0cf
4 changed files with 53 additions and 46 deletions

View File

@ -81,8 +81,8 @@ void ComputeRHEOVShift::init()
cutsq = cut * cut; cutsq = cut * cut;
cutthird = cut / 3.0; cutthird = cut / 3.0;
multiphase_flag = fix_rheo->shift_multiphase_flag; cross_type_flag = fix_rheo->shift_cross_type_flag;
if (multiphase_flag) { if (cross_type_flag) {
scale = fix_rheo->shift_scale; scale = fix_rheo->shift_scale;
wmin = fix_rheo->shift_wmin; wmin = fix_rheo->shift_wmin;
cmin = fix_rheo->shift_cmin; cmin = fix_rheo->shift_cmin;
@ -134,7 +134,7 @@ void ComputeRHEOVShift::compute_peratom()
if (nmax_store < atom->nmax) { if (nmax_store < atom->nmax) {
memory->grow(vshift, atom->nmax, 3, "rheo:vshift"); memory->grow(vshift, atom->nmax, 3, "rheo:vshift");
if (multiphase_flag) { if (cross_type_flag) {
memory->grow(ct, atom->nmax, "rheo:ct"); memory->grow(ct, atom->nmax, "rheo:ct");
memory->grow(cgradt, atom->nmax, 3, "rheo:cgradt"); memory->grow(cgradt, atom->nmax, 3, "rheo:cgradt");
memory->grow(wsame, atom->nmax, "rheo:wsame"); memory->grow(wsame, atom->nmax, "rheo:wsame");
@ -254,7 +254,7 @@ void ComputeRHEOVShift::compute_peratom()
for (a = 0; a < dim; a++) for (a = 0; a < dim; a++)
vshift[i][a] = 0.0; vshift[i][a] = 0.0;
if (multiphase_flag) correct_interfaces(); if (cross_type_flag) correct_interfaces();
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -624,7 +624,7 @@ double ComputeRHEOVShift::memory_usage()
{ {
double bytes = 3 * nmax_store * sizeof(double); double bytes = 3 * nmax_store * sizeof(double);
if (multiphase_flag) if (cross_type_flag)
bytes += 5 * nmax_store * sizeof(double); bytes += 5 * nmax_store * sizeof(double);
return bytes; return bytes;

View File

@ -46,7 +46,7 @@ class ComputeRHEOVShift : public Compute {
int nmax_store, comm_stage; int nmax_store, comm_stage;
double dtv, cut, cutsq, cutthird; double dtv, cut, cutsq, cutthird;
double scale, wmin, cmin; double scale, wmin, cmin;
int surface_flag, interface_flag, multiphase_flag; int surface_flag, interface_flag, cross_type_flag;
double *rho0; double *rho0;
double *wsame, *ct, **cgradt; double *wsame, *ct, **cgradt;
int *shift_type; int *shift_type;

View File

@ -52,9 +52,9 @@ static const char cite_rheo[] =
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), rho0(nullptr), csq(nullptr), compute_grad(nullptr), Fix(lmp, narg, arg), rho0(nullptr), csq(nullptr), shift_type(nullptr),
compute_kernel(nullptr), compute_interface(nullptr), compute_surface(nullptr), compute_grad(nullptr), compute_kernel(nullptr), compute_interface(nullptr),
compute_rhosum(nullptr), compute_vshift(nullptr) compute_surface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr)
{ {
time_integrate = 1; time_integrate = 1;
@ -68,20 +68,18 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
shift_flag = 0; shift_flag = 0;
interface_flag = 0; interface_flag = 0;
surface_flag = 0; surface_flag = 0;
oxidation_flag = 0;
self_mass_flag = 0;
coordination_flag = 0; coordination_flag = 0;
shift_multiphase_flag = 0;
rhosum_self_mass_flag = 0;
shift_cross_type_flag = 0;
int i; int i;
int n = atom->ntypes; int n = atom->ntypes;
memory->create(rho0, n + 1, "rheo:rho0"); memory->create(rho0, n + 1, "rheo:rho0");
memory->create(csq, n + 1, "rheo:csq"); memory->create(csq, n + 1, "rheo:csq");
memory->create(shift_type, n + 1, "rheo:shift_type");
for (i = 1; i <= n; i++) { for (i = 1; i <= n; i++) {
rho0[i] = 1.0; rho0[i] = 1.0;
csq[i] = 1.0; csq[i] = 1.0;
shift_type[i] = 1;
} }
if (igroup != 0) error->all(FLERR, "fix rheo command requires group all"); if (igroup != 0) error->all(FLERR, "fix rheo command requires group all");
@ -115,19 +113,26 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
while (iarg < narg) { while (iarg < narg) {
if (strcmp(arg[iarg], "shift") == 0) { if (strcmp(arg[iarg], "shift") == 0) {
shift_flag = 1; shift_flag = 1;
} else if (strcmp(arg[iarg], "shift/multiphase/scale") == 0) { memory->create(shift_type, n + 1, "rheo:shift_type");
if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo shift/multiphase/scale", error); for (i = 1; i <= n; i++) shift_type[i] = 1;
shift_multiphase_flag = 1; while (iarg < narg) { // optional sub-arguments
shift_scale = utils::numeric(FLERR, arg[iarg + 1], false, lmp); if (strcmp(arg[iarg], "scale/cross/type") == 0) {
shift_wmin = utils::numeric(FLERR, arg[iarg + 2], false, lmp); if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo shift scale/cross/type", error);
shift_cmin = utils::numeric(FLERR, arg[iarg + 3], false, lmp); shift_cross_type_flag = 1;
iarg += 3; shift_scale = utils::numeric(FLERR, arg[iarg + 1], false, lmp);
} else if (strcmp(arg[iarg], "shift/type") == 0) { shift_wmin = utils::numeric(FLERR, arg[iarg + 2], false, lmp);
if (iarg + n >= narg) utils::missing_cmd_args(FLERR, "fix rheo shift/type", error); shift_cmin = utils::numeric(FLERR, arg[iarg + 3], false, lmp);
for (i = 1; i <= n; i++) { iarg += 3;
shift_type[i] = utils::logical(FLERR, arg[iarg + i], false, lmp); } else if (strcmp(arg[iarg], "exclude/type") == 0) {
if (iarg + n >= narg) utils::missing_cmd_args(FLERR, "fix rheo shift exclude/type", error);
for (i = 1; i <= n; i++)
shift_type[i] = utils::logical(FLERR, arg[iarg + i], false, lmp);
iarg += n;
} else {
break;
}
iarg += 1;
} }
iarg += n;
} else if (strcmp(arg[iarg], "thermal") == 0) { } else if (strcmp(arg[iarg], "thermal") == 0) {
thermal_flag = 1; thermal_flag = 1;
} else if (strcmp(arg[iarg], "surface/detection") == 0) { } else if (strcmp(arg[iarg], "surface/detection") == 0) {
@ -149,8 +154,14 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
interface_flag = 1; interface_flag = 1;
} else if (strcmp(arg[iarg], "rho/sum") == 0) { } else if (strcmp(arg[iarg], "rho/sum") == 0) {
rhosum_flag = 1; rhosum_flag = 1;
} else if (strcmp(arg[iarg], "self/mass") == 0) { while (iarg < narg) { // optional sub-arguments
self_mass_flag = 1; if (strcmp(arg[iarg], "self/mass") == 0) {
rhosum_self_mass_flag = 1;
} else {
break;
}
iarg += 1;
}
} else if (strcmp(arg[iarg], "density") == 0) { } else if (strcmp(arg[iarg], "density") == 0) {
if (iarg + n >= narg) utils::missing_cmd_args(FLERR, "fix rheo density", error); if (iarg + n >= narg) utils::missing_cmd_args(FLERR, "fix rheo density", error);
for (i = 1; i <= n; i++) rho0[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp); for (i = 1; i <= n; i++) rho0[i] = utils::numeric(FLERR, arg[iarg + i], false, lmp);
@ -168,12 +179,6 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
iarg += 1; iarg += 1;
} }
if ((!shift_flag) && shift_multiphase_flag)
error->all(FLERR, "Cannot use shift/multiphase/scale without shifting");
if (self_mass_flag && (!rhosum_flag))
error->all(FLERR, "Cannot use self/mass setting without rho/sum");
#if 0 #if 0
if (lmp->citeme) lmp->citeme->add(cite_rheo); if (lmp->citeme) lmp->citeme->add(cite_rheo);
#endif #endif
@ -212,7 +217,7 @@ void FixRHEO::post_constructor()
if (rhosum_flag) { if (rhosum_flag) {
compute_rhosum = dynamic_cast<ComputeRHEORhoSum *>( compute_rhosum = dynamic_cast<ComputeRHEORhoSum *>(
modify->add_compute(fmt::format("rheo_rhosum all RHEO/RHO/SUM {}", self_mass_flag))); modify->add_compute(fmt::format("rheo_rhosum all RHEO/RHO/SUM {}", rhosum_self_mass_flag)));
compute_rhosum->fix_rheo = this; compute_rhosum->fix_rheo = this;
} }

View File

@ -41,23 +41,25 @@ class FixRHEO : public Fix {
// Model parameters // Model parameters
double cut; double cut;
double *rho0, *csq; double *rho0, *csq;
int *shift_type;
int self_mass_flag;
int zmin_kernel, zmin_surface, zmin_splash; int zmin_kernel, zmin_surface, zmin_splash;
int kernel_style, surface_style; int kernel_style, surface_style;
double divr_surface; double divr_surface;
// Settings flags
int thermal_flag;
int rhosum_flag;
int interface_flag;
int surface_flag;
int shift_flag;
int coordination_flag;
// Optional sub-flags/parameters
int rhosum_self_mass_flag;
int *shift_type;
int shift_cross_type_flag;
double shift_scale, shift_wmin, shift_cmin; double shift_scale, shift_wmin, shift_cmin;
// Accessory fixes/computes // Accessory fixes/computes
int thermal_flag;
int rhosum_flag;
int shift_flag;
int interface_flag;
int surface_flag;
int oxidation_flag;
int coordination_flag;
int shift_multiphase_flag;
int viscosity_fix_defined; int viscosity_fix_defined;
int pressure_fix_defined; int pressure_fix_defined;
int thermal_fix_defined; int thermal_fix_defined;