Magnetic nanostructures by adaptive twinning in strained epitaxial films.