  We present a finite element approach for diffusion problems with thermal
fluctuations based on a fluctuating hydrodynamics model. The governing
transport equations are stochastic partial differential equations with a
fluctuating forcing term. We propose a discrete formulation of the stochastic
forcing term that has the correct covariance matrix up to a standard
discretization error. Furthermore, to obtain a numerical solution with spatial
correlations that converge to those of the continuum equation, we derive a
linear mapping to transform the finite element solution into an equivalent
discrete solution that is free from the artificial correlations introduced by
the spatial discretization. The method is validated by applying it to two
diffusion problems: a second-order diffusion equation and a fourth-order
diffusion equation. The theoretical (continuum) solution to the first case
presents spatially decorrelated fluctuations, while the second case presents
fluctuations correlated over a finite length. In both cases, the numerical
solution presents a structure factor that approximates well the continuum one.
