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

📄 problem_bc_irregular.m

📁 efg code with matlab
💻 M
📖 第 1 页 / 共 2 页
字号:
% *************************************************************************
%                 TWO DIMENSIONAL ELEMENT FREE GALERKIN CODE
%                            Nguyen Vinh Phu
%                        LTDS, ENISE, Juillet 2006
% *************************************************************************

% Description:
% This is a simple Matlab code of the EFG method which is the most familiar
% meshless methods using MLS approximation and Galerkin procedure to derive
% the discrete equations.
% Domain of influence can be : (1) circle and (2) rectangle
% Weight function : cubic or quartic spline function
% Nodes can be uniformly distributed nodes or randomly distributed
% (in the latter case, this is read from a finite element mesh file)
% Numerical integration is done with background mesh
% Essential boundary condition is imposed using Lagrange multipliers or
% penalty method.
% In case of Lagrange multipliers, but use the Dirac delta function to
% approximate lamda, we obtain the boundary point collocation method

% External utilities: the mesh, post processing is done with the Matlab
% code of Northwestern university, Illinois, USA

% *************************************************************************

% Problem: Infinite plate with centered hole
% Plate dimensions: 10x10 with hole of unity radius
% The plate is meshed with SYSTUS program and stored in the file hole.asc
% Due to symmetry, only 1/4 plate is modeled.

% +++++++++++++++++++++++++++++++++++++
%          PROBLEM INPUT DATA
% +++++++++++++++++++++++++++++++++++++

clear all
clc
state = 0;
tic;           % help us to see the time required for each step

% Dimension of the domain (it is simply a rectangular region L x W)
L = 1 ;
D = 1 ;

% Material properties
E  = 1000;
nu = 0.3 ;
stressState='PLANE_STRAIN'; % set to either 'PLANE_STRAIN' or "PLANE_STRESS'

% Inputs special to meshless methods, domain of influence

shape = 'circle' ;         % shape of domain of influence
dmax  = 2.0;                 % radius = dmax * nodal spacing
form  = 'cubic_spline' ;   % using cubic spline weight function

% Choose method to impose essential boundary condition
% disp_bc_method = 1 : Lagrange multiplier method
% disp_bc_method = 2 : Penalty method

disp_bc_method = 1 ;

% If Lagrange multiplier is used, choose approximation to be used for lamda
% la_approx = 100 ;       % using finite element approximation
% la_approx = 200 ;       % using point collocation method   
if disp_bc_method == 1
    la_approx = 200 ;         
end

% If penalty function is used, then choose "smart" penalty number :-)
if disp_bc_method == 2
    alpha = 1e7 ;           % penalty number
end

% +++++++++++++++++++++++++++++++++++++
%            NODE GENERATION
% +++++++++++++++++++++++++++++++++++++
% Steps:
%  1. Node coordinates
%  2. Nodes' weight function including : shape (circle or rectangle), size
%  and form (quartic spline or the other)

disp([num2str(toc),'   NODE GENERATION'])

gmshFileName = 'boundary.msh';  % name of gmsh input file

bottomBoundaryID   = 20;
rghBoundaryID      = 21;
topBoundaryID      = 22;
interiorID         = 30;

% READ GMSH FILE

[node,elements,elemType] = msh2mlab(gmshFileName);
[node,elements]          = remove_free_nodes(node,elements);


% GET NODE AND CONNECTIVITY MATRICES FOR INTERIOR
node     = node(:,1:2);                        % a nodal coordinate matix (reference config)
element  = elements{interiorID};       % connectivity matrix for interior

numnode = size(node,1);    % number of nodes
numelem = size(element,1); % number of elements

% GET NODE AND CONNECTIVITY MATRICES FOR BCs
botEdge   = elements{bottomBoundaryID};      
topEdge   = elements{topBoundaryID };           
rghEdge   = elements{rghBoundaryID };    

% GET NODES ON DIRICHLET BOUNDARY AND ESSENTIAL BOUNDARY
disp_nodes_1   = unique(botEdge);   
disp_nodes_2   = unique(rghEdge);     
disp_nodes_3   = unique(topEdge);     

     
% define collocation points along displacement boundaries

%disp_nodes_1 = linspace(0,D,24)';
%disp_nodes_1 = [disp_nodes_1 zeros(length(disp_nodes_1),1)];

%disp_nodes_2 = linspace(0,L,24)';
%disp_nodes_2 = [zeros(length(disp_nodes_2),1) disp_nodes_2 ];

%disp_nodes_3 = linspace(0,L/3,8)';
%disp_nodes_3 = [disp_nodes_3 ones(length(disp_nodes_3),1)];

%num_disp_nodes = size(disp_nodes_1,1)+size(disp_nodes_2,1)+...
%                 size(disp_nodes_3,1);

