A two-dimensional finite element method to calculate the AC loss in superconducting cables, wires and coated conductors