A generating and absorbing boundary condition for dispersive waves in detailed simulations of free-surface flow interaction with marine structures