  We perform a numerical study of the heat transfer and flow structure of
Rayleigh-B\'enard (RB) convection in (in most cases regular) porous media,
which are comprised of circular, solid obstacles located on a square lattice.
This study is focused on the role of porosity $\phi$ in the flow properties
during the transition process from the traditional RB convection with $\phi=1$
(so no obstacles included) to Darcy-type porous-media convection with $\phi$
approaching 0. Simulations are carried out in a cell with unity aspect ratio,
for the Rayleigh number $Ra$ from $10^5$ to $10^{10}$ and varying porosities
$\phi$, at a fixed Prandtl number $Pr=4.3$, and we restrict ourselves to the
two dimensional case. For fixed $Ra$, the Nusselt number $Nu$ is found to vary
non-monotonously as a function of $\phi$; namely, with decreasing $\phi$, it
first increases, before it decreases for $\phi$ approaching 0. The
non-monotonous behaviour of $Nu(\phi)$ originates from two competing effects of
the porous structure on the heat transfer. On the one hand, the flow coherence
is enhanced in the porous media, which is beneficial for the heat transfer. On
the other hand, the convection is slowed down by the enhanced resistance due to
the porous structure, leading to heat transfer reduction. For fixed $\phi$,
depending on $Ra$, two different heat transfer regimes are identified, with
different effective power-law behaviours of $Nu$ vs $Ra$, namely, a steep one
for low $Ra$ when viscosity dominates, and the standard classical one for large
$Ra$. The scaling crossover occurs when the thermal boundary layer thickness
and the pore scale are comparable. The influences of the porous structure on
the temperature and velocity fluctuations, convective heat flux, and energy
dissipation rates are analysed, further demonstrating the competing effects of
the porous structure to enhance or reduce the heat transfer.
