Skip to content

Instantly share code, notes, and snippets.

@rleegates
Created December 5, 2014 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rleegates/d5f13ab5524878c99b19 to your computer and use it in GitHub Desktop.
Save rleegates/d5f13ab5524878c99b19 to your computer and use it in GitHub Desktop.
Computes element coordinate from global coordinate
% local coordinates from global coordinates
function eta = globalToLocal(obj, xPt, nodalX)
% tolerance
tol = 1e-13;
% get an initial guess at [0,0]
eta = zeros(size(xPt));
% NR iteration
deta = 1;
iter = 0;
maxIter = 20;
while norm(deta) > tol
iter = iter+1;
if iter > maxIter
disp('Convergence not met!');
break;
end
N = obj.shapeFun(eta);
dN_deta = obj.shapeFunDeriv(eta);
deta = -(nodalX*dN_deta)\(nodalX*N - xPt);
eta = eta + deta;
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment