High-speed rainbow trapping and release by mechanical approaches in the terahertz regime