Micromagnetics of shape anisotropy based permanent magnets