%-----------------------------------------------------------------------
% Computes the non-singular displacement gradient produced by
% the dislocation structure.
%
% DDD-XRD
% nbertin@stanford.edu
%-----------------------------------------------------------------------

function dudx = displacement_gradient_structure(rn,links,NU,a,r)

dudx = zeros(size(r,1),3,3);

for j=1:size(r,1)
    for i=1:size(links,1)
        n1 = links(i,1);
        n2 = links(i,2);
        r1 = rn(n1,1:3);
        r2 = rn(n2,1:3);
        b = links(i,3:5);
        dudx(j,:,:) = squeeze(dudx(j,:,:)) + displacement_gradient_seg(NU,b,r1,r2,r(j,1:3),a);
    end
end

end

