Device for controlling the flow of a fluid in a pipe