Controlling macroscopic heat transfer with thermal metamaterials: Theory, experiment and application