Transverse-momentum and event-shape dependence of D-meson flow harmonics in Pb–Pb collisions at sNN=5.02TeV