Given a surface with a single elevation value for every x and y how can I find the places where the isoelevation contours have the tightest bends? And how can I differentiate between bends that are ridges and bends that are valleys? I've gone as far as finding the gradient in x and gradient in y and then found where these gradients change the most rapidly with respect to x and y and some combination of these 4 fields kind of gives me what I want, but I'm honestly at a loss here. It's been a very long time since I've used basic multi-D calculus and could use a refresher! Thanks.

Take the gradient of the surface and then find the divergence of the gradient vector field.