A numerical model of idealized sunspots and pores is presented, where axisymmetric cylindrical domains are used with aspect ratios (radius versus depth) up to 4. The model contains a compressible plasma with density and temperature gradients simulating the upper layer of the Sun’s convection zone. Non-linear magnetohydrodynamic equations are solved numerically and time-dependent solutions are obtained where the magnetic field is pushed to the centre of the domain by convection cells. This central magnetic flux bundle is maintained by an inner convection cell, situated next to it and with a flow such that there is an inflow at the top of the numerical domain towards the flux bundle. For aspect ratio 4, a large inner cell persists in time, but for lower aspect ratios it becomes highly time dependent. For aspect ratios 2 and 3 this inner convection cell is smaller, tends to be situated towards the top of the domain next to the flux bundle, and appears and disappears with time. When it is gone, the neighbouring cell (with an opposite sense of rotation, i.e. outflow at the top) pulls the magnetic field away from the central axis. As this happens a new inner cell forms with an inflow which pushes the magnetic field towards the centre. This suggests that to maintain their form, both pores and sunspots need a neighbouring convection cell with inflow at the top towards the magnetic flux bundle. This convection cell does not have to be at the top of the convection zone and could be underneath the penumbral structure around sunspots. For an aspect ratio of 1, there is not enough space in the numerical domain for magnetic flux and convection to separate. In this case the solution oscillates between two steady states: two dominant convection cells threaded by magnetic field and one dominant cell that pushes magnetic flux towards the central axis.