Consistent inlet and outlet boundary conditions for particle methods