A computationally efficient subspace harmonic relaxation algorithm for coarse-graining of molecular systems with nearly exact thermodynamic consistency