Numerical boundary conditions for solar magnetohydrodynamic flows using the method of characteristics