Controlling Defects in Nematic and Smectic Liquid Crystals Through Boundary Geometry