Adaptive harmonic balance method for nonlinear time-periodic flows