We approximate functions defined on smooth bounded domains by elements of the eigenspaces of the Laplacian or the Stokes operator in such a way that the approximations are bounded and converge in both Sobolev and Lebesgue spaces. We prove an abstract result referred to fractional power spaces of positive, self-adjoint, compact-inverse operators on Hilbert spaces, and then obtain our main result by using the explicit form of these fractional power spaces for the Dirichlet Laplacian and Stokes operators. As a simple application, we prove that all weak solutions of the incompressible convective Brinkman--Forchheimer equations posed on a bounded domain in ${mathbb R}^3$ satisfy the energy equality.