Topology Optimization and Analysis of Thermal and Mechanical Metamaterials