Microalgae are microorganisms which have been only recently used for biotechnological applications, especially in the perspective of biofuel production. Here we focus on the shape optimization and optimal control of an innovative process where the microalgae are fixed on a support. They are thus successively exposed to light and dark conditions. The resulting growth can be represented by a dynamical system describing the denaturation of key proteins due to an excess of light. A Partial Differential Equations (PDE) model of the Rotating Algal Biofilm (RAB) is then proposed, representing local microalgal growth submitted to the time varying light. An adjoint-based gradient method is proposed to identify the optimal (constant) process folding and the (time varying) velocity of the biofilm. When applied to a realistic case, the optimization points out a particular configuration which significantly increases the productivity compared to a base case where the biofilm is fixed.