  We present an on-the-fly geometrical approach for shock detection and Mach
number calculation in simulations employing smoothed particle hydrodynamics
(SPH). We utilize pressure gradients to select shock candidates and define up-
and downstream positions. We obtain hydrodynamical states in the up- and
downstream regimes with a series of normal and inverted kernel weightings
parallel and perpendicular to the shock normals. Our on-the-fly geometrical
Mach detector incorporates well within the SPH formalism and has low
computational cost.
  We implement our Mach detector into the simulation code GADGET and alongside
many SPH improvements. We test our shock finder in a sequence of shock-tube
tests with successively increasing Mach numbers exceeding by far the typical
values inside galaxy clusters. For all shocks, we resolve the shocks well and
the correct Mach numbers are assigned. An application to a strong magnetized
shock-tube gives stable results in full magnetohydrodynamic set-ups. We
simulate a merger of two idealized galaxy clusters and study the shock front.
Shock structures within the merging clusters as well as the cluster shock are
well-captured by our algorithm and assigned correct Mach numbers.
