Invariant solutions for a class of diffusion equations