A method for dynamic simulation of rigid and flexible fibers in a flow field