have compute_reduce require either peratom or local inputs

This commit is contained in:
Steve Plimpton
2023-08-17 16:12:14 -06:00
parent 0d739439c7
commit 299eda8ca3
5 changed files with 149 additions and 106 deletions

View File

@ -26,6 +26,8 @@
using namespace LAMMPS_NS;
enum{UNDECIDED,PERATOM,LOCAL}; // same as in ComputeReduce
static constexpr double BIG = 1.0e20;
/* ---------------------------------------------------------------------- */
@ -97,7 +99,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
// invoke compute if not previously invoked
} else if (val.which == ArgInfo::COMPUTE) {
if (val.flavor == PERATOM) {
if (input_mode == PERATOM) {
if (!(val.val.c->invoked_flag & Compute::INVOKED_PERATOM)) {
val.val.c->compute_peratom();
val.val.c->invoked_flag |= Compute::INVOKED_PERATOM;
@ -122,7 +124,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
one = compute_array[flag][aidxm1];
}
} else if (val.flavor == LOCAL) {
} else if (input_mode == LOCAL) {
if (!(val.val.c->invoked_flag & Compute::INVOKED_LOCAL)) {
val.val.c->compute_local();
val.val.c->invoked_flag |= Compute::INVOKED_LOCAL;
@ -151,7 +153,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
if (update->ntimestep % val.val.f->peratom_freq)
error->all(FLERR, "Fix {} used in compute {} not computed at compatible time", val.id, style);
if (val.flavor == PERATOM) {
if (input_mode == PERATOM) {
if (aidx == 0) {
double *fix_vector = val.val.f->vector_atom;
if (flag < 0) {
@ -171,7 +173,7 @@ double ComputeReduceRegion::compute_one(int m, int flag)
one = fix_array[flag][aidxm1];
}
} else if (val.flavor == LOCAL) {
} else if (input_mode == LOCAL) {
if (aidx == 0) {
double *fix_vector = val.val.f->vector_local;
if (flag < 0)
@ -219,18 +221,18 @@ bigint ComputeReduceRegion::count(int m)
if (val.which == ArgInfo::X || val.which == ArgInfo::V || val.which == ArgInfo::F)
return group->count(igroup, region);
else if (val.which == ArgInfo::COMPUTE) {
if (val.flavor == PERATOM) {
if (input_mode == PERATOM) {
return group->count(igroup, region);
} else if (val.flavor == LOCAL) {
} else if (input_mode == LOCAL) {
bigint ncount = val.val.c->size_local_rows;
bigint ncountall;
MPI_Allreduce(&ncount, &ncountall, 1, MPI_DOUBLE, MPI_SUM, world);
return ncountall;
}
} else if (val.which == ArgInfo::FIX) {
if (val.flavor == PERATOM) {
if (input_mode == PERATOM) {
return group->count(igroup, region);
} else if (val.flavor == LOCAL) {
} else if (input_mode == LOCAL) {
bigint ncount = val.val.f->size_local_rows;
bigint ncountall;
MPI_Allreduce(&ncount, &ncountall, 1, MPI_DOUBLE, MPI_SUM, world);