A theory for optimal heat transfer in a partitioned convection cell