Skip to content
Snippets Groups Projects
Commit e351fbfc authored by Nicola Vigano's avatar Nicola Vigano
Browse files

FwdProj: reformatted a bit

parent d0f34b70
No related branches found
No related tags found
No related merge requests found
function DefT = gtFedDefTensorFromComps(dcin, dcomps, method, eyemode) function DefT = gtFedDefTensorFromComps(dcin, dcomps, method, eyemode)
% Gives deformation, rotation and strain tensors from the def. components. % Gives deformation, rotation and strain tensors from the def. components.
% This function contains the definition (including sign) of the deformation % This function contains the definition (including sign) of the deformation
% components. Takes multiple input dc-s. % components. Takes multiple input dc-s.
% %
% SAMPLE coordinate system is orthogonal, right handed [X,Y,Z]. % SAMPLE coordinate system is orthogonal, right handed [X,Y,Z].
% %
%
% INPUT % INPUT
% dcin - deformation components; see below % dcin - deformation components; see below
% dcomps - true for indices of deformation components present in dcin % dcomps - true for indices of deformation components present in dcin
...@@ -19,7 +17,6 @@ function DefT = gtFedDefTensorFromComps(dcin, dcomps, method, eyemode) ...@@ -19,7 +17,6 @@ function DefT = gtFedDefTensorFromComps(dcin, dcomps, method, eyemode)
% if eyemode=0, it excludes the identity matrix % if eyemode=0, it excludes the identity matrix
% if eyemode=1, it includes the identity matrix % if eyemode=1, it includes the identity matrix
% %
%
% SMALL DEFORMATIONS % SMALL DEFORMATIONS
% %
% Deformation components are defined as: % Deformation components are defined as:
...@@ -52,130 +49,72 @@ function DefT = gtFedDefTensorFromComps(dcin, dcomps, method, eyemode) ...@@ -52,130 +49,72 @@ function DefT = gtFedDefTensorFromComps(dcin, dcomps, method, eyemode)
% dc(9) dc(5) dc(7); ... % dc(9) dc(5) dc(7); ...
% dc(8) dc(7) dc(6)]; % dc(8) dc(7) dc(6)];
% %
%
% LARGE DEFORMATIONS (FINITE DEFORMATION THEORY) % LARGE DEFORMATIONS (FINITE DEFORMATION THEORY)
% dc(1:3) - orientation dviation expressed as a Rodrigues vector % dc(1:3) - orientation dviation expressed as a Rodrigues vector
% dc(4:9) - right stretch tensor components (symmetric) % dc(4:9) - right stretch tensor components (symmetric)
% %
% DefT = RotT*RightStretchT % DefT = RotT * RightStretchT
% %
if (~islogical(dcomps))
if ~islogical(dcomps) error('dcomps needs to be 1x9 vector of logicals.')
error('dcomps needs to be 1x9 vector of logicals.')
end
% Create dc with 9 components
dc = zeros(9, size(dcin,2));
dc(dcomps,:) = dcin;
if strcmp(method,'small')
if eyemode
DefT = [dc(4,:) + 1 ;...
dc(9,:)+dc(3,:) ;...
dc(8,:)-dc(2,:) ;...
dc(9,:)-dc(3,:) ;...
dc(5,:) + 1 ;...
dc(7,:)+dc(1,:) ;...
dc(8,:)+dc(2,:) ;...
dc(7,:)-dc(1,:) ;...
dc(6,:) + 1 ];
else
DefT = [dc(4,:) ;...
dc(9,:)+dc(3,:) ;...
dc(8,:)-dc(2,:) ;...
dc(9,:)-dc(3,:) ;...
dc(5,:) ;...
dc(7,:)+dc(1,:) ;...
dc(8,:)+dc(2,:) ;...
dc(7,:)-dc(1,:) ;...
dc(6,:) ];
end end
DefT = reshape(DefT,3,3,[]); % Create dc with 9 components
dc = zeros(9, size(dcin, 2));
dc(dcomps, :) = dcin;
elseif strcmp(method,'rod_rightstretch')
if strcmp(method, 'small')
% DefT = zeros(3, 3, size(dc,2)); if (eyemode)
% DefT = [dc(4,:) + 1 ;...
% % Rodrigues vector -> normalised rotation vector dc(9,:)+dc(3,:) ;...
% rotdirnorm = sqrt( sum( dc(1:3,:).*dc(1:3,:), 1) ); dc(8,:)-dc(2,:) ;...
% rotdir = dc(1:3,:) ./ rotdirnorm([1 1 1],:); dc(9,:)-dc(3,:) ;...
% rotdir(isnan(rotdir)) = 0; dc(5,:) + 1 ;...
% dc(7,:)+dc(1,:) ;...
% % Angles dc(8,:)+dc(2,:) ;...
% angle = 2*atand(rotdirnorm); dc(7,:)-dc(1,:) ;...
% dc(6,:) + 1 ];
% for ii = 1:size(dc,2) else
% DefT = [dc(4,:) ;...
% % Rotation vector -> rotation matrix components dc(9,:)+dc(3,:) ;...
% rotmatcomp = gtMathsRotationMatrixComp(rotdir(:,ii), 'col'); dc(8,:)-dc(2,:) ;...
% dc(9,:)-dc(3,:) ;...
% % Rotation matrix dc(5,:) ;...
% RotT = gtMathsRotationTensor(angle(ii), rotmatcomp); dc(7,:)+dc(1,:) ;...
% dc(8,:)+dc(2,:) ;...
% % Right stretch tensor from its components dc(7,:)-dc(1,:) ;...
% RightStretchT = [dc(4,ii), dc(9,ii), dc(8,ii) ; ... dc(6,:) ];
% dc(9,ii), dc(5,ii), dc(7,ii) ; ... end
% dc(8,ii), dc(7,ii), dc(6,ii) ] + eye(3); DefT = reshape(DefT,3,3,[]);
%
% DefT(:,:,ii) = RotT*RightStretchT; elseif strcmp(method, 'rod_rightstretch')
% end DefT = zeros(size(dc));
% Rotation tensors unfolded
RotT = gtMathsRod2OriMat(-dc(1:3, :));
% % Right stretch tensor from its components RotT = reshape(RotT, 9, []);
% RightStretchT = [dc(4,:) + 1; ...
% dc(9,:); ... % Multiply rotation tensors and right-stretch tensors
% dc(8,:); ... rr = RotT .* dc([4 4 4 9 9 9 8 8 8], :);
% dc(9,:); ... DefT(1:3, :) = rr(1:3, :) + rr(4:6,:) + rr(7:9,:);
% dc(5,:) + 1; ...
% dc(7,:); ... rr = RotT .* dc([9 9 9 5 5 5 7 7 7], :);
% dc(8,:); ... DefT(4:6, :) = rr(1:3, :) + rr(4:6,:) + rr(7:9,:);
% dc(7,:); ...
% dc(6,:) + 1 ]; rr = RotT .* dc([8 8 8 7 7 7 6 6 6], :);
% DefT(7:9, :) = rr(1:3, :) + rr(4:6, :) + rr(7:9, :);
% RightStretchT = reshape(RightStretchT, 3, []);
% % Add the identity component in the right-stretch tensor
% DefT = RotT.*RightStretchT([1 1 1],:); DefT = DefT + RotT;
% DefT = DefT + RotT.*RightStretchT([2 2 2],:);
% DefT = DefT + RotT.*RightStretchT([3 3 3],:);
% DefT = reshape(DefT, 3, 3, []);
% DefT = reshape(DefT, 3, 3, []);
if (~eyemode)
DefT(1, 1, :) = DefT(1, 1, :) - 1;
DefT = zeros(size(dc)); DefT(2, 2, :) = DefT(2, 2, :) - 1;
DefT(3, 3, :) = DefT(3, 3, :) - 1;
% Rotation tensors unfolded end
RotT = reshape(gtFedRod2RotTensor(dc(1:3,:)), 9, []);
% Multiply rotation tensors and right-stretch tensors
rr = RotT.*dc([4 4 4 9 9 9 8 8 8],:);
DefT(1:3,:) = rr(1:3,:) + rr(4:6,:) + rr(7:9,:);
rr = RotT.*dc([9 9 9 5 5 5 7 7 7],:);
DefT(4:6,:) = rr(1:3,:) + rr(4:6,:) + rr(7:9,:);
rr = RotT.*dc([8 8 8 7 7 7 6 6 6],:);
DefT(7:9,:) = rr(1:3,:) + rr(4:6,:) + rr(7:9,:);
% Add the identity component in the right-stretch tensor
DefT = DefT + RotT;
DefT = reshape(DefT, 3, 3, []);
if ~eyemode
DefT(1,1,:) = DefT(1,1,:) - 1;
DefT(2,2,:) = DefT(2,2,:) - 1;
DefT(3,3,:) = DefT(3,3,:) - 1;
end end
end end
end % of function
...@@ -126,7 +126,7 @@ function bl = gtDefFwdProjGvdm2UVW(grain, ref_sel, gv, fedpars, parameters, det_ ...@@ -126,7 +126,7 @@ function bl = gtDefFwdProjGvdm2UVW(grain, ref_sel, gv, fedpars, parameters, det_
sinth = sinths(ii_b) ./ drel; sinth = sinths(ii_b) ./ drel;
% Predict omega angles: 4 for each plane normal % Predict omega angles: 4 for each plane normal
[om, pllab, ~, rot_l2s] = gtFedPredictOmegaMultiple(pl_samd, ... [om, pllab, ~, rot_s2l_c] = gtFedPredictOmegaMultiple(pl_samd, ...
sinth, labgeo.beamdir', labgeo.rotdir', labgeo.rotcomp, ominds(ii_b)); sinth, labgeo.beamdir', labgeo.rotdir', labgeo.rotcomp, ominds(ii_b));
valid_voxels(:, ii_b) = ~isnan(om); valid_voxels(:, ii_b) = ~isnan(om);
...@@ -143,8 +143,8 @@ function bl = gtDefFwdProjGvdm2UVW(grain, ref_sel, gv, fedpars, parameters, det_ ...@@ -143,8 +143,8 @@ function bl = gtDefFwdProjGvdm2UVW(grain, ref_sel, gv, fedpars, parameters, det_
% Diffraction vector % Diffraction vector
dvec_lab = gtFedPredictDiffVecMultiple(pllab, labgeo.beamdir'); dvec_lab = gtFedPredictDiffVecMultiple(pllab, labgeo.beamdir');
rot_s2l = permute(rot_l2s, [2 1 3]); rot_s2l_r = permute(rot_s2l_c, [2 1 3]);
gvcs_lab = gtGeoSam2Lab(gvpcs', rot_s2l, labgeo, samgeo, false, 'element_wise', element_wise_gcs); gvcs_lab = gtGeoSam2Lab(gvpcs', rot_s2l_r, labgeo, samgeo, false, 'element_wise', element_wise_gcs);
uvw_bl = gtFedPredictUVWMultiple([], dvec_lab, gvcs_lab', ... uvw_bl = gtFedPredictUVWMultiple([], dvec_lab, gvcs_lab', ...
detgeo.detrefpos', detgeo.detnorm', detgeo.Qdet, ... detgeo.detrefpos', detgeo.detnorm', detgeo.Qdet, ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment