We compute steady planar incompressible flows and wall shapes that maximize the rate of heat transfer (
$Nu$
) between hot and cold walls, for a given rate of viscous dissipation by the flow (
$Pe^2$
), with no-slip boundary conditions at the walls. In the case of no flow, we show theoretically that the optimal walls are flat and horizontal, at the minimum separation distance. We use a decoupled approximation to show that flat walls remain optimal up to a critical non-zero flow magnitude. Beyond this value, our computed optimal flows and wall shapes converge to a set of forms that are invariant except for a
$Pe^{-1/3}$
scaling of horizontal lengths. The corresponding rate of heat transfer
$Nu \sim Pe^{2/3}$
. We show that these scalings result from flows at the interface between the diffusion-dominated and convection-dominated regimes. We also show that the separation distance of the walls remains at its minimum value at large
$Pe$
.