Theory and Computation of Line Defect Fields in Solids and Liquid Crystals