The observed properties of mesogranules are related to structures found in idealized numerical experiments on turbulent convection. We describe results obtained for three-dimensional Boussinesq convection in a layer with a very large aspect ratio. There are two distinct cellular patterns at the surface. Energy-transporting convection cells (corresponding to granules in the solar photosphere) have diameters comparable to the layer depth, while macrocells (corresponding to mesogranules) are several times larger. The motion acts as a small-scale turbulent dynamo, generating a disordered magnetic field that is concentrated at macrocellular corners and, to a lesser extent, in the lanes that join them. These results imply that mesogranules owe their origin to collective interactions between the granules.