  We analyze a bilinear optimal control problem for the Stokes--Brinkman
equations: the control variable enters the state equations as a coefficient. In
two- and three-dimensional Lipschitz domains, we perform a complete continuous
analysis that includes the existence of solutions and first- and second-order
optimality conditions. We also develop two finite element methods that differ
fundamentally in whether the admissible control set is discretized or not. For
each of the proposed methods, we perform a convergence analysis and derive a
priori error estimates; the latter under the assumption that the domain is
convex. Finally, assuming that the domain is Lipschitz, we develop an a
posteriori error estimator for each discretization scheme, obtain a global
reliability bound, and investigate local efficiency estimates.
