  Numerical effects are known to plague adaptive mesh refinement (AMR) codes
when treating massive particles, e.g. representing massive black holes (MBHs).
In an evolving background, they can experience strong, spurious perturbations
and then follow unphysical orbits. We study by means of numerical simulations
the dynamical evolution of a pair MBHs in the rapidly and violently evolving
gaseous and stellar background that follows a galaxy major merger. We confirm
that spurious numerical effects alter the MBH orbits in AMR simulations, and
show that numerical issues are ultimately due to a drop in the spatial
resolution during the simulation, drastically reducing the accuracy in the
gravitational force computation. We therefore propose a new refinement
criterion suited for massive particles, able to solve in a fast and precise way
for their orbits in highly dynamical backgrounds. The new refinement criterion
we designed enforces the region around each massive particle to remain at the
maximum resolution allowed, independently upon the local gas density. Such
maximally-resolved regions then follow the MBHs along their orbits, and
effectively avoids all spurious effects caused by resolution changes. Our suite
of high resolution, adaptive mesh-refinement hydrodynamic simulations,
including different prescriptions for the sub-grid gas physics, shows that the
new refinement implementation has the advantage of not altering the physical
evolution of the MBHs, accounting for all the non trivial physical processes
taking place in violent dynamical scenarios, such as the final stages of a
galaxy major merger.
