In English, if someone visits a grave or goes to a funeral of someone who has died, we can say he is going "to pay his respects" or "to pay his last respects." While it's hard to explain what this means, it can involve saying goodbye, expressing grief and admiration, and reminiscing about the life of the departed person.
Is there a similar phrase in Spanish for what someone is doing when they visit the grave of a departed friend or family member?