Well-behaved coarse-grained model of density-functional theory