An energy-preserving level set method for multiphase flows