Fixing compilation errors
This commit is contained in:
@ -34,18 +34,19 @@
|
||||
#include <cmath>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
using namespace RHEO_NS;
|
||||
|
||||
#define EPSILON 1e-1
|
||||
static constexpr double EPSILON = 1e-1;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
ComputeRHEOInterface::ComputeRHEOInterface(LAMMPS *lmp, int narg, char **arg) :
|
||||
Compute(lmp, narg, arg), fix_rheo(nullptr), compute_kernel(nullptr), fx_m_norm(nullptr),
|
||||
norm(nullptr), normwf(nullptr), chi(nullptr), f_pressure(nullptr), id_fix_pa(nullptr)
|
||||
Compute(lmp, narg, arg), fix_rheo(nullptr), compute_kernel(nullptr), fp_store(nullptr),
|
||||
norm(nullptr), normwf(nullptr), chi(nullptr), id_fix_pa(nullptr)
|
||||
{
|
||||
if (narg != 3) error->all(FLERR,"Illegal compute rheo/interface command");
|
||||
|
||||
nmax = 0;
|
||||
nmax_store = 0;
|
||||
|
||||
comm_forward = 3;
|
||||
comm_reverse = 4;
|
||||
@ -74,15 +75,15 @@ void ComputeRHEOInterface::init()
|
||||
compute_kernel = fix_rheo->compute_kernel;
|
||||
rho0 = fix_rheo->rho0;
|
||||
cut = fix_rheo->cut;
|
||||
cs = fix_rheo->cs;
|
||||
cs_inv = 1.0 / cs;
|
||||
csq = fix_rheo->csq;
|
||||
csq_inv = 1.0 / csq;
|
||||
cutsq = cut * cut;
|
||||
wall_max = sqrt(3.0) / 12.0 * cut;
|
||||
|
||||
// Create chi array if it doesn't already exist
|
||||
// Create a custom atom property so it works with compute property/atom
|
||||
// Do not create grow callback as there's no reason to copy/exchange data
|
||||
// Manually grow if nmax_old exceeded
|
||||
// Manually grow if nmax_store exceeded
|
||||
|
||||
int tmp1, tmp2;
|
||||
int nmax = atom->nmax;
|
||||
@ -93,7 +94,7 @@ void ComputeRHEOInterface::init()
|
||||
memory->destroy(normwf);
|
||||
memory->create(norm, nmax, "rheo/interface:norm");
|
||||
memory->create(normwf, nmax, "rheo/interface:normwf");
|
||||
nmax_old = nmax;
|
||||
nmax_store = nmax;
|
||||
}
|
||||
chi = atom->dvector[index];
|
||||
|
||||
@ -104,13 +105,13 @@ void ComputeRHEOInterface::init()
|
||||
index = atom->find_custom("fp_store", tmp1, tmp2);
|
||||
if (index == -1) {
|
||||
id_fix_pa = utils::strdup(id + std::string("_fix_property_atom"));
|
||||
modify->add_fix(fmt::format("{} all property/atom d2_fp_store 3", id_fix_pa)));
|
||||
modify->add_fix(fmt::format("{} all property/atom d2_fp_store 3", id_fix_pa));
|
||||
index = atom->find_custom("fp_store", tmp1, tmp2);
|
||||
}
|
||||
fp_store = atom->darray[index];
|
||||
|
||||
// need an occasional half neighbor list
|
||||
neighbor->add_request(this, NeighConst::REQ_HALF);
|
||||
neighbor->add_request(this, NeighConst::REQ_DEFAULT);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -142,17 +143,17 @@ void ComputeRHEOInterface::compute_peratom()
|
||||
numneigh = list->numneigh;
|
||||
firstneigh = list->firstneigh;
|
||||
|
||||
if (atom->nmax > nmax_old) {
|
||||
nmax_old = atom->nmax;
|
||||
if (atom->nmax > nmax_store) {
|
||||
nmax_store = atom->nmax;
|
||||
memory->destroy(norm);
|
||||
memory->destroy(normwf);
|
||||
memory->create(norm, nmax_old, "rheo/interface:norm");
|
||||
memory->create(normwf, nmax_old, "rheo/interface:normwf");
|
||||
memory->grow(chi, nmax_old, "rheo/interface:chi");
|
||||
memory->create(norm, nmax_store, "rheo/interface:norm");
|
||||
memory->create(normwf, nmax_store, "rheo/interface:normwf");
|
||||
memory->grow(chi, nmax_store, "rheo/interface:chi");
|
||||
}
|
||||
|
||||
for (i = 0; i < nall; i++) {
|
||||
if (!(status[i] & FixRHEO::STATUS_FLUID)) rho[i] = 0.0;
|
||||
if (!(status[i] & STATUS_FLUID)) rho[i] = 0.0;
|
||||
normwf[i] = 0.0;
|
||||
norm[i] = 0.0;
|
||||
chi[i] = 0.0;
|
||||
@ -164,7 +165,7 @@ void ComputeRHEOInterface::compute_peratom()
|
||||
ytmp = x[i][1];
|
||||
ztmp = x[i][2];
|
||||
itype = type[i];
|
||||
fluidi = status[i] & FixRHEO::STATUS_FLUID;
|
||||
fluidi = status[i] & STATUS_FLUID;
|
||||
jlist = firstneigh[i];
|
||||
jnum = numneigh[i];
|
||||
|
||||
@ -179,12 +180,12 @@ void ComputeRHEOInterface::compute_peratom()
|
||||
|
||||
if (rsq < cutsq) {
|
||||
jtype = type[j];
|
||||
fluidj = status[j] & FixRHEO::STATUS_FLUID;
|
||||
fluidj = status[j] & STATUS_FLUID;
|
||||
w = compute_kernel->calc_w_quintic(i, j, delx, dely, delz, sqrt(rsq));
|
||||
|
||||
status_match = 0;
|
||||
norm[i] += w;
|
||||
if ((fluidi && fluidj) || ((!fluid) && (!fluidj)))
|
||||
if ((fluidi && fluidj) || ((!fluidi) && (!fluidj)))
|
||||
status_match = 1;
|
||||
|
||||
if (status_match) {
|
||||
@ -194,7 +195,7 @@ void ComputeRHEOInterface::compute_peratom()
|
||||
dot = (-fp_store[0][j] + fp_store[0][i]) * delx;
|
||||
dot += (-fp_store[1][j] + fp_store[1][i]) * dely;
|
||||
dot += (-fp_store[2][j] + fp_store[2][i]) * delz;
|
||||
rho[i] += w * (cs * (rho[j] - rho0) - rho[j] * dot);
|
||||
rho[i] += w * (csq * (rho[j] - rho0) - rho[j] * dot);
|
||||
normwf[i] += w;
|
||||
}
|
||||
}
|
||||
@ -208,7 +209,7 @@ void ComputeRHEOInterface::compute_peratom()
|
||||
dot = (-fp_store[0][i] + fp_store[0][j]) * delx;
|
||||
dot += (-fp_store[1][i] + fp_store[1][j]) * dely;
|
||||
dot += (-fp_store[2][i] + fp_store[2][j]) * delz;
|
||||
rho[j] += w * (cs * (rho[i] - rho0) + rho[i] * dot);
|
||||
rho[j] += w * (csq * (rho[i] - rho0) + rho[i] * dot);
|
||||
normwf[j] += w;
|
||||
}
|
||||
}
|
||||
@ -223,10 +224,10 @@ void ComputeRHEOInterface::compute_peratom()
|
||||
if (norm[i] != 0.0) chi[i] /= norm[i];
|
||||
|
||||
// Recalculate rho for non-fluid particles
|
||||
if (!(status[i] & FixRHEO::STATUS_FLUID)) {
|
||||
if (!(status[i] & STATUS_FLUID)) {
|
||||
if (normwf[i] != 0.0) {
|
||||
// Stores rho for solid particles 1+Pw in Adami Adams 2012
|
||||
rho[i] = MAX(EPSILON, rho0 + (rho[i] / normwf[i]) * cs_inv);
|
||||
rho[i] = MAX(EPSILON, rho0 + (rho[i] / normwf[i]) * csq_inv);
|
||||
} else {
|
||||
rho[i] = rho0;
|
||||
}
|
||||
@ -310,7 +311,7 @@ void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf)
|
||||
j = list[i];
|
||||
norm[j] += buf[m++];
|
||||
chi[j] += buf[m++];
|
||||
if (!(status[j] & FixRHEO::STATUS_FLUID)){
|
||||
if (!(status[j] & STATUS_FLUID)){
|
||||
normwf[j] += buf[m++];
|
||||
rho[j] += buf[m++];
|
||||
} else {
|
||||
@ -322,7 +323,7 @@ void ComputeRHEOInterface::unpack_reverse_comm(int n, int *list, double *buf)
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
void ComputeRHEOInterface::correct_v(double *vi, double *vj, double *vi_out, int i, int j)
|
||||
void ComputeRHEOInterface::correct_v(double *vi, double *vj, int i, int j)
|
||||
{
|
||||
double wall_prefactor, wall_denom, wall_numer;
|
||||
|
||||
@ -333,9 +334,9 @@ void ComputeRHEOInterface::correct_v(double *vi, double *vj, double *vi_out, int
|
||||
|
||||
wall_prefactor = wall_numer / wall_denom;
|
||||
|
||||
vi_out[0] = (vi[0] - vj[0]) * wall_prefactor + vi[0];
|
||||
vi_out[1] = (vi[1] - vj[1]) * wall_prefactor + vi[1];
|
||||
vi_out[2] = (vi[2] - vj[2]) * wall_prefactor + vi[2];
|
||||
vi[0] = (vi[0] - vj[0]) * wall_prefactor + vi[0];
|
||||
vi[1] = (vi[1] - vj[1]) * wall_prefactor + vi[1];
|
||||
vi[2] = (vi[2] - vj[2]) * wall_prefactor + vi[2];
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -352,28 +353,30 @@ double ComputeRHEOInterface::correct_rho(int i, int j)
|
||||
void ComputeRHEOInterface::store_forces()
|
||||
{
|
||||
double minv;
|
||||
double mass = atom->mass;
|
||||
double type = atom->type;
|
||||
double **f = atom->f;
|
||||
int *type = atom->type;
|
||||
int *mask = atom->mask;
|
||||
double *mass = atom->mass;
|
||||
double **f = atom->f;
|
||||
|
||||
// When this is called, fp_store stores the pressure force
|
||||
// After this method, fp_store instead stores non-pressure forces
|
||||
// and is also normalized by the particles mass
|
||||
// If forces are overwritten by a fix, there are no pressure forces
|
||||
// so just normalize
|
||||
int ifix = modify->find_fix_by_style("setforce");
|
||||
if (ifix != -1) {
|
||||
for (int i = 0; i < atom->nlocal; i++) {
|
||||
minv = 1.0 / mass[type[i]];
|
||||
if (mask[i] & modify->fix[ifix]->groupbit) {
|
||||
fp_store[i][0] = f[i][0] * minv;
|
||||
fp_store[i][1] = f[i][1] * minv;
|
||||
fp_store[i][2] = f[i][2] * minv;
|
||||
} else {
|
||||
fp_store[i][0] = (f[i][0] - fp_store[i][0]) * minv;
|
||||
fp_store[i][1] = (f[i][1] - fp_store[i][1]) * minv;
|
||||
fp_store[i][2] = (f[i][2] - fp_store[i][2]) * minv;
|
||||
auto fixlist = modify->get_fix_by_style("setforce");
|
||||
if (fixlist.size() == 0) {
|
||||
for (const auto &fix : fixlist) {
|
||||
for (int i = 0; i < atom->nlocal; i++) {
|
||||
minv = 1.0 / mass[type[i]];
|
||||
if (mask[i] & fix->groupbit) {
|
||||
fp_store[i][0] = f[i][0] * minv;
|
||||
fp_store[i][1] = f[i][1] * minv;
|
||||
fp_store[i][2] = f[i][2] * minv;
|
||||
} else {
|
||||
fp_store[i][0] = (f[i][0] - fp_store[i][0]) * minv;
|
||||
fp_store[i][1] = (f[i][1] - fp_store[i][1]) * minv;
|
||||
fp_store[i][2] = (f[i][2] - fp_store[i][2]) * minv;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -397,7 +400,7 @@ void ComputeRHEOInterface::store_forces()
|
||||
|
||||
double ComputeRHEOInterface::memory_usage()
|
||||
{
|
||||
double bytes = 3 * nmax_old * sizeof(double);
|
||||
double bytes = 3 * nmax_store * sizeof(double);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user