We recast the problem of hydrogel swelling under physical constraints as an
energy optimization problem. We apply this approach to compute equilibrium
shapes of hydrogel spheres confined within a jammed matrix of rigid beads, and
interpret the results to determine how confinement modifies the mechanics of
swollen hydrogels. In contrast to the unconfined case, we find a spatial
separation of strains within the bulk of the hydrogel as strain becomes
localized to an outer region. We also explore the contact mechanics of the gel,
finding a transition from Hertzian behavior to non-Hertzian behavior as a
function of swelling. Our model, implemented in the Morpho shape optimization
environment, can be applied in any dimension, readily adapted to diverse
swelling scenarios and extended to use other energies in conjunction