Lagrangian and Hamiltonian formalism for discontinuous fluid and gravitational field | Synapse