Sandy beach dynamics by constrained wave energy minimization