% Domain of influence for every nodes 
% Uniformly distributed nodes
% Definition : rad = dmax*max(deltaX,deltaY)
% deltaX,deltaY are nodal spacing along x,y directions
h = 0.2 ;
di     = ones(1,numnode)*dmax*h ;

% +++++++++++++++++++++++++++++++++++++
%            GAUSS POINTS
% +++++++++++++++++++++++++++++++++++++
% Steps:
% 1. Mesh generation using available meshing algorithm of FEM
% 2. Using isoparametric mapping to transform Gauss points defined in each
%   element (background element) to global coordinates
% For this problem, since the geometry is not regular, the background mesh
% is used.

disp([num2str(toc),'   BUILD GAUSS POINT FOR DOMAIN '])

% Building Gauss points
% 4x4 Gaussian quadrature for each element
[w,q]=quadrature(1, 'TRIANGULAR', 2 );
W = [];   % weight
Q = [];   % coord
J = [];   % det J
for e = 1 : size(element,1)        % element loop
    sctr=element(e,:);             % element scatter vector
    for i = 1:size(w,1)                        % quadrature loop
        pt=q(i,:);                             % quadrature point
        wt=w(i);                               % quadrature weight
        [N,dNdxi]=lagrange_basis('T3',pt);     % Q4 shape functions
        J0=node(sctr,:)'*dNdxi;                % element Jacobian matrix
        Q = [Q; N' * node(sctr,:)];            % global Gauss point
        W = [W; wt];                           % global Gauss point
        J = [J; det(J0)];
    end
end
clear w,q ;

% +++++++++++++++++++++++++++++++++++++
%  PLOT NODES,BACKGROUND MESH, GPOINTS
% +++++++++++++++++++++++++++++++++++++
disp([num2str(toc),'   PLOT NODES AND GAUSS POINTS'])

disp_nodes = [disp_nodes_1;disp_nodes_2;disp_nodes_3];
%disp_nodes = [disp_nodes_1;disp_nodes_2];

figure
hold on
h = plot(node(:,1),node(:,2),'bo');
set(h,'MarkerSize',6);
cd = plot([0 1 1 0 0],[0 0 1 1 0],'b-');
set(cd,'LineWidth',2);
g = plot(node(disp_nodes,1),node(disp_nodes,2),'rp');
set(g,'MarkerSize',12);
%s = plot(disp_nodes_1(:,1),disp_nodes_1(:,2),'rp');
%set(s,'MarkerSize',12);
%s = plot(disp_nodes_2(:,1),disp_nodes_2(:,2),'rp');
%set(s,'MarkerSize',12);
%s = plot(disp_nodes_3(:,1),disp_nodes_3(:,2),'rp');
%set(s,'MarkerSize',12);
axis equal
axis off

opts = struct('Color','rgb','Bounds','tight');
exportfig(gcf,'boundary_collocation_point2.eps',opts);

% +++++++++++++++++++++++++++++++++++++
%          DOMAIN ASSEMBLY
% +++++++++++++++++++++++++++++++++++++

disp([num2str(toc),'   DOMAIN ASSEMBLY'])

% Initialisation
K = sparse(2*numnode,2*numnode);
f = zeros(2*numnode,1);

if ( strcmp(stressState,'PLANE_STRESS') )
    C=E/(1-nu^2)*[ 1      nu          0;
        nu     1          0 ;
        0     0  0.5*(1-nu) ];
else
    C=E/(1+nu)/(1-2*nu)*[ 1-nu  nu     0;
        nu    1-nu   0;
        0     0  0.5-nu ];
end


% ---------------------------------
%       Loop on Gauss points
% ---------------------------------

for igp = 1 : size(W,1)
    pt = Q(igp,:);               % quadrature point
    wt = W(igp);                 % quadrature weight

    % ----------------------------------------------
    % find nodes in neighbouring of Gauss point pt
    % ----------------------------------------------
    [index] = define_support(node,pt,di);

    % --------------------------------------
    %   compute B matrix, K matrix
    % --------------------------------------
    % Loop on nodes within the support, compute dPhi of each node
    % Then get the B matrix
    % Finally assemble to the K matrix

    B = zeros(3,2*size(index,2)) ;
    en = zeros(1,2*size(index,2));
    [phi,dphidx,dphidy] = MLS_ShapeFunction(pt,index,node,di,form);
    for m = 1 : size(index,2)
        B(1:3,2*m-1:2*m) = [dphidx(m) 0 ;
            0 dphidy(m);
            dphidy(m) dphidx(m)];
        en(2*m-1) = 2*index(m)-1;
        en(2*m  ) = 2*index(m)  ;
    end
    K(en,en) = K(en,en) + B'*C*B * W(igp)*J(igp) ;
end

% +++++++++++++++++++++++++++++++++++++
%   INTEGRATE ON DISPLACEMENT BOUNDARY
% +++++++++++++++++++++++++++++++++++++

⌨️ 快捷键说明

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