  We construct a discrete model of fluid particles according to the GENERIC
formalism. The model has the form of Smoothed Particle Hydrodynamics including
correct thermal fluctuations. A slight variation of the model reproduces the
Dissipative Particle Dynamics model with any desired thermodynamic behavior.
The resulting algorithm has the following properties: mass, momentum and energy
are conserved, entropy is a non-decreasing function of time and the thermal
fluctuations produce the correct Einstein distribution function at equilibrium.
