Structural optimization of porous media for fast and controlled capillary flows.