Starting with the advection equation in conservation form.
$$ u_t = (a(x)u)_x $$
where $a(x)$ is a velocity which depend on space, and $u$ is a concentration of a species which is conserved.
Discretising the flux (where the flux $f=a(x)u$, is defined on the edges of the cells between mesh points) gives, $$ u_t = \frac{1}{h}\left( f_{j-{\frac{1}{2}}} - f_{j+{\frac{1}{2}}} \right) $$
Using a first order upwind we approximate the fluxes as,
$$ f_{j-{\frac{1}{2}}} = a(x_{j-\frac{1}{2}})u_{j-1} \\ f_{j+{\frac{1}{2}}} = a(x_{j+\frac{1}{2}})u_{j} $$ Which gives, $$ u_t = \frac{1}{h} \left( a(x_{j-\frac{1}{2}})u_{j-1} - a(x_{j+\frac{1}{2}})u_{j} \right) $$
If $a(x)$ was constant then this will reduce to the familiar upwind scheme i.e., $ u_t = \frac{a}{h} \left( u_{j-1} - u_{j} \right) $.
My question is, how can we treat the non-constant coefficients of the advection equation? The velocity is defined at the cell centers, so a simple approach would be the following,
$$ a(x_{j-\frac{1}{2}}) \rightarrow a(x_{j-1}) \\ a(x_{j+\frac{1}{2}}) \rightarrow a(x_{j}) $$
This is my preferred approach because it is very simple to implement.
However, we could also use (I am guessing) an averaging scheme to define the velocity at the cell edges, $$ a(x_{j-\frac{1}{2}}) \rightarrow \frac{1}{2}a(x_{j-1} ) + \frac{1}{2}a(x_{j} ) \\ a(x_{j+\frac{1}{2}}) \rightarrow \frac{1}{2}a(x_{j} ) + \frac{1}{2}a(x_{j+1} ) \\ $$
In LeVeque's book he says,
So far we have assumed that the variable velocity $a(x)$ is specified by a constant value $a_j$ within the j-th grid cell. In some cases it is more natural to instead assume that a velocity $a_{j−{\frac{1}{2}}}$ is specified at each cell interface.
But he doesn't really elaborate too much after that. What is a common approach?
I am solving a conservation problem (I am using the advection equation as a continuity equation) so I want to make sure that after applying discretisation that the conservation property is preserved. I would like to avoid any hidden surprises regarding these variable coefficients! Does anybody have some general comments and guidance?
Update There are two really good answers below and I could only pick one :(