When nematic liquid crystals are constrained to a curved surface, the geometry induces distortions in the molecular orientation. The mechanisms of the geometrical frustration involve the intrinsic as well as the extrinsic geometry of the underlying substrate. We show that the nematic elastic energy promotes the alignment of the flux lines of the nematic director towards geodesics and/or lines of curvature of the surface. As a consequence, the influence of the curvature can be tuned through the Frank elastic moduli. To illustrate this effect, we consider the simple case of nematics lying on a cylindrical shell. By combining the curvature effects with external magnetic fields, the molecular alignment can be reoriented or switched between two stable configurations. This enables the manipulation of nematic alignment for the design of new materials and technological devices.