⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 problem_bc_irregular.m

📁 efg code with matlab
💻 M
📖 第 1 页 / 共 2 页
字号:
% Steps:
% 1. Build up Gauss points on the boundary, 4 GPs are used
% 2. Loop on these GPs to form the vector q and matrix G

disp([num2str(toc),'   INTEGRATION ON DISPLACEMENT BOUNDARY'])

% --------------------------------------
%       Form vector q and matrix G
% --------------------------------------
qk = zeros(1,2*num_disp_nodes);
G = zeros(2*numnode,2*num_disp_nodes);

% *****************************
%   Point collocation is used
% *****************************

if (la_approx == 200)

    % bottom edge with imposed BCs on u_y
    % +++++++++++++++++++++++++++++++++++
    ind = 0 ;
    for i = 1 : size(disp_nodes_1,1)
        ind = ind + 1 ;
        pt  = disp_nodes_1(i,:);
        S   = [0 0; 0 1]; % both directions
        % G matrix
        [index] = define_support(node,pt,di);
        [phi,dphidx,dphidy] = MLS_ShapeFunction(pt,index,node,di,form);
        for j = 1 : size(index,2)
            row1 = 2*index(j)-1 ;
            row2 = 2*index(j)   ;
            Gj   =  -phi(j) * S ;
            G(row1:row2,2*ind-1:2*ind) = G(row1:row2,2*ind-1:2*ind) + Gj ;
        end
    end

    % left edge with imposed BCs on u_x
    % +++++++++++++++++++++++++++++++++
    for i = 1 : size(disp_nodes_2,1)
        ind = ind + 1 ;
        pt  = disp_nodes_2(i,:);
        S   = [1 0; 0 0]; % both directions
        % G matrix
        [index] = define_support(node,pt,di);
        [phi,dphidx,dphidy] = MLS_ShapeFunction(pt,index,node,di,form);
        for j = 1 : size(index,2)
            row1 = 2*index(j)-1 ;
            row2 = 2*index(j)   ;
            Gj   =  -phi(j) * S ;
            G(row1:row2,2*ind-1:2*ind) = G(row1:row2,2*ind-1:2*ind) + Gj ;
        end
    end

    % top edge with imposed BCs on u_y = - 0.2
    % ++++++++++++++++++++++++++++++++++++++++
    for i = 1 : size(disp_nodes_3,1)
        ind = ind + 1 ;
        pt = disp_nodes_3(i,:);
        S = [0 0; 0 1]; % both directions
        % qk vector
        qk(1,2*ind-1) = 0 ;
        qk(1,2*ind)   = 0.2 ;
        % G matrix
        [index] = define_support(node,pt,di);
        [phi,dphidx,dphidy] = MLS_ShapeFunction(pt,index,node,di,form);
        for j = 1 : size(index,2)
            row1 = 2*index(j)-1 ;
            row2 = 2*index(j)   ;
            Gj   =  -phi(j) * S ;
            G(row1:row2,2*ind-1:2*ind) = G(row1:row2,2*ind-1:2*ind) + Gj ;
        end
    end
end

% *****************************
%   FE interpolation for ML
% *****************************

% 4 point quadrature for each "1D element"
[W1,Q1]=quadrature(4, 'GAUSS', 1 ); 

