Finished implementation of the function. Refs #8744.