# 2nd order accurate finite difference method variable material properties near boundary

I'm aware that a 2nd order accurate finite-difference method using variable properties for central differencing can be written in a finite-volume type way:

$$\nabla \bullet (k \nabla f) = \frac{\frac{f_{i+1}-f_{i}}{\Delta x_{i+1/2}}k_{i+1/2}-\frac{f_{i}-f_{i-1}}{\Delta x_{i-1/2}} k_{i-1/2}}{\Delta x_{i}}$$

This discretization is 2nd order accurate for interior points, but what formula is typically used near boundaries? I'm curious about 2 cases: where $f$ is located at (1) cell center and (2) cell corner locations.

Any help is greatly appreciated.

1.) Let for instance $x_{i-1/2}$ is located at boundary. If $f_i$ is located at cell center then the flux based boundary conditions are straightforward to implement, replace in your scheme the term $$k_{i-1/2} \frac{f_i - f_{i-1}}{\Delta x_{i-1/2}}$$ by the term prescribed for $k \partial_x f$ in flux based boundary condition.
If you have Dirichlet B.C., then more effort is necessary. Typically you extrapolate linearly the missing (outer) value $f_{i-1}$ from given value $f_{i-1/2}$ from B.C. and from $f_i$ and then plug such $f_{i-1}$ to your scheme. In fact you might use a quadratic extrapolation depending also on $f_{i+1}$.
2.) If $f_i$ is located in corner locations and if $x_i$ is located at boundary and you have Dirichlet B.C., you need not to apply the scheme here, the value $f_i$ is given by B.C. If you have flux-based B.C. then one typically use a "half" finite volume, so your scheme is then $$\frac{\frac{f_{i+1}-f_{i}}{\Delta x_{i+1/2}}k_{i+1/2}-Flux_i}{\Delta x_{i}/2}$$ where the value $Flux_i$ is obtained from B.C.