I want to understand how does the simulation identifies and models when two bodies are colliding with each other. For example car crash simulation. The car moves towards the wall or another crash. Until they collide some equations of moving works, but how do they change and what are the methods of dealing with the situation when the collision occures? Do the algorithms for collision detection for games work the same way (physical engines etc)?
Collision is typically modeled through equations like the obstacle problem, i.e., you have a partial differential equation with an inequality constraint. This leads to variational inequalities. An important step is indeed to find out whether two objects are in contact, and there you do use similar techniques as for games.