We formulate an optimization method for flow field based on transient information of the flow field. The flow field is solved by the lattice Boltzmann method. We use a level-set function in order to represent the boundary clearly, and apply non-slip boundary conditions at the boundary. We formulate the sensitivity considering that the boundary moves during the process of optimization. We also show a numerical examples.