  We have developed an adaptive multigrid code for solving the Poisson equation
in gravitational simulations. Finer rectangular subgrids are adaptively created
in locations where the density exceeds a local level-dependent threshold. We
describe the code, test it in cosmological simulations, and apply it to the
study of the birth and evolution of a typical pancake singularity. The initial
conditions for the pancake are generated on the basis of the theory of
Lagrangian singularities; we follow its evolution for a few collapse times,
finding a rich substructure in the final object. We achieve a spatial
resolution of 1/1024 of the size of the overall computational cube in the
central parts of the pancake, with computing time comparable to that of the
FFT-solvers.