if (la_approx == 100)
    disp(' Finite element interpolation for ML is used ')
    m1 = 0 ;
    for i = 1 : (size(disp_nodes_1,1) - 1)
        sctr = [disp_nodes_1(i) disp_nodes_1(i+1)];
        m1 = m1 + 1 ;
        m2 = m1 + 1 ;
        le = norm(node(sctr(1),:) - node(sctr(2),:));
        for q = 1:size(W1,1)
            pt = Q1(q,:);
            wt = W1(q);
            [N,dNdxi] = lagrange_basis('L2',pt);
            J0 = dNdxi'*node(sctr,:);
            detJ = norm(J0) ;
            pt = N' * node(sctr,:); % global GP
            N1 = 1 - pt(1,2)/le ; N2 = 1 - N1 ;
            % G matrix
            [index] = define_support(node,pt,di);
            [phi,dphidx,dphidy] = MLS_ShapeFunction(pt,index,node,di,form);
            % S matrix, BCs imposed on y direction
            S = [0 0 ; 0 1];
            for j = 1 : size(index,2)
                row1 = 2*index(j)-1 ;
                row2 = 2*index(j)   ;
                G1   = - wt * detJ * phi(j) * N1 * S ;
                G2   = - wt * detJ * phi(j) * N2 * S ;
                G(row1:row2,2*m1-1:2*m1) = G(row1:row2,2*m1-1:2*m1) + G1;
                G(row1:row2,2*m2-1:2*m2) = G(row1:row2,2*m2-1:2*m2) + G2;
            end
        end % end of loop on GPs of each element
    end % end of loop on 1D elements
    
    % For the left edge ...
    for i = 1 : (size(disp_nodes_2,1) - 1)
        sctr = [disp_nodes_2(i) disp_nodes_2(i+1)];
        m1 = m1 + 1 ;
        m2 = m1 + 1 ;
        le = norm(node(sctr(1),:) - node(sctr(2),:));
        for q = 1:size(W1,1)
            pt = Q1(q,:);
            wt = W1(q);
            [N,dNdxi] = lagrange_basis('L2',pt);
            J0 = dNdxi'*node(sctr,:);
            detJ = norm(J0) ;
            pt = N' * node(sctr,:); % global GP
            N1 = 1 - pt(1,2)/le ; N2 = 1 - N1 ;
            % G matrix
            [index] = define_support(node,pt,di);
            [phi,dphidx,dphidy] = MLS_ShapeFunction(pt,index,node,di,form);
            % S matrix, BCs imposed on x direction
            S = [1 0 ; 0 0];
            for j = 1 : size(index,2)
                row1 = 2*index(j)-1 ;
                row2 = 2*index(j)   ;
                G1   = - wt * detJ * phi(j) * N1 * S ;
                G2   = - wt * detJ * phi(j) * N2 * S ;
                G(row1:row2,2*m1-1:2*m1) = G(row1:row2,2*m1-1:2*m1) + G1;
                G(row1:row2,2*m2-1:2*m2) = G(row1:row2,2*m2-1:2*m2) + G2;
            end
        end % end of loop on GPs of each element
    end % end of loop on 1D elements
    
    % for the top edge
    
    for i = 1 : (size(disp_nodes_3,1) - 1)
        %sctr = [i i+1];
        sctr = [disp_nodes_3(i) disp_nodes_3(i+1)];
        m1 = m1 + 1 ;
        m2 = m1 + 1 ;
        le = norm(node(sctr(1),:) - node(sctr(2),:));
        %le = norm( disp_nodes_3(i,:) - disp_nodes_3(i+1,:) );
        for q = 1:size(W1,1)
            pt = Q1(q,:);
            wt = W1(q);
            [N,dNdxi] = lagrange_basis('L2',pt);
            J0 = dNdxi'*node(sctr,:);
            detJ = norm(J0) ;
            pt = N' * node(sctr,:); % global GP
            %pt =  N' * disp_nodes_3(sctr,:); % global GP
            N1 = 1 - pt(1,2)/le ; N2 = 1 - N1 ;
            % qk vector
            qk(2*m1-1) = qk(2*m1-1) - wt * detJ * N1 * 0 ;
            qk(2*m1)   = qk(2*m1)   - wt * detJ * N1 * (-0.2) ;
            qk(2*m2-1) = qk(2*m2-1) - wt * detJ * N2 * 0 ;
            qk(2*m2)   = qk(2*m2)   - wt * detJ * N2 * (-0.2) ;
            % G matrix
            [index] = define_support(node,pt,di);
            [phi,dphidx,dphidy] = MLS_ShapeFunction(pt,index,node,di,form);
            % S matrix, BCs imposed on y direction
            S = [0 0 ; 0 1];
            for j = 1 : size(index,2)
                row1 = 2*index(j)-1 ;
                row2 = 2*index(j)   ;
                G1   = - wt * detJ * phi(j) * N1 * S ;
                G2   = - wt * detJ * phi(j) * N2 * S ;
                G(row1:row2,2*m1-1:2*m1) = G(row1:row2,2*m1-1:2*m1) + G1;
                G(row1:row2,2*m2-1:2*m2) = G(row1:row2,2*m2-1:2*m2) + G2;
            end
        end % end of loop on GPs of each element
    end % end of loop on 1D elements
    
end

% +++++++++++++++++++++++++++++++++++++
%      SOLUTION OF THE EQUATIONS
% +++++++++++++++++++++++++++++++++++++

disp([num2str(toc),'   SOLUTION OF EQUATIONS'])

if disp_bc_method == 1
    f = [f;qk'];                              % f = {f;qk}
    m = ([K G; G' zeros(2*num_disp_nodes)]);    % m = [K GG;GG' 0]
    d = m\f;                                  % d = {u;lamda}
    u2 = d(1:numnode*2);
    % just get displacement parameters u_i
    for i = 1 : numnode
        u(1,i) = d(2*i-1); % x displacement
        u(2,i) = d(2*i);   % y displacement
    end
end

clear d ;

% +++++++++++++++++++++++++++++++++++++
%    COMPUTE THE TRUE DISPLACEMENTS
% +++++++++++++++++++++++++++++++++++++
disp([num2str(toc),'   INTERPOLATION TO GET TRUE DISPLACEMENT'])
disp = zeros(1,2*numnode);
for i = 1 : numnode
    [index] = define_support(node,node(i,:),di);
    % shape function at nodes in neighbouring of node i
    [phi,dphidx,dphidy] = MLS_ShapeFunction(node(i,:),index,node,di,form);
    disp(1,2*i-1) = phi*u(1,index)'; % x nodal displacement
    disp(1,2*i)   = phi*u(2,index)'; % y nodal displacement
end
clear u;

% +++++++++++++++++++++++++++++++++++++
%            VISUALIATION
% +++++++++++++++++++++++++++++++++++++

% Deformed configuration
% ----------------------

figure
plot_mesh(node,element,'Q4','k--');
fac = 1 ; % visualization factor
hold on
h = plot(node(:,1)+fac*disp(1,1:2:2*numnode-1)',...
    node(:,2)+fac*disp(1,2:2:2*numnode)','r*');
set(h,'MarkerSize',7);
title('Deformed configuration (scaled)');
opts = struct('Color','rgb','Bounds','tight');
exportfig(gcf,'boundary_deformed3.eps',opts);


% Remove used memory
clear coord; clear Q; clear W; clear J; clear stress_gp;

% ------------------------------
%      END OF THE PROGRAM
% ------------------------------







⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -