Finish stencil classes

This commit is contained in:
Joel Clemmer
2020-11-10 20:03:00 -07:00
parent af57879416
commit dd1cce1da5
15 changed files with 779 additions and 707 deletions

View File

@ -31,33 +31,33 @@ using namespace LAMMPS_NS;
sx,sy,sz = bin bounds = furthest the stencil could possibly extend
calculated below in create_setup()
3d creates xyz stencil, 2d creates xy stencil
for half list with newton off:
for full list or half list with newton off
use a full stencil
stencil is all surrounding bins including self
regardless of triclinic
for half list with newton on:
for half list with newton on
use a half stencil
stencil is bins to the "upper right" of central bin
stencil does not include self
no versions that allow ghost on (no callers need it?)
for half list with newton on and triclinic:
use a half stencil
stencil is all bins in z-plane of self and above, but not below
in 2d is all bins in y-plane of self and above, but not below
stencil includes self
no versions that allow ghost on (no callers need it?)
for full list:
stencil is all surrounding bins including self
regardless of newton on/off or triclinic
for multi:
create one stencil for each atom type
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:
for multi2:
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
full stencils including all surrounding bins are always used except
for same-type stencils with newton on which uses a half stencil
for orthogonal boxes, a half stencil includes bins to the "upper right" of central bin
for triclinic, a half 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?)
------------------------------------------------------------------------- */
@ -74,7 +74,7 @@ NStencil::NStencil(LAMMPS *lmp) : Pointers(lmp)
stencil_multi = nullptr;
distsq_multi = nullptr;
stencil_split = nullptr;
stencil_half = nullptr;
stencil_skip = nullptr;
stencil_bin_type = nullptr;
stencil_cut = nullptr;
@ -101,31 +101,31 @@ NStencil::~NStencil()
delete [] distsq_multi;
}
if (stencil_multi_tiered) {
if (stencil_multi2) {
int n = atom->ntypes;
memory->destroy(nstencil_multi_tiered);
memory->destroy(nstencil_multi2);
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]);
memory->destroy(stencil_multi2[i][j]);
}
delete [] stencil_multi_tiered[i];
delete [] stencil_multi2[i];
}
delete [] stencil_multi_tiered;
memory->destroy(maxstencil_multi_tiered);
memory->destroy(stencil_split);
delete [] stencil_multi2;
memory->destroy(maxstencil_multi2);
memory->destroy(stencil_half);
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(sx_multi2);
memory->destroy(sy_multi2);
memory->destroy(sz_multi2);
memory->destroy(binsizex_multi_tiered);
memory->destroy(binsizey_multi_tiered);
memory->destroy(binsizez_multi_tiered);
memory->destroy(binsizex_multi2);
memory->destroy(binsizey_multi2);
memory->destroy(binsizez_multi2);
}
}
@ -179,17 +179,17 @@ void NStencil::copy_bin_info()
copy needed info for a given type from NBin class to this stencil class
------------------------------------------------------------------------- */
void NStencil::copy_bin_info_multi_tiered(int type)
void NStencil::copy_bin_info_multi2(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];
mbinx = nb->mbinx2[type];
mbiny = nb->mbiny2[type];
mbinz = nb->mbinz2[type];
binsizex = nb->binsizex2[type];
binsizey = nb->binsizey2[type];
binsizez = nb->binsizez2[type];
bininvx = nb->bininvx2[type];
bininvy = nb->bininvy2[type];
bininvz = nb->bininvz2[type];
}
/* ----------------------------------------------------------------------
@ -200,7 +200,7 @@ void NStencil::copy_bin_info_multi_tiered(int type)
void NStencil::create_setup()
{
if (neighstyle != Neighbor::MULTI_TIERED){
if (neighstyle != Neighbor::MULTI2){
if (nb) copy_bin_info();
last_stencil = update->ntimestep;
@ -263,34 +263,53 @@ void NStencil::create_setup()
int n = atom->ntypes;
// 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(stencil_half, n+1, n+1,
"neighstencil:stencil_half");
memory->create(stencil_skip, n+1, n+1,
"neighstencil:stencil_skip");
memory->create(stencil_bin_type, n+1, n+1,
"neighstencil:stencil_bin_type");
memory->create(stencil_cut, n+1, n+1,
"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(sx_multi2, n+1, n+1, "neighstencil:sx_multi2");
memory->create(sy_multi2, n+1, n+1, "neighstencil:sy_multi2");
memory->create(sz_multi2, n+1, n+1, "neighstencil:sz_multi2");
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");"
memory->create(binsizex_multi2, n+1, n+1,
"neighstencil:binsizex_multi2");
memory->create(binsizey_multi2, n+1, n+1,
"neighstencil:binsizey_multi2");
memory->create(binsizez_multi2, n+1, n+1,
"neighstencil:binsizez_multi2");
// Skip all stencils by default, initialize smax
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
stencil_skip[i][j] = 1;
maxstencil_multi2[i][j] = 0;
}
}
// Determine which stencils need to be built
set_stencil_properties();
for (i = 1; i <= n; ++i) {
for (j = 1; j <= n; ++j) {
// Allocate arrays to store stencils
if (!maxstencil_multi2) {
memory->create(maxstencil_multi2, n+1, n+1, "neighstencil::stencil_multi2");
memory->create(nstencil_multi2, n+1, n+1, "neighstencil::nstencil_multi2");
stencil_multi2 = new int**[n+1]();
for (i = 1; i <= n; ++i) {
stencil_multi2[i] = new int*[n+1]();
for (j = 1; j <= n; ++j) {
maxstencil_multi2[i][j] = 0;
}
}
}
for (i = 1; i <= n; i++) {
for (j = 1; j <= n; j++) {
// Skip creation of unused stencils
if (stencil_skip[i][j]) continue;
@ -299,9 +318,9 @@ void NStencil::create_setup()
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;
binsizex_multi2[i][j] = binsizex;
binsizey_multi2[i][j] = binsizey;
binsizez_multi2[i][j] = binsizez;
stencil_range = stencil_cut[i][j];
@ -312,17 +331,17 @@ void NStencil::create_setup()
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;
sx_multi2[i][j] = sx;
sy_multi2[i][j] = sy;
sz_multi2[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");
if (smax > maxstencil_multi2[i][j]) {
maxstencil_multi2[i][j] = smax;
memory->destroy(stencil_multi2[i][j]);
memory->create(stencil_multi2[i][j], smax,
"neighstencil::stencil_multi2");
}
}
}
@ -363,10 +382,18 @@ 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);
} else if (neighstyle == Neighbor::MULTI2) {
int n = atom->ntypes;
for (i = 1; i <= n; ++i) {
for (j = 1; j <= n; ++j) {
bytes += maxstencil_multi2[i][j] * sizeof(int);
bytes += maxstencil_multi2[i][j] * sizeof(int);
bytes += maxstencil_multi2[i][j] * sizeof(double);
}
}
bytes += 2 * n * n * sizeof(bool);
bytes += 6 * n * n * sizeof(int);
bytes += 4 * n * n * sizeof(double);
}
return bytes;
}