missing bonds after deleting atoms during the run

Dear LAMMPS users,

I wrote the code which deletes atoms in the post_force step, at the
end I do the following:

  bigint nblocal = atom->nlocal;
  MPI_Allreduce(&nblocal, &atom->natoms, 1, MPI_LMP_BIGINT, MPI_SUM, world);
  if (atom->map_style)
  {
    atom->nghost = 0; //it looks like it is not necessary here
    atom->map_init();
    atom->map_set();
    //neighbor->build();
  }

When after that, I, for instance, write to restart or do other
operations with bobds, than the message "Bonds are missing occurs"
from the code

for (i = 0; i < nlocal; i++)
    for (m = 0; m < num_bond[i]; m++) {
      atom1 = atom->map(bond_atom[i][m]);
      if (atom1 == -1) {
        char str[128];
        sprintf(str, "Bond atoms %d %d missing on proc %d at step "
BIGINT_FORMAT,
                tag[i],bond_atom[i][m],me,update->ntimestep);
        error->one(FLERR,str);
      }

Because, not surprisingly, atom1 == -1. But when Neighbor::bond_all
is called from the verlet code, this atom1 is initialized and not -1.

Do you know where exactly this initialization happens so map is valid
again and map(bond_atom[i][m]) != -1? I want to call it after deleting
atoms to have get rid of this error.

Dear LAMMPS users,

I wrote the code which deletes atoms in the post_force step, at the
end I do the following:

i don't think you can do that. if i remember correctly, particle
insertion/deletion has to happen in Fix::pre_exchange() so that all
derived information (ghost atoms, neighbor/bond lists, exclusions,
etc.) can be updated accordingly.

axel.