Transport equation on the whole space $\mathbb{R}^3.$ If one has the equation:
$$v\cdot \nabla_x f = g(x),$$
where the domain is $D =\{x:x = (x_1,x_2,x_3)\in\mathbb{R}^3\},$
how does one write down a closed formula for $f$ in terms of $g$ ? I looked at method of characteristics but every example I looked at was dealing with either bounded domains or domains that has boundaries. So I am not sure how to write down the closed formula for $f,$ if it is possible at all. 
I am not particularly concerned with the smoothness assumptions, so we can assume $g$ whatever necessary to make the problem well-posed. 
 A: First, the form of this equation is a  little odd, in that you haven't declared one variable the "time" variable. This is odd because to solve the transport equation you need an initial value, and the word "initial" doesn't make sense unless you have a time variable. With this in mind, I have two attempts at answers for this question. 
1) Without specifying one variable as time, you still need some sort of condition for the solution to satisfy in order to get a unique solution. The only types of conditions I know of would be prescribing the value of $f$ along some hypersurface $S \subset \mathbb{R}^3$. Of course, defining $x_1 = t$ and setting $S = \{(x_2, x_3) = (0, 0)\}$ yields the familiar "prescribing initial data." This is how I'll answer in part 2; I don't know off the top of my head how to solve it for general hypersurfaces $S$. 
2) Call the time variable $t = x_1$. Say we prescribe $f(0, x_2, x_3) = f_0(x_2, x_3)$. Call $x = (x_2, x_3)$ for brevity. By standard transport equation techniques (see Evans, for instance), the characteristic curves for this equation are straight lines of slope $v$ in spacetime. Thus the equation tells us that if we parametrize $f$ along these lines, say $z(t) = f(l(t))$, it has time derivative $g(t, x)$. So this says $z'(t) = g(t, x(t))$, so $z(t) = f(l(0)) + \int_0^t g(s, x(s))\, ds = f(0, x_0) + \int_0^t g(s, x(s))\, ds$. This gives you a closed form for the whole of $\mathbb{R}^3$. 
The takeaway is that the transport equation takes an initial datum and evolves it forwards in time from the initial condition according to the right-hand side of the equation.
A: Let us consider that $f$ and $g$ are scalar fields, which depend on the position $x = (x_1,x_2,x_3)^\top \in \Bbb R^3$. Moreover, we assume that the vector $v = (v_1,v_2,v_3)^\top \neq 0$ does not depend on $x$. The PDE $v\cdot \nabla f = g$ reads
$$
 \sum_{i=1}^3 v_i \frac{\partial}{\partial x_i} f(x) = g(x) \, .
$$
The method of characteristics for the above PDE leads to the system


*

*$\frac{\text d}{\text d s} x = v$, letting $x(0) = x^\circ$ we know $x(s) = x^\circ + s v$;

*$\frac{\text d}{\text d s} f = g$, letting $f(0) = f^\circ$ we know $f(s) = f^\circ + \int_0^s g(x(\sigma)) \, \text d \sigma$.
A condition to deduce $f(x)$ from the above system is that $x - x^\circ$ and $v$ are collinear vectors, i.e. we need to know the value $f^\circ$ of $f$ at some position $x^\circ$ such that the cross product $(x - x^\circ) \times v$ equals zero. Hence, the knowledge of boundary conditions is crucial.
If $v_1\neq 0$, division by $v_1$ in the PDE restricts the study to vectors $v$ of the form $v = (1,a,b)^\top$, for which we must have $(x - x^\circ) \times v=0$.
For instance, we can let $x^\circ$ describe the plane of equation $x_1^\circ = 0$. In other words, we know the boundary data $f^\circ(x_2^\circ,x_3^\circ) = f(0,x_2^\circ,x_3^\circ)$ for all $x_2^\circ$, $x_3^\circ$. The corresponding characteristics satisfy
$$x(s) = (s, x_2^\circ + a s, x_3^\circ + b s)^\top \qquad\text{and}\qquad f(s) = f^\circ(x_2^\circ,x_3^\circ) + \int_0^s g(x(\sigma)) \, \text d \sigma \, .$$
Finally, we are left with
$$
f(x) = f^\circ(x_2-ax_1,x_3-bx_1) + \int_0^{x_1} g\big(\sigma, x_2 - a (x_1-\sigma), x_3 - b (x_1-\sigma)\big) \, \text d \sigma \, .
$$
Note that if $g = 0$, then the two-dimensional advection equation is recovered (cf. §18.2 of (1)), for which the initial density $f^\circ$ simply translates at the velocity $a,b$ along $x_2$, $x_3$. Also, note that if both $a$ and $b$ equal zero, then we recover the evolution equation $f_{x_1} = g$.

(1) R.J. LeVeque, Finite Volume Methods for Hyperbolic Problems, Cambridge university press, 2002. doi:10.1017/CBO9780511791253
