Various small cleanups to RHEO package flagged by compiler warnings
The individual changes are: - remove of unused function parameters - replace non-standard variable length arrays on the stack with static ones - disable citation removed from the manual - replace #defined constants with enum or static constexpr - enable and apply clang-format
This commit is contained in:
@ -1,4 +1,3 @@
|
||||
// clang-format off
|
||||
/* ----------------------------------------------------------------------
|
||||
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||
https://www.lammps.org/, Sandia National Laboratories
|
||||
@ -23,9 +22,9 @@
|
||||
#include "citeme.h"
|
||||
#include "compute_rheo_grad.h"
|
||||
#include "compute_rheo_interface.h"
|
||||
#include "compute_rheo_surface.h"
|
||||
#include "compute_rheo_kernel.h"
|
||||
#include "compute_rheo_rho_sum.h"
|
||||
#include "compute_rheo_surface.h"
|
||||
#include "compute_rheo_vshift.h"
|
||||
#include "domain.h"
|
||||
#include "error.h"
|
||||
@ -39,20 +38,23 @@ using namespace LAMMPS_NS;
|
||||
using namespace RHEO_NS;
|
||||
using namespace FixConst;
|
||||
|
||||
#if 0
|
||||
// publication was removed from documentation
|
||||
static const char cite_rheo[] =
|
||||
"@article{PalermoInPrep,\n"
|
||||
" journal = {in prep},\n"
|
||||
" title = {RHEO: A Hybrid Mesh-Free Model Framework for Dynamic Multi-Phase Flows},\n"
|
||||
" year = {2024},\n"
|
||||
" author = {Eric T. Palermo and Ki T. Wolf and Joel T. Clemmer and Thomas C. O'Connor},\n"
|
||||
"}\n\n";
|
||||
"@article{PalermoInPrep,\n"
|
||||
" journal = {in prep},\n"
|
||||
" title = {RHEO: A Hybrid Mesh-Free Model Framework for Dynamic Multi-Phase Flows},\n"
|
||||
" year = {2024},\n"
|
||||
" author = {Eric T. Palermo and Ki T. Wolf and Joel T. Clemmer and Thomas C. O'Connor},\n"
|
||||
"}\n\n";
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
|
||||
Fix(lmp, narg, arg), rho0(nullptr), csq(nullptr), compute_grad(nullptr), compute_kernel(nullptr),
|
||||
compute_interface(nullptr), compute_surface(nullptr), compute_rhosum(nullptr),
|
||||
compute_vshift(nullptr)
|
||||
Fix(lmp, narg, arg), rho0(nullptr), csq(nullptr), compute_grad(nullptr),
|
||||
compute_kernel(nullptr), compute_interface(nullptr), compute_surface(nullptr),
|
||||
compute_rhosum(nullptr), compute_vshift(nullptr)
|
||||
{
|
||||
time_integrate = 1;
|
||||
|
||||
@ -78,44 +80,42 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
|
||||
csq[i] = 1.0;
|
||||
}
|
||||
|
||||
if (igroup != 0)
|
||||
error->all(FLERR, "fix rheo command requires group all");
|
||||
if (igroup != 0) error->all(FLERR, "fix rheo command requires group all");
|
||||
|
||||
if (atom->pressure_flag != 1)
|
||||
error->all(FLERR, "fix rheo command requires atom_style with pressure");
|
||||
if (atom->rho_flag != 1)
|
||||
error->all(FLERR, "fix rheo command requires atom_style with density");
|
||||
if (atom->rho_flag != 1) error->all(FLERR, "fix rheo command requires atom_style with density");
|
||||
if (atom->viscosity_flag != 1)
|
||||
error->all(FLERR, "fix rheo command requires atom_style with viscosity");
|
||||
if (atom->rheo_status_flag != 1)
|
||||
error->all(FLERR, "fix rheo command requires atom_style with status");
|
||||
|
||||
if (narg < 5)
|
||||
utils::missing_cmd_args(FLERR, "fix rheo", error);
|
||||
if (narg < 5) utils::missing_cmd_args(FLERR, "fix rheo", error);
|
||||
|
||||
cut = utils::numeric(FLERR, arg[3], false, lmp);
|
||||
if (strcmp(arg[4], "quintic") == 0) {
|
||||
kernel_style = QUINTIC;
|
||||
kernel_style = QUINTIC;
|
||||
} else if (strcmp(arg[4], "wendland/c4") == 0) {
|
||||
kernel_style = WENDLANDC4;
|
||||
kernel_style = WENDLANDC4;
|
||||
} else if (strcmp(arg[4], "RK0") == 0) {
|
||||
kernel_style = RK0;
|
||||
kernel_style = RK0;
|
||||
} else if (strcmp(arg[4], "RK1") == 0) {
|
||||
kernel_style = RK1;
|
||||
kernel_style = RK1;
|
||||
} else if (strcmp(arg[4], "RK2") == 0) {
|
||||
kernel_style = RK2;
|
||||
} else error->all(FLERR, "Unknown kernel style {} in fix rheo", arg[4]);
|
||||
kernel_style = RK2;
|
||||
} else
|
||||
error->all(FLERR, "Unknown kernel style {} in fix rheo", arg[4]);
|
||||
zmin_kernel = utils::numeric(FLERR, arg[5], false, lmp);
|
||||
|
||||
int iarg = 6;
|
||||
while (iarg < narg){
|
||||
while (iarg < narg) {
|
||||
if (strcmp(arg[iarg], "shift") == 0) {
|
||||
shift_flag = 1;
|
||||
} else if (strcmp(arg[iarg], "thermal") == 0) {
|
||||
thermal_flag = 1;
|
||||
} else if (strcmp(arg[iarg], "surface/detection") == 0) {
|
||||
surface_flag = 1;
|
||||
if(iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo surface/detection", error);
|
||||
if (iarg + 3 >= narg) utils::missing_cmd_args(FLERR, "fix rheo surface/detection", error);
|
||||
if (strcmp(arg[iarg + 1], "coordination") == 0) {
|
||||
surface_style = COORDINATION;
|
||||
zmin_surface = utils::inumeric(FLERR, arg[iarg + 2], false, lmp);
|
||||
@ -137,8 +137,7 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
|
||||
self_mass_flag = 1;
|
||||
} else if (strcmp(arg[iarg], "density") == 0) {
|
||||
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);
|
||||
iarg += n;
|
||||
} else if (strcmp(arg[iarg], "speed/sound") == 0) {
|
||||
if (iarg + n >= narg) utils::missing_cmd_args(FLERR, "fix rheo speed/sound", error);
|
||||
@ -156,7 +155,9 @@ FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
|
||||
if (self_mass_flag && (!rhosum_flag))
|
||||
error->all(FLERR, "Cannot use self/mass setting without rho/sum");
|
||||
|
||||
#if 0
|
||||
if (lmp->citeme) lmp->citeme->add(cite_rheo);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -174,15 +175,14 @@ FixRHEO::~FixRHEO()
|
||||
memory->destroy(rho0);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
Create necessary internal computes
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void FixRHEO::post_constructor()
|
||||
{
|
||||
compute_kernel = dynamic_cast<ComputeRHEOKernel *>(modify->add_compute(
|
||||
fmt::format("rheo_kernel all RHEO/KERNEL {}", kernel_style)));
|
||||
compute_kernel = dynamic_cast<ComputeRHEOKernel *>(
|
||||
modify->add_compute(fmt::format("rheo_kernel all RHEO/KERNEL {}", kernel_style)));
|
||||
compute_kernel->fix_rheo = this;
|
||||
|
||||
std::string cmd = "rheo_grad all RHEO/GRAD velocity rho viscosity";
|
||||
@ -191,26 +191,26 @@ void FixRHEO::post_constructor()
|
||||
compute_grad->fix_rheo = this;
|
||||
|
||||
if (rhosum_flag) {
|
||||
compute_rhosum = dynamic_cast<ComputeRHEORhoSum *>(modify->add_compute(
|
||||
fmt::format("rheo_rhosum all RHEO/RHO/SUM {}", self_mass_flag)));
|
||||
compute_rhosum = dynamic_cast<ComputeRHEORhoSum *>(
|
||||
modify->add_compute(fmt::format("rheo_rhosum all RHEO/RHO/SUM {}", self_mass_flag)));
|
||||
compute_rhosum->fix_rheo = this;
|
||||
}
|
||||
|
||||
if (shift_flag) {
|
||||
compute_vshift = dynamic_cast<ComputeRHEOVShift *>(modify->add_compute(
|
||||
"rheo_vshift all RHEO/VSHIFT"));
|
||||
compute_vshift =
|
||||
dynamic_cast<ComputeRHEOVShift *>(modify->add_compute("rheo_vshift all RHEO/VSHIFT"));
|
||||
compute_vshift->fix_rheo = this;
|
||||
}
|
||||
|
||||
if (interface_flag) {
|
||||
compute_interface = dynamic_cast<ComputeRHEOInterface *>(modify->add_compute(
|
||||
"rheo_interface all RHEO/INTERFACE"));
|
||||
compute_interface = dynamic_cast<ComputeRHEOInterface *>(
|
||||
modify->add_compute("rheo_interface all RHEO/INTERFACE"));
|
||||
compute_interface->fix_rheo = this;
|
||||
}
|
||||
|
||||
if (surface_flag) {
|
||||
compute_surface = dynamic_cast<ComputeRHEOSurface *>(modify->add_compute(
|
||||
"rheo_surface all RHEO/SURFACE"));
|
||||
compute_surface =
|
||||
dynamic_cast<ComputeRHEOSurface *>(modify->add_compute("rheo_surface all RHEO/SURFACE"));
|
||||
compute_surface->fix_rheo = this;
|
||||
}
|
||||
}
|
||||
@ -237,23 +237,23 @@ void FixRHEO::init()
|
||||
error->all(FLERR, "Can only specify one instance of fix rheo");
|
||||
|
||||
if (atom->rheo_status_flag != 1)
|
||||
error->all(FLERR,"fix rheo command requires atom property status");
|
||||
if (atom->rho_flag != 1)
|
||||
error->all(FLERR,"fix rheo command requires atom property rho");
|
||||
error->all(FLERR, "fix rheo command requires atom property status");
|
||||
if (atom->rho_flag != 1) error->all(FLERR, "fix rheo command requires atom property rho");
|
||||
if (atom->pressure_flag != 1)
|
||||
error->all(FLERR,"fix rheo command requires atom property pressure");
|
||||
error->all(FLERR, "fix rheo command requires atom property pressure");
|
||||
if (atom->viscosity_flag != 1)
|
||||
error->all(FLERR,"fix rheo command requires atom property viscosity");
|
||||
error->all(FLERR, "fix rheo command requires atom property viscosity");
|
||||
|
||||
if (thermal_flag) {
|
||||
if (atom->esph_flag != 1)
|
||||
error->all(FLERR,"fix rheo command requires atom property esph with thermal setting");
|
||||
error->all(FLERR, "fix rheo command requires atom property esph with thermal setting");
|
||||
if (atom->temperature_flag != 1)
|
||||
error->all(FLERR,"fix rheo command requires atom property temperature with thermal setting");
|
||||
error->all(FLERR, "fix rheo command requires atom property temperature with thermal setting");
|
||||
if (atom->heatflow_flag != 1)
|
||||
error->all(FLERR,"fix rheo command requires atom property heatflow with thermal setting");
|
||||
error->all(FLERR, "fix rheo command requires atom property heatflow with thermal setting");
|
||||
if (atom->conductivity_flag != 1)
|
||||
error->all(FLERR,"fix rheo command requires atom property conductivity with thermal setting");
|
||||
error->all(FLERR,
|
||||
"fix rheo command requires atom property conductivity with thermal setting");
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,14 +281,11 @@ void FixRHEO::setup(int /*vflag*/)
|
||||
{
|
||||
// Confirm all accessory fixes are defined
|
||||
// Note: fixes set this flag in setup_pre_force()
|
||||
if (!viscosity_fix_defined)
|
||||
error->all(FLERR, "Missing fix rheo/viscosity");
|
||||
if (!viscosity_fix_defined) error->all(FLERR, "Missing fix rheo/viscosity");
|
||||
|
||||
if (!pressure_fix_defined)
|
||||
error->all(FLERR, "Missing fix rheo/pressure");
|
||||
if (!pressure_fix_defined) error->all(FLERR, "Missing fix rheo/pressure");
|
||||
|
||||
if(thermal_flag && !thermal_fix_defined)
|
||||
error->all(FLERR, "Missing fix rheo/thermal");
|
||||
if (thermal_flag && !thermal_fix_defined) error->all(FLERR, "Missing fix rheo/thermal");
|
||||
|
||||
// Reset to zero for future runs
|
||||
thermal_fix_defined = 0;
|
||||
@ -296,8 +293,7 @@ void FixRHEO::setup(int /*vflag*/)
|
||||
pressure_fix_defined = 0;
|
||||
oxidation_fix_defined = 0;
|
||||
|
||||
if (rhosum_flag)
|
||||
compute_rhosum->compute_peratom();
|
||||
if (rhosum_flag) compute_rhosum->compute_peratom();
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -321,15 +317,13 @@ void FixRHEO::initial_integrate(int /*vflag*/)
|
||||
double **gradr = compute_grad->gradr;
|
||||
double **gradv = compute_grad->gradv;
|
||||
double **vshift;
|
||||
if (shift_flag)
|
||||
vshift = compute_vshift->vshift;
|
||||
if (shift_flag) vshift = compute_vshift->vshift;
|
||||
|
||||
int nlocal = atom->nlocal;
|
||||
int rmass_flag = atom->rmass_flag;
|
||||
int dim = domain->dimension;
|
||||
|
||||
if (igroup == atom->firstgroup)
|
||||
nlocal = atom->nfirst;
|
||||
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
|
||||
|
||||
//Density Half-step
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
@ -349,7 +343,7 @@ void FixRHEO::initial_integrate(int /*vflag*/)
|
||||
}
|
||||
|
||||
// Update gradients and interpolate solid properties
|
||||
compute_grad->forward_fields(); // also forwards v and rho for chi
|
||||
compute_grad->forward_fields(); // also forwards v and rho for chi
|
||||
if (interface_flag) {
|
||||
// Need to save, wiped in exchange
|
||||
compute_interface->store_forces();
|
||||
@ -360,9 +354,7 @@ void FixRHEO::initial_integrate(int /*vflag*/)
|
||||
// Position half-step
|
||||
for (i = 0; i < nlocal; i++) {
|
||||
if (mask[i] & groupbit) {
|
||||
for (a = 0; a < dim; a++) {
|
||||
x[i][a] += dtv * v[i][a];
|
||||
}
|
||||
for (a = 0; a < dim; a++) { x[i][a] += dtv * v[i][a]; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,9 +366,7 @@ void FixRHEO::initial_integrate(int /*vflag*/)
|
||||
if (status[i] & PHASECHECK) continue;
|
||||
|
||||
divu = 0;
|
||||
for (a = 0; a < dim; a++) {
|
||||
divu += gradv[i][a * (1 + dim)];
|
||||
}
|
||||
for (a = 0; a < dim; a++) { divu += gradv[i][a * (1 + dim)]; }
|
||||
rho[i] += dtf * (drho[i] - rho[i] * divu);
|
||||
}
|
||||
}
|
||||
@ -392,16 +382,12 @@ void FixRHEO::initial_integrate(int /*vflag*/)
|
||||
if (mask[i] & groupbit) {
|
||||
for (a = 0; a < dim; a++) {
|
||||
x[i][a] += dtv * vshift[i][a];
|
||||
for (b = 0; b < dim; b++) {
|
||||
v[i][a] += dtv * vshift[i][b] * gradv[i][a * dim + b];
|
||||
}
|
||||
for (b = 0; b < dim; b++) { v[i][a] += dtv * vshift[i][b] * gradv[i][a * dim + b]; }
|
||||
}
|
||||
|
||||
if (!rhosum_flag) {
|
||||
if (status[i] & PHASECHECK) continue;
|
||||
for (a = 0; a < dim; a++) {
|
||||
rho[i] += dtv * vshift[i][a] * gradr[i][a];
|
||||
}
|
||||
for (a = 0; a < dim; a++) { rho[i] += dtv * vshift[i][a] * gradr[i][a]; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -412,10 +398,9 @@ void FixRHEO::initial_integrate(int /*vflag*/)
|
||||
|
||||
void FixRHEO::pre_force(int /*vflag*/)
|
||||
{
|
||||
compute_kernel->compute_coordination(); // Needed for rho sum
|
||||
compute_kernel->compute_coordination(); // Needed for rho sum
|
||||
|
||||
if (rhosum_flag)
|
||||
compute_rhosum->compute_peratom();
|
||||
if (rhosum_flag) compute_rhosum->compute_peratom();
|
||||
|
||||
compute_kernel->compute_peratom();
|
||||
|
||||
@ -428,22 +413,19 @@ void FixRHEO::pre_force(int /*vflag*/)
|
||||
compute_grad->compute_peratom();
|
||||
compute_grad->forward_gradients();
|
||||
|
||||
if (shift_flag)
|
||||
compute_vshift->compute_peratom();
|
||||
if (shift_flag) compute_vshift->compute_peratom();
|
||||
|
||||
// Remove temporary options
|
||||
int *mask = atom->mask;
|
||||
int *status = atom->rheo_status;
|
||||
int nall = atom->nlocal + atom->nghost;
|
||||
for (int i = 0; i < nall; i++)
|
||||
if (mask[i] & groupbit)
|
||||
status[i] &= OPTIONSMASK;
|
||||
if (mask[i] & groupbit) status[i] &= OPTIONSMASK;
|
||||
|
||||
// Calculate surfaces, update status
|
||||
if (surface_flag) {
|
||||
compute_surface->compute_peratom();
|
||||
if (shift_flag)
|
||||
compute_vshift->correct_surfaces();
|
||||
if (shift_flag) compute_vshift->correct_surfaces();
|
||||
}
|
||||
}
|
||||
|
||||
@ -452,8 +434,7 @@ void FixRHEO::pre_force(int /*vflag*/)
|
||||
void FixRHEO::final_integrate()
|
||||
{
|
||||
int nlocal = atom->nlocal;
|
||||
if (igroup == atom->firstgroup)
|
||||
nlocal = atom->nfirst;
|
||||
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
|
||||
|
||||
double dtfm, divu;
|
||||
int i, a;
|
||||
@ -482,9 +463,7 @@ void FixRHEO::final_integrate()
|
||||
dtfm = dtf / mass[type[i]];
|
||||
}
|
||||
|
||||
for (a = 0; a < dim; a++) {
|
||||
v[i][a] += dtfm * f[i][a];
|
||||
}
|
||||
for (a = 0; a < dim; a++) { v[i][a] += dtfm * f[i][a]; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -496,9 +475,7 @@ void FixRHEO::final_integrate()
|
||||
if (status[i] & PHASECHECK) continue;
|
||||
|
||||
divu = 0;
|
||||
for (a = 0; a < dim; a++) {
|
||||
divu += gradv[i][a * (1 + dim)];
|
||||
}
|
||||
for (a = 0; a < dim; a++) { divu += gradv[i][a * (1 + dim)]; }
|
||||
rho[i] += dtf * (drho[i] - rho[i] * divu);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user