To solve the heat equation, using the separation of variables and decomposition into Fourier series usually works well.
Consider the homogeneous equation
\begin{align*}
& u_t-u_{xx}=0\\
& u_x(0,t)=u_x(\pi,t)=0
\end{align*}
whitout bothering about the initial condition. We wish to find solutions of the form $u(x,t)=c(t)v(x)$. Plugging this into the equation, we get
$$
c'(t)v(x)-c(t)v''(x)=0.
$$
This equation has to be true for any $x,t$, which means there exists $k\geq0$ such that $c'=\pm k^2 c$ and $v''=\pm k^2 v$. We only seek physically relevant solutions, so we can disregard the case $c'=k^2c$, because it would lead to a diverging solution when $t\to+\infty$. The equation for $v$ becomes $v'+k^2v=0$, and the general solution of this equation is
$$
\{x\mapsto A\cos(kx)+B\sin(kx),\;A,B\in\mathbb{R}\}
$$
The condition $u_x(0,t)=u_x(\pi,t)=0$ implies $B=0$ and $k\in\mathbb{N}$. Thus, for $k\in\mathbb{N}$, let
$$
\boxed{v_k:x\mapsto A_k\cos(kx)}.
$$
Note that this will be very convenient for Fourier series.
Now, what if we plug a function $u_k(x,t)=c_k(t)v_k(t)$, where $c_k$ is to be determined, into $u_t-u_{xx}$? We get
$$
(c'_k(t)+k^2c_k(t))A_k\cos(kx)
$$
We want to find $u(x,t)=\sum{k\geq0} u_k(x,t)$ such that it verifies the inhomogeneous equation, so we seek $c_k$ such that
$$
(c'_k(t)+k^2c_k(t))A_k\cos(kx)=tA_k\cos(kx)
$$
which is equivalent, assuming continuity, to
$$
c'_k(t)+k^2c_k(t)=t
$$
If $k=0$, the solution is $\boxed{c_0(t)=t^2/2+B_0}$.
Assume that $k>0$.
One solution to the homogeneous version of this equation is $\lambda(t)=\exp(-k^2t)$. Using the variation of parameters, $c_k=y\lambda$ with $y'(t)=t\exp(k^2t)$, thus
$$
\boxed{c_k:t\mapsto\frac{1}{k^4}(tk^2-1)+B_k\exp(-k^2t)}.
$$
Consider $u(x,t)=\sum_{k\geq0}c_k(t)v_k(x)$. We want $u$ to be a solution of the PDE.
$$
u_t-u_{xx}=\sum_{k\geq0} tA_k\cos(kx)=t\sum_{k\geq0} A_k\cos(kx)=tx
$$
thus
$$
A_k=\frac{2}{\pi}\int_0^\pi x\cos(kx)\mathrm{d}x=\begin{cases}\pi&\text{if }k=0 \\ \frac{2}{\pi}\frac{(-1)^k-1}{k^2} & \text{if not}\end{cases}
$$
Finally, we need to make sure $u$ verifies the boundary conditions. We already have $u_x(0,t)=u_x(\pi,t)=0$, so the only remaining problem is $u(x,0)=1$.
$$
u(x,0)=B_0A_0+\sum_{k\geq1}\left(B_k-\frac{1}{k^4}\right)v_k(x).
$$
Therefore, setting
$$
B_k=\begin{cases}1/A_0=1/\pi & \text{if }k=0 \\ \frac{1}{k^4} &\text{if not}\end{cases}
$$
solves the problem.
$$xu_x+yu_y+u_z=0$$
With the method of characteristics :
$$\frac{dx}{x}=\frac{dy}{y}=\frac{dz}{1}=\frac{du}{0}$$
First characteristic equation , from $\frac{dx}{x}=\frac{dz}{1} \quad\to\quad x\:e^{-z}=c_1$
Second characteristic equation , from $\frac{dy}{y}=\frac{dz}{1} \quad\to\quad y\:e^{-z}=c_2$
By necessity $du=0 \quad\to\quad u=c_3$ as a third trivial caracteristic.
The general solution on implicit form is : $\Phi\left(x\:e^{-z}\:,\:y\:e^{-z}\:,\:u\right)=0$
Or on the explicit form :
$$u=F\left(x\:e^{-z}\:,\:y\:e^{-z}\right)$$
where $F$ is any differentiable function of two variables.
Boundary condition :
$u(x,y,0)=F\left(xe^0\:,\:ye^0\right)=u_0(x,y)\quad\to\quad F\equiv u_0$
$$u(x,y,z)=u_0\left(x\:e^{-z}\:,\:y\:e^{-z}\right)$$
Best Answer
A counterexample is a bump function (https://en.wikipedia.org/wiki/Bump_function), and f defined as in the answer above would even be smooth.