Compute_snap.cpp does not force energy and virial tally despite needing it

On lines 601 and 616, compute_snap.cpp does the following:

c_pe->compute_scalar();
c_virial->compute_vector();

However, compute_snap.cpp does not force an energy and virial tally - peflag, pressflag and timeflag are all 0.

This causes an error when invoking the compute internally from a custom fix on a timestep without a thermo output, e.g using:

// invoke the compute if not already been done this timestep
if (!(compute_ptr->invoked_flag & Compute::INVOKED_ARRAY)) {
  compute_ptr->compute_array();
  compute_ptr->invoked_flag |= Compute::INVOKED_ARRAY;    
}

Causing this error:

double ComputePE::compute_scalar()
{
  invoked_scalar = update->ntimestep;
  if (update->eflag_global != invoked_scalar){
    error->all(FLERR, Error::NOLASTLINE, "Energy was not tallied on needed  timestep{}", utils::errorurl(22));
  }

This can be fixed simply by setting

peflag = 1;
timeflag = 1;
pressflag = 1;

in the compute_snap.cpp constructor (and ensuring that compute_ptr->addstep(update->ntimestep+1); was used on the previous step in the invoking fix).

Happy to open a Github issue if that’s more appropriate.

Yes, it is.

Done.