This work is concerned with optimal control of partial differential equations where the control enters the state equation as a coefficient and should take on values only from a given discrete set of values corresponding to available materials. A "multibang" framework based on convex analysis is proposed where the desired piecewise constant structure is incorporated using a convex penalty term. Together with a suitable tracking term, this allows formulating the problemof optimizing the topology of the distribution of material parameters as minimizing a convex functional subject to a (nonlinear) equality constraint. The applicability of this approach is validated for two model problems where the control enters as a potential and a diffusion coefficient, respectively. This is illustrated in both cases by numerical results based on a semismooth Newton method.