Renamed to multi2, initial stencil edits
This commit is contained in:
250
src/nstencil.cpp
250
src/nstencil.cpp
@ -51,6 +51,15 @@ using namespace LAMMPS_NS;
|
||||
stencil follows same rules for half/full, newton on/off, triclinic
|
||||
cutoff is not cutneighmaxsq, but max cutoff for that atom type
|
||||
no versions that allow ghost on (any need for it?)
|
||||
for multi/tiered:
|
||||
create one stencil for each itype-jtype pairing
|
||||
stencils do not generally follow the same rules for half/full or newton on/off
|
||||
whole stencils including all surrounding bins are always used except
|
||||
for same-type stencils with newton on which uses a split stencil
|
||||
for orthogonal boxes, a split stencil includes bins to the "upper right" of central bin
|
||||
for triclinic, a split stencil includes bins in the z (3D) or y (2D) plane of self and above
|
||||
cutoff is not cutneighmaxsq, but max cutoff for that atom type
|
||||
no versions that allow ghost on (any need for it?)
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
NStencil::NStencil(LAMMPS *lmp) : Pointers(lmp)
|
||||
@ -64,6 +73,11 @@ NStencil::NStencil(LAMMPS *lmp) : Pointers(lmp)
|
||||
nstencil_multi = nullptr;
|
||||
stencil_multi = nullptr;
|
||||
distsq_multi = nullptr;
|
||||
|
||||
stencil_split = nullptr;
|
||||
stencil_skip = nullptr;
|
||||
stencil_bin_type = nullptr;
|
||||
stencil_cut = nullptr;
|
||||
|
||||
dimension = domain->dimension;
|
||||
}
|
||||
@ -75,16 +89,44 @@ NStencil::~NStencil()
|
||||
memory->destroy(stencil);
|
||||
memory->destroy(stencilxyz);
|
||||
|
||||
if (!stencil_multi) return;
|
||||
if (stencil_multi) {
|
||||
|
||||
int n = atom->ntypes;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
memory->destroy(stencil_multi[i]);
|
||||
memory->destroy(distsq_multi[i]);
|
||||
int n = atom->ntypes;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
memory->destroy(stencil_multi[i]);
|
||||
memory->destroy(distsq_multi[i]);
|
||||
}
|
||||
delete [] nstencil_multi;
|
||||
delete [] stencil_multi;
|
||||
delete [] distsq_multi;
|
||||
}
|
||||
|
||||
if (stencil_multi_tiered) {
|
||||
|
||||
int n = atom->ntypes;
|
||||
memory->destroy(nstencil_multi_tiered);
|
||||
for (int i = 1; i <= n; i++) {
|
||||
for (int j = 0; j <= n; j++) {
|
||||
if (! stencil_skip[i][j])
|
||||
memory->destroy(stencil_multi_tiered[i][j]);
|
||||
}
|
||||
delete [] stencil_multi_tiered[i];
|
||||
}
|
||||
delete [] stencil_multi_tiered;
|
||||
memory->destroy(maxstencil_multi_tiered);
|
||||
memory->destroy(stencil_split);
|
||||
memory->destroy(stencil_skip);
|
||||
memory->destroy(stencil_bin_type);
|
||||
memory->destroy(stencil_cut);
|
||||
|
||||
memory->destroy(sx_multi_tiered);
|
||||
memory->destroy(sy_multi_tiered);
|
||||
memory->destroy(sz_multi_tiered);
|
||||
|
||||
memory->destroy(binsizex_multi_tiered);
|
||||
memory->destroy(binsizey_multi_tiered);
|
||||
memory->destroy(binsizez_multi_tiered);
|
||||
}
|
||||
delete [] nstencil_multi;
|
||||
delete [] stencil_multi;
|
||||
delete [] distsq_multi;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -105,6 +147,7 @@ void NStencil::copy_neighbor_info()
|
||||
cutneighmax = neighbor->cutneighmax;
|
||||
cutneighmaxsq = neighbor->cutneighmaxsq;
|
||||
cuttypesq = neighbor->cuttypesq;
|
||||
cutneighsq = neighbor->cutneighsq;
|
||||
|
||||
// overwrite Neighbor cutoff with custom value set by requestor
|
||||
// only works for style = BIN (checked by Neighbor class)
|
||||
@ -132,6 +175,23 @@ void NStencil::copy_bin_info()
|
||||
bininvz = nb->bininvz;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
copy needed info for a given type from NBin class to this stencil class
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void NStencil::copy_bin_info_multi_tiered(int type)
|
||||
{
|
||||
mbinx = nb->mbinx_tiered[type];
|
||||
mbiny = nb->mbiny_tiered[type];
|
||||
mbinz = nb->mbinz_tiered[type];
|
||||
binsizex = nb->binsizex_tiered[type];
|
||||
binsizey = nb->binsizey_tiered[type];
|
||||
binsizez = nb->binsizez_tiered[type];
|
||||
bininvx = nb->bininvx_tiered[type];
|
||||
bininvy = nb->bininvy_tiered[type];
|
||||
bininvz = nb->bininvz_tiered[type];
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
insure NBin data is current
|
||||
insure stencils are allocated large enough
|
||||
@ -139,59 +199,131 @@ void NStencil::copy_bin_info()
|
||||
|
||||
void NStencil::create_setup()
|
||||
{
|
||||
if (nb) copy_bin_info();
|
||||
last_stencil = update->ntimestep;
|
||||
|
||||
// sx,sy,sz = max range of stencil in each dim
|
||||
// smax = max possible size of entire 3d stencil
|
||||
// stencil will be empty if cutneighmax = 0.0
|
||||
|
||||
sx = static_cast<int> (cutneighmax*bininvx);
|
||||
if (sx*binsizex < cutneighmax) sx++;
|
||||
sy = static_cast<int> (cutneighmax*bininvy);
|
||||
if (sy*binsizey < cutneighmax) sy++;
|
||||
sz = static_cast<int> (cutneighmax*bininvz);
|
||||
if (sz*binsizez < cutneighmax) sz++;
|
||||
if (dimension == 2) sz = 0;
|
||||
|
||||
int smax = (2*sx+1) * (2*sy+1) * (2*sz+1);
|
||||
|
||||
// reallocate stencil structs if necessary
|
||||
// for BIN and MULTI styles
|
||||
|
||||
if (neighstyle == Neighbor::BIN) {
|
||||
if (smax > maxstencil) {
|
||||
maxstencil = smax;
|
||||
memory->destroy(stencil);
|
||||
memory->create(stencil,maxstencil,"neighstencil:stencil");
|
||||
if (xyzflag) {
|
||||
memory->destroy(stencilxyz);
|
||||
memory->create(stencilxyz,maxstencil,3,"neighstencil:stencilxyz");
|
||||
|
||||
if (neighstyle != Neighbor::MULTI_TIERED){
|
||||
if (nb) copy_bin_info();
|
||||
last_stencil = update->ntimestep;
|
||||
|
||||
// sx,sy,sz = max range of stencil in each dim
|
||||
// smax = max possible size of entire 3d stencil
|
||||
// stencil will be empty if cutneighmax = 0.0
|
||||
|
||||
sx = static_cast<int> (cutneighmax*bininvx);
|
||||
if (sx*binsizex < cutneighmax) sx++;
|
||||
sy = static_cast<int> (cutneighmax*bininvy);
|
||||
if (sy*binsizey < cutneighmax) sy++;
|
||||
sz = static_cast<int> (cutneighmax*bininvz);
|
||||
if (sz*binsizez < cutneighmax) sz++;
|
||||
if (dimension == 2) sz = 0;
|
||||
|
||||
int smax = (2*sx+1) * (2*sy+1) * (2*sz+1);
|
||||
|
||||
// reallocate stencil structs if necessary
|
||||
// for BIN and MULTI styles
|
||||
|
||||
if (neighstyle == Neighbor::BIN) {
|
||||
if (smax > maxstencil) {
|
||||
maxstencil = smax;
|
||||
memory->destroy(stencil);
|
||||
memory->create(stencil,maxstencil,"neighstencil:stencil");
|
||||
if (xyzflag) {
|
||||
memory->destroy(stencilxyz);
|
||||
memory->create(stencilxyz,maxstencil,3,"neighstencil:stencilxyz");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
int i;
|
||||
int n = atom->ntypes;
|
||||
if (maxstencil_multi == 0) {
|
||||
nstencil_multi = new int[n+1];
|
||||
stencil_multi = new int*[n+1];
|
||||
distsq_multi = new double*[n+1];
|
||||
for (i = 1; i <= n; i++) {
|
||||
nstencil_multi[i] = 0;
|
||||
stencil_multi[i] = nullptr;
|
||||
distsq_multi[i] = nullptr;
|
||||
}
|
||||
}
|
||||
if (smax > maxstencil_multi) {
|
||||
maxstencil_multi = smax;
|
||||
for (i = 1; i <= n; i++) {
|
||||
memory->destroy(stencil_multi[i]);
|
||||
memory->destroy(distsq_multi[i]);
|
||||
memory->create(stencil_multi[i],maxstencil_multi,
|
||||
"neighstencil:stencil_multi");
|
||||
memory->create(distsq_multi[i],maxstencil_multi,
|
||||
"neighstencil:distsq_multi");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
int i;
|
||||
int i, j, bin_type, smax;
|
||||
double stencil_range;
|
||||
int n = atom->ntypes;
|
||||
if (maxstencil_multi == 0) {
|
||||
nstencil_multi = new int[n+1];
|
||||
stencil_multi = new int*[n+1];
|
||||
distsq_multi = new double*[n+1];
|
||||
for (i = 1; i <= n; i++) {
|
||||
nstencil_multi[i] = 0;
|
||||
stencil_multi[i] = nullptr;
|
||||
distsq_multi[i] = nullptr;
|
||||
}
|
||||
}
|
||||
if (smax > maxstencil_multi) {
|
||||
maxstencil_multi = smax;
|
||||
for (i = 1; i <= n; i++) {
|
||||
memory->destroy(stencil_multi[i]);
|
||||
memory->destroy(distsq_multi[i]);
|
||||
memory->create(stencil_multi[i],maxstencil_multi,
|
||||
"neighstencil:stencil_multi");
|
||||
memory->create(distsq_multi[i],maxstencil_multi,
|
||||
"neighstencil:distsq_multi");
|
||||
|
||||
// Allocate arrays to store stencil information
|
||||
memory->create(stencil_split, n, n,
|
||||
"neighstencil:stencil_split");"
|
||||
memory->create(stencil_skip, n, n,
|
||||
"neighstencil:stencil_skip");"
|
||||
memory->create(stencil_bin_type, n, n,
|
||||
"neighstencil:stencil_bin_type");"
|
||||
memory->create(stencil_cut, n, n,
|
||||
"neighstencil:stencil_cut");"
|
||||
|
||||
memory->create(sx_multi_tiered, n, n,
|
||||
"neighstencil:sx_multi_tiered");"
|
||||
memory->create(sy_multi_tiered, n, n,
|
||||
"neighstencil:sy_multi_tiered");"
|
||||
memory->create(sz_multi_tiered, n, n,
|
||||
"neighstencil:sz_multi_tiered");"
|
||||
|
||||
memory->create(binsizex_multi_tiered, n, n,
|
||||
"neighstencil:binsizex_multi_tiered");"
|
||||
memory->create(binsizey_multi_tiered, n, n,
|
||||
"neighstencil:binsizey_multi_tiered");"
|
||||
memory->create(binsizez_multi_tiered, n, n,
|
||||
"neighstencil:binsizez_multi_tiered");"
|
||||
|
||||
// Determine which stencils need to be built
|
||||
set_stencil_properties();
|
||||
|
||||
for (i = 1; i <= n; ++i) {
|
||||
for (j = 1; j <= n; ++j) {
|
||||
|
||||
// Skip creation of unused stencils
|
||||
if (stencil_skip[i][j]) continue;
|
||||
|
||||
// Copy bin info for this particular pair of types
|
||||
bin_type = stencil_bin_type[i][j];
|
||||
copy_bin_info_bytype(bin_type);
|
||||
|
||||
binsizex_multi_tiered[i][j] = binsizex;
|
||||
binsizey_multi_tiered[i][j] = binsizey;
|
||||
binsizez_multi_tiered[i][j] = binsizez;
|
||||
|
||||
stencil_range = stencil_cut[i][j];
|
||||
|
||||
sx = static_cast<int> (stencil_range*bininvx);
|
||||
if (sx*binsizex < stencil_range) sx++;
|
||||
sy = static_cast<int> (stencil_range*bininvy);
|
||||
if (sy*binsizey < stencil_range) sy++;
|
||||
sz = static_cast<int> (stencil_range*bininvz);
|
||||
if (sz*binsizez < stencil_range) sz++;
|
||||
|
||||
sx_multi_tiered[i][j] = sx;
|
||||
sy_multi_tiered[i][j] = sy;
|
||||
sz_multi_tiered[i][j] = sz;
|
||||
|
||||
smax = ((2*sx+1) * (2*sy+1) * (2*sz+1));
|
||||
|
||||
if (smax > maxstencil_multi_tiered[i][j]) {
|
||||
maxstencil_multi_tiered[i][j] = smax;
|
||||
memory->destroy(stencil_multi_tiered[i][j]);
|
||||
memory->create(stencil_multi_tiered[i][j], smax,
|
||||
"neighstencil::stencil_multi_tiered");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -231,6 +363,10 @@ double NStencil::memory_usage()
|
||||
} else if (neighstyle == Neighbor::MULTI) {
|
||||
bytes += atom->ntypes*maxstencil_multi * sizeof(int);
|
||||
bytes += atom->ntypes*maxstencil_multi * sizeof(double);
|
||||
} else if (neighstyle == Neighbor::MULTI_TIERED) {
|
||||
bytes += atom->ntypes*maxstencil_multi * sizeof(int);
|
||||
bytes += atom->ntypes*maxstencil_multi * sizeof(int);
|
||||
bytes += atom->ntypes*maxstencil_multi * sizeof(double);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user