Cleaning up peratom variables, adding peratom variables to fix rheo/interface

This commit is contained in:
jtclemm
2023-04-12 17:05:05 -06:00
parent 79ddd1445f
commit 986cfd6641
18 changed files with 184 additions and 180 deletions

View File

@ -38,7 +38,7 @@ enum{COMMGRAD, COMMFIELD};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) : ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), compute_interface(nullptr), compute_kernel(nullptr), Compute(lmp, narg, arg), fix_rheo(nullptr), compute_interface(nullptr), compute_kernel(nullptr),
gradv(nullptr), gradr(nullptr), gradt(nullptr), gradn(nullptr) gradv(nullptr), gradr(nullptr), gradt(nullptr), gradn(nullptr)
{ {
if (narg < 4) error->all(FLERR,"Illegal compute rheo/grad command"); if (narg < 4) error->all(FLERR,"Illegal compute rheo/grad command");
@ -61,40 +61,26 @@ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) :
ncomm_grad += dim * dim; ncomm_grad += dim * dim;
ncomm_field += dim; ncomm_field += dim;
comm_reverse += dim * dim; comm_reverse += dim * dim;
indexv = atom->add_custom("rheo_grad_v", 1, dim * dim);
gradv = atom->darray[indexv];
} }
if (rho_flag) { if (rho_flag) {
ncomm_grad += dim; ncomm_grad += dim;
ncomm_field += 1; ncomm_field += 1;
comm_reverse += dim; comm_reverse += dim;
indexr = atom->add_custom("rheo_grad_rho", 1, dim);
gradr = atom->darray[indexr];
} }
if (temperature_flag) { if (temperature_flag) {
ncomm_grad += dim; ncomm_grad += dim;
ncomm_field += 1; ncomm_field += 1;
comm_reverse += dim; comm_reverse += dim;
indext= atom->add_custom("rheo_grad_temp", 1, dim);
gradt = atom->darray[indext];
} }
if (eta_flag) { if (eta_flag) {
ncomm_grad += dim; ncomm_grad += dim;
comm_reverse += dim; comm_reverse += dim;
indexn = atom->add_custom("rheo_grad_eta", 1, dim);
gradn = atom->darray[indexn];
} }
// 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
comm_forward = ncomm_grad; comm_forward = ncomm_grad;
nmax_old = 0;
grow_arrays(atom->nmax);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -102,14 +88,16 @@ ComputeRHEOGrad::ComputeRHEOGrad(LAMMPS *lmp, int narg, char **arg) :
ComputeRHEOGrad::~ComputeRHEOGrad() ComputeRHEOGrad::~ComputeRHEOGrad()
{ {
int dim = domain->dimension; int dim = domain->dimension;
if (velocity_flag) int tmp1, tmp2, index;
atom->remove_custom(indexv, 1, dim * dim);
if (rho_flag) index = atom->find_custom("rheo_grad_v", tmp1, tmp2);
atom->remove_custom(indexr, 1, dim); if (index != 1) atom->remove_custom(index, 1, dim * dim);
if (temperature_flag) index = atom->find_custom("rheo_grad_rho", tmp1, tmp2);
atom->remove_custom(indext, 1, dim); if (index != 1) atom->remove_custom(index, 1, dim);
if (eta_flag) index = atom->find_custom("rheo_grad_t", tmp1, tmp2);
atom->remove_custom(indexn, 1, dim); if (index != 1) atom->remove_custom(index, 1, dim);
index = atom->find_custom("rheo_grad_eta", tmp1, tmp2);
if (index != 1) atom->remove_custom(index, 1, dim);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -123,6 +111,36 @@ void ComputeRHEOGrad::init()
rho0 = fix_rheo->rho0; rho0 = fix_rheo->rho0;
compute_kernel = fix_rheo->compute_kernel; compute_kernel = fix_rheo->compute_kernel;
compute_interface = fix_rheo->compute_interface; compute_interface = fix_rheo->compute_interface;
// Create coordination 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
int index;
int dim = domain->dimension;
if (velocity_flag) {
index = atom->add_custom("rheo_grad_v", 1, dim * dim);
gradv = atom->darray[index];
}
if (rho_flag) {
index = atom->add_custom("rheo_grad_rho", 1, dim);
gradr = atom->darray[index];
}
if (temperature_flag) {
index= atom->add_custom("rheo_grad_temp", 1, dim);
gradt = atom->darray[index];
}
if (eta_flag) {
index = atom->add_custom("rheo_grad_eta", 1, dim);
gradn = atom->darray[index];
}
nmax_old = 0;
grow_arrays(atom->nmax);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -151,13 +169,17 @@ void ComputeRHEOGrad::compute_peratom()
double **v = atom->v; double **v = atom->v;
double *rho = atom->rho; double *rho = atom->rho;
double *temperature = atom->temperature; double *temperature = atom->temperature;
double *eta = atom->viscosity;
int *status = atom->status; int *status = atom->status;
int *type = atom->type; int *type = atom->type;
double *mass = atom->mass; double *mass = atom->mass;
int newton = force->newton; int newton = force->newton;
int dim = domain->dimension; int dim = domain->dimension;
int tmp1, tmp2;
int index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2);
if (index_visc == -1) error->all(FLERR, "Cannot find rheo viscosity");
double *viscosity = atom->dvector[index_visc];
inum = list->inum; inum = list->inum;
ilist = list->ilist; ilist = list->ilist;
numneigh = list->numneigh; numneigh = list->numneigh;
@ -229,7 +251,7 @@ void ComputeRHEOGrad::compute_peratom()
if (rho_flag) drho = rhoi - rhoj; if (rho_flag) drho = rhoi - rhoj;
if (temperature_flag) dT = temperature[i] - temperature[j]; if (temperature_flag) dT = temperature[i] - temperature[j];
if (eta_flag) deta = eta[i] - eta[j]; if (eta_flag) deta = viscosity[i] - viscosity[j];
wp = compute_kernel->calc_dw(i, j, delx, dely, delz, sqrt(rsq)); wp = compute_kernel->calc_dw(i, j, delx, dely, delz, sqrt(rsq));
dWij = compute_kernel->dWij; dWij = compute_kernel->dWij;

View File

@ -42,11 +42,9 @@ class ComputeRHEOGrad : public Compute {
double **gradr; double **gradr;
double **gradt; double **gradt;
double **gradn; double **gradn;
int stage;
private: private:
int comm_stage, ncomm_grad, ncomm_field, nmax_old; int comm_stage, ncomm_grad, ncomm_field, nmax_old;
int indexv, indexr, indext, indexn;
double cut, cutsq, rho0; double cut, cutsq, rho0;
class NeighList *list; class NeighList *list;

View File

@ -18,24 +18,20 @@
#include "compute_rheo_interface.h" #include "compute_rheo_interface.h"
#include "fix_rheo.h"
#include "compute_rheo_kernel.h"
#include "fix_store.h"
#include "fix.h"
#include <cmath>
#include <cstring>
#include "atom.h" #include "atom.h"
#include "update.h" #include "comm.h"
#include "modify.h"
#include "domain.h" #include "domain.h"
#include "compute_rheo_kernel.h"
#include "error.h"
#include "force.h"
#include "fix_rheo.h"
#include "memory.h"
#include "modify.h"
#include "neighbor.h" #include "neighbor.h"
#include "neigh_list.h" #include "neigh_list.h"
#include "neigh_request.h" #include "neigh_request.h"
#include "force.h"
#include "pair.h" #include <cmath>
#include "comm.h"
#include "memory.h"
#include "error.h"
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
@ -44,45 +40,29 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ComputeRHEOInterface::ComputeRHEOInterface(LAMMPS *lmp, int narg, char **arg) : ComputeRHEOInterface::ComputeRHEOInterface(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), Compute(lmp, narg, arg), fix_rheo(nullptr), compute_kernel(nullptr), fx_m_norm(nullptr),
id_fix_chi(nullptr) norm(nullptr), normwf(nullptr), chi(nullptr), f_pressure(nullptr), id_fix_pa(nullptr)
{ {
if (narg != 4) error->all(FLERR,"Illegal compute RHEO/chi command"); if (narg != 3) error->all(FLERR,"Illegal compute rheo/interface command");
cut = utils::numeric(FLERR,arg[3],false,lmp);
cutsq = cut*cut;
wall_max = sqrt(3)/12.0*cut;
nmax = 0; nmax = 0;
comm_forward = 3; comm_forward = 3;
comm_reverse = 4; comm_reverse = 4;
fix_chi = nullptr;
norm = nullptr;
normwf = nullptr;
// new id = fix-ID + FIX_STORE_ATTRIBUTE
// new fix group = group for this fix
id_fix_chi = nullptr;
std::string fixcmd = id + std::string("_chi");
id_fix_chi = new char[fixcmd.size()+1];
strcpy(id_fix_chi,fixcmd.c_str());
fixcmd += fmt::format(" all STORE peratom 0 {}", 1);
modify->add_fix(fixcmd);
fix_chi = (FixStore *) modify->fix[modify->nfix-1];
chi = fix_chi->vstore;
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ComputeRHEOInterface::~ComputeRHEOInterface() ComputeRHEOInterface::~ComputeRHEOInterface()
{ {
if (id_fix_chi && modify->nfix) modify->delete_fix(id_fix_chi); // Remove custom property if it exists
if (modify->nfix) modify->delete_fix("PROPERTY_ATOM_COMP_RHEO_SOLIDS"); int tmp1, tmp2, index;
index = atom->find_custom("rheo_chi", tmp1, tmp2);
if (index != -1) atom->remove_custom(index, 1, 0);
if (id_fix_pa && modify->nfix) modify->delete_fix(id_fix_pa);
memory->destroy(fx_m_norm);
memory->destroy(norm); memory->destroy(norm);
memory->destroy(normwf); memory->destroy(normwf);
} }
@ -91,42 +71,40 @@ ComputeRHEOInterface::~ComputeRHEOInterface()
void ComputeRHEOInterface::init() void ComputeRHEOInterface::init()
{ {
// need an occasional full neighbor list compute_kernel = fix_rheo->compute_kernel;
int irequest = neighbor->request(this,instance_me); cut = fix_rheo->cut;
neighbor->requests[irequest]->pair = 0; cutsq = cut * cut;
neighbor->requests[irequest]->compute = 1; wall_max = sqrt(3.0) / 12.0 * cut;
neighbor->requests[irequest]->half = 1;
neighbor->requests[irequest]->full = 0;
//neighbor->requests[irequest]->occasional = 1; //Anticipate needing regulalry
int icompute = modify->find_compute("rheo_kernel"); // Create chi array if it doesn't already exist
if (icompute == -1) error->all(FLERR, "Using compute/RHEO/chi without compute/RHEO/kernel"); // 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
compute_kernel = ((ComputeRHEOKernel *) modify->compute[icompute]); int create_flag = 0;
int tmp1, tmp2;
int nmax = atom->nmax;
int index = atom->find_custom("rheo_chi", tmp1, tmp2);
if (index == -1) {
index = atom->add_custom("rheo_chi", 1, 0);
nmax_old = nmax;
}
chi = atom->dvector[index];
//Store persistent per atom quantities - need to be exchanged // For fpressure, go ahead and create an instance of fix property atom
char **fixarg = new char*[8]; // Need restarts + exchanging with neighbors since it needs to persist
fixarg[0] = (char *) "PROPERTY_ATOM_COMP_RHEO_SOLIDS"; // between timesteps (fix property atom will handle callbacks)
fixarg[1] = (char *) "all";
fixarg[2] = (char *) "property/atom";
fixarg[3] = (char *) "d_fx";
fixarg[4] = (char *) "d_fy";
fixarg[5] = (char *) "d_fz";
fixarg[6] = (char *) "ghost";
fixarg[7] = (char *) "yes";
modify->add_fix(8,fixarg,1);
delete [] fixarg;
int temp_flag; index = atom->find_custom("rheo_pressure", tmp1, tmp2);
index_fx = atom->find_custom("fx", temp_flag); if (index == -1) {
if ((index_fx < 0) || (temp_flag != 1)) id_fix_pa = utils::strdup(id + std::string("_fix_property_atom"));
error->all(FLERR, "Compute rheo/solids can't find fix property/atom fx"); modify->add_fix(fmt::format("{} all property/atom d2_f_pressure 3", id_fix_pa)));
index_fy = atom->find_custom("fy", temp_flag); index = atom->find_custom("rheo_pressure", tmp1, tmp2);
if ((index_fy < 0) || (temp_flag != 1)) }
error->all(FLERR, "Compute rheo/solids can't find fix property/atom fy"); f_pressure = atom->darray[index];
index_fz = atom->find_custom("fz", temp_flag);
if ((index_fz < 0) || (temp_flag != 1)) // need an occasional half neighbor list
error->all(FLERR, "Compute rheo/solids can't find fix property/atom fz"); neighbor->add_request(this, NeighConst::REQ_HALF);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -138,6 +116,7 @@ void ComputeRHEOInterface::init_list(int /*id*/, NeighList *ptr)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
// Left off here
void ComputeRHEOInterface::compute_peratom() void ComputeRHEOInterface::compute_peratom()
{ {
int i, j, ii, jj, jnum, itype, jtype, phase_match; int i, j, ii, jj, jnum, itype, jtype, phase_match;

View File

@ -27,35 +27,34 @@ namespace LAMMPS_NS {
class ComputeRHEOInterface : public Compute { class ComputeRHEOInterface : public Compute {
public: public:
ComputeRHEOInterface(class LAMMPS *, int, char **); ComputeRHEOInterface(class LAMMPS *, int, char **);
~ComputeRHEOInterface(); ~ComputeRHEOInterface() override;
void init(); void init() override;
void init_list(int, class NeighList *); void init_list(int, class NeighList *) override;
void compute_peratom(); void compute_peratom() override;
int pack_forward_comm(int, int *, double *, int, int *); int pack_forward_comm(int, int *, double *, int, int *) override;
void unpack_forward_comm(int, int, double *); void unpack_forward_comm(int, int, double *) override;
int pack_reverse_comm(int, int, double *); int pack_reverse_comm(int, int, double *) override;
void unpack_reverse_comm(int, int *, double *); void unpack_reverse_comm(int, int *, double *) override;
double memory_usage() override;
void correct_v(double *, double *, double *, int, int); void correct_v(double *, double *, double *, int, int);
double correct_rho(int, int); double correct_rho(int, int);
double memory_usage();
void store_forces(); void store_forces();
double *chi;
double *chi, **f_pressure;
private: private:
int nmax; int nmax_old, comm_stage;
double cut, cutsq, cs2; double cut, cutsq, cs, wall_max;
double **fx_m_norm, *norm, *normwf;
char *id_fix_pa;
class NeighList *list; class NeighList *list;
double *norm, *normwf, wall_max; class FixRHEO *fix_rheo;
class ComputeRHEOKernel *compute_kernel; class ComputeRHEOKernel *compute_kernel;
char *id_fix_chi;
class FixStore *fix_chi;
int index_fx, index_fy, index_fz;
int comm_stage;
}; };
} } // namespace LAMMPS_NS
#endif #endif
#endif #endif

View File

@ -55,7 +55,7 @@ Move away from h notation, use cut?
ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) : ComputeRHEOKernel::ComputeRHEOKernel(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), Compute(lmp, narg, arg),
C(nullptr), C0(nullptr), compute_interface(nullptr); C(nullptr), C0(nullptr), coordination(nullptr), compute_interface(nullptr)
{ {
if (narg != 3) error->all(FLERR,"Illegal compute rheo/kernel command"); if (narg != 3) error->all(FLERR,"Illegal compute rheo/kernel command");
@ -71,7 +71,7 @@ ComputeRHEOKernel::~ComputeRHEOKernel()
// Remove custom property if it exists // Remove custom property if it exists
int tmp1, tmp2, index; int tmp1, tmp2, index;
index = atom->find_custom("rheo_coordination", tmp1, tmp2); index = atom->find_custom("rheo_coordination", tmp1, tmp2);
if (index != -1) atom->remove_custom(index_coord, 1, 0); if (index != -1) atom->remove_custom(index, 0, 0);
memory->destroy(C); memory->destroy(C);
memory->destroy(C0); memory->destroy(C0);
@ -125,12 +125,14 @@ void ComputeRHEOKernel::init()
int tmp1, tmp2; int tmp1, tmp2;
int nmax = atom->nmax; int nmax = atom->nmax;
index_coord = atom->find_custom("rheo_coordination", tmp1, tmp2); int index = atom->find_custom("rheo_coordination", tmp1, tmp2);
if (index_coord == -1) { if (index == -1) {
index_coord = atom->add_custom("rheo_coordination", 0, 0); index = atom->add_custom("rheo_coordination", 0, 0);
nmax_old = nmax; nmax_old = nmax;
} }
coordination = atom->ivector[index];
// Create local arrays for kernel arrays, I can't foresee a reason to print
comm_forward = 1; comm_forward = 1;
ncor = 0; ncor = 0;
Mdim = 0; Mdim = 0;
@ -170,7 +172,6 @@ int ComputeRHEOKernel::check_corrections(int i)
corrections = 0; corrections = 0;
} }
int *coordination = atom->ivector[index_coord];
if (coordination[i] < zmin) corrections = 0; if (coordination[i] < zmin) corrections = 0;
return corrections; return corrections;
@ -503,7 +504,6 @@ void ComputeRHEOKernel::compute_peratom()
double *mass = atom->mass; double *mass = atom->mass;
double *rho = atom->rho; double *rho = atom->rho;
int *status = atom->status; int *status = atom->status;
int *coordination = atom->ivector[index_coord];
tagint *tag = atom->tag; tagint *tag = atom->tag;
int inum, *ilist, *jlist, *numneigh, **firstneigh; int inum, *ilist, *jlist, *numneigh, **firstneigh;
@ -742,7 +742,6 @@ int ComputeRHEOKernel::pack_forward_comm(int n, int *list, double *buf,
int /*pbc_flag*/, int * /*pbc*/) int /*pbc_flag*/, int * /*pbc*/)
{ {
int i,j,k,m,a,b; int i,j,k,m,a,b;
coordination = atom->ivector[index_coord];
m = 0; m = 0;
if (correction_order > 0) { if (correction_order > 0) {
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -774,7 +773,6 @@ int ComputeRHEOKernel::pack_forward_comm(int n, int *list, double *buf,
void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf) void ComputeRHEOKernel::unpack_forward_comm(int n, int first, double *buf)
{ {
int i, k, m, last,a,b; int i, k, m, last,a,b;
coordination = atom->ivector[index_coord];
m = 0; m = 0;
last = first + n; last = first + n;
if (correction_order > 0) { if (correction_order > 0) {

View File

@ -42,6 +42,7 @@ class ComputeRHEOKernel : public Compute {
double dWij[3], dWji[3], Wij, Wji; double dWij[3], dWji[3], Wij, Wji;
int correction_order; int correction_order;
int *coordination;
private: private:
int solid_flag; int solid_flag;
@ -49,7 +50,7 @@ class ComputeRHEOKernel : public Compute {
std::unordered_set<tagint> gsl_error_tags; std::unordered_set<tagint> gsl_error_tags;
int kernel_style, zmin, dim, Mdim, ncor; int kernel_style, zmin, dim, Mdim, ncor;
int nmax_old, index_coord; int nmax_old;
double h, hsq, hinv, hsqinv, pre_w, pre_wp; double h, hsq, hinv, hsqinv, pre_w, pre_wp;
double ***C; double ***C;
double *C0; double *C0;

View File

@ -21,7 +21,6 @@
#include "atom.h" #include "atom.h"
#include "comm.h" #include "comm.h"
#include "compute_rheo_interface.h" #include "compute_rheo_interface.h"
#include "compute_rheo_grad.h"
#include "compute_rheo_kernel.h" #include "compute_rheo_kernel.h"
#include "domain.h" #include "domain.h"
#include "error.h" #include "error.h"
@ -37,8 +36,8 @@ using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) : ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) :
Compute(lmp, narg, arg), vshift(nullptr), fix_rheo(nullptr), compute_kernel(nullptr), Compute(lmp, narg, arg), vshift(nullptr), fix_rheo(nullptr), fix_rheo(nullptr),
compute_grad(nullptr), compute_surface(nullptr), compute_interface(nullptr) compute_kernel(nullptr), compute_interface(nullptr)
{ {
if (narg != 3) error->all(FLERR,"Illegal compute RHEO/VShift command"); if (narg != 3) error->all(FLERR,"Illegal compute RHEO/VShift command");
@ -51,11 +50,12 @@ ComputeRHEOVShift::ComputeRHEOVShift(LAMMPS *lmp, int narg, char **arg) :
// Manually grow if nmax_old exceeded // Manually grow if nmax_old exceeded
int tmp1, tmp2; int tmp1, tmp2;
index_vshift = atom->find_custom("rheo_vshift", tmp1, tmp2); int index = atom->find_custom("rheo_vshift", tmp1, tmp2);
if (index_vshift == -1) { if (index == -1) {
index_vshift = atom->add_custom("rheo_vshift", 1, 3); index = atom->add_custom("rheo_vshift", 1, 3);
nmax_old = atom->nmax; nmax_old = atom->nmax;
} }
vshift = atom->dvector[index];
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -65,7 +65,7 @@ ComputeRHEOVShift::~ComputeRHEOVShift()
// Remove custom property if it exists // Remove custom property if it exists
int tmp1, tmp2, index; int tmp1, tmp2, index;
index = atom->find_custom("rheo_vshift", tmp1, tmp2); index = atom->find_custom("rheo_vshift", tmp1, tmp2);
if (index != -1) atom->remove_custom(index_vshift, 1, 3); if (index != -1) atom->remove_custom(index, 1, 3);
} }
@ -80,7 +80,6 @@ void ComputeRHEOVShift::init()
surface_flag = 1; surface_flag = 1;
compute_kernel = fix_rheo->compute_kernel; compute_kernel = fix_rheo->compute_kernel;
compute_grad = fix_rheo->compute_grad;
compute_interface = fix_rheo->compute_interface; compute_interface = fix_rheo->compute_interface;
cut = fix_rheo->cut; cut = fix_rheo->cut;
@ -119,7 +118,6 @@ void ComputeRHEOVShift::compute_peratom()
int *surface = atom->surface; int *surface = atom->surface;
double *rho = atom->rho; double *rho = atom->rho;
double *mass = atom->mass; double *mass = atom->mass;
double **vshift = atom->darray[index_vshift];
int newton_pair = force->newton_pair; int newton_pair = force->newton_pair;
inum = list->inum; inum = list->inum;
@ -127,7 +125,6 @@ void ComputeRHEOVShift::compute_peratom()
numneigh = list->numneigh; numneigh = list->numneigh;
firstneigh = list->firstneigh; firstneigh = list->firstneigh;
if (nmax_old < atom->nmax) if (nmax_old < atom->nmax)
memory->grow(vshift, atom->nmax, 3, "atom:rheo_vshift"); memory->grow(vshift, atom->nmax, 3, "atom:rheo_vshift");
nmax_old = atom->nmax; nmax_old = atom->nmax;
@ -232,9 +229,9 @@ void ComputeRHEOVShift::correct_surfaces()
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
int i, a, b; int i, a, b;
int dim = domain->dimension; int dim = domain->dimension;
double **vshift = atom->darray[index_vshift];
int tmp1, tmp2; int tmp1, tmp2;
define after surf
int index_nsurf = atom->find_custom("rheo_nsurf", tmp1, tmp2); int index_nsurf = atom->find_custom("rheo_nsurf", tmp1, tmp2);
if (index_nsurf == -1) error->all(FLERR, "Cannot find rheo nsurf"); if (index_nsurf == -1) error->all(FLERR, "Cannot find rheo nsurf");
double **nsurf = atom->darray[index_nsurf]; double **nsurf = atom->darray[index_nsurf];
@ -268,7 +265,6 @@ void ComputeRHEOVShift::correct_surfaces()
int ComputeRHEOVShift::pack_reverse_comm(int n, int first, double *buf) int ComputeRHEOVShift::pack_reverse_comm(int n, int first, double *buf)
{ {
int i,m,last; int i,m,last;
double **vshift = atom->darray[index_vshift];
m = 0; m = 0;
last = first + n; last = first + n;
@ -285,7 +281,6 @@ int ComputeRHEOVShift::pack_reverse_comm(int n, int first, double *buf)
void ComputeRHEOVShift::unpack_reverse_comm(int n, int *list, double *buf) void ComputeRHEOVShift::unpack_reverse_comm(int n, int *list, double *buf)
{ {
int i,j,m; int i,j,m;
double **vshift = atom->darray[index_vshift];
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {

View File

@ -35,17 +35,17 @@ class ComputeRHEOVShift : public Compute {
void unpack_reverse_comm(int, int *, double *) override; void unpack_reverse_comm(int, int *, double *) override;
double memory_usage() override; double memory_usage() override;
void correct_surfaces(); void correct_surfaces();
double **vshift;
private: private:
int nmax_old; int nmax_old;
double dtv, cut, cutsq, cutthird; double dtv, cut, cutsq, cutthird;
int surface_flag, index_vshift; int surface_flag;
class NeighList *list; class NeighList *list;
class FixRHEO *fix_rheo; class FixRHEO *fix_rheo;
class ComputeRHEOInterface *compute_interface ; class ComputeRHEOInterface *compute_interface ;
class ComputeRHEOKernel *compute_kernel; class ComputeRHEOKernel *compute_kernel;
class ComputeRHEOGrad *compute_grad;
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS

View File

@ -21,6 +21,7 @@
#include "atom.h" #include "atom.h"
#include "compute_rheo_grad.h" #include "compute_rheo_grad.h"
#include "compute_rheo_interface.h" #include "compute_rheo_interface.h"
#include "compute_rheo_surface.h"
#include "compute_rheo_kernel.h" #include "compute_rheo_kernel.h"
#include "compute_rheo_rhosum.h" #include "compute_rheo_rhosum.h"
#include "compute_rheo_vshift.h" #include "compute_rheo_vshift.h"
@ -37,7 +38,7 @@ using namespace FixConst;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) : FixRHEO::FixRHEO(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), compute_grad(nullptr), compute_kernel(nullptr), Fix(lmp, narg, arg), compute_grad(nullptr), compute_kernel(nullptr), compute_surface(nullptr),
compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr) compute_interface(nullptr), compute_rhosum(nullptr), compute_vshift(nullptr)
{ {
time_integrate = 1; time_integrate = 1;
@ -258,7 +259,7 @@ void FixRHEO::initial_integrate(int /*vflag*/)
double **gradr = compute_grad->gradr; double **gradr = compute_grad->gradr;
double **gradv = compute_grad->gradv; double **gradv = compute_grad->gradv;
double **vshift = compute_vshift->array_atom; double **vshift = compute_vshift->vshift;
int *type = atom->type; int *type = atom->type;
int *mask = atom->mask; int *mask = atom->mask;

View File

@ -81,6 +81,7 @@ class FixRHEO : public Fix {
class ComputeRHEOGrad *compute_grad; class ComputeRHEOGrad *compute_grad;
class ComputeRHEOKernel *compute_kernel; class ComputeRHEOKernel *compute_kernel;
class ComputeRHEOInterface *compute_interface; class ComputeRHEOInterface *compute_interface;
class ComputeRHEOSurface *compute_surface;
class ComputeRHEORhoSum *compute_rhosum; class ComputeRHEORhoSum *compute_rhosum;
class ComputeRHEOVShift *compute_vshift; class ComputeRHEOVShift *compute_vshift;

View File

@ -36,7 +36,7 @@ enum {NONE, LINEAR, CUBIC, TAITWATER};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) : FixRHEOPressure::FixRHEOPressure(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg) Fix(lmp, narg, arg), fix_rheo(nullptr), pressure(nullptr)
{ {
if (narg < 4) error->all(FLERR,"Illegal fix command"); if (narg < 4) error->all(FLERR,"Illegal fix command");
@ -74,7 +74,7 @@ FixRHEOPressure::~FixRHEOPressure()
// Remove custom property if it exists // Remove custom property if it exists
int tmp1, tmp2, index; int tmp1, tmp2, index;
index = atom->find_custom("rheo_pressure", tmp1, tmp2); index = atom->find_custom("rheo_pressure", tmp1, tmp2);
if (index != -1) atom->remove_custom(index_pres, 1, 0); if (index != -1) atom->remove_custom(index, 1, 0);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -115,11 +115,12 @@ void FixRHEOPressure::setup_pre_force(int /*vflag*/)
// Manually grow if nmax_old exceeded // Manually grow if nmax_old exceeded
int tmp1, tmp2; int tmp1, tmp2;
index_pres = atom->find_custom("rheo_pressure", tmp1, tmp2); int index = atom->find_custom("rheo_pressure", tmp1, tmp2);
if (index_pres == -1) { if (index == -1) {
index_pres = atom->add_custom("rheo_pressure", 1, 0); index = atom->add_custom("rheo_pressure", 1, 0);
nmax_old = atom->nmax; nmax_old = atom->nmax;
} }
pressure = atom->dvector[index];
pre_force(0); pre_force(0);
} }
@ -133,7 +134,6 @@ void FixRHEOPressure::pre_force(int /*vflag*/)
int i; int i;
double dr, rr3, rho_ratio; double dr, rr3, rho_ratio;
double *pressure = atom->dvector[index_pres];
int *mask = atom->mask; int *mask = atom->mask;
double *rho = atom->rho; double *rho = atom->rho;
@ -170,7 +170,6 @@ int FixRHEOPressure::pack_forward_comm(int n, int *list, double *buf,
int /*pbc_flag*/, int * /*pbc*/) int /*pbc_flag*/, int * /*pbc*/)
{ {
int i,j,k,m; int i,j,k,m;
double *pressure = atom->dvector[index_pres];
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -185,7 +184,6 @@ int FixRHEOPressure::pack_forward_comm(int n, int *list, double *buf,
void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf) void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf)
{ {
int i, k, m, last; int i, k, m, last;
double *pressure = atom->dvector[index_pres];
m = 0; m = 0;
last = first + n; last = first + n;
@ -194,6 +192,8 @@ void FixRHEOPressure::unpack_forward_comm(int n, int first, double *buf)
} }
} }
/* ---------------------------------------------------------------------- */
double FixRHEOPressure::calculate_p(double rho) double FixRHEOPressure::calculate_p(double rho)
{ {
double rho; double rho;

View File

@ -38,9 +38,10 @@ class FixRHEOPressure : public Fix {
double calculate_p(double); double calculate_p(double);
private: private:
double c_cubic, csq, rho0, rho0inv; double c_cubic, csq, rho0, rho0inv;
double *pressure;
int pressure_style; int pressure_style;
int first_flag, last_flag; int first_flag, last_flag;
int nmax_old, index_pressure; int nmax_old;
class FixRHEO *fix_rheo; class FixRHEO *fix_rheo;
}; };

View File

@ -37,7 +37,8 @@ enum {NONE, CONSTANT, TYPE};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) : FixRHEOThermal::FixRHEOThermal(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr) Fix(lmp, narg, arg), Tc_type(nullptr), kappa_type(nullptr), cv_type(nullptr),
conductivity(nullptr)
{ {
if (narg < 4) error->all(FLERR,"Illegal fix command"); if (narg < 4) error->all(FLERR,"Illegal fix command");
@ -131,7 +132,7 @@ FixRHEOThermal::~FixRHEOThermal()
// Remove custom property if it exists // Remove custom property if it exists
int tmp1, tmp2, index; int tmp1, tmp2, index;
index = atom->find_custom("rheo_conductivity", tmp1, tmp2); index = atom->find_custom("rheo_conductivity", tmp1, tmp2);
if (index != -1) atom->remove_custom(index_cond, 1, 0); if (index != -1) atom->remove_custom(index, 1, 0);
memory->destroy(cv_type); memory->destroy(cv_type);
memory->destroy(Tc_type); memory->destroy(Tc_type);
@ -199,11 +200,12 @@ void FixRHEOThermal::setup_pre_force(int /*vflag*/)
// Manually grow if nmax_old exceeded // Manually grow if nmax_old exceeded
int tmp1, tmp2; int tmp1, tmp2;
index_cond = atom->find_custom("rheo_conductivity", tmp1, tmp2); index = atom->find_custom("rheo_conductivity", tmp1, tmp2);
if (index_cond == -1) { if (index== -1) {
index_cond = atom->add_custom("rheo_conductivity", 1, 0); index = atom->add_custom("rheo_conductivity", 1, 0);
nmax_old = atom->nmax; nmax_old = atom->nmax;
} }
conductivity = atom->dvector[index];
post_neighbor(); post_neighbor();
pre_force(0); pre_force(0);

View File

@ -48,11 +48,12 @@ class FixRHEOThermal : public Fix {
double *Tc_type, Tc; double *Tc_type, Tc;
double *kappa_type, kappa; double *kappa_type, kappa;
double dtf, dtv; double dtf, dtv;
double *conductivity;
int Tc_style; int Tc_style;
int cv_style; int cv_style;
int conductivity_style; int conductivity_style;
int first_flag, last_flag; int first_flag, last_flag;
int nmax_old, index_cond; int nmax_old;
class FixRHEO *fix_rheo; class FixRHEO *fix_rheo;

View File

@ -37,7 +37,7 @@ enum {NONE, CONSTANT, TYPE, POWER};
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) : FixRHEOViscosity::FixRHEOViscosity(LAMMPS *lmp, int narg, char **arg) :
Fix(lmp, narg, arg), eta_type(nullptr) Fix(lmp, narg, arg), fix_rheo(nullptr), eta_type(nullptr), viscosity(nullptr), compute_grad(nullptr)
{ {
if (narg < 4) error->all(FLERR,"Illegal fix command"); if (narg < 4) error->all(FLERR,"Illegal fix command");
@ -142,11 +142,12 @@ void FixRHEOViscosity::setup_pre_force(int /*vflag*/)
// Manually grow if nmax_old exceeded // Manually grow if nmax_old exceeded
int tmp1, tmp2; int tmp1, tmp2;
index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); int index = atom->find_custom("rheo_viscosity", tmp1, tmp2);
if (index_visc == -1) { if (index_visc == -1) {
index_visc = atom->add_custom("rheo_viscosity", 1, 0); index = atom->add_custom("rheo_viscosity", 1, 0);
nmax_old = atom->nmax; nmax_old = atom->nmax;
} }
viscosity = atom->dvector[index];
post_neighbor(); post_neighbor();
pre_force(0); pre_force(0);
@ -161,7 +162,6 @@ void FixRHEOViscosity::post_neighbor()
int i; int i;
int *type = atom->type; int *type = atom->type;
double *viscosity = atom->dvector[index_visc];
int *mask = atom->mask; int *mask = atom->mask;
int nlocal = atom->nlocal; int nlocal = atom->nlocal;
@ -190,7 +190,6 @@ void FixRHEOViscosity::pre_force(int /*vflag*/)
int i, a, b; int i, a, b;
double tmp, gdot; double tmp, gdot;
double *viscosity = atom->dvector[index_visc];
int *mask = atom->mask; int *mask = atom->mask;
double **gradv = compute_grad->gradv; double **gradv = compute_grad->gradv;
@ -232,7 +231,6 @@ int FixRHEOViscosity::pack_forward_comm(int n, int *list, double *buf,
int /*pbc_flag*/, int * /*pbc*/) int /*pbc_flag*/, int * /*pbc*/)
{ {
int i,j,k,m; int i,j,k,m;
double *viscosity = atom->dvector[index_visc];
m = 0; m = 0;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
@ -247,7 +245,6 @@ int FixRHEOViscosity::pack_forward_comm(int n, int *list, double *buf,
void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf) void FixRHEOViscosity::unpack_forward_comm(int n, int first, double *buf)
{ {
int i, k, m, last; int i, k, m, last;
double *viscosity = atom->dvector[index_visc];
m = 0; m = 0;
last = first + n; last = first + n;

View File

@ -40,9 +40,10 @@ class FixRHEOViscosity : public Fix {
private: private:
double *eta_type, eta; double *eta_type, eta;
double npow, K, gd0, tau0; double npow, K, gd0, tau0;
double *viscosity;
int viscosity_style; int viscosity_style;
int first_flag, last_flag; int first_flag, last_flag;
int nmax_old, index_visc; int nmax_old;
class FixRHEO *fix_rheo; class FixRHEO *fix_rheo;
class ComputeRHEOGrad *compute_grad; class ComputeRHEOGrad *compute_grad;

View File

@ -47,7 +47,7 @@ using namespace MathExtra;
PairRHEO::PairRHEO(LAMMPS *lmp) : PairRHEO::PairRHEO(LAMMPS *lmp) :
Pair(lmp), compute_kernel(nullptr), compute_grad(nullptr), Pair(lmp), compute_kernel(nullptr), compute_grad(nullptr),
compute_interface(nullptr), fix_rheo(nullptr), fix_rheo_pressure(nullptr) compute_interface(nullptr), fix_rheo(nullptr), fix_pressure(nullptr)
{ {
restartinfo = 0; restartinfo = 0;
single_enable = 0; single_enable = 0;
@ -91,8 +91,7 @@ void PairRHEO::compute(int eflag, int vflag)
double **v = atom->v; double **v = atom->v;
double **x = atom->x; double **x = atom->x;
double **f = atom->f; double **f = atom->f;
double **f_pressure = fix_rheo->f_pressure; // rewrite later double **f_pressure = compute_interface->f_pressure;
double *pressure = atom->pressure; // rewrite later
double *rho = atom->rho; double *rho = atom->rho;
double *mass = atom->mass; double *mass = atom->mass;
double *drho = atom->drho; double *drho = atom->drho;
@ -105,15 +104,19 @@ void PairRHEO::compute(int eflag, int vflag)
int *status = atom->status; int *status = atom->status;
int tmp1, tmp2; int tmp1, tmp2;
int index_visc = atom->find_custom("rheo_viscosity", tmp1, tmp2); int index = atom->find_custom("rheo_viscosity", tmp1, tmp2);
if (index_visc == -1) error->all(FLERR, "Cannot find rheo viscosity"); if (index == -1) error->all(FLERR, "Cannot find rheo viscosity");
double *viscosity = atom->dvector[index_visc]; double *viscosity = atom->dvector[index];
index = atom->find_custom("rheo_pressure", tmp1, tmp2);
if (index == -1) error->all(FLERR, "Cannot find rheo pressure");
double *pressure = atom->dvector[index];
double *conductivity; double *conductivity;
if (thermal_flag) { if (thermal_flag) {
int index_cond = atom->find_custom("rheo_conductivity", tmp1, tmp2); index = atom->find_custom("rheo_conductivity", tmp1, tmp2);
if (index_cond == -1) error->all(FLERR, "Cannot find rheo conductivity"); if (index == -1) error->all(FLERR, "Cannot find rheo conductivity");
conductivity = atom->dvector[index_cond]; conductivity = atom->dvector[index];
} }
int *ilist, *jlist, *numneigh, **firstneigh; int *ilist, *jlist, *numneigh, **firstneigh;
@ -195,7 +198,7 @@ void PairRHEO::compute(int eflag, int vflag)
if (fluidi && (!fluidj)) { if (fluidi && (!fluidj)) {
compute_interface->correct_v(vi, vj, i, j); compute_interface->correct_v(vi, vj, i, j);
rhoj = compute_interface->correct_rho(j, i); rhoj = compute_interface->correct_rho(j, i);
Pj = fix_rheo_pressure->calculate_p(rhoj); Pj = fix_pressure->calculate_p(rhoj);
if ((chi[j] > 0.9) && (r < (h * 0.5))) if ((chi[j] > 0.9) && (r < (h * 0.5)))
fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv; fmag = (chi[j] - 0.9) * (h * 0.5 - r) * rho0 * csq * h * rinv;
@ -413,7 +416,12 @@ void PairRHEO::setup()
fixes = modify->get_fix_by_style("rheo/pressure"); fixes = modify->get_fix_by_style("rheo/pressure");
if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo/pressure to use pair rheo"); if (fixes.size() == 0) error->all(FLERR, "Need to define fix rheo/pressure to use pair rheo");
fix_rheo_pressure = dynamic_cast<FixRHEOPressure *>(fixes[0]); fix_pressure = dynamic_cast<FixRHEOPressure *>(fixes[0]);
int tmp1, tmp2;
index_pressure = atom->find_custom("rheo_pressure", tmp1, tmp2);
if (index_pressure == -1) index_pressure = atom->add_custom("rheo_pressure", 1, 0);
else error->all(FLERR, "Cannot find pressure value in pair rheo");
compute_kernel = fix_rheo->compute_kernel; compute_kernel = fix_rheo->compute_kernel;
compute_grad = fix_rheo->compute_grad; compute_grad = fix_rheo->compute_grad;

View File

@ -49,7 +49,7 @@ class PairRHEO : public Pair {
class ComputeRHEOGrad *compute_grad; class ComputeRHEOGrad *compute_grad;
class ComputeRHEOInterface *compute_interface; class ComputeRHEOInterface *compute_interface;
class FixRHEO *fix_rheo; class FixRHEO *fix_rheo;
class FixRHEOPressure *fix_rheo_pressure; class FixRHEOPressure *fix_pressure;
}; };
} // namespace LAMMPS_NS } // namespace LAMMPS_NS