function [IntGrad] = integrofgrad(vtx,simp,mat_ref); function that calculates the integral of the gradients for first order tetrahedral elements. Required for the calculation of the Jacobian. vtx = The vertices matrix simp = The simplices matrix mat_ref = The reference conductivity vector IntGrad = The intgral of the gradients
0001 function [IntGrad] = integrofgrad(vtx,simp,mat_ref); 0002 %function [IntGrad] = integrofgrad(vtx,simp,mat_ref); 0003 % 0004 %function that calculates the integral of the gradients for first order 0005 %tetrahedral elements. Required for the calculation of the Jacobian. 0006 % 0007 % 0008 % 0009 %vtx = The vertices matrix 0010 %simp = The simplices matrix 0011 %mat_ref = The reference conductivity vector 0012 %IntGrad = The intgral of the gradients 0013 0014 0015 0016 [vr,vc] = size(vtx); 0017 [sr,sc] = size(simp); 0018 0019 if sr ~= length(mat_ref) 0020 error('Mismatched data entered') 0021 end 0022 0023 if sc ~= 4 0024 error('Only first order tetrahedral elements supported'); 0025 end 0026 0027 0028 %w = [1/24*ones(4,1)]; 0029 0030 IntGrad = sparse(vr^2,sr); 0031 0032 for i=1:size(simp,1) 0033 0034 vv = []; 0035 0036 for j=1:size(simp,2) 0037 vv = [vv;vtx(simp(i,j),:)]; 0038 end 0039 0040 interp_fun = [-1 1 0 0; -1 0 1 0; -1 0 0 1]; 0041 0042 Jts = interp_fun*vv; 0043 inv_Jts = inv(Jts); 0044 det_Jts = abs(det(Jts)); 0045 0046 Gs = inv_Jts*interp_fun; 0047 0048 %int = 0; 0049 %for q=1:4 0050 % int = int + w(q)*Gs'*Gs; 0051 %end 0052 %Inte = int*det_Jts; % or simplified 0053 % Citation: The FEM displayed G.Dhatt & G. Touzot 0054 0055 Inte = (1/6)*Gs'*Gs*det_Jts; 0056 0057 Local = sparse(vr,vr); 0058 Local(simp(i,:),simp(i,:))= Inte; 0059 IntGrad(:,i) = Local(:); 0060 end 0061 0062 0063 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0064 % This is part of the EIDORS suite. 0065 % Copyright (c) N. Polydorides 2003 0066 % Copying permitted under terms of GNU GPL 0067 % See enclosed file gpl.html for details. 0068 % EIDORS 3D version 2.0 0069 % MATLAB version 5.3 R11 0070 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%