Heavy Flavor Dynamics in Relativistic Heavy-ion Collisions