We introduce level set methods to design new algorithms for self-consistent field theory (SCFT) in polymer physics. SCFT computes the structure and energy of inhomogeneous self-assembling polymers at thermodynamic equilibrium. We present a computational framework, encoded on adaptive quad/oct trees in a parallel environment and introduce the concept of shape derivative into SCFT. We rigorously derive expressions for the change of energy of a diblock copolymer melt with respect to its enclosing shape. The shape derivative is then used to embed SCFT into a variable shape simulation where the internal structure and the enclosing shape are coupled and evolve in tandem in order to reduce the energy. Finally an algorithm for the inverse geometric problem is presented. The algorithm finds a shape in order to obtain a desired internal structure of the confined polymeric material.