A Hamiltonian description of FMR in finite continuous media